reason

clear

......@@ -147,7 +147,7 @@ class _AccountPageState extends State<AccountPage> {
],
);
return Scaffold(
appBar: const MyAppBar(
appBar: MyAppBar(
),
body: Container(
decoration: const BoxDecoration(
......
......@@ -43,7 +43,7 @@ class _CategoriesPageState extends State<CategoriesPage>
return ChangeNotifierProvider<CategoriesPageProvider>(
create: (_) => provider,
child: Scaffold(
appBar: const MyAppBar(
appBar: MyAppBar(
),
body: Column(
key: _bodyKey,
......
......@@ -53,8 +53,8 @@ class _WebViewPageState extends State<WebViewPage> {
return Future.value(true);
},
child: Scaffold(
appBar: MyAppBar(
centerTitle: widget.title,
appBar: const MyAppBar(
),
body: Stack(
children: [
......
......@@ -84,7 +84,6 @@ class _LoginPageState extends State<LoginPage> with ChangeNotifierMixin<LoginPag
return Scaffold(
appBar: MyAppBar(
isBack: false,
actionName: OnePoemLocalizations.of(context).verificationCodeLogin,
onPressed: () {
NavigatorUtils.push(context, LoginRouter.smsLoginPage);
},
......
......@@ -73,8 +73,7 @@ class _RegisterPageState extends State<RegisterPage> with ChangeNotifierMixin<Re
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(
title: OnePoemLocalizations.of(context).register,
appBar: const MyAppBar(
),
body: MyScrollView(
keyboardConfig: Utils.getKeyboardActionsConfig(context, <FocusNode>[_nodeText1, _nodeText2, _nodeText3]),
......
......@@ -70,8 +70,7 @@ class _ResetPasswordPageState extends State<ResetPasswordPage> with ChangeNotifi
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(
title: OnePoemLocalizations.of(context).forgotPasswordLink,
appBar: const MyAppBar(
),
body: MyScrollView(
keyboardConfig: Utils.getKeyboardActionsConfig(context, <FocusNode>[_nodeText1, _nodeText2, _nodeText3]),
......
......@@ -65,7 +65,7 @@ class _SMSLoginPageState extends State<SMSLoginPage> with ChangeNotifierMixin<SM
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: const MyAppBar(),
appBar: MyAppBar(),
body: MyScrollView(
keyboardConfig: Utils.getKeyboardActionsConfig(context, <FocusNode>[_nodeText1, _nodeText2]),
padding: const EdgeInsets.only(left: 16.0, right: 16.0, top: 20.0),
......
......@@ -64,7 +64,6 @@ class _UpdatePasswordPageState extends State<UpdatePasswordPage> with ChangeNoti
Widget build(BuildContext context) {
return Scaffold(
appBar: const MyAppBar(
title: '修改密码',
),
body: MyScrollView(
keyboardConfig: Utils.getKeyboardActionsConfig(context, <FocusNode>[_nodeText1, _nodeText2]),
......
......@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
import 'package:one_poem/res/gaps.dart';
import 'package:one_poem/util/theme_utils.dart';
import 'package:one_poem/util/toast_utils.dart';
import 'package:one_poem/widgets/bars/home_action_bar.dart';
import 'package:one_poem/widgets/bars/home_title_bar.dart';
import 'package:one_poem/widgets/load_image.dart';
import 'package:one_poem/widgets/my_app_bar.dart';
......@@ -24,12 +26,17 @@ class _PoemDetailPageState extends State<PoemDetailPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
// extendBodyBehindAppBar: true,// appbar背景透明
appBar: MyAppBar(
isShowButtons: true,
funcLeft: () {
print("xxxxx");
},
homeTitleHeader: HomeTitleHeader(
funcLeft: (){
print("lefltlelfle");
},
),
homeActionWidgets: HomeActionWidgets(
funcStar: (){
print("starrrrrrr");
},
),
),
body: Container(
decoration: const BoxDecoration(
......
......@@ -10,7 +10,6 @@ class NotFoundPage extends StatelessWidget {
Widget build(BuildContext context) {
return const Scaffold(
appBar: MyAppBar(
centerTitle: '页面不存在',
),
body: StateLayout(
type: StateType.account,
......
......@@ -69,7 +69,6 @@ class _AboutPageState extends State<AboutPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: const MyAppBar(
title: '关于我们',
),
body: Column(
children: <Widget>[
......
......@@ -5,10 +5,8 @@ import 'package:one_poem/widgets/click_item.dart';
import 'package:one_poem/widgets/load_image.dart';
import 'package:one_poem/widgets/my_app_bar.dart';
/// design/8设置/index.html#artboard1
class AccountManagerPage extends StatefulWidget {
const AccountManagerPage({Key? key}) : super(key: key);
@override
......@@ -19,16 +17,12 @@ class _AccountManagerPageState extends State<AccountManagerPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: const MyAppBar(
),
appBar: MyAppBar(),
body: Column(
children: <Widget>[
Stack(
children: <Widget>[
ClickItem(
title: '店铺logo',
onTap: () {}
),
ClickItem(title: '店铺logo', onTap: () {}),
const Positioned(
top: 8.0,
bottom: 8.0,
......@@ -38,10 +32,10 @@ class _AccountManagerPageState extends State<AccountManagerPage> {
],
),
ClickItem(
title: '修改密码',
content: '用于密码登录',
onTap: () => NavigatorUtils.push(context, LoginRouter.updatePasswordPage)
),
title: '修改密码',
content: '用于密码登录',
onTap: () =>
NavigatorUtils.push(context, LoginRouter.updatePasswordPage)),
const ClickItem(
title: '绑定账号',
content: '15000000000',
......
......@@ -7,7 +7,6 @@ import 'package:one_poem/widgets/my_app_bar.dart';
import 'package:provider/provider.dart';
class LocalePage extends StatefulWidget {
const LocalePage({Key? key}) : super(key: key);
@override
......@@ -15,14 +14,13 @@ class LocalePage extends StatefulWidget {
}
class _LocalePageState extends State<LocalePage> {
final List<String> _list = <String>['跟随系统', '中文', 'English'];
@override
Widget build(BuildContext context) {
final String? locale = SpUtil.getString(Constant.locale);
String localeMode;
switch(locale) {
switch (locale) {
case 'zh':
localeMode = _list[1];
break;
......@@ -35,7 +33,6 @@ class _LocalePageState extends State<LocalePage> {
}
return Scaffold(
appBar: const MyAppBar(
title: '多语言',
),
body: ListView.separated(
itemCount: _list.length,
......@@ -43,7 +40,8 @@ class _LocalePageState extends State<LocalePage> {
itemBuilder: (_, int index) {
return InkWell(
onTap: () {
final String locale = index == 0 ? '' : (index == 1 ? 'zh' : 'en');
final String locale =
index == 0 ? '' : (index == 1 ? 'zh' : 'en');
context.read<LocaleProvider>().setLocale(locale);
Toast.show('当前功能仅登录模块有效');
setState(() {});
......
......@@ -25,8 +25,7 @@ class _SettingPageState extends State<SettingPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: const MyAppBar(
centerTitle: '设置',
appBar: const MyAppBar(
),
body: Column(
children: <Widget>[
......
......@@ -6,7 +6,6 @@ import 'package:one_poem/widgets/my_app_bar.dart';
import 'package:provider/provider.dart';
class ThemePage extends StatefulWidget {
const ThemePage({Key? key}) : super(key: key);
@override
......@@ -14,14 +13,13 @@ class ThemePage extends StatefulWidget {
}
class _ThemePageState extends State<ThemePage> {
final List<String> _list = <String>['跟随系统', '开启', '关闭'];
@override
Widget build(BuildContext context) {
final String? theme = SpUtil.getString(Constant.theme);
String themeMode;
switch(theme) {
switch (theme) {
case 'Dark':
themeMode = _list[1];
break;
......@@ -33,16 +31,16 @@ class _ThemePageState extends State<ThemePage> {
break;
}
return Scaffold(
appBar: const MyAppBar(
title: '夜间模式',
),
appBar: const MyAppBar(),
body: ListView.separated(
itemCount: _list.length,
separatorBuilder: (_, __) => const Divider(),
itemBuilder: (_, int index) {
return InkWell(
onTap: () {
final ThemeMode themeMode = index == 0 ? ThemeMode.system : (index == 1 ? ThemeMode.dark : ThemeMode.light);
final ThemeMode themeMode = index == 0
? ThemeMode.system
: (index == 1 ? ThemeMode.dark : ThemeMode.light);
// Provider.of<ThemeProvider>(context, listen: false).setTheme(themeMode);
/// 与上方等价,provider 4.1.0添加的拓展方法
context.read<ThemeProvider>().setTheme(themeMode);
......
import 'package:flutter/material.dart';
import 'package:one_poem/res/resources.dart';
class HomeActionWidgets extends StatelessWidget {
const HomeActionWidgets({
Key? key,
this.funcStar,
this.funcShare,
this.funcMore,
}) : super(key: key);
final Function? funcStar;
final Function? funcShare;
final Function? funcMore;
@override
Widget build(BuildContext context) {
const iconHeight = 30.0;
const iconWidth = 30.0;
const iconSize = 20.0;
return Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: iconHeight,
width: iconWidth,
child: IconButton(
padding: const EdgeInsets.all(0.0),
icon: const Icon(
Icons.star_border,
size: iconSize,
),
onPressed: () {
funcStar!();
},
),
),
SizedBox(
height: iconHeight,
width: iconWidth,
child: IconButton(
padding: const EdgeInsets.all(0.0),
icon: const Icon(
Icons.ios_share,
size: iconSize,
),
onPressed: () {},
),
),
SizedBox(
height: iconHeight,
width: iconWidth,
child: IconButton(
padding: const EdgeInsets.all(0.0),
onPressed: () {},
icon: const Icon(
Icons.more_horiz,
size: iconSize,
),
),
),
],
);
}
}
import 'package:flutter/material.dart';
class HomeTitleHeader extends StatelessWidget {
const HomeTitleHeader({
Key? key,
this.funcLeft,
this.funcCenter,
this.funcRight,
}) : super(key: key);
final Function? funcLeft;
final Function? funcCenter;
final Function? funcRight;
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
margin: const EdgeInsets.symmetric(horizontal: 5.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.min,
//交叉轴的布局方式,对于column来说就是水平方向的布局方式
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 60.0,
child: TextButton(
onPressed: () => funcLeft!(),
child: const Text(
"一言",
style: TextStyle(color: Colors.white),
),
),
),
const VerticalDivider(
color: Colors.white,
width: 1.0,
thickness: 1.0,
indent: 15.0,
endIndent: 15.0,
),
TextButton(
onPressed: () => funcCenter!(),
child: const Text(
"译解",
style: TextStyle(color: Colors.white),
),
),
const VerticalDivider(
color: Colors.white,
width: 1.0,
thickness: 1.0,
indent: 15.0,
endIndent: 15.0,
),
TextButton(
onPressed: () => funcRight!(),
child: const Text(
"临境",
style: TextStyle(color: Colors.white),
),
),
],
));
}
}
......@@ -8,38 +8,18 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
const MyAppBar({
Key? key,
this.backgroundColor,
this.title = '',
this.centerTitle = '',
this.actionName = '',
this.backImg = 'assets/images/ic_back_black.png',
this.backImgColor,
this.onPressed,
this.isBack = true,
this.buttonLeft,
this.funcLeft,
this.buttonCenter,
this.funcCenter,
this.buttonRight,
this.funcRight,
this.isShowButtons = false,
this.homeTitleHeader,
this.homeActionWidgets,
}) : super(key: key);
final Color? backgroundColor;
final String title;
final String centerTitle;
final String backImg;
final Color? backImgColor;
final String actionName;
final VoidCallback? onPressed;
final bool isBack;
final bool isShowButtons;
final String? buttonLeft;
final Function? funcLeft;
final String? buttonCenter;
final Function? funcCenter;
final String? buttonRight;
final Function? funcRight;
final Widget? homeTitleHeader;
final Widget? homeActionWidgets;
@override
Widget build(BuildContext context) {
......@@ -51,34 +31,6 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
? SystemUiOverlayStyle.light
: SystemUiOverlayStyle.dark;
final Widget action = actionName.isNotEmpty
? Positioned(
right: 0.0,
child: Theme(
data: Theme.of(context).copyWith(
buttonTheme: const ButtonThemeData(
padding: EdgeInsets.symmetric(horizontal: 16.0),
minWidth: 60.0,
),
),
child: Row(
children: [
Icon(
Icons.star,
color: Colors.white.withOpacity(0.66),
),
Gaps.hGap10,
Icon(
Icons.ios_share,
color: Colors.white.withOpacity(0.66),
),
Gaps.hGap10,
],
),
),
)
: Gaps.empty;
final Widget back = isBack
? IconButton(
onPressed: () async {
......@@ -90,62 +42,32 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
},
tooltip: '返回',
padding: const EdgeInsets.all(12.0),
icon: Image.asset(
backImg,
color: backImgColor ?? ThemeUtils.getIconColor(context),
),
icon: const Icon(Icons.arrow_back_ios_outlined),
)
: Gaps.empty;
// TODO 复用组件
final Widget titleWidget = Semantics(
namesRoute: true,
header: true,
child: Container(
alignment: Alignment.center,
width: double.infinity,
margin: const EdgeInsets.symmetric(horizontal: 48.0),
child: isShowButtons ? Row(
children: [
TextButton(
onPressed: () => funcLeft!(),
child: Text(
buttonLeft ?? "一言",
style: const TextStyle(color: Colors.white),
),
),
const Text("|"),
TextButton(
onPressed: () => funcCenter!(),
child: Text(
buttonCenter ?? "译解",
style: const TextStyle(color: Colors.white),
),
),
const Text("|"),
TextButton(
onPressed: () => funcRight!(),
child: Text(
buttonRight ?? "临境",
style: const TextStyle(color: Colors.white),
),
),
],
) : Gaps.hGap10,
),
);
return AnnotatedRegion<SystemUiOverlayStyle>(
value: _overlayStyle,
child: Material(
color: Colors.transparent,
child: SafeArea(
child: Stack(
alignment: Alignment.centerLeft,
alignment: Alignment.center,
children: <Widget>[
titleWidget,
back,
action,
Positioned(
left: 5,
child: back,
),
SizedBox(
width: MediaQuery.of(context).size.width,
child: homeTitleHeader,
),
SizedBox(
child: Container(
alignment: Alignment.centerRight,
child: homeActionWidgets,
),
),
],
),
),
......