Showing
18 changed files
with
187 additions
and
142 deletions
... | @@ -147,7 +147,7 @@ class _AccountPageState extends State<AccountPage> { | ... | @@ -147,7 +147,7 @@ class _AccountPageState extends State<AccountPage> { |
147 | ], | 147 | ], |
148 | ); | 148 | ); |
149 | return Scaffold( | 149 | return Scaffold( |
150 | - appBar: const MyAppBar( | 150 | + appBar: MyAppBar( |
151 | ), | 151 | ), |
152 | body: Container( | 152 | body: Container( |
153 | decoration: const BoxDecoration( | 153 | decoration: const BoxDecoration( | ... | ... |
... | @@ -43,7 +43,7 @@ class _CategoriesPageState extends State<CategoriesPage> | ... | @@ -43,7 +43,7 @@ class _CategoriesPageState extends State<CategoriesPage> |
43 | return ChangeNotifierProvider<CategoriesPageProvider>( | 43 | return ChangeNotifierProvider<CategoriesPageProvider>( |
44 | create: (_) => provider, | 44 | create: (_) => provider, |
45 | child: Scaffold( | 45 | child: Scaffold( |
46 | - appBar: const MyAppBar( | 46 | + appBar: MyAppBar( |
47 | ), | 47 | ), |
48 | body: Column( | 48 | body: Column( |
49 | key: _bodyKey, | 49 | key: _bodyKey, | ... | ... |
... | @@ -53,8 +53,8 @@ class _WebViewPageState extends State<WebViewPage> { | ... | @@ -53,8 +53,8 @@ class _WebViewPageState extends State<WebViewPage> { |
53 | return Future.value(true); | 53 | return Future.value(true); |
54 | }, | 54 | }, |
55 | child: Scaffold( | 55 | child: Scaffold( |
56 | - appBar: MyAppBar( | 56 | + appBar: const MyAppBar( |
57 | - centerTitle: widget.title, | 57 | + |
58 | ), | 58 | ), |
59 | body: Stack( | 59 | body: Stack( |
60 | children: [ | 60 | children: [ | ... | ... |
... | @@ -84,7 +84,6 @@ class _LoginPageState extends State<LoginPage> with ChangeNotifierMixin<LoginPag | ... | @@ -84,7 +84,6 @@ class _LoginPageState extends State<LoginPage> with ChangeNotifierMixin<LoginPag |
84 | return Scaffold( | 84 | return Scaffold( |
85 | appBar: MyAppBar( | 85 | appBar: MyAppBar( |
86 | isBack: false, | 86 | isBack: false, |
87 | - actionName: OnePoemLocalizations.of(context).verificationCodeLogin, | ||
88 | onPressed: () { | 87 | onPressed: () { |
89 | NavigatorUtils.push(context, LoginRouter.smsLoginPage); | 88 | NavigatorUtils.push(context, LoginRouter.smsLoginPage); |
90 | }, | 89 | }, | ... | ... |
... | @@ -73,8 +73,7 @@ class _RegisterPageState extends State<RegisterPage> with ChangeNotifierMixin<Re | ... | @@ -73,8 +73,7 @@ class _RegisterPageState extends State<RegisterPage> with ChangeNotifierMixin<Re |
73 | @override | 73 | @override |
74 | Widget build(BuildContext context) { | 74 | Widget build(BuildContext context) { |
75 | return Scaffold( | 75 | return Scaffold( |
76 | - appBar: MyAppBar( | 76 | + appBar: const MyAppBar( |
77 | - title: OnePoemLocalizations.of(context).register, | ||
78 | ), | 77 | ), |
79 | body: MyScrollView( | 78 | body: MyScrollView( |
80 | keyboardConfig: Utils.getKeyboardActionsConfig(context, <FocusNode>[_nodeText1, _nodeText2, _nodeText3]), | 79 | keyboardConfig: Utils.getKeyboardActionsConfig(context, <FocusNode>[_nodeText1, _nodeText2, _nodeText3]), | ... | ... |
... | @@ -70,8 +70,7 @@ class _ResetPasswordPageState extends State<ResetPasswordPage> with ChangeNotifi | ... | @@ -70,8 +70,7 @@ class _ResetPasswordPageState extends State<ResetPasswordPage> with ChangeNotifi |
70 | @override | 70 | @override |
71 | Widget build(BuildContext context) { | 71 | Widget build(BuildContext context) { |
72 | return Scaffold( | 72 | return Scaffold( |
73 | - appBar: MyAppBar( | 73 | + appBar: const MyAppBar( |
74 | - title: OnePoemLocalizations.of(context).forgotPasswordLink, | ||
75 | ), | 74 | ), |
76 | body: MyScrollView( | 75 | body: MyScrollView( |
77 | keyboardConfig: Utils.getKeyboardActionsConfig(context, <FocusNode>[_nodeText1, _nodeText2, _nodeText3]), | 76 | keyboardConfig: Utils.getKeyboardActionsConfig(context, <FocusNode>[_nodeText1, _nodeText2, _nodeText3]), | ... | ... |
... | @@ -65,7 +65,7 @@ class _SMSLoginPageState extends State<SMSLoginPage> with ChangeNotifierMixin<SM | ... | @@ -65,7 +65,7 @@ class _SMSLoginPageState extends State<SMSLoginPage> with ChangeNotifierMixin<SM |
65 | @override | 65 | @override |
66 | Widget build(BuildContext context) { | 66 | Widget build(BuildContext context) { |
67 | return Scaffold( | 67 | return Scaffold( |
68 | - appBar: const MyAppBar(), | 68 | + appBar: MyAppBar(), |
69 | body: MyScrollView( | 69 | body: MyScrollView( |
70 | keyboardConfig: Utils.getKeyboardActionsConfig(context, <FocusNode>[_nodeText1, _nodeText2]), | 70 | keyboardConfig: Utils.getKeyboardActionsConfig(context, <FocusNode>[_nodeText1, _nodeText2]), |
71 | padding: const EdgeInsets.only(left: 16.0, right: 16.0, top: 20.0), | 71 | padding: const EdgeInsets.only(left: 16.0, right: 16.0, top: 20.0), | ... | ... |
... | @@ -64,7 +64,6 @@ class _UpdatePasswordPageState extends State<UpdatePasswordPage> with ChangeNoti | ... | @@ -64,7 +64,6 @@ class _UpdatePasswordPageState extends State<UpdatePasswordPage> with ChangeNoti |
64 | Widget build(BuildContext context) { | 64 | Widget build(BuildContext context) { |
65 | return Scaffold( | 65 | return Scaffold( |
66 | appBar: const MyAppBar( | 66 | appBar: const MyAppBar( |
67 | - title: '修改密码', | ||
68 | ), | 67 | ), |
69 | body: MyScrollView( | 68 | body: MyScrollView( |
70 | keyboardConfig: Utils.getKeyboardActionsConfig(context, <FocusNode>[_nodeText1, _nodeText2]), | 69 | keyboardConfig: Utils.getKeyboardActionsConfig(context, <FocusNode>[_nodeText1, _nodeText2]), | ... | ... |
... | @@ -3,6 +3,8 @@ import 'package:flutter/material.dart'; | ... | @@ -3,6 +3,8 @@ import 'package:flutter/material.dart'; |
3 | import 'package:one_poem/res/gaps.dart'; | 3 | import 'package:one_poem/res/gaps.dart'; |
4 | import 'package:one_poem/util/theme_utils.dart'; | 4 | import 'package:one_poem/util/theme_utils.dart'; |
5 | import 'package:one_poem/util/toast_utils.dart'; | 5 | import 'package:one_poem/util/toast_utils.dart'; |
6 | +import 'package:one_poem/widgets/bars/home_action_bar.dart'; | ||
7 | +import 'package:one_poem/widgets/bars/home_title_bar.dart'; | ||
6 | import 'package:one_poem/widgets/load_image.dart'; | 8 | import 'package:one_poem/widgets/load_image.dart'; |
7 | import 'package:one_poem/widgets/my_app_bar.dart'; | 9 | import 'package:one_poem/widgets/my_app_bar.dart'; |
8 | 10 | ||
... | @@ -24,12 +26,17 @@ class _PoemDetailPageState extends State<PoemDetailPage> { | ... | @@ -24,12 +26,17 @@ class _PoemDetailPageState extends State<PoemDetailPage> { |
24 | @override | 26 | @override |
25 | Widget build(BuildContext context) { | 27 | Widget build(BuildContext context) { |
26 | return Scaffold( | 28 | return Scaffold( |
27 | - // extendBodyBehindAppBar: true,// appbar背景透明 | ||
28 | appBar: MyAppBar( | 29 | appBar: MyAppBar( |
29 | - isShowButtons: true, | 30 | + homeTitleHeader: HomeTitleHeader( |
30 | - funcLeft: () { | 31 | + funcLeft: (){ |
31 | - print("xxxxx"); | 32 | + print("lefltlelfle"); |
32 | - }, | 33 | + }, |
34 | + ), | ||
35 | + homeActionWidgets: HomeActionWidgets( | ||
36 | + funcStar: (){ | ||
37 | + print("starrrrrrr"); | ||
38 | + }, | ||
39 | + ), | ||
33 | ), | 40 | ), |
34 | body: Container( | 41 | body: Container( |
35 | decoration: const BoxDecoration( | 42 | decoration: const BoxDecoration( | ... | ... |
... | @@ -10,7 +10,6 @@ class NotFoundPage extends StatelessWidget { | ... | @@ -10,7 +10,6 @@ class NotFoundPage extends StatelessWidget { |
10 | Widget build(BuildContext context) { | 10 | Widget build(BuildContext context) { |
11 | return const Scaffold( | 11 | return const Scaffold( |
12 | appBar: MyAppBar( | 12 | appBar: MyAppBar( |
13 | - centerTitle: '页面不存在', | ||
14 | ), | 13 | ), |
15 | body: StateLayout( | 14 | body: StateLayout( |
16 | type: StateType.account, | 15 | type: StateType.account, | ... | ... |
... | @@ -69,7 +69,6 @@ class _AboutPageState extends State<AboutPage> { | ... | @@ -69,7 +69,6 @@ class _AboutPageState extends State<AboutPage> { |
69 | Widget build(BuildContext context) { | 69 | Widget build(BuildContext context) { |
70 | return Scaffold( | 70 | return Scaffold( |
71 | appBar: const MyAppBar( | 71 | appBar: const MyAppBar( |
72 | - title: '关于我们', | ||
73 | ), | 72 | ), |
74 | body: Column( | 73 | body: Column( |
75 | children: <Widget>[ | 74 | children: <Widget>[ | ... | ... |
... | @@ -5,10 +5,8 @@ import 'package:one_poem/widgets/click_item.dart'; | ... | @@ -5,10 +5,8 @@ import 'package:one_poem/widgets/click_item.dart'; |
5 | import 'package:one_poem/widgets/load_image.dart'; | 5 | import 'package:one_poem/widgets/load_image.dart'; |
6 | import 'package:one_poem/widgets/my_app_bar.dart'; | 6 | import 'package:one_poem/widgets/my_app_bar.dart'; |
7 | 7 | ||
8 | - | ||
9 | /// design/8设置/index.html#artboard1 | 8 | /// design/8设置/index.html#artboard1 |
10 | class AccountManagerPage extends StatefulWidget { | 9 | class AccountManagerPage extends StatefulWidget { |
11 | - | ||
12 | const AccountManagerPage({Key? key}) : super(key: key); | 10 | const AccountManagerPage({Key? key}) : super(key: key); |
13 | 11 | ||
14 | @override | 12 | @override |
... | @@ -19,16 +17,12 @@ class _AccountManagerPageState extends State<AccountManagerPage> { | ... | @@ -19,16 +17,12 @@ class _AccountManagerPageState extends State<AccountManagerPage> { |
19 | @override | 17 | @override |
20 | Widget build(BuildContext context) { | 18 | Widget build(BuildContext context) { |
21 | return Scaffold( | 19 | return Scaffold( |
22 | - appBar: const MyAppBar( | 20 | + appBar: MyAppBar(), |
23 | - ), | ||
24 | body: Column( | 21 | body: Column( |
25 | children: <Widget>[ | 22 | children: <Widget>[ |
26 | Stack( | 23 | Stack( |
27 | children: <Widget>[ | 24 | children: <Widget>[ |
28 | - ClickItem( | 25 | + ClickItem(title: '店铺logo', onTap: () {}), |
29 | - title: '店铺logo', | ||
30 | - onTap: () {} | ||
31 | - ), | ||
32 | const Positioned( | 26 | const Positioned( |
33 | top: 8.0, | 27 | top: 8.0, |
34 | bottom: 8.0, | 28 | bottom: 8.0, |
... | @@ -38,10 +32,10 @@ class _AccountManagerPageState extends State<AccountManagerPage> { | ... | @@ -38,10 +32,10 @@ class _AccountManagerPageState extends State<AccountManagerPage> { |
38 | ], | 32 | ], |
39 | ), | 33 | ), |
40 | ClickItem( | 34 | ClickItem( |
41 | - title: '修改密码', | 35 | + title: '修改密码', |
42 | - content: '用于密码登录', | 36 | + content: '用于密码登录', |
43 | - onTap: () => NavigatorUtils.push(context, LoginRouter.updatePasswordPage) | 37 | + onTap: () => |
44 | - ), | 38 | + NavigatorUtils.push(context, LoginRouter.updatePasswordPage)), |
45 | const ClickItem( | 39 | const ClickItem( |
46 | title: '绑定账号', | 40 | title: '绑定账号', |
47 | content: '15000000000', | 41 | content: '15000000000', | ... | ... |
... | @@ -7,7 +7,6 @@ import 'package:one_poem/widgets/my_app_bar.dart'; | ... | @@ -7,7 +7,6 @@ import 'package:one_poem/widgets/my_app_bar.dart'; |
7 | import 'package:provider/provider.dart'; | 7 | import 'package:provider/provider.dart'; |
8 | 8 | ||
9 | class LocalePage extends StatefulWidget { | 9 | class LocalePage extends StatefulWidget { |
10 | - | ||
11 | const LocalePage({Key? key}) : super(key: key); | 10 | const LocalePage({Key? key}) : super(key: key); |
12 | 11 | ||
13 | @override | 12 | @override |
... | @@ -15,14 +14,13 @@ class LocalePage extends StatefulWidget { | ... | @@ -15,14 +14,13 @@ class LocalePage extends StatefulWidget { |
15 | } | 14 | } |
16 | 15 | ||
17 | class _LocalePageState extends State<LocalePage> { | 16 | class _LocalePageState extends State<LocalePage> { |
18 | - | ||
19 | final List<String> _list = <String>['跟随系统', '中文', 'English']; | 17 | final List<String> _list = <String>['跟随系统', '中文', 'English']; |
20 | 18 | ||
21 | @override | 19 | @override |
22 | Widget build(BuildContext context) { | 20 | Widget build(BuildContext context) { |
23 | final String? locale = SpUtil.getString(Constant.locale); | 21 | final String? locale = SpUtil.getString(Constant.locale); |
24 | String localeMode; | 22 | String localeMode; |
25 | - switch(locale) { | 23 | + switch (locale) { |
26 | case 'zh': | 24 | case 'zh': |
27 | localeMode = _list[1]; | 25 | localeMode = _list[1]; |
28 | break; | 26 | break; |
... | @@ -35,7 +33,6 @@ class _LocalePageState extends State<LocalePage> { | ... | @@ -35,7 +33,6 @@ class _LocalePageState extends State<LocalePage> { |
35 | } | 33 | } |
36 | return Scaffold( | 34 | return Scaffold( |
37 | appBar: const MyAppBar( | 35 | appBar: const MyAppBar( |
38 | - title: '多语言', | ||
39 | ), | 36 | ), |
40 | body: ListView.separated( | 37 | body: ListView.separated( |
41 | itemCount: _list.length, | 38 | itemCount: _list.length, |
... | @@ -43,7 +40,8 @@ class _LocalePageState extends State<LocalePage> { | ... | @@ -43,7 +40,8 @@ class _LocalePageState extends State<LocalePage> { |
43 | itemBuilder: (_, int index) { | 40 | itemBuilder: (_, int index) { |
44 | return InkWell( | 41 | return InkWell( |
45 | onTap: () { | 42 | onTap: () { |
46 | - final String locale = index == 0 ? '' : (index == 1 ? 'zh' : 'en'); | 43 | + final String locale = |
44 | + index == 0 ? '' : (index == 1 ? 'zh' : 'en'); | ||
47 | context.read<LocaleProvider>().setLocale(locale); | 45 | context.read<LocaleProvider>().setLocale(locale); |
48 | Toast.show('当前功能仅登录模块有效'); | 46 | Toast.show('当前功能仅登录模块有效'); |
49 | setState(() {}); | 47 | setState(() {}); | ... | ... |
... | @@ -25,8 +25,7 @@ class _SettingPageState extends State<SettingPage> { | ... | @@ -25,8 +25,7 @@ class _SettingPageState extends State<SettingPage> { |
25 | @override | 25 | @override |
26 | Widget build(BuildContext context) { | 26 | Widget build(BuildContext context) { |
27 | return Scaffold( | 27 | return Scaffold( |
28 | - appBar: const MyAppBar( | 28 | + appBar: const MyAppBar( |
29 | - centerTitle: '设置', | ||
30 | ), | 29 | ), |
31 | body: Column( | 30 | body: Column( |
32 | children: <Widget>[ | 31 | children: <Widget>[ | ... | ... |
... | @@ -6,7 +6,6 @@ import 'package:one_poem/widgets/my_app_bar.dart'; | ... | @@ -6,7 +6,6 @@ import 'package:one_poem/widgets/my_app_bar.dart'; |
6 | import 'package:provider/provider.dart'; | 6 | import 'package:provider/provider.dart'; |
7 | 7 | ||
8 | class ThemePage extends StatefulWidget { | 8 | class ThemePage extends StatefulWidget { |
9 | - | ||
10 | const ThemePage({Key? key}) : super(key: key); | 9 | const ThemePage({Key? key}) : super(key: key); |
11 | 10 | ||
12 | @override | 11 | @override |
... | @@ -14,14 +13,13 @@ class ThemePage extends StatefulWidget { | ... | @@ -14,14 +13,13 @@ class ThemePage extends StatefulWidget { |
14 | } | 13 | } |
15 | 14 | ||
16 | class _ThemePageState extends State<ThemePage> { | 15 | class _ThemePageState extends State<ThemePage> { |
17 | - | ||
18 | final List<String> _list = <String>['跟随系统', '开启', '关闭']; | 16 | final List<String> _list = <String>['跟随系统', '开启', '关闭']; |
19 | 17 | ||
20 | @override | 18 | @override |
21 | Widget build(BuildContext context) { | 19 | Widget build(BuildContext context) { |
22 | final String? theme = SpUtil.getString(Constant.theme); | 20 | final String? theme = SpUtil.getString(Constant.theme); |
23 | String themeMode; | 21 | String themeMode; |
24 | - switch(theme) { | 22 | + switch (theme) { |
25 | case 'Dark': | 23 | case 'Dark': |
26 | themeMode = _list[1]; | 24 | themeMode = _list[1]; |
27 | break; | 25 | break; |
... | @@ -33,16 +31,16 @@ class _ThemePageState extends State<ThemePage> { | ... | @@ -33,16 +31,16 @@ class _ThemePageState extends State<ThemePage> { |
33 | break; | 31 | break; |
34 | } | 32 | } |
35 | return Scaffold( | 33 | return Scaffold( |
36 | - appBar: const MyAppBar( | 34 | + appBar: const MyAppBar(), |
37 | - title: '夜间模式', | ||
38 | - ), | ||
39 | body: ListView.separated( | 35 | body: ListView.separated( |
40 | itemCount: _list.length, | 36 | itemCount: _list.length, |
41 | separatorBuilder: (_, __) => const Divider(), | 37 | separatorBuilder: (_, __) => const Divider(), |
42 | itemBuilder: (_, int index) { | 38 | itemBuilder: (_, int index) { |
43 | return InkWell( | 39 | return InkWell( |
44 | onTap: () { | 40 | onTap: () { |
45 | - final ThemeMode themeMode = index == 0 ? ThemeMode.system : (index == 1 ? ThemeMode.dark : ThemeMode.light); | 41 | + final ThemeMode themeMode = index == 0 |
42 | + ? ThemeMode.system | ||
43 | + : (index == 1 ? ThemeMode.dark : ThemeMode.light); | ||
46 | // Provider.of<ThemeProvider>(context, listen: false).setTheme(themeMode); | 44 | // Provider.of<ThemeProvider>(context, listen: false).setTheme(themeMode); |
47 | /// 与上方等价,provider 4.1.0添加的拓展方法 | 45 | /// 与上方等价,provider 4.1.0添加的拓展方法 |
48 | context.read<ThemeProvider>().setTheme(themeMode); | 46 | context.read<ThemeProvider>().setTheme(themeMode); | ... | ... |
lib/widgets/bars/home_action_bar.dart
0 → 100644
1 | +import 'package:flutter/material.dart'; | ||
2 | +import 'package:one_poem/res/resources.dart'; | ||
3 | + | ||
4 | +class HomeActionWidgets extends StatelessWidget { | ||
5 | + const HomeActionWidgets({ | ||
6 | + Key? key, | ||
7 | + this.funcStar, | ||
8 | + this.funcShare, | ||
9 | + this.funcMore, | ||
10 | + }) : super(key: key); | ||
11 | + | ||
12 | + final Function? funcStar; | ||
13 | + final Function? funcShare; | ||
14 | + final Function? funcMore; | ||
15 | + | ||
16 | + @override | ||
17 | + Widget build(BuildContext context) { | ||
18 | + const iconHeight = 30.0; | ||
19 | + const iconWidth = 30.0; | ||
20 | + const iconSize = 20.0; | ||
21 | + return Row( | ||
22 | + mainAxisSize: MainAxisSize.min, | ||
23 | + mainAxisAlignment: MainAxisAlignment.center, | ||
24 | + children: [ | ||
25 | + SizedBox( | ||
26 | + height: iconHeight, | ||
27 | + width: iconWidth, | ||
28 | + child: IconButton( | ||
29 | + padding: const EdgeInsets.all(0.0), | ||
30 | + icon: const Icon( | ||
31 | + Icons.star_border, | ||
32 | + size: iconSize, | ||
33 | + ), | ||
34 | + onPressed: () { | ||
35 | + funcStar!(); | ||
36 | + }, | ||
37 | + ), | ||
38 | + ), | ||
39 | + SizedBox( | ||
40 | + height: iconHeight, | ||
41 | + width: iconWidth, | ||
42 | + child: IconButton( | ||
43 | + padding: const EdgeInsets.all(0.0), | ||
44 | + icon: const Icon( | ||
45 | + Icons.ios_share, | ||
46 | + size: iconSize, | ||
47 | + ), | ||
48 | + onPressed: () {}, | ||
49 | + ), | ||
50 | + ), | ||
51 | + SizedBox( | ||
52 | + height: iconHeight, | ||
53 | + width: iconWidth, | ||
54 | + child: IconButton( | ||
55 | + padding: const EdgeInsets.all(0.0), | ||
56 | + onPressed: () {}, | ||
57 | + icon: const Icon( | ||
58 | + Icons.more_horiz, | ||
59 | + size: iconSize, | ||
60 | + ), | ||
61 | + ), | ||
62 | + ), | ||
63 | + ], | ||
64 | + ); | ||
65 | + } | ||
66 | +} |
lib/widgets/bars/home_title_bar.dart
0 → 100644
1 | +import 'package:flutter/material.dart'; | ||
2 | + | ||
3 | +class HomeTitleHeader extends StatelessWidget { | ||
4 | + const HomeTitleHeader({ | ||
5 | + Key? key, | ||
6 | + this.funcLeft, | ||
7 | + this.funcCenter, | ||
8 | + this.funcRight, | ||
9 | + }) : super(key: key); | ||
10 | + | ||
11 | + final Function? funcLeft; | ||
12 | + final Function? funcCenter; | ||
13 | + final Function? funcRight; | ||
14 | + | ||
15 | + @override | ||
16 | + Widget build(BuildContext context) { | ||
17 | + return Container( | ||
18 | + alignment: Alignment.center, | ||
19 | + margin: const EdgeInsets.symmetric(horizontal: 5.0), | ||
20 | + child: Row( | ||
21 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
22 | + mainAxisSize: MainAxisSize.min, | ||
23 | + //交叉轴的布局方式,对于column来说就是水平方向的布局方式 | ||
24 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
25 | + children: <Widget>[ | ||
26 | + SizedBox( | ||
27 | + width: 60.0, | ||
28 | + child: TextButton( | ||
29 | + onPressed: () => funcLeft!(), | ||
30 | + child: const Text( | ||
31 | + "一言", | ||
32 | + style: TextStyle(color: Colors.white), | ||
33 | + ), | ||
34 | + ), | ||
35 | + ), | ||
36 | + const VerticalDivider( | ||
37 | + color: Colors.white, | ||
38 | + width: 1.0, | ||
39 | + thickness: 1.0, | ||
40 | + indent: 15.0, | ||
41 | + endIndent: 15.0, | ||
42 | + ), | ||
43 | + TextButton( | ||
44 | + onPressed: () => funcCenter!(), | ||
45 | + child: const Text( | ||
46 | + "译解", | ||
47 | + style: TextStyle(color: Colors.white), | ||
48 | + ), | ||
49 | + ), | ||
50 | + const VerticalDivider( | ||
51 | + color: Colors.white, | ||
52 | + width: 1.0, | ||
53 | + thickness: 1.0, | ||
54 | + indent: 15.0, | ||
55 | + endIndent: 15.0, | ||
56 | + ), | ||
57 | + TextButton( | ||
58 | + onPressed: () => funcRight!(), | ||
59 | + child: const Text( | ||
60 | + "临境", | ||
61 | + style: TextStyle(color: Colors.white), | ||
62 | + ), | ||
63 | + ), | ||
64 | + ], | ||
65 | + )); | ||
66 | + } | ||
67 | +} |
... | @@ -8,38 +8,18 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget { | ... | @@ -8,38 +8,18 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget { |
8 | const MyAppBar({ | 8 | const MyAppBar({ |
9 | Key? key, | 9 | Key? key, |
10 | this.backgroundColor, | 10 | this.backgroundColor, |
11 | - this.title = '', | ||
12 | - this.centerTitle = '', | ||
13 | - this.actionName = '', | ||
14 | - this.backImg = 'assets/images/ic_back_black.png', | ||
15 | - this.backImgColor, | ||
16 | this.onPressed, | 11 | this.onPressed, |
17 | this.isBack = true, | 12 | this.isBack = true, |
18 | - this.buttonLeft, | 13 | + this.homeTitleHeader, |
19 | - this.funcLeft, | 14 | + this.homeActionWidgets, |
20 | - this.buttonCenter, | ||
21 | - this.funcCenter, | ||
22 | - this.buttonRight, | ||
23 | - this.funcRight, | ||
24 | - this.isShowButtons = false, | ||
25 | }) : super(key: key); | 15 | }) : super(key: key); |
26 | 16 | ||
27 | final Color? backgroundColor; | 17 | final Color? backgroundColor; |
28 | - final String title; | ||
29 | - final String centerTitle; | ||
30 | - final String backImg; | ||
31 | - final Color? backImgColor; | ||
32 | - final String actionName; | ||
33 | final VoidCallback? onPressed; | 18 | final VoidCallback? onPressed; |
34 | final bool isBack; | 19 | final bool isBack; |
35 | - final bool isShowButtons; | ||
36 | 20 | ||
37 | - final String? buttonLeft; | 21 | + final Widget? homeTitleHeader; |
38 | - final Function? funcLeft; | 22 | + final Widget? homeActionWidgets; |
39 | - final String? buttonCenter; | ||
40 | - final Function? funcCenter; | ||
41 | - final String? buttonRight; | ||
42 | - final Function? funcRight; | ||
43 | 23 | ||
44 | @override | 24 | @override |
45 | Widget build(BuildContext context) { | 25 | Widget build(BuildContext context) { |
... | @@ -51,34 +31,6 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget { | ... | @@ -51,34 +31,6 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget { |
51 | ? SystemUiOverlayStyle.light | 31 | ? SystemUiOverlayStyle.light |
52 | : SystemUiOverlayStyle.dark; | 32 | : SystemUiOverlayStyle.dark; |
53 | 33 | ||
54 | - final Widget action = actionName.isNotEmpty | ||
55 | - ? Positioned( | ||
56 | - right: 0.0, | ||
57 | - child: Theme( | ||
58 | - data: Theme.of(context).copyWith( | ||
59 | - buttonTheme: const ButtonThemeData( | ||
60 | - padding: EdgeInsets.symmetric(horizontal: 16.0), | ||
61 | - minWidth: 60.0, | ||
62 | - ), | ||
63 | - ), | ||
64 | - child: Row( | ||
65 | - children: [ | ||
66 | - Icon( | ||
67 | - Icons.star, | ||
68 | - color: Colors.white.withOpacity(0.66), | ||
69 | - ), | ||
70 | - Gaps.hGap10, | ||
71 | - Icon( | ||
72 | - Icons.ios_share, | ||
73 | - color: Colors.white.withOpacity(0.66), | ||
74 | - ), | ||
75 | - Gaps.hGap10, | ||
76 | - ], | ||
77 | - ), | ||
78 | - ), | ||
79 | - ) | ||
80 | - : Gaps.empty; | ||
81 | - | ||
82 | final Widget back = isBack | 34 | final Widget back = isBack |
83 | ? IconButton( | 35 | ? IconButton( |
84 | onPressed: () async { | 36 | onPressed: () async { |
... | @@ -90,62 +42,32 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget { | ... | @@ -90,62 +42,32 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget { |
90 | }, | 42 | }, |
91 | tooltip: '返回', | 43 | tooltip: '返回', |
92 | padding: const EdgeInsets.all(12.0), | 44 | padding: const EdgeInsets.all(12.0), |
93 | - icon: Image.asset( | 45 | + icon: const Icon(Icons.arrow_back_ios_outlined), |
94 | - backImg, | ||
95 | - color: backImgColor ?? ThemeUtils.getIconColor(context), | ||
96 | - ), | ||
97 | ) | 46 | ) |
98 | : Gaps.empty; | 47 | : Gaps.empty; |
99 | 48 | ||
100 | - // TODO 复用组件 | ||
101 | - final Widget titleWidget = Semantics( | ||
102 | - namesRoute: true, | ||
103 | - header: true, | ||
104 | - child: Container( | ||
105 | - alignment: Alignment.center, | ||
106 | - width: double.infinity, | ||
107 | - margin: const EdgeInsets.symmetric(horizontal: 48.0), | ||
108 | - child: isShowButtons ? Row( | ||
109 | - children: [ | ||
110 | - TextButton( | ||
111 | - onPressed: () => funcLeft!(), | ||
112 | - child: Text( | ||
113 | - buttonLeft ?? "一言", | ||
114 | - style: const TextStyle(color: Colors.white), | ||
115 | - ), | ||
116 | - ), | ||
117 | - const Text("|"), | ||
118 | - TextButton( | ||
119 | - onPressed: () => funcCenter!(), | ||
120 | - child: Text( | ||
121 | - buttonCenter ?? "译解", | ||
122 | - style: const TextStyle(color: Colors.white), | ||
123 | - ), | ||
124 | - ), | ||
125 | - const Text("|"), | ||
126 | - TextButton( | ||
127 | - onPressed: () => funcRight!(), | ||
128 | - child: Text( | ||
129 | - buttonRight ?? "临境", | ||
130 | - style: const TextStyle(color: Colors.white), | ||
131 | - ), | ||
132 | - ), | ||
133 | - ], | ||
134 | - ) : Gaps.hGap10, | ||
135 | - ), | ||
136 | - ); | ||
137 | - | ||
138 | return AnnotatedRegion<SystemUiOverlayStyle>( | 49 | return AnnotatedRegion<SystemUiOverlayStyle>( |
139 | value: _overlayStyle, | 50 | value: _overlayStyle, |
140 | child: Material( | 51 | child: Material( |
141 | color: Colors.transparent, | 52 | color: Colors.transparent, |
142 | child: SafeArea( | 53 | child: SafeArea( |
143 | child: Stack( | 54 | child: Stack( |
144 | - alignment: Alignment.centerLeft, | 55 | + alignment: Alignment.center, |
145 | children: <Widget>[ | 56 | children: <Widget>[ |
146 | - titleWidget, | 57 | + Positioned( |
147 | - back, | 58 | + left: 5, |
148 | - action, | 59 | + child: back, |
60 | + ), | ||
61 | + SizedBox( | ||
62 | + width: MediaQuery.of(context).size.width, | ||
63 | + child: homeTitleHeader, | ||
64 | + ), | ||
65 | + SizedBox( | ||
66 | + child: Container( | ||
67 | + alignment: Alignment.centerRight, | ||
68 | + child: homeActionWidgets, | ||
69 | + ), | ||
70 | + ), | ||
149 | ], | 71 | ], |
150 | ), | 72 | ), |
151 | ), | 73 | ), | ... | ... |
-
Please register or login to post a comment