@@ -4,7 +4,6 @@ import 'package:components/toly_ui/toly_ui.dart';
4
4
import 'package:flutter/material.dart' ;
5
5
import 'package:flutter_bloc/flutter_bloc.dart' ;
6
6
7
-
8
7
/// create by 张风捷特烈 on 2020-04-10
9
8
/// contact me by email [email protected]
10
9
/// 说明:
@@ -27,53 +26,77 @@ class FontSettingPage extends StatelessWidget {
27
26
BuildContext context, List <String > fontFamilySupport, String fontFamily) {
28
27
return GridView .count (
29
28
padding: const EdgeInsets .only (top: 20 , left: 10 , right: 10 ),
30
- shrinkWrap: true ,
31
29
crossAxisCount: 2 ,
32
30
mainAxisSpacing: 10 ,
33
31
crossAxisSpacing: 10 ,
34
32
childAspectRatio: 1.5 ,
35
- children: fontFamilySupport
36
- .map ((e) => FeedbackWidget (
37
- a: 0.95 ,
38
- duration: const Duration (milliseconds: 200 ),
39
- onPressed: () {
40
- BlocProvider .of <AppBloc >(context).switchFontFamily (e);
41
- },
42
- child: Card (
43
- child: GridTile (
44
- header: Container (
45
- padding: const EdgeInsets .only (left: 10 , right: 5 ),
46
- height: 30 ,
47
- color: fontFamily == e
48
- ? Colors .blue.withAlpha (88 )
49
- : Colors .grey.withAlpha (88 ),
50
- child: Row (
51
- children: < Widget > [
52
- Text (e,
53
- style: TextStyle (
54
- color: Colors .black,
55
- fontFamily: e,
56
- )),
57
- const Spacer (),
58
- if (fontFamily == e) Circle (color: Theme .of (context).primaryColor,)
59
- ],
60
- ),
61
- ),
62
- child: Container (
63
- decoration: BoxDecoration (
64
- gradient: LinearGradient (colors: [
65
- Colors .blueAccent.withAlpha (22 ),
66
- Colors .blueAccent.withAlpha (22 ),
67
- Theme .of (context).primaryColor.withAlpha (88 )
68
- ])),
69
- alignment: const Alignment (0 , 0.4 ),
70
- child: Text (
71
- '张风捷特烈\n @toly1994' ,
72
- style: TextStyle (fontFamily: e, fontSize: 16 ),
73
- )),
74
- ),
75
- )))
76
- .toList (),
33
+ children: fontFamilySupport.map ((e) {
34
+ return FontCell (
35
+ active: fontFamily == e,
36
+ fontFamily: e,
37
+ onSelect: (font) {
38
+ BlocProvider .of <AppBloc >(context).switchFontFamily (font);
39
+ },
40
+ );
41
+ }).toList (),
77
42
);
78
43
}
79
44
}
45
+
46
+ class FontCell extends StatelessWidget {
47
+ final bool active;
48
+ final ValueChanged <String > onSelect;
49
+ final String fontFamily;
50
+
51
+ const FontCell (
52
+ {Key ? key,
53
+ required this .active,
54
+ required this .onSelect,
55
+ required this .fontFamily})
56
+ : super (key: key);
57
+
58
+ @override
59
+ Widget build (BuildContext context) {
60
+ return FeedbackWidget (
61
+ a: 0.95 ,
62
+ duration: const Duration (milliseconds: 200 ),
63
+ onPressed: () => onSelect (fontFamily),
64
+ child: GridTile (
65
+ header: Container (
66
+ padding: const EdgeInsets .only (left: 10 , right: 5 ),
67
+ height: 30 ,
68
+ color: active
69
+ ? Colors .blue.withAlpha (88 )
70
+ : Colors .grey.withAlpha (88 ),
71
+ child: Row (
72
+ children: < Widget > [
73
+ Text (fontFamily,
74
+ style: TextStyle (
75
+ color: Colors .black,
76
+ fontFamily: fontFamily,
77
+ )),
78
+ const Spacer (),
79
+ if (active)
80
+ Circle (color: Theme .of (context).primaryColor)
81
+ ],
82
+ ),
83
+ ),
84
+ child: Container (
85
+ decoration: BoxDecoration (
86
+ borderRadius: BorderRadius .only (
87
+ bottomLeft: Radius .circular (8 ),
88
+ bottomRight: Radius .circular (8 ),
89
+ ),
90
+ gradient: LinearGradient (colors: [
91
+ Colors .blueAccent.withAlpha (22 ),
92
+ Colors .blueAccent.withAlpha (22 ),
93
+ Theme .of (context).primaryColor.withAlpha (88 )
94
+ ])),
95
+ alignment: const Alignment (0 , 0.4 ),
96
+ child: Text (
97
+ '张风捷特烈\n @toly1994' ,
98
+ style: TextStyle (fontFamily: fontFamily, fontSize: 16 ),
99
+ )),
100
+ ));
101
+ }
102
+ }
0 commit comments