Advertisement
harmonyV

ProfilePage

Apr 6th, 2025
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 2.26 KB | None | 0 0
  1. class ProfilePage extends ConsumerStatefulWidget {
  2.   final String? userId;
  3.  
  4.   const ProfilePage({super.key, this.userId});
  5.  
  6.   @override
  7.   ConsumerState<ProfilePage> createState() => _ProfilePageState();
  8. }
  9.  
  10. class _ProfilePageState extends ConsumerState<ProfilePage>
  11.     with SingleTickerProviderStateMixin {
  12.   late final TabController _tabController;
  13.  
  14.   @override
  15.   void initState() {
  16.     super.initState();
  17.     _tabController = TabController(length: 3, vsync: this);
  18.   }
  19.  
  20.   @override
  21.   void dispose() {
  22.     _tabController.dispose();
  23.     super.dispose();
  24.   }
  25.  
  26.   @override
  27.   Widget build(BuildContext context) {
  28.     final colorScheme = Theme.of(context).colorScheme;
  29.  
  30.     final currentUserId = AuthRepository().currentUser?.id;
  31.     final targetUserId = widget.userId ?? currentUserId;
  32.     final isCurrentUser = targetUserId == currentUserId;
  33.  
  34.     final profile = ref.watch(cachedProfileProvider);
  35.  
  36.     return Scaffold(
  37.       backgroundColor: colorScheme.surface,
  38.       body: NestedScrollView(
  39.         headerSliverBuilder: (context, innerBoxScrolled) {
  40.           return [
  41.             _ProfileAppBar(),
  42.             SliverPadding(
  43.               padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
  44.               sliver: SliverToBoxAdapter(
  45.                 child: _ProfileHeader(),
  46.               ),
  47.             ),
  48.             SliverPersistentHeader(
  49.               pinned: true,
  50.               delegate: _SliverAppBarDelegate(
  51.                 TabBar(
  52.                   controller: _tabController,
  53.                   tabs: const [
  54.                     Tab(text: 'Profile'),
  55.                     Tab(text: 'Private'),
  56.                     Tab(text: 'Settings'),
  57.                   ],
  58.                 ),
  59.               ),
  60.             ),
  61.           ];
  62.         },
  63.         body: TabBarView(
  64.           controller: _tabController,
  65.           children: [
  66.             TabViewTab(
  67.               children: [
  68.                 _ProfileBio(),
  69.                 ActivityCard(),
  70.                 DietaryInfoCard(),
  71.               ],
  72.             ),
  73.             TabViewTab(
  74.               children: [PrivateInfoCard()],
  75.             ),
  76.             TabViewTab(
  77.               children: [Text('Settings')],
  78.             ),
  79.           ],
  80.         ),
  81.       ),
  82.     );
  83.   }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement