Remove child from AppPage (use builder instead).

This commit is contained in:
Dain Nilsson 2024-01-10 21:05:54 +01:00
parent fa05e72538
commit 50dd72b83b
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8
6 changed files with 11 additions and 17 deletions

View File

@ -33,8 +33,7 @@ final _navExpandedKey = GlobalKey();
class AppPage extends StatelessWidget {
final Widget? title;
final Widget? child;
final Widget Function(BuildContext context, bool expanded)? builder;
final Widget Function(BuildContext context, bool expanded) builder;
final Widget Function(BuildContext context)? detailViewBuilder;
final List<Widget> actions;
final Widget Function(BuildContext context)? keyActionsBuilder;
@ -47,8 +46,7 @@ class AppPage extends StatelessWidget {
const AppPage({
super.key,
this.title,
this.child,
this.builder,
required this.builder,
this.actions = const [],
this.centered = false,
this.keyActionsBuilder,
@ -58,12 +56,8 @@ class AppPage extends StatelessWidget {
this.onFileDropped,
this.delayedContent = false,
this.keyActionsBadge = false,
}) : assert(!(onFileDropped != null && fileDropOverlay == null),
'Declaring onFileDropped requires declaring a fileDropOverlay'),
assert(
((child == null && builder != null) ||
(child != null && builder == null)),
'Exactly one of child and builder must be declared');
}) : assert(!(onFileDropped != null && fileDropOverlay == null),
'Declaring onFileDropped requires declaring a fileDropOverlay');
@override
Widget build(BuildContext context) => LayoutBuilder(
@ -159,7 +153,7 @@ class AppPage extends StatelessWidget {
Widget _buildMainContent(BuildContext context, bool expanded) {
final content = Column(
children: [
child ?? builder!(context, expanded),
builder(context, expanded),
if (actions.isNotEmpty)
Align(
alignment: centered ? Alignment.center : Alignment.centerLeft,

View File

@ -59,7 +59,7 @@ class MessagePage extends StatelessWidget {
onFileDropped: onFileDropped,
actionButtonBuilder: actionButtonBuilder,
delayedContent: delayedContent,
child: Padding(
builder: (context, _) => Padding(
padding: const EdgeInsets.only(
left: 8.0, top: 0.0, right: 8.0, bottom: 96.0),
child: Column(

View File

@ -39,7 +39,7 @@ class FidoScreen extends ConsumerWidget {
title: Text(l10n.s_webauthn),
centered: true,
delayedContent: true,
child: const CircularProgressIndicator(),
builder: (context, _) => const CircularProgressIndicator(),
),
error: (error, _) {
final supported = deviceData

View File

@ -92,7 +92,7 @@ class FidoLockedPage extends ConsumerWidget {
return AppPage(
title: Text(l10n.s_webauthn),
keyActionsBuilder: hasActions ? _buildActions : null,
child: Column(
builder: (context, _) => Column(
children: [
_PinEntryForm(state, node),
],

View File

@ -365,7 +365,7 @@ class _FidoUnlockedPageState extends ConsumerState<FidoUnlockedPage> {
title: Text(AppLocalizations.of(context)!.s_webauthn),
centered: true,
delayedContent: true,
child: const CircularProgressIndicator(),
builder: (context, _) => const CircularProgressIndicator(),
);
}

View File

@ -81,7 +81,7 @@ class _LockedView extends ConsumerWidget {
keyActionsBuilder: hasActions
? (context) => oathBuildActions(context, devicePath, oathState, ref)
: null,
child: Padding(
builder: (context, _) => Padding(
padding: const EdgeInsets.symmetric(vertical: 18),
child: UnlockForm(
devicePath,
@ -259,7 +259,7 @@ class _UnlockedViewState extends ConsumerState<_UnlockedView> {
),
centered: numCreds == null,
delayedContent: numCreds == null,
child: numCreds != null
builder: (context, expanded) => numCreds != null
? Consumer(
builder: (context, ref, _) {
return AccountList(