Make proper use of Material3 colour schemes.
This is a big improvement over what we had before and relies on the theme to provide dark mode rather than manually checking brightness each time we pick a colour. The buttons in the primary container aren't quite right, I'm not sure why.
This commit is contained in:
parent
920b8488c7
commit
d3fe2c8c4f
|
@ -22,6 +22,26 @@ class App extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AppState extends State<App> with PreferencesMixin {
|
class _AppState extends State<App> with PreferencesMixin {
|
||||||
|
// Define the primary dark grey color.
|
||||||
|
static const int _darkGreyPrimaryValue = 0xFF424242;
|
||||||
|
|
||||||
|
// Create a map of shades for the dark grey color.
|
||||||
|
static const MaterialColor darkGrey = MaterialColor(
|
||||||
|
_darkGreyPrimaryValue,
|
||||||
|
<int, Color>{
|
||||||
|
50: Color(0xFFE0E0E0),
|
||||||
|
100: Color(0xFFBDBDBD),
|
||||||
|
200: Color(0xFF9E9E9E),
|
||||||
|
300: Color(0xFF757575),
|
||||||
|
400: Color(0xFF616161),
|
||||||
|
500: Color(_darkGreyPrimaryValue),
|
||||||
|
600: Color(0xFF3D3D3D),
|
||||||
|
700: Color(0xFF333333),
|
||||||
|
800: Color(0xFF2B2B2B),
|
||||||
|
900: Color(0xFF1C1C1C),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FutureBuilder<SharedPreferences>(
|
return FutureBuilder<SharedPreferences>(
|
||||||
|
@ -39,8 +59,21 @@ class _AppState extends State<App> with PreferencesMixin {
|
||||||
}
|
}
|
||||||
return Consumer<AppSettings>(
|
return Consumer<AppSettings>(
|
||||||
builder: (context, appSettings, _) => MaterialApp(
|
builder: (context, appSettings, _) => MaterialApp(
|
||||||
theme: ThemeData(primarySwatch: Colors.pink),
|
theme: ThemeData(
|
||||||
darkTheme: ThemeData.dark(),
|
useMaterial3: true,
|
||||||
|
colorScheme: ColorScheme.fromSwatch(
|
||||||
|
primarySwatch: Colors.pink,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
darkTheme: ThemeData(
|
||||||
|
useMaterial3: true,
|
||||||
|
colorScheme: ColorScheme.fromSwatch(
|
||||||
|
primarySwatch: darkGrey,
|
||||||
|
backgroundColor: darkGrey.shade700,
|
||||||
|
brightness: Brightness.dark,
|
||||||
|
),
|
||||||
|
),
|
||||||
themeMode: appSettings.themeMode,
|
themeMode: appSettings.themeMode,
|
||||||
home: AppVersion.packageInfo == null
|
home: AppVersion.packageInfo == null
|
||||||
? const DebgetNotFoundPage()
|
? const DebgetNotFoundPage()
|
||||||
|
|
|
@ -26,6 +26,8 @@ class _MainPageState extends State<MainPage> {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(context.t('Main menu')),
|
title: Text(context.t('Main menu')),
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||||
|
foregroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||||
),
|
),
|
||||||
drawer: const LeftMenu(),
|
drawer: const LeftMenu(),
|
||||||
body: const Column(
|
body: const Column(
|
||||||
|
|
|
@ -174,9 +174,7 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
||||||
|
|
||||||
Widget _buildVmList() {
|
Widget _buildVmList() {
|
||||||
List<Widget> widgetList = [];
|
List<Widget> widgetList = [];
|
||||||
final Color buttonColor = Theme.of(context).brightness == Brightness.dark
|
final Color buttonColor = Theme.of(context).colorScheme.primary;
|
||||||
? Colors.white70
|
|
||||||
: Theme.of(context).colorScheme.primary;
|
|
||||||
widgetList.addAll(
|
widgetList.addAll(
|
||||||
[
|
[
|
||||||
Padding(
|
Padding(
|
||||||
|
@ -186,30 +184,30 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"${context.t('Directory where the machines are stored')}:",
|
"${context.t('Directory where the machines are stored')}:",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 8,
|
width: 8,
|
||||||
),
|
),
|
||||||
Text.rich(
|
ElevatedButton(
|
||||||
TextSpan(
|
style: ElevatedButton.styleFrom(
|
||||||
recognizer: TapGestureRecognizer()
|
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
||||||
..onTap = () async {
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
String? result =
|
|
||||||
await FilePicker.platform.getDirectoryPath();
|
|
||||||
if (result != null) {
|
|
||||||
setState(() {
|
|
||||||
Directory.current = result;
|
|
||||||
});
|
|
||||||
|
|
||||||
savePreference(
|
|
||||||
prefWorkingDirectory, Directory.current.path);
|
|
||||||
_getVms(context);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
text: Directory.current.path,
|
|
||||||
style:
|
|
||||||
TextStyle(color: Theme.of(context).colorScheme.primary),
|
|
||||||
),
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
var folder = await FilePicker.platform
|
||||||
|
.getDirectoryPath(dialogTitle: "Pick a folder");
|
||||||
|
if (folder != null) {
|
||||||
|
setState(() {
|
||||||
|
Directory.current = folder;
|
||||||
|
});
|
||||||
|
savePreference(
|
||||||
|
prefWorkingDirectory, Directory.current.path);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text(Directory.current.path),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -21,9 +21,7 @@ class CancelDismissButton extends StatelessWidget {
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
foregroundColor: Theme.of(context).brightness == Brightness.dark
|
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
||||||
? Colors.white70
|
|
||||||
: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
),
|
||||||
onPressed: !downloadFinished
|
onPressed: !downloadFinished
|
||||||
? onCancel
|
? onCancel
|
||||||
|
|
|
@ -31,9 +31,7 @@ class _DownloaderMenuState extends State<DownloaderMenu> with PreferencesMixin {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
color: Theme.of(context).brightness == Brightness.dark
|
color: Theme.of(context).colorScheme.primaryContainer,
|
||||||
? Theme.of(context).colorScheme.surface
|
|
||||||
: Theme.of(context).colorScheme.primary,
|
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
|
@ -44,9 +42,7 @@ class _DownloaderMenuState extends State<DownloaderMenu> with PreferencesMixin {
|
||||||
Text(
|
Text(
|
||||||
"${context.t('Directory where the machines are stored')}:",
|
"${context.t('Directory where the machines are stored')}:",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).brightness == Brightness.dark
|
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||||
? Theme.of(context).colorScheme.onSurface
|
|
||||||
: Theme.of(context).colorScheme.onPrimary,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
@ -54,10 +50,8 @@ class _DownloaderMenuState extends State<DownloaderMenu> with PreferencesMixin {
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
foregroundColor: Theme.of(context).brightness == Brightness.dark
|
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
||||||
? Colors.white70
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
: Theme.of(context).colorScheme.primary,
|
|
||||||
backgroundColor: Theme.of(context).canvasColor,
|
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var folder = await FilePicker.platform
|
var folder = await FilePicker.platform
|
||||||
|
|
|
@ -35,10 +35,8 @@ class DownloaderPageButton extends StatelessWidget {
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
foregroundColor: Theme.of(context).brightness == Brightness.dark
|
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
||||||
? Colors.white70
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
: Theme.of(context).colorScheme.primary,
|
|
||||||
backgroundColor: Theme.of(context).canvasColor,
|
|
||||||
),
|
),
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
|
|
|
@ -32,10 +32,8 @@ class HomePageButton extends StatelessWidget {
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Theme.of(context).canvasColor,
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
foregroundColor: Theme.of(context).brightness == Brightness.dark
|
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
||||||
? Colors.white70
|
|
||||||
: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
),
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
|
|
|
@ -12,9 +12,7 @@ class MainMenu extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
color: Theme.of(context).brightness == Brightness.dark
|
color: Theme.of(context).colorScheme.primaryContainer,
|
||||||
? Theme.of(context).colorScheme.surface
|
|
||||||
: Theme.of(context).colorScheme.primary,
|
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|
|
@ -58,11 +58,15 @@ class _LeftMenuState extends State<LeftMenu> with PreferencesMixin {
|
||||||
child: Container(),
|
child: Container(),
|
||||||
),
|
),
|
||||||
Switch(
|
Switch(
|
||||||
value: Theme.of(context).brightness == Brightness.dark,
|
value: Theme.of(context).colorScheme.brightness == Brightness.dark,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
appSettings.useDarkMode = value;
|
appSettings.useDarkMode = value;
|
||||||
savePreference(prefThemeMode, value);
|
savePreference(prefThemeMode, value);
|
||||||
},
|
},
|
||||||
|
activeColor: Colors.white,
|
||||||
|
activeTrackColor: Colors.black26,
|
||||||
|
inactiveThumbColor: Theme.of(context).colorScheme.onPrimary,
|
||||||
|
inactiveTrackColor: Theme.of(context).colorScheme.primary,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue