Skip to content

Commit 3ed25b7

Browse files
committed
个人信息编辑页
1 parent a1217ad commit 3ed25b7

File tree

7 files changed

+197
-36
lines changed

7 files changed

+197
-36
lines changed

ios/Runner.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,4 +549,4 @@
549549
/* End XCConfigurationList section */
550550
};
551551
rootObject = 97C146E61CF9000F007C117D /* Project object */;
552-
}
552+
}

lib/app_routes.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:icoffee/pages/beans/new_beans_page.dart';
99
import 'package:icoffee/pages/login_page.dart';
1010
import 'package:icoffee/pages/main_page.dart';
1111
import 'package:icoffee/pages/splash.dart';
12+
import 'package:icoffee/pages/user/user_detail_page.dart';
1213

1314
abstract class AppRoutes {
1415
static const splash = '/splash';
@@ -20,6 +21,8 @@ abstract class AppRoutes {
2021
static const newCoffeeBeans = '/newCoffeeBeans';
2122

2223
static const beansDetail = '/beansDetail';
24+
25+
static const userDetail = '/userDetail';
2326
}
2427

2528
final GoRouter appRouter = GoRouter(
@@ -50,5 +53,10 @@ final GoRouter appRouter = GoRouter(
5053
name: AppRoutes.beansDetail,
5154
builder: (BuildContext context, GoRouterState state) => const BeanDetailPage(),
5255
),
56+
GoRoute(
57+
path: AppRoutes.userDetail,
58+
name: AppRoutes.userDetail,
59+
builder: (BuildContext context, GoRouterState state) => const UserDetailPage(),
60+
),
5361
],
5462
);

lib/main.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ class App extends StatelessWidget {
5656
Locale('en', 'US'),
5757
Locale('zh', 'CN'),
5858
],
59+
builder: (context, child) => Scaffold(
60+
body: GestureDetector(
61+
onTap: () {
62+
FocusScopeNode currentFocus = FocusScope.of(context);
63+
if (!currentFocus.hasPrimaryFocus &&
64+
currentFocus.focusedChild != null) {
65+
FocusManager.instance.primaryFocus?.unfocus();
66+
}
67+
},
68+
child: child,
69+
),
70+
),
5971
),
6072
);
6173
}

lib/pages/statistics/statistics_page.dart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// [Author] lg (https://github.com/lemos1235)
33
// [Date] 8/23/2022
44
//
5+
import 'package:bruno/bruno.dart';
56
import 'package:flutter/material.dart';
67

