Browse Source

代码整理,给BuildContext添加样式和颜色的扩展方法,减少获取颜色和文本样式等的代码量

gjh 1 day ago
parent
commit
7bd32fa5ee

+ 3 - 2
lib/dialog/app_start_agreement_dialog.dart

@@ -1,3 +1,4 @@
1
+import 'package:eitc_erm_dental_flutter/exts.dart';
1
 import 'package:eitc_erm_dental_flutter/funcs.dart';
2
 import 'package:eitc_erm_dental_flutter/funcs.dart';
2
 import 'package:eitc_erm_dental_flutter/widget/main_button.dart';
3
 import 'package:eitc_erm_dental_flutter/widget/main_button.dart';
3
 import 'package:flutter/gestures.dart';
4
 import 'package:flutter/gestures.dart';
@@ -23,7 +24,7 @@ class AppStartAgreementDialog extends StatelessWidget {
23
                 Text(
24
                 Text(
24
                   getS().permissionDescDialogTitle,
25
                   getS().permissionDescDialogTitle,
25
                   textAlign: TextAlign.center,
26
                   textAlign: TextAlign.center,
26
-                  style: Theme.of(context).textTheme.titleMedium,
27
+                  style: context.titleMedium,
27
                 ),
28
                 ),
28
                 SizedBox(
29
                 SizedBox(
29
                   height: 20.h,
30
                   height: 20.h,
@@ -78,7 +79,7 @@ class AppStartAgreementDialog extends StatelessWidget {
78
       BuildContext context, String text, GestureTapCallback onTap) {
79
       BuildContext context, String text, GestureTapCallback onTap) {
79
     return TextSpan(
80
     return TextSpan(
80
         text: text,
81
         text: text,
81
-        style: TextStyle(color: Theme.of(context).colorScheme.primary),
82
+        style: TextStyle(color: context.primaryColor),
82
         recognizer: TapGestureRecognizer()..onTap = onTap);
83
         recognizer: TapGestureRecognizer()..onTap = onTap);
83
   }
84
   }
84
 }
85
 }

+ 4 - 3
lib/dialog/app_update_dialog.dart

@@ -2,6 +2,7 @@ import 'dart:io';
2
 
2
 
3
 import 'package:app_installer/app_installer.dart';
3
 import 'package:app_installer/app_installer.dart';
4
 import 'package:dio/dio.dart';
4
 import 'package:dio/dio.dart';
5
+import 'package:eitc_erm_dental_flutter/exts.dart';
5
 import 'package:eitc_erm_dental_flutter/funcs.dart';
6
 import 'package:eitc_erm_dental_flutter/funcs.dart';
6
 import 'package:eitc_erm_dental_flutter/widget/custom_divider.dart';
7
 import 'package:eitc_erm_dental_flutter/widget/custom_divider.dart';
7
 import 'package:eitc_erm_dental_flutter/widget/main_button.dart';
8
 import 'package:eitc_erm_dental_flutter/widget/main_button.dart';
