feat:增加查询朋友朋友圈功能
This commit is contained in:
117
lib/views/profile_user.dart
Normal file
117
lib/views/profile_user.dart
Normal file
@@ -0,0 +1,117 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_common/utils/sp_utils.dart';
|
||||
import 'package:flutter_common/widget/common_widget.dart';
|
||||
import 'package:flutter_common/widget/dialog_widget.dart';
|
||||
import 'package:food_hub_app/models/session.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/common/index.dart';
|
||||
import 'package:food_hub_app/widgets/moment/list.dart';
|
||||
import 'package:food_hub_app/widgets/profile/basic_info.dart';
|
||||
import 'package:food_hub_app/widgets/recipe/calendar.dart';
|
||||
import 'package:food_hub_app/widgets/recipe/list.dart';
|
||||
import 'package:food_hub_app/widgets/recipe/timeline.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
enum ProfileTab {
|
||||
moment('朋友圈'),
|
||||
recipe('菜谱');
|
||||
|
||||
final String label;
|
||||
|
||||
const ProfileTab(this.label);
|
||||
}
|
||||
|
||||
class ProfileUserPage extends StatefulWidget {
|
||||
const ProfileUserPage({super.key});
|
||||
|
||||
@override
|
||||
State<ProfileUserPage> createState() => ProfileUserPageState();
|
||||
}
|
||||
|
||||
class ProfileUserPageState extends State<ProfileUserPage> {
|
||||
late ProfileTab currentTab = ProfileTab.moment;
|
||||
|
||||
void _onTabChange(ProfileTab tab) {
|
||||
setState(() {
|
||||
currentTab = tab;
|
||||
});
|
||||
|
||||
// provider.onRecordTabChange();
|
||||
}
|
||||
|
||||
Widget _buildTabs({
|
||||
required BuildContext context,
|
||||
required ProfileTab currentTab,
|
||||
required ValueChanged<ProfileTab> onTabChanged,
|
||||
}) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: buildToggleSwitch(
|
||||
context: context,
|
||||
currentTab: currentTab,
|
||||
tabValues: ProfileTab.values,
|
||||
labels: ProfileTab.values.map((e) => e.label).toList(),
|
||||
onTabChanged: onTabChanged,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContent(UserProvider provider) {
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ProfileInfo(user: provider.currentUser),
|
||||
),
|
||||
_buildTabs(
|
||||
context: context,
|
||||
currentTab: currentTab,
|
||||
onTabChanged: (tab) => _onTabChange(tab),
|
||||
),
|
||||
Expanded(
|
||||
child: IndexedStack(
|
||||
index: currentTab.index,
|
||||
children: [
|
||||
MomentList(momentList: provider.momentList, isUser: false),
|
||||
Text('个人菜谱'),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = context.watch<UserProvider>();
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'${provider.currentUser.username}的个人信息',
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
backgroundColor: colors.primary,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Stack(
|
||||
children: [
|
||||
if (provider.isLoading)
|
||||
buildLoadingIndicator()
|
||||
else if (provider.error.isNotEmpty)
|
||||
Text(provider.error)
|
||||
else
|
||||
_buildContent(provider),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user