| 1 | import 'package:cached_network_image/cached_network_image.dart'; |
| 2 | import 'package:flutter/material.dart'; |
| 3 | import 'package:go_router/go_router.dart'; |
| 4 | import 'package:aero/notifiers/user.dart'; |
| 5 | import 'package:provider/provider.dart'; |
| 6 | |
| 7 | class ProfileScreen extends StatefulWidget |
| 8 | const ProfileScreen({super |
| 9 | |
| 10 | @override |
| 11 | State<ProfileScreen> createState |
| 12 | } |
| 13 | |
| 14 | class _ProfileScreenState extends State |
| 15 | @override |
| 16 | Widget build(BuildContext |
| 17 | return Scaffold( |
| 18 | backgroundColor: Colors.white, |
| 19 | appBar: AppBar( |
| 20 | title: const Text( |
| 21 | 'Profile', |
| 22 | style: TextStyle( |
| 23 | fontFamily: "CalSans", |
| 24 | fontSize: 20, |
| 25 | fontWeight: FontWeight.bold, |
| 26 | color: Colors.black, |
| 27 | ), |
| 28 | ), |
| 29 | centerTitle: false, |
| 30 | backgroundColor: Colors.white, |
| 31 | elevation: 0, |
| 32 | scrolledUnderElevation: 0, |
| 33 | ), |
| 34 | body: SafeArea( |
| 35 | child: SingleChildScrollView( |
| 36 | padding: const EdgeInsets. |
| 37 | child: Column( |
| 38 | crossAxisAlignment: CrossAxisAlignment.stretch, |
| 39 | children: [ |
| 40 | // User Avatar Section |
| 41 | Builder( |
| 42 | builder: (context) { |
| 43 | final user = Provider. |
| 44 | return Column( |
| 45 | children: [ |
| 46 | Hero( |
| 47 | tag: "avatar", |
| 48 | child: CircleAvatar( |
| 49 | radius: 50, |
| 50 | backgroundColor: Colors.grey.shade200 |
| 51 | backgroundImage: CachedNetworkImageProvider( |
| 52 | "https://api.dicebear.com/9.x/initials/png?seed=${user?.name} |
| 53 | ), |
| 54 | ), |
| 55 | ), |
| 56 | const SizedBox(height: |
| 57 | Text( |
| 58 | user?.name ?? 'User', |
| 59 | style: const TextStyle( |
| 60 | fontSize: 24, |
| 61 | fontWeight: FontWeight.bold, |
| 62 | fontFamily: "CalSans", |
| 63 | color: Colors.black, |
| 64 | letterSpacing: -0.5, |
| 65 | ), |
| 66 | ), |
| 67 | ], |
| 68 | ); |
| 69 | }, |
| 70 | ), |
| 71 | const SizedBox(height: |
| 72 | // Menu Items |
| 73 | _ProfileMenuItem( |
| 74 | icon: Icons.flight_takeoff_outlined, |
| 75 | title: 'Flight Stats', |
| 76 | onTap: () { |
| 77 | GoRouter.of(context).push |
| 78 | }, |
| 79 | ), |
| 80 | const SizedBox(height: |
| 81 | _ProfileMenuItem( |
| 82 | icon: Icons.watch_outlined, |
| 83 | title: 'Connected Wear OS Devices', |
| 84 | onTap: () { |
| 85 | GoRouter.of(context).push |
| 86 | }, |
| 87 | ), |
| 88 | const SizedBox(height: |
| 89 | _ProfileMenuItem( |
| 90 | icon: Icons.image_outlined, |
| 91 | title: 'App Icon', |
| 92 | onTap: () { |
| 93 | GoRouter.of(context).push |
| 94 | }, |
| 95 | ), |
| 96 | const SizedBox(height: |
| 97 | // Log Out Button |
| 98 | Consumer( |
| 99 | builder: (context, ref, child) { |
| 100 | return SizedBox( |
| 101 | height: 52, |
| 102 | child: OutlinedButton( |
| 103 | onPressed: () { |
| 104 | final user = Provider. |
| 105 | context, |
| 106 | listen: false, |
| 107 | ); |
| 108 | user.logOut(); |
| 109 | if (context.mounted) { |
| 110 | GoRouter.of(context).go |
| 111 | } |
| 112 | }, |
| 113 | style: OutlinedButton.styleFrom( |
| 114 | foregroundColor: Colors.black, |
| 115 | side: const BorderSide( |
| 116 | color: Colors.black, |
| 117 | width: 1.5, |
| 118 | ), |
| 119 | shape: RoundedRectangleBorder( |
| 120 | borderRadius: BorderRadius.circular( |
| 121 | ), |
| 122 | ), |
| 123 | child: const Text( |
| 124 | "Log Out", |
| 125 | style: TextStyle( |
| 126 | fontSize: 16, |
| 127 | fontWeight: FontWeight.w600, |
| 128 | fontFamily: "CalSans", |
| 129 | letterSpacing: 0.5, |
| 130 | ), |
| 131 | ), |
| 132 | ), |
| 133 | ); |
| 134 | }, |
| 135 | ), |
| 136 | ], |
| 137 | ), |
| 138 | ), |
| 139 | ), |
| 140 | ); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | class _ProfileMenuItem extends StatelessWidget |
| 145 | final IconData icon; |
| 146 | final String title; |
| 147 | final VoidCallback onTap; |
| 148 | |
| 149 | const _ProfileMenuItem({ |
| 150 | required this.icon, |
| 151 | required this.title, |
| 152 | required this.onTap, |
| 153 | }); |
| 154 | |
| 155 | @override |
| 156 | Widget build(BuildContext |
| 157 | return InkWell( |
| 158 | onTap: onTap, |
| 159 | borderRadius: BorderRadius.circular( |
| 160 | child: Container( |
| 161 | padding: const EdgeInsets. |
| 162 | decoration: BoxDecoration( |
| 163 | border: Border.all( |
| 164 | color: Colors.grey.shade300 |
| 165 | width: 1, |
| 166 | ), |
| 167 | borderRadius: BorderRadius.circular( |
| 168 | ), |
| 169 | child: Row( |
| 170 | children: [ |
| 171 | Icon( |
| 172 | icon, |
| 173 | color: Colors.black, |
| 174 | size: 24, |
| 175 | ), |
| 176 | const SizedBox(width: |
| 177 | Expanded( |
| 178 | child: Text( |
| 179 | title, |
| 180 | style: const TextStyle( |
| 181 | fontSize: 16, |
| 182 | fontWeight: FontWeight.w500, |
| 183 | fontFamily: "DM Sans", |
| 184 | color: Colors.black, |
| 185 | ), |
| 186 | ), |
| 187 | ), |
| 188 | Icon( |
| 189 | Icons.chevron_right, |
| 190 | color: Colors.grey.shade400 |
| 191 | size: 24, |
| 192 | ), |
| 193 | ], |
| 194 | ), |
| 195 | ), |
| 196 | ); |
| 197 | } |
| 198 | } |