From c6e1d534144594bf41d797138b287f02fca9fad4 Mon Sep 17 00:00:00 2001 From: Michael Jansen Date: Thu, 2 Jan 2025 14:00:23 -0500 Subject: [PATCH] Fix dialog background colors (#963) --- lib/pages/home_page.dart | 7 + lib/pages/nav_grid_page.dart | 3 + lib/pages/project/project_item_card.dart | 3 + lib/pages/project/project_page.dart | 31 ++ lib/widgets/app_settings.dart | 9 + lib/widgets/dialogs/edit_field_dialog.dart | 3 + lib/widgets/dialogs/import_field_dialog.dart | 2 + lib/widgets/dialogs/management_dialog.dart | 279 ++++++++++-------- lib/widgets/dialogs/settings_dialog.dart | 4 + .../dialogs/trajectory_render_dialog.dart | 2 + .../editor/tree_widgets/waypoints_tree.dart | 3 + 11 files changed, 215 insertions(+), 131 deletions(-) diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index b6c550c76..edcfffeb9 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -135,7 +135,11 @@ class _HomePageState extends State with TickerProviderStateMixin { context: this.context, barrierDismissible: false, builder: (context) { + ColorScheme colorScheme = Theme.of(context).colorScheme; + return AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, title: const Text('New Field Image Available'), content: const SizedBox( width: 400, @@ -187,7 +191,10 @@ class _HomePageState extends State with TickerProviderStateMixin { context: this.context, barrierDismissible: false, builder: (context) { + ColorScheme colorScheme = Theme.of(context).colorScheme; return AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, title: const Text('Non-standard Field Mirroring'), content: const SizedBox( width: 300, diff --git a/lib/pages/nav_grid_page.dart b/lib/pages/nav_grid_page.dart index 5fd716c1b..9421bae9e 100644 --- a/lib/pages/nav_grid_page.dart +++ b/lib/pages/nav_grid_page.dart @@ -156,7 +156,10 @@ class _NavGridPageState extends State { showDialog( context: this.context, builder: (context) { + ColorScheme colorScheme = Theme.of(context).colorScheme; return AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, title: const Text('Edit Grid'), content: SizedBox( width: 350, diff --git a/lib/pages/project/project_item_card.dart b/lib/pages/project/project_item_card.dart index 787121662..5628d650f 100644 --- a/lib/pages/project/project_item_card.dart +++ b/lib/pages/project/project_item_card.dart @@ -251,7 +251,10 @@ class _ProjectItemCardState extends State { showDialog( context: context, builder: (context) { + ColorScheme colorScheme = Theme.of(context).colorScheme; return AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, title: const Text('Delete File'), content: Text( 'Are you sure you want to delete the file: ${widget.name}? This cannot be undone.\n\nIf this is a path, any autos using it will have their reference to it removed.'), diff --git a/lib/pages/project/project_page.dart b/lib/pages/project/project_page.dart index d49b1bf52..60c7160f1 100644 --- a/lib/pages/project/project_page.dart +++ b/lib/pages/project/project_page.dart @@ -811,7 +811,18 @@ class _ProjectPageState extends State { context: context, builder: (BuildContext context) { + ColorScheme + colorScheme = + Theme.of( + context) + .colorScheme; return AlertDialog( + backgroundColor: + colorScheme + .surface, + surfaceTintColor: + colorScheme + .surfaceTint, title: const Text( 'Unable to Rename'), content: Text( @@ -1052,7 +1063,10 @@ class _ProjectPageState extends State { showDialog( context: context, builder: (BuildContext context) { + ColorScheme colorScheme = Theme.of(context).colorScheme; return AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, title: const Text('Unable to Rename'), content: Text('The file "$newName.path" already exists'), actions: [ @@ -1300,7 +1314,18 @@ class _ProjectPageState extends State { context: context, builder: (BuildContext context) { + ColorScheme + colorScheme = + Theme.of( + context) + .colorScheme; return AlertDialog( + backgroundColor: + colorScheme + .surface, + surfaceTintColor: + colorScheme + .surfaceTint, title: const Text( 'Unable to Rename'), content: Text( @@ -1524,7 +1549,10 @@ class _ProjectPageState extends State { showDialog( context: this.context, builder: (context) { + ColorScheme colorScheme = Theme.of(context).colorScheme; return AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, title: const Text('Delete Folder'), content: SizedBox( width: 400, @@ -1787,7 +1815,10 @@ class _ProjectPageState extends State { showDialog( context: context, builder: (BuildContext context) { + ColorScheme colorScheme = Theme.of(context).colorScheme; return AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, title: const Text('Unable to Rename'), content: Text('The file "$newName.auto" already exists'), actions: [ diff --git a/lib/widgets/app_settings.dart b/lib/widgets/app_settings.dart index 0e7c55cbe..7296e9287 100644 --- a/lib/widgets/app_settings.dart +++ b/lib/widgets/app_settings.dart @@ -410,7 +410,10 @@ class _AppSettingsState extends State { showDialog( context: context, builder: (context) { + ColorScheme colorScheme = Theme.of(context).colorScheme; return AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, title: const Text('Delete Custom Field Image'), content: Text( 'Are you sure you want to delete the custom field "${_selectedField.name}"? This cannot be undone.'), @@ -472,7 +475,10 @@ class _AppSettingsState extends State { context: context, barrierColor: Colors.transparent, builder: (BuildContext context) { + ColorScheme colorScheme = Theme.of(context).colorScheme; return AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, title: const Text('Pick Theme Color'), content: Padding( padding: const EdgeInsets.symmetric(vertical: 4.0), @@ -534,10 +540,13 @@ class _AppSettingsState extends State { showDialog( context: context, builder: (BuildContext context) { + ColorScheme colorScheme = Theme.of(context).colorScheme; return KeyBoardShortcuts( keysToPress: {LogicalKeyboardKey.enter}, onKeysPressed: () => Navigator.of(context).pop(), child: AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, title: const Text('Failed to Import Field'), content: Text('Field with the name "$name" already exists.'), diff --git a/lib/widgets/dialogs/edit_field_dialog.dart b/lib/widgets/dialogs/edit_field_dialog.dart index 3d1762ef1..c9510937c 100644 --- a/lib/widgets/dialogs/edit_field_dialog.dart +++ b/lib/widgets/dialogs/edit_field_dialog.dart @@ -36,10 +36,13 @@ class _EditFieldDialogState extends State { @override Widget build(BuildContext context) { + ColorScheme colorScheme = Theme.of(context).colorScheme; return KeyBoardShortcuts( keysToPress: {LogicalKeyboardKey.enter}, onKeysPressed: () => confirm(context), child: AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, title: const Text('Edit Custom Field'), content: Column( mainAxisSize: MainAxisSize.min, diff --git a/lib/widgets/dialogs/import_field_dialog.dart b/lib/widgets/dialogs/import_field_dialog.dart index 25362c2de..635181342 100644 --- a/lib/widgets/dialogs/import_field_dialog.dart +++ b/lib/widgets/dialogs/import_field_dialog.dart @@ -40,6 +40,8 @@ class _ImportFieldDialogState extends State { keysToPress: {LogicalKeyboardKey.enter}, onKeysPressed: () => confirm(context), child: AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, title: const Text('Import Custom Field'), content: Column( mainAxisSize: MainAxisSize.min, diff --git a/lib/widgets/dialogs/management_dialog.dart b/lib/widgets/dialogs/management_dialog.dart index b278bc29f..fc81ad474 100644 --- a/lib/widgets/dialogs/management_dialog.dart +++ b/lib/widgets/dialogs/management_dialog.dart @@ -132,29 +132,34 @@ class _ManagementDialogState extends State { onPressed: () { showDialog( context: context, - builder: (BuildContext context) => AlertDialog( - title: const Text('Remove Event'), - content: Text( - 'Are you sure you want to remove the event "$eventName"? This cannot be undone.'), - actions: [ - TextButton( - onPressed: Navigator.of(context).pop, - child: const Text('Cancel'), - ), - TextButton( - onPressed: () { - setState(() { - widget.onEventDeleted(eventName); - ProjectPage.events - .remove(eventName); - }); + builder: (BuildContext context) { + ColorScheme colorScheme = + Theme.of(context).colorScheme; + return AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, + title: const Text('Remove Event'), + content: Text( + 'Are you sure you want to remove the event "$eventName"? This cannot be undone.'), + actions: [ + TextButton( + onPressed: Navigator.of(context).pop, + child: const Text('Cancel'), + ), + TextButton( + onPressed: () { + setState(() { + widget.onEventDeleted(eventName); + ProjectPage.events.remove(eventName); + }); - Navigator.of(context).pop(); - }, - child: const Text('Confirm'), - ), - ], - )); + Navigator.of(context).pop(); + }, + child: const Text('Confirm'), + ), + ], + ); + }); }, icon: Icon( Icons.delete_forever_rounded, @@ -203,27 +208,33 @@ class _ManagementDialogState extends State { onPressed: () { showDialog( context: context, - builder: (BuildContext context) => AlertDialog( - title: const Text('Remove Linked Waypoint'), - content: Text( - 'Are you sure you want to remove the linked waypoint "$waypointName"? This cannot be undone.'), - actions: [ - TextButton( - onPressed: Navigator.of(context).pop, - child: const Text('Cancel'), - ), - TextButton( - onPressed: () { - setState(() { - widget.onLinkedDeleted(waypointName); - }); + builder: (BuildContext context) { + ColorScheme colorScheme = + Theme.of(context).colorScheme; + return AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, + title: const Text('Remove Linked Waypoint'), + content: Text( + 'Are you sure you want to remove the linked waypoint "$waypointName"? This cannot be undone.'), + actions: [ + TextButton( + onPressed: Navigator.of(context).pop, + child: const Text('Cancel'), + ), + TextButton( + onPressed: () { + setState(() { + widget.onLinkedDeleted(waypointName); + }); - Navigator.of(context).pop(); - }, - child: const Text('Confirm'), - ), - ], - )); + Navigator.of(context).pop(); + }, + child: const Text('Confirm'), + ), + ], + ); + }); }, icon: Icon( Icons.delete_forever_rounded, @@ -243,55 +254,58 @@ class _ManagementDialogState extends State { TextEditingController controller = TextEditingController(text: originalName); - ColorScheme colorScheme = Theme.of(context).colorScheme; - showDialog( context: context, - builder: (BuildContext context) => AlertDialog( - title: const Text('Rename Event'), - content: SizedBox( - height: 42, - width: 400, - child: TextField( - controller: controller, - style: TextStyle(fontSize: 14, color: colorScheme.onSurface), - decoration: InputDecoration( - contentPadding: const EdgeInsets.fromLTRB(8, 4, 8, 4), - labelText: 'Event Name', - border: - OutlineInputBorder(borderRadius: BorderRadius.circular(8)), + builder: (BuildContext context) { + ColorScheme colorScheme = Theme.of(context).colorScheme; + return AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, + title: const Text('Rename Event'), + content: SizedBox( + height: 42, + width: 400, + child: TextField( + controller: controller, + style: TextStyle(fontSize: 14, color: colorScheme.onSurface), + decoration: InputDecoration( + contentPadding: const EdgeInsets.fromLTRB(8, 4, 8, 4), + labelText: 'Event Name', + border: + OutlineInputBorder(borderRadius: BorderRadius.circular(8)), + ), ), ), - ), - actions: [ - TextButton( - onPressed: Navigator.of(context).pop, - child: const Text('Cancel'), - ), - TextButton( - onPressed: () { - if (controller.text == originalName) { - Navigator.of(context).pop(); - } else if (ProjectPage.events.contains(controller.text)) { - Navigator.of(context).pop(); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('An event with that name already exists'), - ), - ); - } else { - Navigator.of(context).pop(); - setState(() { - widget.onEventRenamed(originalName, controller.text); - ProjectPage.events.remove(originalName); - ProjectPage.events.add(controller.text); - }); - } - }, - child: const Text('Confirm'), - ), - ], - ), + actions: [ + TextButton( + onPressed: Navigator.of(context).pop, + child: const Text('Cancel'), + ), + TextButton( + onPressed: () { + if (controller.text == originalName) { + Navigator.of(context).pop(); + } else if (ProjectPage.events.contains(controller.text)) { + Navigator.of(context).pop(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('An event with that name already exists'), + ), + ); + } else { + Navigator.of(context).pop(); + setState(() { + widget.onEventRenamed(originalName, controller.text); + ProjectPage.events.remove(originalName); + ProjectPage.events.add(controller.text); + }); + } + }, + child: const Text('Confirm'), + ), + ], + ); + }, ); } @@ -299,54 +313,57 @@ class _ManagementDialogState extends State { TextEditingController controller = TextEditingController(text: originalName); - ColorScheme colorScheme = Theme.of(context).colorScheme; - showDialog( context: context, - builder: (BuildContext context) => AlertDialog( - title: const Text('Rename Linked Waypoint'), - content: SizedBox( - height: 42, - width: 400, - child: TextField( - controller: controller, - style: TextStyle(fontSize: 14, color: colorScheme.onSurface), - decoration: InputDecoration( - contentPadding: const EdgeInsets.fromLTRB(8, 4, 8, 4), - labelText: 'Waypoint Name', - border: - OutlineInputBorder(borderRadius: BorderRadius.circular(8)), + builder: (BuildContext context) { + ColorScheme colorScheme = Theme.of(context).colorScheme; + return AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, + title: const Text('Rename Linked Waypoint'), + content: SizedBox( + height: 42, + width: 400, + child: TextField( + controller: controller, + style: TextStyle(fontSize: 14, color: colorScheme.onSurface), + decoration: InputDecoration( + contentPadding: const EdgeInsets.fromLTRB(8, 4, 8, 4), + labelText: 'Waypoint Name', + border: + OutlineInputBorder(borderRadius: BorderRadius.circular(8)), + ), ), ), - ), - actions: [ - TextButton( - onPressed: Navigator.of(context).pop, - child: const Text('Cancel'), - ), - TextButton( - onPressed: () { - if (controller.text == originalName) { - Navigator.of(context).pop(); - } else if (Waypoint.linked.containsKey(controller.text)) { - Navigator.of(context).pop(); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: - Text('A linked waypoint with that name already exists'), - ), - ); - } else { - Navigator.of(context).pop(); - setState(() { - widget.onLinkedRenamed(originalName, controller.text); - }); - } - }, - child: const Text('Confirm'), - ), - ], - ), + actions: [ + TextButton( + onPressed: Navigator.of(context).pop, + child: const Text('Cancel'), + ), + TextButton( + onPressed: () { + if (controller.text == originalName) { + Navigator.of(context).pop(); + } else if (Waypoint.linked.containsKey(controller.text)) { + Navigator.of(context).pop(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text( + 'A linked waypoint with that name already exists'), + ), + ); + } else { + Navigator.of(context).pop(); + setState(() { + widget.onLinkedRenamed(originalName, controller.text); + }); + } + }, + child: const Text('Confirm'), + ), + ], + ); + }, ); } } diff --git a/lib/widgets/dialogs/settings_dialog.dart b/lib/widgets/dialogs/settings_dialog.dart index e60c4e745..1caf01980 100644 --- a/lib/widgets/dialogs/settings_dialog.dart +++ b/lib/widgets/dialogs/settings_dialog.dart @@ -24,9 +24,13 @@ class SettingsDialog extends StatelessWidget { @override Widget build(BuildContext context) { + ColorScheme colorScheme = Theme.of(context).colorScheme; + return DefaultTabController( length: 2, child: AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, title: const TabBar( tabs: [ Tab( diff --git a/lib/widgets/dialogs/trajectory_render_dialog.dart b/lib/widgets/dialogs/trajectory_render_dialog.dart index d3dd47273..571bdf2bd 100644 --- a/lib/widgets/dialogs/trajectory_render_dialog.dart +++ b/lib/widgets/dialogs/trajectory_render_dialog.dart @@ -64,6 +64,8 @@ class _TrajectoryRenderDialogState extends State { ColorScheme colorScheme = Theme.of(context).colorScheme; return AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, content: Column( mainAxisSize: MainAxisSize.min, children: [ diff --git a/lib/widgets/editor/tree_widgets/waypoints_tree.dart b/lib/widgets/editor/tree_widgets/waypoints_tree.dart index 5188569df..734a458bd 100644 --- a/lib/widgets/editor/tree_widgets/waypoints_tree.dart +++ b/lib/widgets/editor/tree_widgets/waypoints_tree.dart @@ -414,7 +414,10 @@ class _WaypointsTreeState extends State { showDialog( context: context, builder: (context) { + ColorScheme colorScheme = Theme.of(context).colorScheme; return AlertDialog( + backgroundColor: colorScheme.surface, + surfaceTintColor: colorScheme.surfaceTint, title: const Text('Link Waypoint'), content: SizedBox( width: 400,