@@ -63,7 +64,7 @@ class _AppUpdateDialogState extends State<AppUpdateDialog> {
63
       children: [
64
       children: [
64
         Text(
65
         Text(
65
           getS().hasNewVersion,
66
           getS().hasNewVersion,
66
-          style: Theme.of(context).textTheme.titleMedium,
67
+          style: context.titleMedium,
67
         ),
68
         ),
68
         Text("V${widget.version}"),
69
         Text("V${widget.version}"),
69
         SizedBox(
70
         SizedBox(
@@ -114,7 +115,7 @@ class _AppUpdateDialogState extends State<AppUpdateDialog> {
114
       children: [
115
       children: [
115
         Text(
116
         Text(
116
           title,
117
           title,
117
-          style: Theme.of(context).textTheme.titleMedium,
118
+          style: context.titleMedium,
118
         ),
119
         ),
119
         SizedBox(
120
         SizedBox(
120
           height: 10.h,
121
           height: 10.h,
@@ -122,7 +123,7 @@ class _AppUpdateDialogState extends State<AppUpdateDialog> {
122
         pi.LinearPercentIndicator(
123
         pi.LinearPercentIndicator(
123
           percent: _downloadProgress,
124
           percent: _downloadProgress,
124
           lineHeight: 15.h,
125
           lineHeight: 15.h,
125
-          progressColor: Theme.of(context).colorScheme.primary,
126
+          progressColor: context.primaryColor,
126
           barRadius: Radius.circular(15.h),
127
           barRadius: Radius.circular(15.h),
127
           center: Text(
128
           center: Text(
128
             "${(_downloadProgress * 100.0).round()}%",
129
             "${(_downloadProgress * 100.0).round()}%",

+ 32 - 0
lib/exts.dart

@@ -1,3 +1,5 @@
1
+import 'package:flutter/material.dart';
2
+
1
 extension MapExt<K, V> on Map<K, V> {
3
 extension MapExt<K, V> on Map<K, V> {
2
   T? getCheck<T>(K? key) {
4
   T? getCheck<T>(K? key) {
3
     if (key == null || !containsKey(key)) {
5
     if (key == null || !containsKey(key)) {
@@ -27,3 +29,33 @@ extension DateTimeExt on DateTime {
27
   String get yyyyMMddHHmmss =>
29
   String get yyyyMMddHHmmss =>
28
       "$year-${month < 10 ? "$month".padLeft(2, "0") : month}-$day ${hour < 10 ? "$hour".padLeft(2, "0") : hour}:${minute < 10 ? "$minute".padLeft(2, "0") : minute}:${second < 10 ? "$second".padLeft(2, "0") : second}";
30
       "$year-${month < 10 ? "$month".padLeft(2, "0") : month}-$day ${hour < 10 ? "$hour".padLeft(2, "0") : hour}:${minute < 10 ? "$minute".padLeft(2, "0") : minute}:${second < 10 ? "$second".padLeft(2, "0") : second}";
29
 }
31
 }
32
+
33
+extension ContextExt on BuildContext {
34
+  ThemeData get theme => Theme.of(this);
35
+
36
+  TextTheme get textTheme => theme.textTheme;
37
+
38
+  TextStyle? get titleLarge => textTheme.titleLarge;
39
+
40
+  TextStyle? get titleMedium => textTheme.titleMedium;
41
+
42
+  TextStyle? get titleSmall => textTheme.titleSmall;
43
+
44
+  TextStyle? get bodyLarge => textTheme.bodyLarge;
45
+
46
+  TextStyle? get bodyMedium => textTheme.bodyMedium;
47
+
48
+  TextStyle? get bodySmall => textTheme.bodySmall;
49
+
50
+  ColorScheme get colorScheme => theme.colorScheme;
51
+
52
+  Color get primaryColor => colorScheme.primary;
53
+
54
+  Color get onPrimaryColor => colorScheme.onPrimary;
55
+
56
+  Color get surfaceContainerHighColor => colorScheme.surfaceContainerHigh;
57
+
58
+  Color get onSurfaceVariantColor => colorScheme.onSurfaceVariant;
59
+
60
+  Color get onSurfaceColor => colorScheme.onSurface;
61
+}

+ 4 - 3
lib/pages/history/history_page.dart

@@ -3,6 +3,7 @@ import 'dart:io';
3
 import 'package:auto_route/auto_route.dart';
3
 import 'package:auto_route/auto_route.dart';
4
 import 'package:eitc_erm_dental_flutter/app_router.gr.dart';
4
 import 'package:eitc_erm_dental_flutter/app_router.gr.dart';
5
 import 'package:eitc_erm_dental_flutter/entity/history_item_info.dart';
5
 import 'package:eitc_erm_dental_flutter/entity/history_item_info.dart';
6
+import 'package:eitc_erm_dental_flutter/exts.dart';
6
 import 'package:eitc_erm_dental_flutter/funcs.dart';
7
 import 'package:eitc_erm_dental_flutter/funcs.dart';
7
 import 'package:eitc_erm_dental_flutter/pages/history/vm/history_view_model.dart';
8
 import 'package:eitc_erm_dental_flutter/pages/history/vm/history_view_model.dart';
8
 import 'package:eitc_erm_dental_flutter/pages/history/widget/history_item_view.dart';
9
 import 'package:eitc_erm_dental_flutter/pages/history/widget/history_item_view.dart';
@@ -131,7 +132,7 @@ class _HistoryPageState extends ConsumerState<HistoryPage> {
131
   Widget _getSelectedCount(BuildContext context) {
132
   Widget _getSelectedCount(BuildContext context) {
132
     return Consumer(builder: (ctx, ref, _) {
133
     return Consumer(builder: (ctx, ref, _) {
133
       bool isSelectedMode = ref.watch(historySelectModeProvider);
134
       bool isSelectedMode = ref.watch(historySelectModeProvider);
134
-      Color primaryColor = Theme.of(context).colorScheme.primary;
135
+      Color primaryColor = context.primaryColor;
135
       //如果不用Visibility的方式,当进入选择模式时,GridView会滚到最上面
136
       //如果不用Visibility的方式,当进入选择模式时,GridView会滚到最上面
136
       return Visibility(
137
       return Visibility(
137
           visible: isSelectedMode,
138
           visible: isSelectedMode,
@@ -222,7 +223,7 @@ class _HistoryPageState extends ConsumerState<HistoryPage> {
222
         children: [
223
         children: [
223
           Text(
224
           Text(
224
             getS().photo,
225
             getS().photo,
225
-            style: Theme.of(context).textTheme.titleMedium,
226
+            style: context.titleMedium,
226
           ),
227
           ),
227
           SizedBox(
228
           SizedBox(
228
             height: 10.h,
229
             height: 10.h,
@@ -233,7 +234,7 @@ class _HistoryPageState extends ConsumerState<HistoryPage> {
233
           ),
234
           ),
234
           Text(
235
           Text(
235
             getS().video,
236
             getS().video,
236
-            style: Theme.of(context).textTheme.titleMedium,
237
+            style: context.titleMedium,
237
           ),
238
           ),
238
           SizedBox(
239
           SizedBox(
239
             height: 10.h,
240
             height: 10.h,

+ 3 - 8
lib/pages/history/widget/history_view_title.dart

@@ -1,5 +1,6 @@
1
 import 'dart:io';
1
 import 'dart:io';
2
 
2
 
3
+import 'package:eitc_erm_dental_flutter/exts.dart';
3
 import 'package:eitc_erm_dental_flutter/funcs.dart';
4
 import 'package:eitc_erm_dental_flutter/funcs.dart';
4
 import 'package:flutter/material.dart';
5
 import 'package:flutter/material.dart';
5
 
6
 
@@ -25,10 +26,7 @@ class HistoryViewTitle extends StatelessWidget {
25
             ),
26
             ),
26
             Text(
27
             Text(
27
               name ?? "",
28
               name ?? "",
28
-              style: Theme.of(context)
29
-                  .textTheme
30
-                  .titleMedium
31
-                  ?.copyWith(color: Colors.white),
29
+              style: context.titleMedium?.copyWith(color: Colors.white),
32
             ),
30
             ),
33
           ],
31
           ],
34
         ),
32
         ),
@@ -36,10 +34,7 @@ class HistoryViewTitle extends StatelessWidget {
36
             visible: area != null,
34
             visible: area != null,
37
             child: Text(
35
             child: Text(
38
               toothAreaTranslate(area ?? ""),
36
               toothAreaTranslate(area ?? ""),
39
-              style: Theme.of(context)
40
-                  .textTheme
41
-                  .titleLarge
42
-                  ?.copyWith(color: Colors.white),
37
+              style: context.titleLarge?.copyWith(color: Colors.white),
43
             ))
38
             ))
44
       ],
39
       ],
45
     );
40
     );

+ 5 - 4
lib/pages/login/login_page.dart

@@ -1,5 +1,6 @@
1
 import 'package:auto_route/auto_route.dart';
1
 import 'package:auto_route/auto_route.dart';
2
 import 'package:eitc_erm_dental_flutter/app_router.gr.dart';
2
 import 'package:eitc_erm_dental_flutter/app_router.gr.dart';
3
+import 'package:eitc_erm_dental_flutter/exts.dart';
3
 import 'package:eitc_erm_dental_flutter/funcs.dart';
4
 import 'package:eitc_erm_dental_flutter/funcs.dart';
4
 import 'package:eitc_erm_dental_flutter/pages/login/vm/login_view_model.dart';
5
 import 'package:eitc_erm_dental_flutter/pages/login/vm/login_view_model.dart';
5
 import 'package:eitc_erm_dental_flutter/pages/patient/vm/patient_view_model.dart';
6
 import 'package:eitc_erm_dental_flutter/pages/patient/vm/patient_view_model.dart';
@@ -63,7 +64,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
63
             Text(
64
             Text(
64
               getS().registerHint,
65
               getS().registerHint,
65
               textAlign: TextAlign.center,
66
               textAlign: TextAlign.center,
66
-              style: Theme.of(context).textTheme.titleMedium,
67
+              style: context.titleMedium,
67
             ),
68
             ),
68
             SizedBox(
69
             SizedBox(
69
               height: 80.h,
70
               height: 80.h,
@@ -128,7 +129,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
128
                       return Text(
129
                       return Text(
129
                         str,
130
                         str,
130
                         style: TextStyle(
131
                         style: TextStyle(
131
-                            color: Theme.of(context).colorScheme.onPrimary,
132
+                            color: context.onPrimaryColor,
132
                             fontWeight: FontWeight.bold),
133
                             fontWeight: FontWeight.bold),
133
                       );
134
                       );
134
                     },
135
                     },
@@ -165,7 +166,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
165
     return Container(
166
     return Container(
166
       padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 10.h),
167
       padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 10.h),
167
       decoration: BoxDecoration(
168
       decoration: BoxDecoration(
168
-          color: Theme.of(context).colorScheme.surfaceContainerHigh,
169
+          color: context.surfaceContainerHighColor,
169
           borderRadius: BorderRadius.circular(8.r)),
170
           borderRadius: BorderRadius.circular(8.r)),
170
       child: TextField(
171
       child: TextField(
171
         controller: controller,
172
         controller: controller,
@@ -214,7 +215,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
214
   TextSpan getClickTextSpan(String text, GestureTapCallback onTap) {
215
   TextSpan getClickTextSpan(String text, GestureTapCallback onTap) {
215
     return TextSpan(
216
     return TextSpan(
216
         text: text,
217
         text: text,
217
-        style: TextStyle(color: Theme.of(context).colorScheme.primary),
218
+        style: TextStyle(color: context.primaryColor),
218
         recognizer: TapGestureRecognizer()..onTap = onTap);
219
         recognizer: TapGestureRecognizer()..onTap = onTap);
219
   }
220
   }
220
 
221
 

+ 3 - 1
lib/pages/main/main_page.dart

@@ -3,8 +3,10 @@ import 'dart:io';
3
 
3
 
4
 import 'package:auto_route/auto_route.dart';
4
 import 'package:auto_route/auto_route.dart';
5
 import 'package:eitc_erm_dental_flutter/app_router.gr.dart';
5
 import 'package:eitc_erm_dental_flutter/app_router.gr.dart';
6
+import 'package:eitc_erm_dental_flutter/dialog/app_start_agreement_dialog.dart';
6
 import 'package:eitc_erm_dental_flutter/dialog/switch_patient_dialog.dart';
7
 import 'package:eitc_erm_dental_flutter/dialog/switch_patient_dialog.dart';
7
 import 'package:eitc_erm_dental_flutter/entity/db/local_patient_info.dart';
8
 import 'package:eitc_erm_dental_flutter/entity/db/local_patient_info.dart';
9
+import 'package:eitc_erm_dental_flutter/exts.dart';
8
 import 'package:eitc_erm_dental_flutter/funcs.dart';
10
 import 'package:eitc_erm_dental_flutter/funcs.dart';
9
 import 'package:eitc_erm_dental_flutter/global.dart';
11
 import 'package:eitc_erm_dental_flutter/global.dart';
10
 import 'package:eitc_erm_dental_flutter/pages/main/widget/connected_view.dart';
12
 import 'package:eitc_erm_dental_flutter/pages/main/widget/connected_view.dart';
@@ -90,7 +92,7 @@ class _MainPageState extends ConsumerState<MainPage> {
90
   }
92
   }
91
 
93
 
92
   AppBar _getAppBar() {
94
   AppBar _getAppBar() {
93
-    Color color = Theme.of(context).colorScheme.onSurfaceVariant;
95
+    Color color = context.onSurfaceVariantColor;
94
     ButtonStyle buttonStyle = ButtonStyle(
96
     ButtonStyle buttonStyle = ButtonStyle(
95
         padding: WidgetStatePropertyAll(EdgeInsets.symmetric(horizontal: 5.w)));
97
         padding: WidgetStatePropertyAll(EdgeInsets.symmetric(horizontal: 5.w)));
96
     TextStyle textStyle = TextStyle(fontSize: 12.sp, color: color);
98
     TextStyle textStyle = TextStyle(fontSize: 12.sp, color: color);

+ 5 - 7
lib/pages/patient/add_patient_page.dart

@@ -17,12 +17,12 @@ EdgeInsets get _itemPadding =>
17
 Widget _getTitleText(BuildContext context, String text) {
17
 Widget _getTitleText(BuildContext context, String text) {
18
   return Text(
18
   return Text(
19
     text,
19
     text,
20
-    style: Theme.of(context).textTheme.titleMedium,
20
+    style: context.titleMedium,
21
   );
21
   );
22
 }
22
 }
23
 
23
 
24
 TextStyle? _getTextStyle(BuildContext context) {
24
 TextStyle? _getTextStyle(BuildContext context) {
25
-  return Theme.of(context).textTheme.bodySmall;
25
+  return context.bodySmall;
26
 }
26
 }
27
 
27
 
28
 ///添加咨询人页面
28
 ///添加咨询人页面
@@ -131,10 +131,8 @@ class _AddPatientPageState extends ConsumerState<AddPatientPage> {
131
         border: InputBorder.none,
131
         border: InputBorder.none,
132
         hintText: hint,
132
         hintText: hint,
133
         counterText: "",
133
         counterText: "",
134
-        hintStyle: Theme.of(context)
135
-            .textTheme
136
-            .bodySmall
137
-            ?.copyWith(color: Theme.of(context).colorScheme.onSurfaceVariant),
134
+        hintStyle:
135
+            context.bodySmall?.copyWith(color: context.onSurfaceVariantColor),
138
       ),
136
       ),
139
     );
137
     );
140
   }
138
   }
@@ -366,7 +364,7 @@ class __RelationSelectorState extends ConsumerState<_RelationSelector> {
366
                     child: Text(
364
                     child: Text(
367
                       relation,
365
                       relation,
368
                       textAlign: TextAlign.center,
366
                       textAlign: TextAlign.center,
369
-                      style: Theme.of(ctx).textTheme.titleMedium,
367
+                      style: ctx.titleMedium,
370
                     ),
368
                     ),
371
                   ),
369
                   ),
372
                 );
370
                 );

+ 1 - 1
lib/pages/patient/patient_list_page.dart

@@ -57,7 +57,7 @@ class _PatientListPageState extends ConsumerState<PatientListPage> {
57
           children: [
57
           children: [
58
             Text(
58
             Text(
59
               getS().pleaseSelectPatient,
59
               getS().pleaseSelectPatient,
60
-              style: Theme.of(context).textTheme.titleMedium,
60
+              style: context.titleMedium,
61
             ),
61
             ),
62
             SizedBox(
62
             SizedBox(
63
               height: 6.h,
63
               height: 6.h,

+ 4 - 3
lib/pages/patient/widget/patient_info_bar.dart

@@ -1,4 +1,5 @@
1
 import 'package:eitc_erm_dental_flutter/entity/db/local_patient_info.dart';
1
 import 'package:eitc_erm_dental_flutter/entity/db/local_patient_info.dart';
2
+import 'package:eitc_erm_dental_flutter/exts.dart';
2
 import 'package:eitc_erm_dental_flutter/funcs.dart';
3
 import 'package:eitc_erm_dental_flutter/funcs.dart';
3
 import 'package:eitc_erm_dental_flutter/global.dart';
4
 import 'package:eitc_erm_dental_flutter/global.dart';
4
 import 'package:eitc_erm_dental_flutter/pages/patient/vm/patient_view_model.dart';
5
 import 'package:eitc_erm_dental_flutter/pages/patient/vm/patient_view_model.dart';
@@ -60,7 +61,7 @@ class _PatientInfoBarState extends ConsumerState<PatientInfoBar> {
60
       padding: EdgeInsets.symmetric(horizontal: 12.w),
61
       padding: EdgeInsets.symmetric(horizontal: 12.w),
61
       height: 62.h,
62
       height: 62.h,
62
       decoration: BoxDecoration(
63
       decoration: BoxDecoration(
63
-        color: Theme.of(context).colorScheme.surfaceContainerHigh,
64
+        color: context.surfaceContainerHighColor,
64
         borderRadius: BorderRadius.circular(8.r),
65
         borderRadius: BorderRadius.circular(8.r),
65
       ),
66
       ),
66
       child: _getContent(value),
67
       child: _getContent(value),
@@ -149,12 +150,12 @@ class _PatientInfoBarState extends ConsumerState<PatientInfoBar> {
149
       child: Container(
150
       child: Container(
150
         padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 6.h),
151
         padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 6.h),
151
         decoration: BoxDecoration(
152
         decoration: BoxDecoration(
152
-          color: Theme.of(context).colorScheme.primary,
153
+          color: context.primaryColor,
153
           borderRadius: BorderRadius.circular(4.r),
154
           borderRadius: BorderRadius.circular(4.r),
154
         ),
155
         ),
155
         child: Text(
156
         child: Text(
156
           text,
157
           text,
157
-          style: TextStyle(color: Theme.of(context).colorScheme.onPrimary),
158
+          style: TextStyle(color: context.onPrimaryColor),
158
         ),
159
         ),
159
       ),
160
       ),
160
     );
161
     );

+ 6 - 6
lib/pages/patient/widget/patient_list_item.dart

@@ -1,3 +1,4 @@
1
+import 'package:eitc_erm_dental_flutter/exts.dart';
1
 import 'package:eitc_erm_dental_flutter/funcs.dart';
2
 import 'package:eitc_erm_dental_flutter/funcs.dart';
2
 import 'package:flutter/material.dart';
3
 import 'package:flutter/material.dart';
3
 import 'package:flutter_screenutil/flutter_screenutil.dart';
4
 import 'package:flutter_screenutil/flutter_screenutil.dart';
@@ -25,7 +26,7 @@ class PatientListItem extends StatelessWidget {
25
       child: Container(
26
       child: Container(
26
         padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.h),
27
         padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.h),
27
         decoration: BoxDecoration(
28
         decoration: BoxDecoration(
28
-            color: Theme.of(context).colorScheme.surfaceContainerHigh,
29
+            color: context.surfaceContainerHighColor,
29
             borderRadius: BorderRadius.circular(8.r)),
30
             borderRadius: BorderRadius.circular(8.r)),
30
         child: Column(
31
         child: Column(
31
           crossAxisAlignment: CrossAxisAlignment.start,
32
           crossAxisAlignment: CrossAxisAlignment.start,
@@ -40,15 +41,14 @@ class PatientListItem extends StatelessWidget {
40
                   padding:
41
                   padding:
41
                       EdgeInsets.symmetric(horizontal: 10.w, vertical: 1.h),
42
                       EdgeInsets.symmetric(horizontal: 10.w, vertical: 1.h),
42
                   decoration: BoxDecoration(
43
                   decoration: BoxDecoration(
43
-                    border: Border.fromBorderSide(BorderSide(
44
-                        color: Theme.of(context).colorScheme.primary)),
44
+                    border: Border.fromBorderSide(
45
+                        BorderSide(color: context.primaryColor)),
45
                     borderRadius: BorderRadius.circular(30.r),
46
                     borderRadius: BorderRadius.circular(30.r),
46
                   ),
47
                   ),
47
                   child: Text(
48
                   child: Text(
48
                     relation,
49
                     relation,
49
-                    style: TextStyle(
50
-                        fontSize: 10.sp,
51
-                        color: Theme.of(context).colorScheme.primary),
50
+                    style:
51
+                        TextStyle(fontSize: 10.sp, color: context.primaryColor),
52
                   ),
52
                   ),
53
                 )
53
                 )
54
               ],
54
               ],

+ 4 - 6
lib/pages/settings/delay_shot_settings_page.dart

@@ -1,4 +1,5 @@
1
 import 'package:auto_route/annotations.dart';
1
 import 'package:auto_route/annotations.dart';
2
+import 'package:eitc_erm_dental_flutter/exts.dart';
2
 import 'package:eitc_erm_dental_flutter/funcs.dart';
3
 import 'package:eitc_erm_dental_flutter/funcs.dart';
3
 import 'package:eitc_erm_dental_flutter/sp_util.dart';
4
 import 'package:eitc_erm_dental_flutter/sp_util.dart';
4
 import 'package:eitc_erm_dental_flutter/widget/custom_divider.dart';
5
 import 'package:eitc_erm_dental_flutter/widget/custom_divider.dart';
@@ -168,9 +169,7 @@ class _RadioItem extends StatelessWidget {
168
   final void Function() onTap;
169
   final void Function() onTap;
169
 
170
 
170
   const _RadioItem(
171
   const _RadioItem(
171
-      {required this.text,
172
-      required this.isChecked,
173
-      required this.onTap});
172
+      {required this.text, required this.isChecked, required this.onTap});
174
 
173
 
175
   @override
174
   @override
176
   Widget build(BuildContext context) {
175
   Widget build(BuildContext context) {
@@ -183,8 +182,7 @@ class _RadioItem extends StatelessWidget {
183
           children: [
182
           children: [
184
             Text(
183
             Text(
185
               text,
184
               text,
186
-              style: TextStyle(
187
-                  color: Theme.of(context).colorScheme.onSurfaceVariant),
185
+              style: TextStyle(color: context.onSurfaceVariantColor),
188
             ),
186
             ),
189
             const Spacer(),
187
             const Spacer(),
190
             _CheckedIcon(isChecked: isChecked),
188
             _CheckedIcon(isChecked: isChecked),
@@ -206,7 +204,7 @@ class _CheckedIcon extends StatelessWidget {
206
         ? Icon(
204
         ? Icon(
207
             size: 24.r,
205
             size: 24.r,
208
             Icons.check_circle,
206
             Icons.check_circle,
209
-            color: Theme.of(context).colorScheme.primary,
207
+            color: context.primaryColor,
210
           )
208
           )
211
         : Icon(
209
         : Icon(
212
             size: 24.r,
210
             size: 24.r,

+ 5 - 4
lib/pages/settings/faqs_page.dart

@@ -1,4 +1,5 @@
1
 import 'package:auto_route/annotations.dart';
1
 import 'package:auto_route/annotations.dart';
2
+import 'package:eitc_erm_dental_flutter/exts.dart';
2
 import 'package:eitc_erm_dental_flutter/funcs.dart';
3
 import 'package:eitc_erm_dental_flutter/funcs.dart';
3
 import 'package:flutter/material.dart';
4
 import 'package:flutter/material.dart';
4
 import 'package:flutter_screenutil/flutter_screenutil.dart';
5
 import 'package:flutter_screenutil/flutter_screenutil.dart';
@@ -35,7 +36,7 @@ class FaqsPage extends StatelessWidget {
35
           padding: EdgeInsets.symmetric(horizontal: 0.w, vertical: 5.h),
36
           padding: EdgeInsets.symmetric(horizontal: 0.w, vertical: 5.h),
36
           child: Text(
37
           child: Text(
37
             getS().faq1Title,
38
             getS().faq1Title,
38
-            style: Theme.of(context).textTheme.titleSmall,
39
+            style: context.titleSmall,
39
           ),
40
           ),
40
         ),
41
         ),
41
         SizedBox(
42
         SizedBox(
@@ -43,16 +44,16 @@ class FaqsPage extends StatelessWidget {
43
         ),
44
         ),
44
         Text(
45
         Text(
45
           getS().faq1Desc1,
46
           getS().faq1Desc1,
46
-          style: Theme.of(context).textTheme.bodySmall,
47
+          style: context.bodySmall,
47
         ),
48
         ),
48
         SizedBox(
49
         SizedBox(
49
           height: 8.h,
50
           height: 8.h,
50
         ),
51
         ),
51
-        Text(getS().faq1Desc2, style: Theme.of(context).textTheme.bodySmall),
52
+        Text(getS().faq1Desc2, style: context.bodySmall),
52
         SizedBox(
53
         SizedBox(
53
           height: 8.h,
54
           height: 8.h,
54
         ),
55
         ),
55
-        Text(getS().faq1Desc3, style: Theme.of(context).textTheme.bodySmall),
56
+        Text(getS().faq1Desc3, style: context.bodySmall),
56
       ],
57
       ],
57
     );
58
     );
58
   }
59
   }

+ 2 - 1
lib/pages/settings/settings_page.dart

@@ -1,5 +1,6 @@
1
 import 'package:auto_route/auto_route.dart';
1
 import 'package:auto_route/auto_route.dart';
2
 import 'package:eitc_erm_dental_flutter/app_router.gr.dart';
2
 import 'package:eitc_erm_dental_flutter/app_router.gr.dart';
3
+import 'package:eitc_erm_dental_flutter/exts.dart';
3
 import 'package:eitc_erm_dental_flutter/funcs.dart';
4
 import 'package:eitc_erm_dental_flutter/funcs.dart';
4
 import 'package:eitc_erm_dental_flutter/global.dart';
5
 import 'package:eitc_erm_dental_flutter/global.dart';
5
 import 'package:eitc_erm_dental_flutter/pages/login/vm/login_view_model.dart';
6
 import 'package:eitc_erm_dental_flutter/pages/login/vm/login_view_model.dart';
@@ -75,7 +76,7 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
75
                 children: [
76
                 children: [
76
                   Text(
77
                   Text(
77
                     item.name,
78
                     item.name,
78
-                    style: Theme.of(context).textTheme.bodyMedium,
79
+                    style: context.bodyMedium,
79
                   ),
80
                   ),
80
                   const Spacer(),
81
                   const Spacer(),
81
                   item.subText.isNotEmpty
82
                   item.subText.isNotEmpty

+ 3 - 2
lib/pages/upload/upload_page.dart

@@ -3,6 +3,7 @@ import 'dart:io';
3
 import 'package:auto_route/annotations.dart';
3
 import 'package:auto_route/annotations.dart';
4
 import 'package:dio/dio.dart';
4
 import 'package:dio/dio.dart';
5
 import 'package:eitc_erm_dental_flutter/entity/clinic_info.dart';
5
 import 'package:eitc_erm_dental_flutter/entity/clinic_info.dart';
6
+import 'package:eitc_erm_dental_flutter/exts.dart';
6
 import 'package:eitc_erm_dental_flutter/funcs.dart';
7
 import 'package:eitc_erm_dental_flutter/funcs.dart';
7
 import 'package:eitc_erm_dental_flutter/global.dart';
8
 import 'package:eitc_erm_dental_flutter/global.dart';
8
 import 'package:eitc_erm_dental_flutter/http/gzkj_response.dart';
9
 import 'package:eitc_erm_dental_flutter/http/gzkj_response.dart';
@@ -342,7 +343,7 @@ class _UploadingView extends StatelessWidget {
342
         children: [
343
         children: [
343
           Text(
344
           Text(
344
             getS().uploadingHint,
345
             getS().uploadingHint,
345
-            style: Theme.of(context).textTheme.titleMedium,
346
+            style: context.titleMedium,
346
           ),
347
           ),
347
           SizedBox(
348
           SizedBox(
348
             height: 40.h,
349
             height: 40.h,
@@ -353,7 +354,7 @@ class _UploadingView extends StatelessWidget {
353
               pi.LinearPercentIndicator(
354
               pi.LinearPercentIndicator(
354
                   percent: progress,
355
                   percent: progress,
355
                   lineHeight: 15.h,
356
                   lineHeight: 15.h,
356
-                  progressColor: Theme.of(context).colorScheme.primary,
357
+                  progressColor: context.primaryColor,
357
                   barRadius: Radius.circular(15.h),
358
                   barRadius: Radius.circular(15.h),
358
                   padding: EdgeInsets.zero,
359
                   padding: EdgeInsets.zero,
359
                   center: Text(
360
                   center: Text(

+ 3 - 3
lib/pages/upload/upload_select_clinic_page.dart

@@ -58,7 +58,7 @@ class _UploadSelectClinicPageState extends State<UploadSelectClinicPage> {
58
             children: [
58
             children: [
59
               Text(
59
               Text(
60
                 getS().pleaseSelectUploadClinic,
60
                 getS().pleaseSelectUploadClinic,
61
-                style: Theme.of(context).textTheme.titleLarge,
61
+                style: context.titleLarge,
62
               ),
62
               ),
63
               SizedBox(
63
               SizedBox(
64
                 height: 24.h,
64
                 height: 24.h,
@@ -138,7 +138,7 @@ class _UploadSelectClinicPageState extends State<UploadSelectClinicPage> {
138
       child: Container(
138
       child: Container(
139
         padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 14.h),
139
         padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 14.h),
140
         decoration: BoxDecoration(
140
         decoration: BoxDecoration(
141
-            color: Theme.of(context).colorScheme.surfaceContainerHigh,
141
+            color: context.surfaceContainerHighColor,
142
             borderRadius: BorderRadius.circular(8.r)),
142
             borderRadius: BorderRadius.circular(8.r)),
143
         child: Row(
143
         child: Row(
144
           children: [
144
           children: [
@@ -154,7 +154,7 @@ class _UploadSelectClinicPageState extends State<UploadSelectClinicPage> {
154
   Widget _getList(BuildContext context, List<ClinicInfo> list) {
154
   Widget _getList(BuildContext context, List<ClinicInfo> list) {
155
     return Container(
155
     return Container(
156
       decoration: BoxDecoration(
156
       decoration: BoxDecoration(
157
-          color: Theme.of(context).colorScheme.surfaceContainerHigh,
157
+          color: context.surfaceContainerHighColor,
158
           borderRadius: BorderRadius.circular(8.r)),
158
           borderRadius: BorderRadius.circular(8.r)),
159
       child: ListView.separated(
159
       child: ListView.separated(
160
           shrinkWrap: true,
160
           shrinkWrap: true,

+ 2 - 4
lib/pages/view/widget/preview_title.dart

@@ -1,5 +1,6 @@
1
 import 'dart:io';
1
 import 'dart:io';
2
 
2
 
3
+import 'package:eitc_erm_dental_flutter/exts.dart';
3
 import 'package:flutter/material.dart';
4
 import 'package:flutter/material.dart';
4
 
5
 
5
 ///预览标题
6
 ///预览标题
@@ -23,10 +24,7 @@ class PreviewTitle extends StatelessWidget {
23
             ),
24
             ),
24
             Text(
25
             Text(
25
               title ?? "",
26
               title ?? "",
26
-              style: Theme.of(context)
27
-                  .textTheme
28
-                  .titleMedium
29
-                  ?.copyWith(color: Colors.white),
27
+              style: context.titleMedium?.copyWith(color: Colors.white),
30
             ),
28
             ),
31
           ],
29
           ],
32
         ),
30
         ),

+ 2 - 2
lib/pages/view/widget/video_operation_view.dart

@@ -1,5 +1,6 @@
1
 import 'dart:async';
1
 import 'dart:async';
2
 
2
 
3
+import 'package:eitc_erm_dental_flutter/exts.dart';
3
 import 'package:eitc_erm_dental_flutter/funcs.dart';
4
 import 'package:eitc_erm_dental_flutter/funcs.dart';
4
 import 'package:eitc_erm_dental_flutter/sp_util.dart';
5
 import 'package:eitc_erm_dental_flutter/sp_util.dart';
5
 import 'package:eitc_erm_dental_flutter/widget/count_down_text.dart';
6
 import 'package:eitc_erm_dental_flutter/widget/count_down_text.dart';
@@ -96,8 +97,7 @@ class _VideoOperationViewState extends State<VideoOperationView> {
96
 
97
 
97
   ///获取倒计时,保持等
98
   ///获取倒计时,保持等
98
   Widget _getCountHold() {
99
   Widget _getCountHold() {
99
-    TextStyle? style =
100
-        Theme.of(context).textTheme.titleMedium?.copyWith(color: Colors.white);
100
+    TextStyle? style = context.titleMedium?.copyWith(color: Colors.white);
101
     return Align(
101
     return Align(
102
       alignment: Alignment.topCenter,
102
       alignment: Alignment.topCenter,
103
       child: Padding(
103
       child: Padding(

+ 1 - 2
lib/pages/view/widget/video_patient_info_bar.dart

@@ -102,8 +102,7 @@ class _VideoPatientInfoBarState extends State<VideoPatientInfoBar> {
102
   Widget _getText(String str) {
102
   Widget _getText(String str) {
103
     return Text(
103
     return Text(
104
       str,
104
       str,
105
-      style:
106
-          Theme.of(context).textTheme.bodyMedium?.copyWith(color: Colors.white),
105
+      style: context.bodyMedium?.copyWith(color: Colors.white),
107
     );
106
     );
108
   }
107
   }
109
 
108
 

+ 2 - 1
lib/widget/counting_button.dart

@@ -1,5 +1,6 @@
1
 import 'dart:async';
1
 import 'dart:async';
2
 
2
 
3
+import 'package:eitc_erm_dental_flutter/exts.dart';
3
 import 'package:flutter/material.dart';
4
 import 'package:flutter/material.dart';
4
 
5
 
5
 ///计时按钮
6
 ///计时按钮
@@ -43,7 +44,7 @@ class _CountingButtonState extends State<CountingButton> {
43
         style: widget.buttonStyle ??
44
         style: widget.buttonStyle ??
44
             ButtonStyle(
45
             ButtonStyle(
45
                 backgroundColor:
46
                 backgroundColor:
46
-                    WidgetStatePropertyAll(Theme.of(context).primaryColor),
47
+                    WidgetStatePropertyAll(context.primaryColor),
47
                 elevation: const WidgetStatePropertyAll(0.0)),
48
                 elevation: const WidgetStatePropertyAll(0.0)),
48
         child: widget.onGetChild(
49
         child: widget.onGetChild(
49
             widget.controller.counter.value, widget.controller.isCounting));
50
             widget.controller.counter.value, widget.controller.isCounting));

+ 4 - 5
lib/widget/main_button.dart

@@ -1,3 +1,4 @@
1
+import 'package:eitc_erm_dental_flutter/exts.dart';
1
 import 'package:flutter/material.dart';
2
 import 'package:flutter/material.dart';
2
 
3
 
3
 ///主要按钮
4
 ///主要按钮
@@ -27,7 +28,7 @@ class MainButton extends StatelessWidget {
27
                     BorderSide(color: Color(0xFFD2D2D2)))),
28
                     BorderSide(color: Color(0xFFD2D2D2)))),
28
             child: Text(
29
             child: Text(
29
               text,
30
               text,
30
-              style: TextStyle(color: Theme.of(context).colorScheme.onSurface),
31
+              style: TextStyle(color: context.onSurfaceColor),
31
             ))
32
             ))
32
         : ElevatedButton(
33
         : ElevatedButton(
33
             onPressed: onPressed,
34
             onPressed: onPressed,
@@ -35,15 +36,13 @@ class MainButton extends StatelessWidget {
35
                 padding: buttonPadding == null
36
                 padding: buttonPadding == null
36
                     ? null
37
                     ? null
37
                     : WidgetStatePropertyAll(buttonPadding),
38
                     : WidgetStatePropertyAll(buttonPadding),
38
-                backgroundColor:
39
-                    WidgetStatePropertyAll(Theme.of(context).primaryColor),
39
+                backgroundColor: WidgetStatePropertyAll(context.primaryColor),
40
                 elevation: const WidgetStatePropertyAll(0.0)),
40
                 elevation: const WidgetStatePropertyAll(0.0)),
41
             child: Text(
41
             child: Text(
42
               text,
42
               text,
43
               textAlign: TextAlign.center,
43
               textAlign: TextAlign.center,
44
               style: TextStyle(
44
               style: TextStyle(
45
-                  color: Theme.of(context).colorScheme.onPrimary,
46
-                  fontWeight: FontWeight.bold),
45
+                  color: context.onPrimaryColor, fontWeight: FontWeight.bold),
47
             ));
46
             ));
48
   }
47
   }
49
 }
48
 }