mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 10:11:52 +03:00
Separate "detailed view" from "key actions".
This commit is contained in:
parent
0e709f0085
commit
fa05e72538
@ -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),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -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
|
||||
_ => null
|
||||
},
|
||||
keyActionsBuilder: hasActions
|
||||
? (context) => fidoBuildActions(
|
||||
context, widget.node, widget.state, nFingerprints)
|
||||
: null
|
||||
},
|
||||
: null,
|
||||
keyActionsBadge: fidoShowActionsNotifier(widget.state),
|
||||
builder: (context, expanded) => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
: null,
|
||||
keyActionsBuilder: hasFeature(features.actions)
|
||||
? (context) => pivBuildActions(
|
||||
context, widget.devicePath, pivState, ref)
|
||||
: null),
|
||||
: null,
|
||||
builder: (context, expanded) {
|
||||
// De-select if window is resized to be non-expanded.
|
||||
if (!expanded) {
|
||||
|
Loading…
Reference in New Issue
Block a user