feat:重构模块
This commit is contained in:
@@ -5,6 +5,8 @@ import 'package:flutter_common/widget/dialog_widget.dart';
|
||||
import 'package:food_hub_app/provider/app_provider.dart';
|
||||
import 'package:food_hub_app/provider/user_provider.dart';
|
||||
import 'package:food_hub_app/widgets/profile/basic_info.dart';
|
||||
import 'package:liquid_glass_widgets/liquid_glass_widgets.dart';
|
||||
import 'package:liquid_glass_widgets/widgets/containers/glass_card.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class ProfilePage extends StatefulWidget {
|
||||
@@ -44,8 +46,13 @@ class ProfilePageState extends State<ProfilePage> {
|
||||
Navigator.pushNamed(context, '/momentUser');
|
||||
}
|
||||
|
||||
Widget _buildFunctionButtons() {
|
||||
return CommonCard(
|
||||
Widget _buildFunctionButtons(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return GlassCard(
|
||||
padding: EdgeInsetsGeometry.symmetric(vertical: 0, horizontal: 10),
|
||||
useOwnLayer: true,
|
||||
settings: LiquidGlassSettings(glassColor: colors.surface),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildFunctionButton(
|
||||
@@ -56,13 +63,13 @@ class ProfilePageState extends State<ProfilePage> {
|
||||
// LogUtils.i('点击编辑资料');
|
||||
},
|
||||
),
|
||||
const Divider(height: 1),
|
||||
const Divider(height: 1, thickness: 0.2),
|
||||
_buildFunctionButton(
|
||||
icon: Icons.group_outlined,
|
||||
text: '朋友圈',
|
||||
onTap: _onTapMoment,
|
||||
),
|
||||
const Divider(height: 1),
|
||||
const Divider(height: 1, thickness: 0.2),
|
||||
_buildFunctionButton(
|
||||
icon: Icons.favorite,
|
||||
text: '我的收藏',
|
||||
@@ -71,7 +78,7 @@ class ProfilePageState extends State<ProfilePage> {
|
||||
// LogUtils.i('点击浏览历史');
|
||||
},
|
||||
),
|
||||
const Divider(height: 1),
|
||||
const Divider(height: 1, thickness: 0.2),
|
||||
_buildFunctionButton(
|
||||
icon: Icons.lock,
|
||||
text: '更改密码',
|
||||
@@ -80,11 +87,11 @@ class ProfilePageState extends State<ProfilePage> {
|
||||
// LogUtils.i('点击帮助与反馈');
|
||||
},
|
||||
),
|
||||
const Divider(height: 1),
|
||||
const Divider(height: 1, thickness: 0.2),
|
||||
_buildFunctionButton(icon: Icons.message, text: '反馈意见', onTap: () {}),
|
||||
const Divider(height: 1),
|
||||
const Divider(height: 1, thickness: 0.2),
|
||||
_buildFunctionButton(icon: Icons.refresh, text: '检查更新', onTap: () {}),
|
||||
const Divider(height: 1),
|
||||
const Divider(height: 1, thickness: 0.2),
|
||||
_buildFunctionButton(
|
||||
icon: Icons.exit_to_app,
|
||||
text: '退出登录',
|
||||
@@ -117,13 +124,13 @@ class ProfilePageState extends State<ProfilePage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContent(UserProvider provider) {
|
||||
Widget _buildContent(UserProvider provider, BuildContext context) {
|
||||
final user = provider.currentUser;
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(width: double.infinity, child: ProfileInfo(user: user)),
|
||||
const SizedBox(height: 16),
|
||||
_buildFunctionButtons(),
|
||||
_buildFunctionButtons(context),
|
||||
const SizedBox(height: 8),
|
||||
_buildVersionInfo(),
|
||||
],
|
||||
@@ -134,15 +141,27 @@ class ProfilePageState extends State<ProfilePage> {
|
||||
Widget build(BuildContext context) {
|
||||
final provider = context.watch<UserProvider>();
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
if (provider.isLoading)
|
||||
buildLoadingIndicator()
|
||||
else if (provider.error.isNotEmpty)
|
||||
Text(provider.error)
|
||||
else
|
||||
_buildContent(provider),
|
||||
],
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: AppBar(
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
title: Text('我的', style: Theme.of(context).textTheme.titleLarge),
|
||||
centerTitle: true,
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
body: Padding(
|
||||
padding: EdgeInsetsGeometry.all(10),
|
||||
child: Stack(
|
||||
children: [
|
||||
if (provider.isLoading)
|
||||
buildLoadingIndicator()
|
||||
else if (provider.error.isNotEmpty)
|
||||
Text(provider.error)
|
||||
else
|
||||
SingleChildScrollView(child: _buildContent(provider, context)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user