From 7b08fa73debdf609df376d48b4963b18b45f2fab Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Fri, 9 Jan 2026 10:49:18 -0800 Subject: [PATCH] Show user name in Account screen instead of User #ID - Load user profile on Account screen init - Display FirstName LastInitial format - Fall back to User #ID if profile fails to load Co-Authored-By: Claude Opus 4.5 --- lib/screens/account_screen.dart | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/screens/account_screen.dart b/lib/screens/account_screen.dart index ccb99ac..8261c73 100644 --- a/lib/screens/account_screen.dart +++ b/lib/screens/account_screen.dart @@ -19,6 +19,7 @@ class _AccountScreenState extends State { bool _isLoadingAvatar = true; bool _isUploadingAvatar = false; String? _avatarUrl; + String? _userName; final ImagePicker _picker = ImagePicker(); @@ -26,6 +27,7 @@ class _AccountScreenState extends State { void initState() { super.initState(); _loadAvatar(); + _loadProfile(); } Future _loadAvatar() async { @@ -52,6 +54,26 @@ class _AccountScreenState extends State { } } + Future _loadProfile() async { + final appState = context.read(); + if (!appState.isLoggedIn) return; + + try { + final profile = await Api.getProfile(); + if (mounted) { + final firstName = profile.firstName; + final lastInitial = profile.lastName.isNotEmpty + ? '${profile.lastName[0]}.' + : ''; + setState(() { + _userName = '$firstName $lastInitial'.trim(); + }); + } + } catch (e) { + debugPrint('Error loading profile: $e'); + } + } + Future _pickAndUploadAvatar() async { // Check if user is logged in first final appState = context.read(); @@ -354,7 +376,7 @@ class _AccountScreenState extends State { _buildAvatar(), const SizedBox(height: 16), Text( - 'User #${appState.userId ?? "?"}', + _userName ?? 'User #${appState.userId ?? "?"}', style: Theme.of(context).textTheme.titleLarge, ), const SizedBox(height: 4),