优化
This commit is contained in:
@@ -1,9 +1,14 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
import 'package:remixicon/remixicon.dart';
|
import 'package:remixicon/remixicon.dart';
|
||||||
|
|
||||||
import '../page/home/home_page.dart';
|
import '../page/home/home_page.dart';
|
||||||
import '../page/profile/my/my_page.dart';
|
import '../page/profile/my/my_page.dart';
|
||||||
import '../page/record/list/record_list_page.dart';
|
import '../page/record/list/record_list_page.dart';
|
||||||
|
import '../providers/user_store.dart';
|
||||||
|
import '../router/config/route_paths.dart';
|
||||||
import 'tabbar.dart';
|
import 'tabbar.dart';
|
||||||
|
|
||||||
class LayoutPage extends StatefulWidget {
|
class LayoutPage extends StatefulWidget {
|
||||||
@@ -41,6 +46,44 @@ class _LayoutPageState extends State<LayoutPage> {
|
|||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _init() async {
|
||||||
|
UserStore userStore = context.read<UserStore>();
|
||||||
|
await userStore.init();
|
||||||
|
print(userStore.profile.toString());
|
||||||
|
if (userStore.profile.qStatus != 1) {
|
||||||
|
showCupertinoDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => CupertinoAlertDialog(
|
||||||
|
title: Text("Complete Your Profile"),
|
||||||
|
content: Text("Let’s get to know you better! Please take a quick survey to personalize your experience."),
|
||||||
|
actions: [
|
||||||
|
CupertinoDialogAction(
|
||||||
|
child: Text("Take Survey"),
|
||||||
|
onPressed: () {
|
||||||
|
context.pop();
|
||||||
|
_goEditProfile();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _goEditProfile() async {
|
||||||
|
var isUpload = await context.push(RoutePaths.myEdit);
|
||||||
|
if (isUpload == true) {
|
||||||
|
UserStore userStore = context.read<UserStore>();
|
||||||
|
userStore.init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:food_health/providers/user_store.dart';
|
||||||
import 'package:food_health/router/routes.dart';
|
import 'package:food_health/router/routes.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
@@ -12,6 +13,7 @@ void main() {
|
|||||||
MultiProvider(
|
MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
ChangeNotifierProvider(create: (context) => AppStore()),
|
ChangeNotifierProvider(create: (context) => AppStore()),
|
||||||
|
ChangeNotifierProvider(create: (context) => UserStore()),
|
||||||
],
|
],
|
||||||
child: MyApp(),
|
child: MyApp(),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:food_health/api/dto/profile_options_dto.dart';
|
import 'package:food_health/api/dto/profile_options_dto.dart';
|
||||||
import 'package:food_health/api/dto/user_profile_dto.dart';
|
|
||||||
import 'package:food_health/api/endpoints/profile_api.dart';
|
import 'package:food_health/api/endpoints/profile_api.dart';
|
||||||
import 'package:food_health/config/theme/custom_colors.dart';
|
import 'package:food_health/config/theme/custom_colors.dart';
|
||||||
import 'package:food_health/page/profile/edit/widget/food_allergies.dart';
|
import 'package:food_health/page/profile/edit/widget/food_allergies.dart';
|
||||||
|
import 'package:food_health/providers/user_store.dart';
|
||||||
import 'package:food_health/widgets/common/app_backend.dart';
|
import 'package:food_health/widgets/common/app_backend.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
import 'package:remixicon/remixicon.dart';
|
import 'package:remixicon/remixicon.dart';
|
||||||
|
|
||||||
import 'data/state.dart';
|
import 'data/state.dart';
|
||||||
@@ -14,9 +15,7 @@ import 'widget/dietary_preferences.dart';
|
|||||||
import 'widget/health_profile.dart';
|
import 'widget/health_profile.dart';
|
||||||
|
|
||||||
class MyEditPage extends StatefulWidget {
|
class MyEditPage extends StatefulWidget {
|
||||||
final UserProfileDto userProfile;
|
const MyEditPage({super.key});
|
||||||
|
|
||||||
const MyEditPage({super.key, required this.userProfile});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<MyEditPage> createState() => _MyEditPageState();
|
State<MyEditPage> createState() => _MyEditPageState();
|
||||||
@@ -57,7 +56,8 @@ class _MyEditPageState extends State<MyEditPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _init() async {
|
void _init() async {
|
||||||
selectionState = SelectionState(widget.userProfile);
|
UserStore userStore = context.read<UserStore>();
|
||||||
|
selectionState = SelectionState(userStore.profile);
|
||||||
var res = await getProfileOptionsApi();
|
var res = await getProfileOptionsApi();
|
||||||
setState(() {
|
setState(() {
|
||||||
_options = res;
|
_options = res;
|
||||||
@@ -91,74 +91,89 @@ class _MyEditPageState extends State<MyEditPage> {
|
|||||||
if (_loading) {
|
if (_loading) {
|
||||||
return Center(child: CircularProgressIndicator());
|
return Center(child: CircularProgressIndicator());
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return PopScope(
|
||||||
body: AppBackend(
|
canPop: false,
|
||||||
child: ListView(
|
onPopInvokedWithResult: (didPop, __) async {
|
||||||
padding: EdgeInsets.only(top: 30),
|
if (didPop) return;
|
||||||
children: [
|
if (selectionState.userProfile.qStatus == 1) {
|
||||||
buildHeader(),
|
context.pop();
|
||||||
buildStep(),
|
}
|
||||||
buildStepInfo(),
|
},
|
||||||
SelectionProvider(
|
child: Scaffold(
|
||||||
notifier: selectionState,
|
body: AppBackend(
|
||||||
child: Builder(
|
child: Column(
|
||||||
builder: (context) {
|
children: [
|
||||||
if (_step == 0) {
|
Expanded(
|
||||||
return FoodAllergies(
|
child: ListView(
|
||||||
options: _options,
|
padding: EdgeInsets.only(top: 20),
|
||||||
);
|
children: [
|
||||||
} else if (_step == 1) {
|
buildHeader(),
|
||||||
return DietaryPreferences(
|
buildStep(),
|
||||||
options: _options,
|
buildStepInfo(),
|
||||||
);
|
SelectionProvider(
|
||||||
} else if (_step == 2) {
|
notifier: selectionState,
|
||||||
return HealthProfile(
|
child: Builder(
|
||||||
options: _options,
|
builder: (context) {
|
||||||
);
|
if (_step == 0) {
|
||||||
}
|
return FoodAllergies(
|
||||||
return SizedBox();
|
options: _options,
|
||||||
},
|
);
|
||||||
|
} else if (_step == 1) {
|
||||||
|
return DietaryPreferences(
|
||||||
|
options: _options,
|
||||||
|
);
|
||||||
|
} else if (_step == 2) {
|
||||||
|
return HealthProfile(
|
||||||
|
options: _options,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return SizedBox();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Container(
|
||||||
Container(
|
margin: EdgeInsets.only(top: 20),
|
||||||
margin: EdgeInsets.only(top: 30),
|
child: Row(
|
||||||
child: Row(
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
children: [
|
||||||
children: [
|
Opacity(
|
||||||
Opacity(
|
opacity: _step == 0 ? 0.4 : 1,
|
||||||
opacity: _step == 0 ? 0.4 : 1,
|
child: buildItemButton(
|
||||||
child: buildItemButton(
|
title: "Previous",
|
||||||
title: "Previous",
|
color: Colors.black,
|
||||||
color: Colors.black,
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
_handStep(false);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
buildItemButton(
|
||||||
|
title: _step == 2 ? "Complete Setup" : "Continue",
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
color: _step == 2 ? Theme.of(context).colorScheme.success : null,
|
||||||
|
gradient: _step == 2
|
||||||
|
? null
|
||||||
|
: LinearGradient(
|
||||||
|
colors: [
|
||||||
|
Theme.of(context).colorScheme.primary,
|
||||||
|
Theme.of(context).colorScheme.primaryEnd,
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_handStep(false);
|
_handStep(true);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
buildItemButton(
|
),
|
||||||
title: _step == 2 ? "Complete Setup" : "Continue",
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: _step == 2 ? Theme.of(context).colorScheme.success : null,
|
|
||||||
gradient: _step == 2
|
|
||||||
? null
|
|
||||||
: LinearGradient(
|
|
||||||
colors: [
|
|
||||||
Theme.of(context).colorScheme.primary,
|
|
||||||
Theme.of(context).colorScheme.primaryEnd,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
_handStep(true);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:food_health/api/dto/user_profile_dto.dart';
|
|
||||||
import 'package:food_health/api/endpoints/profile_api.dart';
|
|
||||||
import 'package:food_health/config/theme/custom_colors.dart';
|
import 'package:food_health/config/theme/custom_colors.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:food_health/providers/user_store.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
import 'package:remixicon/remixicon.dart';
|
import 'package:remixicon/remixicon.dart';
|
||||||
|
|
||||||
import '../../../router/config/route_paths.dart';
|
|
||||||
import 'widget/title_card.dart';
|
import 'widget/title_card.dart';
|
||||||
import 'widget/user_card.dart';
|
import 'widget/user_card.dart';
|
||||||
|
|
||||||
@@ -18,56 +15,6 @@ class MyPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MyPageState extends State<MyPage> with AutomaticKeepAliveClientMixin {
|
class _MyPageState extends State<MyPage> with AutomaticKeepAliveClientMixin {
|
||||||
UserProfileDto _userProfile = UserProfileDto();
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _init() async {
|
|
||||||
var res = await getUserProfileApi();
|
|
||||||
setState(() {
|
|
||||||
_userProfile = res;
|
|
||||||
});
|
|
||||||
_showEditProfile();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _goEdit() async {
|
|
||||||
var isUpload = await context.push(RoutePaths.myEdit, extra: _userProfile);
|
|
||||||
if (isUpload == true) {
|
|
||||||
_init();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _showEditProfile() {
|
|
||||||
if (_userProfile.qStatus != 1) {
|
|
||||||
showCupertinoDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (_) => CupertinoAlertDialog(
|
|
||||||
title: Text("Complete Your Profile"),
|
|
||||||
content: Text("Let’s get to know you better! Please take a quick survey to personalize your experience."),
|
|
||||||
actions: [
|
|
||||||
CupertinoDialogAction(
|
|
||||||
child: Text("Not Now"),
|
|
||||||
onPressed: () {
|
|
||||||
context.pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
CupertinoDialogAction(
|
|
||||||
child: Text("Take Survey"),
|
|
||||||
onPressed: () {
|
|
||||||
context.pop();
|
|
||||||
_goEdit();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
@@ -75,70 +22,92 @@ class _MyPageState extends State<MyPage> with AutomaticKeepAliveClientMixin {
|
|||||||
child: ListView(
|
child: ListView(
|
||||||
padding: EdgeInsets.all(15),
|
padding: EdgeInsets.all(15),
|
||||||
children: [
|
children: [
|
||||||
UserCard(
|
UserCard(),
|
||||||
detail: _userProfile,
|
Consumer<UserStore>(
|
||||||
onEdit: _goEdit,
|
builder: (context, store, _) {
|
||||||
),
|
return Column(
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
TitleCard(
|
|
||||||
title: "Food Allergies",
|
|
||||||
icon: Icon(
|
|
||||||
RemixIcons.shield_line,
|
|
||||||
color: Theme.of(context).colorScheme.danger,
|
|
||||||
),
|
|
||||||
child: buildTagList(
|
|
||||||
emptyText: "No allergies reported",
|
|
||||||
tags: _userProfile.foodAllergiesList,
|
|
||||||
color: Theme.of(context).colorScheme.danger,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TitleCard(
|
|
||||||
title: "No preferences",
|
|
||||||
icon: Icon(
|
|
||||||
RemixIcons.heart_line,
|
|
||||||
color: Theme.of(context).colorScheme.success,
|
|
||||||
),
|
|
||||||
child: buildTagList(
|
|
||||||
emptyText: "No dietary preferences reported",
|
|
||||||
tags: _userProfile.dietaryPreferencesList,
|
|
||||||
color: Theme.of(context).colorScheme.success,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TitleCard(
|
|
||||||
title: "Medical Information",
|
|
||||||
icon: Icon(
|
|
||||||
RemixIcons.user_line,
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
Container(
|
TitleCard(
|
||||||
margin: EdgeInsets.only(bottom: 10),
|
title: "Food Allergies",
|
||||||
child: Text("Medical Conditions"),
|
icon: Icon(
|
||||||
),
|
RemixIcons.shield_line,
|
||||||
Container(
|
color: Theme
|
||||||
margin: EdgeInsets.only(bottom: 10),
|
.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.danger,
|
||||||
|
),
|
||||||
child: buildTagList(
|
child: buildTagList(
|
||||||
emptyText: "No medical conditions reported",
|
emptyText: "No allergies reported",
|
||||||
tags: _userProfile.medicalInformationList,
|
tags: store.profile.foodAllergiesList,
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme
|
||||||
|
.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.danger,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
TitleCard(
|
||||||
margin: EdgeInsets.only(bottom: 10),
|
title: "No preferences",
|
||||||
child: Text("Current Medications"),
|
icon: Icon(
|
||||||
|
RemixIcons.heart_line,
|
||||||
|
color: Theme
|
||||||
|
.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.success,
|
||||||
|
),
|
||||||
|
child: buildTagList(
|
||||||
|
emptyText: "No dietary preferences reported",
|
||||||
|
tags: store.profile.dietaryPreferencesList,
|
||||||
|
color: Theme
|
||||||
|
.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.success,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
buildTagList(
|
TitleCard(
|
||||||
emptyText: "No medications reported",
|
title: "Medical Information",
|
||||||
tags: _userProfile.currentMedicationsList,
|
icon: Icon(
|
||||||
color: Theme.of(context).colorScheme.primary,
|
RemixIcons.user_line,
|
||||||
|
color: Theme
|
||||||
|
.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.primary,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
margin: EdgeInsets.only(bottom: 10),
|
||||||
|
child: Text("Medical Conditions"),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
margin: EdgeInsets.only(bottom: 10),
|
||||||
|
child: buildTagList(
|
||||||
|
emptyText: "No medical conditions reported",
|
||||||
|
tags: store.profile.medicalInformationList,
|
||||||
|
color: Theme
|
||||||
|
.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
margin: EdgeInsets.only(bottom: 10),
|
||||||
|
child: Text("Current Medications"),
|
||||||
|
),
|
||||||
|
buildTagList(
|
||||||
|
emptyText: "No medications reported",
|
||||||
|
tags: store.profile.currentMedicationsList,
|
||||||
|
color: Theme
|
||||||
|
.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.primary,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
);
|
||||||
),
|
}
|
||||||
],
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:food_health/api/dto/user_profile_dto.dart';
|
|||||||
import 'package:food_health/api/endpoints/user_api.dart';
|
import 'package:food_health/api/endpoints/user_api.dart';
|
||||||
import 'package:food_health/config/theme/custom_colors.dart';
|
import 'package:food_health/config/theme/custom_colors.dart';
|
||||||
import 'package:food_health/providers/app_store.dart';
|
import 'package:food_health/providers/app_store.dart';
|
||||||
|
import 'package:food_health/providers/user_store.dart';
|
||||||
import 'package:food_health/router/config/route_paths.dart';
|
import 'package:food_health/router/config/route_paths.dart';
|
||||||
import 'package:food_health/utils/common.dart';
|
import 'package:food_health/utils/common.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
@@ -12,22 +13,19 @@ import 'package:provider/provider.dart';
|
|||||||
import 'package:remixicon/remixicon.dart';
|
import 'package:remixicon/remixicon.dart';
|
||||||
|
|
||||||
class UserCard extends StatefulWidget {
|
class UserCard extends StatefulWidget {
|
||||||
final UserProfileDto detail;
|
const UserCard({super.key});
|
||||||
final Function() onEdit;
|
|
||||||
|
|
||||||
const UserCard({
|
|
||||||
super.key,
|
|
||||||
required this.detail,
|
|
||||||
required this.onEdit,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<UserCard> createState() => _UserCardState();
|
State<UserCard> createState() => _UserCardState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _UserCardState extends State<UserCard> {
|
class _UserCardState extends State<UserCard> {
|
||||||
void _goEdit() {
|
void _goEditProfile() async {
|
||||||
widget.onEdit();
|
var isUpload = await context.push(RoutePaths.myEdit);
|
||||||
|
if (isUpload == true && mounted) {
|
||||||
|
UserStore userStore = context.read<UserStore>();
|
||||||
|
userStore.init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///退出登陆
|
///退出登陆
|
||||||
@@ -105,57 +103,61 @@ class _UserCardState extends State<UserCard> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Consumer<UserStore>(
|
||||||
children: [
|
builder: (context, store, _) {
|
||||||
avatarWidget(),
|
return Column(
|
||||||
Container(
|
children: [
|
||||||
margin: const EdgeInsets.only(top: 12),
|
avatarWidget(),
|
||||||
child: Text(getNotEmpty(widget.detail.name) ?? "user", style: Theme.of(context).textTheme.titleMedium),
|
Container(
|
||||||
),
|
margin: const EdgeInsets.only(top: 12),
|
||||||
Container(
|
child: Text(getNotEmpty(store.profile.name) ?? "user", style: Theme.of(context).textTheme.titleMedium),
|
||||||
margin: const EdgeInsets.only(top: 5),
|
|
||||||
child: Text(widget.detail.email ?? "", style: Theme.of(context).textTheme.labelMedium),
|
|
||||||
),
|
|
||||||
buildTitledTags(
|
|
||||||
title: "Age Range",
|
|
||||||
tag: getNotEmpty(widget.detail.ageRange),
|
|
||||||
),
|
|
||||||
buildTitledTags(
|
|
||||||
title: "Activity Level",
|
|
||||||
tag: getNotEmpty(widget.detail.activityLevel),
|
|
||||||
),
|
|
||||||
SizedBox(height: 20),
|
|
||||||
btnItem(
|
|
||||||
title: "Edit Profile",
|
|
||||||
icon: RemixIcons.edit_box_line,
|
|
||||||
color: Colors.white,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
gradient: LinearGradient(
|
|
||||||
colors: [
|
|
||||||
Theme.of(context).colorScheme.primary,
|
|
||||||
Theme.of(context).colorScheme.primaryEnd,
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
Container(
|
||||||
onTap: _goEdit,
|
margin: const EdgeInsets.only(top: 5),
|
||||||
),
|
child: Text(store.profile.email ?? "", style: Theme.of(context).textTheme.labelMedium),
|
||||||
btnItem(
|
|
||||||
title: "Logout",
|
|
||||||
icon: RemixIcons.logout_circle_line,
|
|
||||||
decoration: BoxDecoration(color: Theme.of(context).colorScheme.surfaceContainer),
|
|
||||||
onTap: _handLogout,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
margin: const EdgeInsets.only(top: 10),
|
|
||||||
child: InkWell(
|
|
||||||
onTap: _handDelete,
|
|
||||||
child: Text(
|
|
||||||
"Delete Account ",
|
|
||||||
style: TextStyle(color: Colors.red, fontSize: 14),
|
|
||||||
),
|
),
|
||||||
),
|
buildTitledTags(
|
||||||
),
|
title: "Age Range",
|
||||||
],
|
tag: getNotEmpty(store.profile.ageRange),
|
||||||
|
),
|
||||||
|
buildTitledTags(
|
||||||
|
title: "Activity Level",
|
||||||
|
tag: getNotEmpty(store.profile.activityLevel),
|
||||||
|
),
|
||||||
|
SizedBox(height: 20),
|
||||||
|
btnItem(
|
||||||
|
title: "Edit Profile",
|
||||||
|
icon: RemixIcons.edit_box_line,
|
||||||
|
color: Colors.white,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: [
|
||||||
|
Theme.of(context).colorScheme.primary,
|
||||||
|
Theme.of(context).colorScheme.primaryEnd,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: _goEditProfile,
|
||||||
|
),
|
||||||
|
btnItem(
|
||||||
|
title: "Logout",
|
||||||
|
icon: RemixIcons.logout_circle_line,
|
||||||
|
decoration: BoxDecoration(color: Theme.of(context).colorScheme.surfaceContainer),
|
||||||
|
onTap: _handLogout,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
margin: const EdgeInsets.only(top: 10),
|
||||||
|
child: InkWell(
|
||||||
|
onTap: _handDelete,
|
||||||
|
child: Text(
|
||||||
|
"Delete Account ",
|
||||||
|
style: TextStyle(color: Colors.red, fontSize: 14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:food_health/providers/app_store.dart';
|
import 'package:food_health/providers/app_store.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:food_health/providers/user_store.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
|||||||
14
lib/providers/user_store.dart
Normal file
14
lib/providers/user_store.dart
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:food_health/api/dto/user_profile_dto.dart';
|
||||||
|
import 'package:food_health/api/endpoints/profile_api.dart';
|
||||||
|
|
||||||
|
class UserStore with ChangeNotifier {
|
||||||
|
UserProfileDto profile = UserProfileDto();
|
||||||
|
|
||||||
|
//初始化数据
|
||||||
|
Future<void> init() async {
|
||||||
|
var res = await getUserProfileApi();
|
||||||
|
profile = res;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,10 +8,7 @@ List<RouteType> serverRoutes = [
|
|||||||
RouteType(
|
RouteType(
|
||||||
path: RoutePaths.myEdit,
|
path: RoutePaths.myEdit,
|
||||||
child: (state) {
|
child: (state) {
|
||||||
var extra = state.extra as dynamic;
|
return MyEditPage();
|
||||||
return MyEditPage(
|
|
||||||
userProfile: extra,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user