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 null;
}
Future<void> deletePreference(String key) async {

View File

@ -74,11 +74,18 @@ class _OperatingSystemSelectionState extends State<OperatingSystemSelection> {
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),

View File

@ -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,
),

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(
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,
),

View File

@ -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<HomePageButtonGroup> {
}
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<HomePageButtonGroup> {
});
},
),
HomePageButton(
DownloaderPageButton(
label: context.t('Version'),
text: _versionButtonLabel, //_selectedVersion?.version ?? 'Select...',
onPressed: (_selectedOperatingSystem != null)
@ -80,7 +80,7 @@ class _HomePageButtonGroupState extends State<HomePageButtonGroup> {
}
: null,
),
HomePageButton(
DownloaderPageButton(
label: context.t('Download'),
text: context.t('Download'),
onPressed: (_selectedVersion == null)
@ -122,7 +122,7 @@ class _HomePageButtonGroupState extends State<HomePageButtonGroup> {
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<HomePageButtonGroup> {
'Target : ${Directory.current.absolute.path}',
style: Theme.of(context)
.textTheme
.bodyText1
.bodyLarge
?.copyWith(color: Colors.white),
),
),
@ -170,7 +170,7 @@ class _HomePageButtonGroupState extends State<HomePageButtonGroup> {
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<HomePageButtonGroup> {
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<HomePageButtonGroup> {
'Dismiss',
style: Theme.of(context)
.textTheme
.bodyText1
.bodyLarge
?.copyWith(color: Colors.white),
),
),

View File

@ -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: [

View File

@ -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<LeftMenu> with PreferencesMixin {
children: [
ListTile(
title: Text("quickgui $_version",
style: Theme.of(context).textTheme.headline6),
style: Theme.of(context).textTheme.titleLarge),
),
const Divider(),
Padding(