Skip to content

Commit 3d4851e

Browse files
committed
update material 3 and material you
1 parent efcff14 commit 3d4851e

File tree

4 files changed

+33
-59
lines changed

4 files changed

+33
-59
lines changed

lib/main.dart

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:dynamic_color/dynamic_color.dart';
12
import 'package:flutter/material.dart';
23
import 'package:get/get.dart';
34
import 'package:hive_flutter/hive_flutter.dart';
@@ -46,15 +47,21 @@ class _MyAppState extends State<MyApp> {
4647

4748
@override
4849
Widget build(BuildContext context) {
49-
return GetMaterialApp(
50-
builder: (context, child) =>
51-
MediaQuery(data: MediaQuery.of(context).copyWith(alwaysUse24HourFormat: true), child: child!),
52-
debugShowCheckedModeBanner: false,
53-
title: 'Personal Health Record',
54-
theme: themeData(context),
55-
darkTheme: themeDataDark(context),
56-
// Check setting has data if not goto setting page
57-
home: (boxSettings.values.isEmpty) ? const SettingPage() : const HomePage(),
58-
);
50+
return DynamicColorBuilder(
51+
builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) {
52+
return GetMaterialApp(
53+
builder: (context, child) => MediaQuery(
54+
data: MediaQuery.of(context).copyWith(alwaysUse24HourFormat: true),
55+
child: child!),
56+
debugShowCheckedModeBanner: false,
57+
title: 'Personal Health Record',
58+
theme: themeData(context, lightDynamic),
59+
darkTheme: themeDataDark(context, darkDynamic),
60+
// Check setting has data if not goto setting page
61+
home: (boxSettings.values.isEmpty)
62+
? const SettingPage()
63+
: const HomePage(),
64+
);
65+
});
5966
}
6067
}

lib/themes/theme.dart

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,16 @@
11
import 'package:flutter/material.dart';
2-
import 'package:google_fonts/google_fonts.dart';
32

4-
ThemeData themeData(BuildContext context) {
3+
ThemeData themeData(BuildContext context, ColorScheme? lightDynamic) {
54
return ThemeData(
65
useMaterial3: true,
7-
primarySwatch: Colors.grey,
8-
canvasColor: Colors.grey.shade200,
9-
appBarTheme: const AppBarTheme(
10-
foregroundColor: Colors.black,
11-
backgroundColor: Colors.white,
12-
elevation: 1.0,
13-
centerTitle: true,
14-
titleTextStyle: TextStyle(
15-
color: Colors.black,
16-
fontSize: 20.0,
17-
),
18-
),
19-
cardTheme: const CardTheme(
20-
clipBehavior: Clip.antiAlias,
21-
shape: RoundedRectangleBorder(
22-
borderRadius: BorderRadius.all(Radius.circular(12.0)),
23-
),
24-
),
25-
textTheme: GoogleFonts.latoTextTheme(
26-
Theme.of(context).textTheme,
27-
),
6+
colorScheme: lightDynamic,
287
);
298
}
309

31-
// FIXME : custome theme for dark mode
32-
ThemeData themeDataDark(BuildContext context) {
33-
return ThemeData.dark(
10+
ThemeData themeDataDark(BuildContext context, ColorScheme? darkDynamic) {
11+
return ThemeData(
3412
useMaterial3: true,
35-
).copyWith(
36-
appBarTheme: AppBarTheme(
37-
elevation: 1.0,
38-
centerTitle: true,
39-
titleTextStyle: GoogleFonts.lato(
40-
fontSize: 20,
41-
),
42-
),
43-
textTheme: TextTheme(
44-
bodyLarge: GoogleFonts.lato(),
45-
bodyMedium: GoogleFonts.lato(),
46-
titleMedium: GoogleFonts.lato(),
47-
titleLarge: GoogleFonts.lato(),
48-
labelLarge: GoogleFonts.lato(),
49-
),
50-
cardTheme: const CardTheme(
51-
clipBehavior: Clip.antiAlias,
52-
shape: RoundedRectangleBorder(
53-
borderRadius: BorderRadius.all(Radius.circular(12.0)),
54-
),
55-
),
13+
colorScheme: darkDynamic,
5614
);
5715
}
5816

pubspec.lock

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,14 @@ packages:
217217
url: "https://pub.dev"
218218
source: hosted
219219
version: "2.2.4"
220+
dynamic_color:
221+
dependency: "direct main"
222+
description:
223+
name: dynamic_color
224+
sha256: c4a508284b14ec4dda5adba2c28b2cdd34fbae1afead7e8c52cad87d51c5405b
225+
url: "https://pub.dev"
226+
source: hosted
227+
version: "1.6.2"
220228
fake_async:
221229
dependency: transitive
222230
description:
@@ -1023,4 +1031,4 @@ packages:
10231031
version: "3.1.1"
10241032
sdks:
10251033
dart: ">=2.18.0 <3.0.0"
1026-
flutter: ">=3.3.0"
1034+
flutter: ">=3.4.0-17.0.pre"

pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ description: A new Flutter project.
1414
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
1515
# Read more about iOS versioning at
1616
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
17-
version: 1.8.0+9
17+
version: 1.9.0+10
1818

1919
environment:
2020
sdk: ">=2.12.0 <3.0.0"
@@ -28,6 +28,7 @@ environment:
2828
dependencies:
2929
csv: ^5.0.1
3030
cupertino_icons: ^1.0.4
31+
dynamic_color: ^1.6.2
3132
file_picker: ^5.2.5
3233
flutter:
3334
sdk: flutter

0 commit comments

Comments
 (0)