Updated deprecated code, added check for svg files, fixed visibility of buttons in download page

This commit is contained in:
codseus 2023-04-08 19:17:19 +03:00 committed by Mark Johnson
parent 174b43e83f
commit 245c1f5251
No known key found for this signature in database
GPG Key ID: EB30E1468CFAE242
8 changed files with 91 additions and 32 deletions

View File

@ -31,6 +31,7 @@ mixin PreferencesMixin {
return prefs.getStringList(key) as T; return prefs.getStringList(key) as T;
} }
} }
return null;
} }
Future<void> deletePreference(String key) async { Future<void> deletePreference(String key) async {

View File

@ -74,11 +74,18 @@ class _OperatingSystemSelectionState extends State<OperatingSystemSelection> {
itemCount: list.length, itemCount: list.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
var item = list[index]; var item = list[index];
var icon = SvgPicture.asset( Widget icon;
"assets/quickemu-icons/${item.code}.svg",
width: 32, try {
height: 32, 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( return Card(
child: ListTile( child: ListTile(
title: Text(item.name), title: Text(item.name),

View File

@ -20,8 +20,8 @@ class CancelDismissButton extends StatelessWidget {
children: [ children: [
ElevatedButton( ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: Theme.of(context).colorScheme.surface, backgroundColor: Theme.of(context).colorScheme.surface,
onPrimary: Theme.of(context).brightness == Brightness.dark foregroundColor: Theme.of(context).brightness == Brightness.dark
? Colors.white70 ? Colors.white70
: Theme.of(context).colorScheme.primary, : Theme.of(context).colorScheme.primary,
), ),

View File

@ -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),
),
),
],
),
),
);
}
}

View File

@ -21,22 +21,19 @@ class HomePageButton extends StatelessWidget {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Padding( Center(
padding: const EdgeInsets.only(bottom: 24), child: Text(
child: Center( label?.toUpperCase() ?? '',
child: Text( style: Theme.of(context)
label?.toUpperCase() ?? '', .textTheme
style: Theme.of(context) .titleSmall
.textTheme ?.copyWith(color: Colors.white),
.subtitle2
?.copyWith(color: Colors.white),
),
), ),
), ),
ElevatedButton( ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: Theme.of(context).canvasColor, backgroundColor: Theme.of(context).canvasColor,
onPrimary: Theme.of(context).brightness == Brightness.dark foregroundColor: Theme.of(context).brightness == Brightness.dark
? Colors.white70 ? Colors.white70
: Theme.of(context).colorScheme.primary, : Theme.of(context).colorScheme.primary,
), ),

View File

@ -1,8 +1,8 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:tuple/tuple.dart';
import 'package:gettext_i18n/gettext_i18n.dart'; import 'package:gettext_i18n/gettext_i18n.dart';
import 'package:tuple/tuple.dart';
import '../../model/operating_system.dart'; import '../../model/operating_system.dart';
import '../../model/option.dart'; import '../../model/option.dart';
@ -10,7 +10,7 @@ import '../../model/version.dart';
import '../../pages/downloader.dart'; import '../../pages/downloader.dart';
import '../../pages/operating_system_selection.dart'; import '../../pages/operating_system_selection.dart';
import '../../pages/version_selection.dart'; import '../../pages/version_selection.dart';
import '../home_page/home_page_button.dart'; import 'downloader_page_button.dart';
class HomePageButtonGroup extends StatefulWidget { class HomePageButtonGroup extends StatefulWidget {
const HomePageButtonGroup({Key? key}) : super(key: key); const HomePageButtonGroup({Key? key}) : super(key: key);
@ -33,7 +33,7 @@ class _HomePageButtonGroupState extends State<HomePageButtonGroup> {
} }
return Row( return Row(
children: [ children: [
HomePageButton( DownloaderPageButton(
label: context.t("Operating system"), label: context.t("Operating system"),
text: _selectedOperatingSystem?.name ?? context.t('Select...'), text: _selectedOperatingSystem?.name ?? context.t('Select...'),
onPressed: () { onPressed: () {
@ -58,7 +58,7 @@ class _HomePageButtonGroupState extends State<HomePageButtonGroup> {
}); });
}, },
), ),
HomePageButton( DownloaderPageButton(
label: context.t('Version'), label: context.t('Version'),
text: _versionButtonLabel, //_selectedVersion?.version ?? 'Select...', text: _versionButtonLabel, //_selectedVersion?.version ?? 'Select...',
onPressed: (_selectedOperatingSystem != null) onPressed: (_selectedOperatingSystem != null)
@ -80,7 +80,7 @@ class _HomePageButtonGroupState extends State<HomePageButtonGroup> {
} }
: null, : null,
), ),
HomePageButton( DownloaderPageButton(
label: context.t('Download'), label: context.t('Download'),
text: context.t('Download'), text: context.t('Download'),
onPressed: (_selectedVersion == null) onPressed: (_selectedVersion == null)
@ -122,7 +122,7 @@ class _HomePageButtonGroupState extends State<HomePageButtonGroup> {
child: Text(context.t('Downloading...'), child: Text(context.t('Downloading...'),
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.bodyText1 .bodyLarge
?.copyWith(color: Colors.white)), ?.copyWith(color: Colors.white)),
), ),
const CircularProgressIndicator(), const CircularProgressIndicator(),
@ -132,7 +132,7 @@ class _HomePageButtonGroupState extends State<HomePageButtonGroup> {
'Target : ${Directory.current.absolute.path}', 'Target : ${Directory.current.absolute.path}',
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.bodyText1 .bodyLarge
?.copyWith(color: Colors.white), ?.copyWith(color: Colors.white),
), ),
), ),
@ -170,7 +170,7 @@ class _HomePageButtonGroupState extends State<HomePageButtonGroup> {
child: Text(context.t('Done !'), child: Text(context.t('Done !'),
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.bodyText1 .bodyLarge
?.copyWith(color: Colors.white)), ?.copyWith(color: Colors.white)),
), ),
Text( Text(
@ -178,7 +178,7 @@ class _HomePageButtonGroupState extends State<HomePageButtonGroup> {
args: ["quickemu --vm $operatingSystem-$version"]), args: ["quickemu --vm $operatingSystem-$version"]),
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.bodyText1 .bodyLarge
?.copyWith(color: Colors.white)), ?.copyWith(color: Colors.white)),
Padding( Padding(
padding: const EdgeInsets.symmetric(vertical: 32), padding: const EdgeInsets.symmetric(vertical: 32),
@ -190,7 +190,7 @@ class _HomePageButtonGroupState extends State<HomePageButtonGroup> {
'Dismiss', 'Dismiss',
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.bodyText1 .bodyLarge
?.copyWith(color: Colors.white), ?.copyWith(color: Colors.white),
), ),
), ),

View File

@ -8,7 +8,7 @@ class Logo extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SizedBox( return SizedBox(
height: 250, height: 230,
child: Flex( child: Flex(
direction: Axis.vertical, direction: Axis.vertical,
children: [ children: [

View File

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:gettext_i18n/gettext_i18n.dart'; import 'package:gettext_i18n/gettext_i18n.dart';
import 'package:provider/provider.dart';
import 'package:quickgui/src/supported_locales.dart'; import 'package:quickgui/src/supported_locales.dart';
import '../globals.dart'; import '../globals.dart';
@ -46,7 +46,7 @@ class _LeftMenuState extends State<LeftMenu> with PreferencesMixin {
children: [ children: [
ListTile( ListTile(
title: Text("quickgui $_version", title: Text("quickgui $_version",
style: Theme.of(context).textTheme.headline6), style: Theme.of(context).textTheme.titleLarge),
), ),
const Divider(), const Divider(),
Padding( Padding(