diff --git a/lib/src/mixins/preferences_mixin.dart b/lib/src/mixins/preferences_mixin.dart index 59706cc..a43d9ae 100644 --- a/lib/src/mixins/preferences_mixin.dart +++ b/lib/src/mixins/preferences_mixin.dart @@ -31,6 +31,7 @@ mixin PreferencesMixin { return prefs.getStringList(key) as T; } } + return null; } Future deletePreference(String key) async { diff --git a/lib/src/pages/operating_system_selection.dart b/lib/src/pages/operating_system_selection.dart index 033933d..b032724 100644 --- a/lib/src/pages/operating_system_selection.dart +++ b/lib/src/pages/operating_system_selection.dart @@ -74,11 +74,18 @@ class _OperatingSystemSelectionState extends State { itemCount: list.length, itemBuilder: (context, index) { var item = list[index]; - var icon = SvgPicture.asset( - "assets/quickemu-icons/${item.code}.svg", - width: 32, - height: 32, - ); + Widget icon; + + try { + icon = SvgPicture.asset( + "assets/quickemu-icons/${item.code}.svg", + width: 32, + height: 32, + ); + } catch (e) { + // Replace with generic icon + icon = const Icon(Icons.computer, size: 32); + } return Card( child: ListTile( title: Text(item.name), diff --git a/lib/src/widgets/downloader/cancel_dismiss_button.dart b/lib/src/widgets/downloader/cancel_dismiss_button.dart index ac5eea9..994ebb7 100644 --- a/lib/src/widgets/downloader/cancel_dismiss_button.dart +++ b/lib/src/widgets/downloader/cancel_dismiss_button.dart @@ -20,8 +20,8 @@ class CancelDismissButton extends StatelessWidget { children: [ ElevatedButton( style: ElevatedButton.styleFrom( - primary: Theme.of(context).colorScheme.surface, - onPrimary: Theme.of(context).brightness == Brightness.dark + backgroundColor: Theme.of(context).colorScheme.surface, + foregroundColor: Theme.of(context).brightness == Brightness.dark ? Colors.white70 : Theme.of(context).colorScheme.primary, ), diff --git a/lib/src/widgets/home_page/downloader_page_button.dart b/lib/src/widgets/home_page/downloader_page_button.dart new file mode 100644 index 0000000..20b1515 --- /dev/null +++ b/lib/src/widgets/home_page/downloader_page_button.dart @@ -0,0 +1,54 @@ +import 'package:flutter/material.dart'; + +class DownloaderPageButton extends StatelessWidget { + const DownloaderPageButton({ + Key? key, + this.label, + required this.text, + this.onPressed, + }) : super(key: key); + + final String? label; + final String text; + final VoidCallback? onPressed; + + @override + Widget build(BuildContext context) { + return Expanded( + flex: 1, + child: Padding( + padding: const EdgeInsets.fromLTRB(12, 0, 12, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Padding( + padding: const EdgeInsets.all(4.0), + child: Center( + child: Text( + label?.toUpperCase() ?? '', + style: Theme.of(context) + .textTheme + .titleSmall + ?.copyWith(color: Colors.white), + ), + ), + ), + ElevatedButton( + style: ElevatedButton.styleFrom( + foregroundColor: Theme.of(context).brightness == Brightness.dark + ? Colors.white70 + : Theme.of(context).colorScheme.primary, + backgroundColor: Theme.of(context).canvasColor, + ), + onPressed: onPressed, + child: Padding( + padding: const EdgeInsets.fromLTRB(0, 16, 0, 16), + child: Text(text), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/src/widgets/home_page/home_page_button.dart b/lib/src/widgets/home_page/home_page_button.dart index 84a0fde..5345145 100644 --- a/lib/src/widgets/home_page/home_page_button.dart +++ b/lib/src/widgets/home_page/home_page_button.dart @@ -21,22 +21,19 @@ class HomePageButton extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Padding( - padding: const EdgeInsets.only(bottom: 24), - child: Center( - child: Text( - label?.toUpperCase() ?? '', - style: Theme.of(context) - .textTheme - .subtitle2 - ?.copyWith(color: Colors.white), - ), + Center( + child: Text( + label?.toUpperCase() ?? '', + style: Theme.of(context) + .textTheme + .titleSmall + ?.copyWith(color: Colors.white), ), ), ElevatedButton( style: ElevatedButton.styleFrom( - primary: Theme.of(context).canvasColor, - onPrimary: Theme.of(context).brightness == Brightness.dark + backgroundColor: Theme.of(context).canvasColor, + foregroundColor: Theme.of(context).brightness == Brightness.dark ? Colors.white70 : Theme.of(context).colorScheme.primary, ), diff --git a/lib/src/widgets/home_page/home_page_button_group.dart b/lib/src/widgets/home_page/home_page_button_group.dart index 9f4d8fb..91c45c2 100644 --- a/lib/src/widgets/home_page/home_page_button_group.dart +++ b/lib/src/widgets/home_page/home_page_button_group.dart @@ -1,8 +1,8 @@ import 'dart:io'; import 'package:flutter/material.dart'; -import 'package:tuple/tuple.dart'; import 'package:gettext_i18n/gettext_i18n.dart'; +import 'package:tuple/tuple.dart'; import '../../model/operating_system.dart'; import '../../model/option.dart'; @@ -10,7 +10,7 @@ import '../../model/version.dart'; import '../../pages/downloader.dart'; import '../../pages/operating_system_selection.dart'; import '../../pages/version_selection.dart'; -import '../home_page/home_page_button.dart'; +import 'downloader_page_button.dart'; class HomePageButtonGroup extends StatefulWidget { const HomePageButtonGroup({Key? key}) : super(key: key); @@ -33,7 +33,7 @@ class _HomePageButtonGroupState extends State { } return Row( children: [ - HomePageButton( + DownloaderPageButton( label: context.t("Operating system"), text: _selectedOperatingSystem?.name ?? context.t('Select...'), onPressed: () { @@ -58,7 +58,7 @@ class _HomePageButtonGroupState extends State { }); }, ), - HomePageButton( + DownloaderPageButton( label: context.t('Version'), text: _versionButtonLabel, //_selectedVersion?.version ?? 'Select...', onPressed: (_selectedOperatingSystem != null) @@ -80,7 +80,7 @@ class _HomePageButtonGroupState extends State { } : null, ), - HomePageButton( + DownloaderPageButton( label: context.t('Download'), text: context.t('Download'), onPressed: (_selectedVersion == null) @@ -122,7 +122,7 @@ class _HomePageButtonGroupState extends State { child: Text(context.t('Downloading...'), style: Theme.of(context) .textTheme - .bodyText1 + .bodyLarge ?.copyWith(color: Colors.white)), ), const CircularProgressIndicator(), @@ -132,7 +132,7 @@ class _HomePageButtonGroupState extends State { 'Target : ${Directory.current.absolute.path}', style: Theme.of(context) .textTheme - .bodyText1 + .bodyLarge ?.copyWith(color: Colors.white), ), ), @@ -170,7 +170,7 @@ class _HomePageButtonGroupState extends State { child: Text(context.t('Done !'), style: Theme.of(context) .textTheme - .bodyText1 + .bodyLarge ?.copyWith(color: Colors.white)), ), Text( @@ -178,7 +178,7 @@ class _HomePageButtonGroupState extends State { args: ["quickemu --vm $operatingSystem-$version"]), style: Theme.of(context) .textTheme - .bodyText1 + .bodyLarge ?.copyWith(color: Colors.white)), Padding( padding: const EdgeInsets.symmetric(vertical: 32), @@ -190,7 +190,7 @@ class _HomePageButtonGroupState extends State { 'Dismiss', style: Theme.of(context) .textTheme - .bodyText1 + .bodyLarge ?.copyWith(color: Colors.white), ), ), diff --git a/lib/src/widgets/home_page/logo.dart b/lib/src/widgets/home_page/logo.dart index 72c677c..912dbf8 100644 --- a/lib/src/widgets/home_page/logo.dart +++ b/lib/src/widgets/home_page/logo.dart @@ -8,7 +8,7 @@ class Logo extends StatelessWidget { @override Widget build(BuildContext context) { return SizedBox( - height: 250, + height: 230, child: Flex( direction: Axis.vertical, children: [ diff --git a/lib/src/widgets/left_menu.dart b/lib/src/widgets/left_menu.dart index f048efd..b7a8596 100644 --- a/lib/src/widgets/left_menu.dart +++ b/lib/src/widgets/left_menu.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:gettext_i18n/gettext_i18n.dart'; +import 'package:provider/provider.dart'; import 'package:quickgui/src/supported_locales.dart'; import '../globals.dart'; @@ -46,7 +46,7 @@ class _LeftMenuState extends State with PreferencesMixin { children: [ ListTile( title: Text("quickgui $_version", - style: Theme.of(context).textTheme.headline6), + style: Theme.of(context).textTheme.titleLarge), ), const Divider(), Padding(