Skip to content

Commit 26ddbd5

Browse files
committed
Move root GestureDetector to AppPage
1 parent 716bd98 commit 26ddbd5

File tree

2 files changed

+138
-136
lines changed

2 files changed

+138
-136
lines changed

lib/app/app.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,7 @@ class YubicoAuthenticatorApp extends StatelessWidget {
4040
theme: AppTheme.getLightTheme(primaryColor),
4141
darkTheme: AppTheme.getDarkTheme(primaryColor),
4242
themeMode: ref.watch(themeModeProvider),
43-
home: GestureDetector(
44-
onTap: () {
45-
// If tap is not absorbed downstream, treat it as dead space
46-
// and invoke escape intent
47-
Actions.invoke(context, const EscapeIntent());
48-
},
49-
child: page,
50-
),
43+
home: page,
5144
debugShowCheckedModeBanner: false,
5245
locale: ref.watch(currentLocaleProvider),
5346
supportedLocales: AppLocalizations.supportedLocales,

lib/app/views/app_page.dart

Lines changed: 137 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import '../../management/models.dart';
3030
import '../../widgets/delayed_visibility.dart';
3131
import '../../widgets/file_drop_target.dart';
3232
import '../message.dart';
33+
import '../shortcuts.dart';
3334
import '../state.dart';
3435
import 'fs_dialog.dart';
3536
import 'keys.dart';
@@ -569,7 +570,7 @@ class _AppPageState extends ConsumerState<AppPage> {
569570
);
570571
}
571572