78
/// 统计页
@@ -15,8 +16,18 @@ class StatisticsPage extends StatefulWidget {
1516
class _StatisticsPageState extends State<StatisticsPage> {
1617
@override
1718
Widget build(BuildContext context) {
18-
return Container(
19-
child: Text("StatisticsPage"),
19+
return Scaffold(
20+
appBar: BrnAppBar(
21+
automaticallyImplyLeading: false,
22+
title: "统计",
23+
actions: Icon(
24+
Icons.sync_rounded,
25+
color: Color(0xFF616161),
26+
),
27+
),
28+
body: Center(
29+
child: Text("暂无数据"),
30+
),
2031
);
2132
}
2233
}

lib/pages/user/user_detail_page.dart

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
//
2+
// [Author] lg (https://github.com/lemos1235)
3+
// [Date] 2022/8/22
4+
//
5+
import 'package:bruno/bruno.dart';
6+
import 'package:flutter/material.dart';
7+
import 'package:flutter_svg/flutter_svg.dart';
8+
import 'package:icoffee/widgets/gf_action_tile.dart';
9+
10+
/// "我-编辑资料"页
11+
class UserDetailPage extends StatefulWidget {
12+
const UserDetailPage({Key? key}) : super(key: key);
13+
14+
@override
15+
State<UserDetailPage> createState() => _UserDetailPageState();
16+
}
17+
18+
class _UserDetailPageState extends State<UserDetailPage> {
19+
bool isLoading = false;
20+
21+
@override
22+
void initState() {
23+
getUserDetail();
24+
super.initState();
25+
}
26+
27+
Future<void> getUserDetail() async {
28+
isLoading = true;
29+
Future.delayed(Duration(seconds: 1)).then((value) => {
30+
setState(() {
31+
isLoading = false;
32+
})
33+
});
34+
}
35+
36+
@override
37+
Widget build(BuildContext context) {
38+
return Scaffold(
39+
appBar: BrnAppBar(
40+
title: "编辑资料",
41+
elevation: 0.1,
42+
),
43+
body: isLoading
44+
? BrnPageLoading()
45+
: Column(
46+
children: [
47+
Expanded(
48+
child: ListView(
49+
children: [
50+
Container(
51+
alignment: Alignment.center,
52+
margin: EdgeInsets.symmetric(vertical: 20),
53+
child: Material(
54+
elevation: 2,
55+
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(70)),
56+
child: AnimatedContainer(
57+
width: 70,
58+
height: 70,
59+
padding: EdgeInsets.symmetric(vertical: 12, horizontal: 12),
60+
duration: kThemeChangeDuration,
61+
child: SvgPicture.asset(
62+
"assets/icons/coffee.svg",
63+
color: Colors.black,
64+
),
65+
),
66+
),
67+
),
68+
GFActionCard(
69+
children: [
70+
BrnTextInputFormItem(
71+
title: "昵称",
72+
hint: "请输入",
73+
),
74+
GFActionTile(
75+
title: "性别",
76+
trailingText: "保密",
77+
onTap: () {
78+
showGenderSheet();
79+
},
80+
)
81+
],
82+
),
83+
],
84+
),
85+
),
86+
Align(
87+
alignment: Alignment.bottomCenter,
88+
child: BrnBottomButtonPanel(
89+
mainButtonName: '保存',
90+
mainButtonOnTap: () {
91+
BrnToast.show("保存成功", context);
92+
},
93+
),
94+
),
95+
],
96+
),
97+
);
98+
}
99+
100+
void showGenderSheet() {
101+
showModalBottomSheet(
102+
context: context,
103+
builder: (BuildContext context) {
104+
return BrnCommonActionSheet(
105+
actions: [
106+
BrnCommonActionSheetItem("男"),
107+
BrnCommonActionSheetItem("女"),
108+
BrnCommonActionSheetItem("保密"),
109+
],
110+
cancelTitle: "取消",
111+
clickCallBack: (int index, BrnCommonActionSheetItem actionEle) {
112+
String title = actionEle.title;
113+
print(title);
114+
},
115+
);
116+
});
117+
}
118+
}

lib/pages/user/user_page.dart

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//
55
import 'package:flutter/material.dart';
66
import 'package:flutter_svg/flutter_svg.dart';
7+
import 'package:go_router/go_router.dart';
8+
import 'package:icoffee/app_routes.dart';
79
import 'package:icoffee/constants/app_colors.dart';
810
import 'package:icoffee/widgets/gf_action_tile.dart';
911

@@ -50,31 +52,37 @@ class _UserPageState extends State<UserPage> {
5052
),
5153
),
5254
),
53-
Column(
54-
crossAxisAlignment: CrossAxisAlignment.start,
55-
children: [
56-
Text(
57-
"匿名用户",
58-
style: TextStyle(fontSize: 26, fontWeight: FontWeight.bold),
59-
),
60-
SizedBox(height: 5),
61-
Row(
62-
children: [
63-
Text(
64-
"编辑个人信息",
65-
style: TextStyle(color: AppColors.deactivatedText),
66-
),
67-
SizedBox(
68-
width: 3,
69-
),
70-
Icon(
71-
Icons.arrow_forward_ios_rounded,
72-
size: 18,
73-
color: Colors.grey,
74-
)
75-
],
76-
)
77-
],
55+
GestureDetector(
56+
behavior: HitTestBehavior.translucent,
57+
onTap: () {
58+
GoRouter.of(context).pushNamed(AppRoutes.userDetail);
59+
},
60+
child: Column(
61+
crossAxisAlignment: CrossAxisAlignment.start,
62+
children: [
63+
Text(
64+
"匿名用户",
65+
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
66+
),
67+
SizedBox(height: 5),
68+
Row(
69+
children: [
70+
Text(
71+
"编辑个人信息",
72+
style: TextStyle(color: AppColors.deactivatedText),
73+
),
74+
SizedBox(
75+
width: 3,
76+
),
77+
Icon(
78+
Icons.arrow_forward_ios_rounded,
79+
size: 18,
80+
color: Colors.grey,
81+
)
82+
],
83+
)
84+
],
85+
),
7886
)
7987
],
8088
),
@@ -85,7 +93,7 @@ class _UserPageState extends State<UserPage> {
8593
return Column(
8694
children: [
8795
GFActionCard(
88-
tiles: [
96+
children: [
8997
GFActionTile(
9098
title: "我的会员",
9199
trailingText: "未开通",
@@ -105,7 +113,7 @@ class _UserPageState extends State<UserPage> {
105113
return Column(
106114
children: [
107115
GFActionCard(
108-
tiles: [
116+
children: [
109117
GFActionTile(
110118
title: "智能电子秤",
111119
onTap: () {},

lib/widgets/gf_action_tile.dart

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import 'package:collection/collection.dart';
66
import 'package:flutter/material.dart';
77

88
class GFActionCard extends StatelessWidget {
9-
const GFActionCard({super.key, required this.tiles});
9+
const GFActionCard({super.key, required this.children});
1010

11-
final List<GFActionTile> tiles;
11+
final List<Widget> children;
1212

1313
@override
1414
Widget build(BuildContext context) {
1515
List<Widget> widgets = [];
16-
tiles.forEachIndexed((index, element) {
17-
if (index != 0 && index != tiles.length) {
16+
children.forEachIndexed((index, element) {
17+
if (index != 0 && index != children.length) {
1818
widgets.add(
1919
Divider(indent: 12, endIndent: 12, height: 1, color: Color(0xFFECECEC)),
2020
);
@@ -84,7 +84,7 @@ class GFActionTile extends StatelessWidget {
8484
maxLines: 1,
8585
overflow: TextOverflow.ellipsis,
8686
style: TextStyle(
87-
fontSize: 17,
87+
fontSize: 16,
8888
),
8989
),
9090
);
@@ -104,7 +104,11 @@ class GFActionTile extends StatelessWidget {
104104
trailingText ?? "",
105105
overflow: TextOverflow.ellipsis,
106106
style: TextStyle(
107-
fontSize: 17,
107+
fontSize: 16,
108+
),
109+
strutStyle: StrutStyle(
110+
height: 1,
111+
leading: 0.5,
108112
),
109113
),
110114
),

0 commit comments

Comments
 (0)