Separate "detailed view" from "key actions".

This commit is contained in:
Dain Nilsson 2024-01-10 20:58:25 +01:00
parent 0e709f0085
commit fa05e72538
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8
4 changed files with 30 additions and 22 deletions

View File

@ -35,6 +35,7 @@ class AppPage extends StatelessWidget {
final Widget? title;
final Widget? child;
final Widget Function(BuildContext context, bool expanded)? builder;
final Widget Function(BuildContext context)? detailViewBuilder;
final List<Widget> actions;
final Widget Function(BuildContext context)? keyActionsBuilder;
final bool keyActionsBadge;
@ -51,6 +52,7 @@ class AppPage extends StatelessWidget {
this.actions = const [],
this.centered = false,
this.keyActionsBuilder,
this.detailViewBuilder,
this.actionButtonBuilder,
this.fileDropOverlay,
this.onFileDropped,
@ -228,13 +230,21 @@ class AppPage extends StatelessWidget {
body
]),
)),
if (hasManage && keyActionsBuilder != null)
if (hasManage &&
(detailViewBuilder != null || keyActionsBuilder != null))
SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: SizedBox(
width: 320,
child: keyActionsBuilder!(context),
child: Column(
children: [
if (detailViewBuilder != null)
detailViewBuilder!(context),
if (keyActionsBuilder != null)
keyActionsBuilder!(context),
],
),
),
),
),

View File

@ -235,7 +235,7 @@ class _FidoUnlockedPageState extends ConsumerState<FidoUnlockedPage> {
},
child: AppPage(
title: Text(l10n.s_webauthn),
keyActionsBuilder: switch (selected) {
detailViewBuilder: switch (selected) {
FidoCredential credential => (context) =>
_registerCredentialActions(credential,
ref: ref,
@ -319,11 +319,12 @@ class _FidoUnlockedPageState extends ConsumerState<FidoUnlockedPage> {
],
),
),
_ => hasActions
? (context) => fidoBuildActions(
context, widget.node, widget.state, nFingerprints)
: null
_ => null
},
keyActionsBuilder: hasActions
? (context) => fidoBuildActions(
context, widget.node, widget.state, nFingerprints)
: null,
keyActionsBadge: fidoShowActionsNotifier(widget.state),
builder: (context, expanded) => Column(
crossAxisAlignment: CrossAxisAlignment.start,

View File

@ -80,7 +80,7 @@ class _OtpScreenState extends ConsumerState<OtpScreen> {
},
child: AppPage(
title: Text(l10n.s_slots),
keyActionsBuilder: selected != null
detailViewBuilder: selected != null
? (context) => registerOtpActions(
widget.devicePath,
selected,
@ -125,10 +125,11 @@ class _OtpScreenState extends ConsumerState<OtpScreen> {
],
),
)
: (hasFeature(features.actions)
? (context) => otpBuildActions(
context, widget.devicePath, otpState, ref)
: null),
: null,
keyActionsBuilder: hasFeature(features.actions)
? (context) =>
otpBuildActions(context, widget.devicePath, otpState, ref)
: null,
builder: (context, expanded) {
// De-select if window is resized to be non-expanded.
if (!expanded) {

View File

@ -92,8 +92,7 @@ class _PivScreenState extends ConsumerState<PivScreen> {
},
child: AppPage(
title: Text(l10n.s_certificates),
keyActionsBuilder: selected != null
// TODO: Reuse slot dialog
detailViewBuilder: selected != null
? (context) => registerPivActions(
widget.devicePath,
pivState,
@ -133,17 +132,14 @@ class _PivScreenState extends ConsumerState<PivScreen> {
actions: buildSlotActions(
selected.certInfo != null, l10n),
),
if (hasFeature(features.actions)) ...[
pivBuildActions(
context, widget.devicePath, pivState, ref),
],
],
),
)
: (hasFeature(features.actions)
? (context) => pivBuildActions(
context, widget.devicePath, pivState, ref)
: null),
: null,
keyActionsBuilder: hasFeature(features.actions)
? (context) => pivBuildActions(
context, widget.devicePath, pivState, ref)
: null,
builder: (context, expanded) {
// De-select if window is resized to be non-expanded.
if (!expanded) {