572-
Scaffold _buildScaffold(
573+
Widget _buildScaffold(
573574
BuildContext context,
574575
bool hasDrawer,
575576
bool hasRail,
@@ -689,145 +690,153 @@ class _AppPageState extends ConsumerState<AppPage> {
689690
),
690691
);
691692
}
692-
return Scaffold(
693-
key: scaffoldGlobalKey,
694-
appBar: AppBar(
695-
bottom: PreferredSize(
696-
preferredSize: const Size.fromHeight(1.0),
697-
child: ListenableBuilder(
698-
listenable: _scrolledUnderController,
699-
builder: (context, child) {
700-
final visible = _scrolledUnderController.someIsScrolledUnder;
701-
return AnimatedOpacity(
702-
opacity: visible ? 1 : 0,
703-
duration: const Duration(milliseconds: 300),
704-
child: Container(
705-
color: Theme.of(context).hoverColor,
706-
height: 1.0,
707-
),
708-
);
709-
},
693+
return GestureDetector(
694+
behavior: HitTestBehavior.deferToChild,
695+
onTap: () {
696+
// If tap is not absorbed downstream, treat it as dead space
697+
// and invoke escape intent
698+
Actions.invoke(context, EscapeIntent());
699+
},
700+
child: Scaffold(
701+
key: scaffoldGlobalKey,
702+
appBar: AppBar(
703+
bottom: PreferredSize(
704+
preferredSize: const Size.fromHeight(1.0),
705+
child: ListenableBuilder(
706+
listenable: _scrolledUnderController,
707+
builder: (context, child) {
708+
final visible = _scrolledUnderController.someIsScrolledUnder;
709+
return AnimatedOpacity(
710+
opacity: visible ? 1 : 0,
711+
duration: const Duration(milliseconds: 300),
712+
child: Container(
713+
color: Theme.of(context).hoverColor,
714+
height: 1.0,
715+
),
716+
);
717+
},
718+
),
710719
),
711-
),
712-
iconTheme: IconThemeData(
713-
color: Theme.of(context).colorScheme.onSurfaceVariant,
714-
),
715-
scrolledUnderElevation: 0.0,
716-
leadingWidth: hasRail ? 84 : null,
717-
backgroundColor: Theme.of(context).colorScheme.surface,
718-
title: _buildAppBarTitle(context, hasRail, hasManage, fullyExpanded),
719-
centerTitle: true,
720-
leading:
721-
hasRail
722-
? Row(
723-
mainAxisAlignment: MainAxisAlignment.spaceAround,
724-
children: [
725-
Expanded(
726-
child: Padding(
727-
padding: const EdgeInsets.symmetric(horizontal: 8),
728-
child: IconButton(
729-
icon: Icon(
730-
Symbols.menu,
731-
semanticLabel: navigationText,
720+
iconTheme: IconThemeData(
721+
color: Theme.of(context).colorScheme.onSurfaceVariant,
722+
),
723+
scrolledUnderElevation: 0.0,
724+
leadingWidth: hasRail ? 84 : null,
725+
backgroundColor: Theme.of(context).colorScheme.surface,
726+
title: _buildAppBarTitle(context, hasRail, hasManage, fullyExpanded),
727+
centerTitle: true,
728+
leading:
729+
hasRail
730+
? Row(
731+
mainAxisAlignment: MainAxisAlignment.spaceAround,
732+
children: [
733+
Expanded(
734+
child: Padding(
735+
padding: const EdgeInsets.symmetric(horizontal: 8),
736+
child: IconButton(
737+
icon: Icon(
738+
Symbols.menu,
739+
semanticLabel: navigationText,
740+
),
741+
tooltip: navigationText,
742+
onPressed:
743+
fullyExpanded
744+
? () {
745+
ref
746+
.read(
747+
_navigationVisibilityProvider
748+
.notifier,
749+
)
750+
.toggleExpanded();
751+
}
752+
: () {
753+
scaffoldGlobalKey.currentState
754+
?.openDrawer();
755+
},
732756
),
733-
tooltip: navigationText,
734-
onPressed:
735-
fullyExpanded
736-
? () {
737-
ref
738-
.read(
739-
_navigationVisibilityProvider
740-
.notifier,
741-
)
742-
.toggleExpanded();
743-
}
744-
: () {
745-
scaffoldGlobalKey.currentState
746-
?.openDrawer();
747-
},
748757
),
749758
),
750-
),
751-
const SizedBox(width: 12),
752-
],
753-
)
754-
: Builder(
755-
builder: (context) {
756-
// Need to wrap with builder to get Scaffold context
757-
return IconButton(
758-
tooltip: l10n.s_show_navigation,
759-
onPressed: () => Scaffold.of(context).openDrawer(),
760-
icon: Icon(
761-
Symbols.menu,
762-
semanticLabel: l10n.s_show_navigation,
763-
),
759+
const SizedBox(width: 12),
760+
],
761+
)
762+
: Builder(
763+
builder: (context) {
764+
// Need to wrap with builder to get Scaffold context
765+
return IconButton(
766+
tooltip: l10n.s_show_navigation,
767+
onPressed: () => Scaffold.of(context).openDrawer(),
768+
icon: Icon(
769+
Symbols.menu,
770+
semanticLabel: l10n.s_show_navigation,
771+
),
772+
);
773+
},
774+
),
775+
actions: [
776+
if (widget.actionButtonBuilder == null &&
777+
(widget.keyActionsBuilder != null && !hasManage))
778+
Padding(
779+
padding: const EdgeInsets.only(left: 4),
780+
child: IconButton(
781+
key: actionsIconButtonKey,
782+
onPressed: () {
783+
showBlurDialog(
784+
context: context,
785+
barrierColor: Colors.transparent,
786+
builder:
787+
(context) => FsDialog(
788+
child: Padding(
789+
padding: const EdgeInsets.only(top: 32),
790+
child: widget.keyActionsBuilder!(context),
791+
),
792+
),
764793
);
765794
},
766-
),
767-
actions: [
768-
if (widget.actionButtonBuilder == null &&
769-
(widget.keyActionsBuilder != null && !hasManage))
770-
Padding(
771-
padding: const EdgeInsets.only(left: 4),
772-
child: IconButton(
773-
key: actionsIconButtonKey,
774-
onPressed: () {
775-
showBlurDialog(
776-
context: context,
777-
barrierColor: Colors.transparent,
778-
builder:
779-
(context) => FsDialog(
780-
child: Padding(
781-
padding: const EdgeInsets.only(top: 32),
782-
child: widget.keyActionsBuilder!(context),
783-
),
784-
),
785-
);
786-
},
787-
icon:
788-
widget.keyActionsBadge
789-
? Badge(
790-
child: Icon(
795+
icon:
796+
widget.keyActionsBadge
797+
? Badge(
798+
child: Icon(
799+
Symbols.more_vert,
800+
semanticLabel: l10n.s_show_menu,
801+
),
802+
)
803+
: Icon(
791804
Symbols.more_vert,
792805
semanticLabel: l10n.s_show_menu,
793806
),
794-
)
795-
: Icon(
796-
Symbols.more_vert,
797-
semanticLabel: l10n.s_show_menu,
798-
),
799-
iconSize: 24,
800-
tooltip: l10n.s_show_menu,
801-
padding: const EdgeInsets.all(12),
807+
iconSize: 24,
808+
tooltip: l10n.s_show_menu,
809+
padding: const EdgeInsets.all(12),
810+
),
802811
),
803-
),
804-
if (hasManage &&
805-
(widget.keyActionsBuilder != null ||
806-
widget.detailViewBuilder != null))
807-
Padding(
808-
padding: const EdgeInsets.only(left: 4),
809-
child: IconButton(
810-
key: toggleDetailViewIconButtonKey,
811-
onPressed: () {
812-
ref
813-
.read(_detailViewVisibilityProvider.notifier)
814-
.toggleExpanded();
815-
},
816-
icon: const Icon(Symbols.more_vert, weight: 600.0),
817-
iconSize: 24,
818-
tooltip: showDetailView ? l10n.s_hide_menu : l10n.s_show_menu,
819-
padding: const EdgeInsets.all(12),
812+
if (hasManage &&
813+
(widget.keyActionsBuilder != null ||
814+
widget.detailViewBuilder != null))
815+
Padding(
816+
padding: const EdgeInsets.only(left: 4),
817+
child: IconButton(
818+
key: toggleDetailViewIconButtonKey,
819+
onPressed: () {
820+
ref
821+
.read(_detailViewVisibilityProvider.notifier)
822+
.toggleExpanded();
823+
},
824+
icon: const Icon(Symbols.more_vert, weight: 600.0),
825+
iconSize: 24,
826+
tooltip: showDetailView ? l10n.s_hide_menu : l10n.s_show_menu,
827+
padding: const EdgeInsets.all(12),
828+
),
820829
),
821-
),
822-
if (widget.actionButtonBuilder != null)
823-
Padding(
824-
padding: const EdgeInsets.only(right: 12),
825-
child: widget.actionButtonBuilder!.call(context),
826-
),
827-
],
830+
if (widget.actionButtonBuilder != null)
831+
Padding(
832+
padding: const EdgeInsets.only(right: 12),
833+
child: widget.actionButtonBuilder!.call(context),
834+
),
835+
],
836+
),
837+
drawer: hasDrawer ? _buildDrawer(context) : null,
838+
body: body,
828839
),
829-
drawer: hasDrawer ? _buildDrawer(context) : null,
830-
body: body,
831840
);
832841
}
833842
}

0 commit comments

Comments
 (0)