diff --git a/lib/models/ui/user_avatar_details.dart b/lib/models/ui/user_avatar_details.dart index 175ee2d8..c3d3c5f5 100644 --- a/lib/models/ui/user_avatar_details.dart +++ b/lib/models/ui/user_avatar_details.dart @@ -1,5 +1,5 @@ import "package:flutter/foundation.dart"; -import "package:proxima/models/database/user/user_data.dart"; +import "package:proxima/models/database/user/user_firestore.dart"; import "package:proxima/models/database/user/user_id_firestore.dart"; /// A class that stores data for a user avatar UI. @@ -19,14 +19,13 @@ class UserAvatarDetails { required this.userID, }); - /// Converts a [UserData] object, [userData], to a [UserAvatarDetails] object. - factory UserAvatarDetails.fromUserData( - UserData userData, - UserIdFirestore userID, + /// Converts a [UserFirestore] object, [user], to a [UserAvatarDetails] object. + factory UserAvatarDetails.fromUser( + UserFirestore user, ) { return UserAvatarDetails( - displayName: userData.displayName, - userID: userID, + displayName: user.data.displayName, + userID: user.uid, ); } diff --git a/lib/viewmodels/dynamic_user_avatar_view_model.dart b/lib/viewmodels/dynamic_user_avatar_view_model.dart index 5cb611a8..1f207a34 100644 --- a/lib/viewmodels/dynamic_user_avatar_view_model.dart +++ b/lib/viewmodels/dynamic_user_avatar_view_model.dart @@ -33,10 +33,7 @@ class DynamicUserAvatarViewModel extends AutoDisposeFamilyAsyncNotifier< user = await userDataBase.getUser(userID); - return UserAvatarDetails.fromUserData( - user.data, - userID, - ); + return UserAvatarDetails.fromUser(user); } } diff --git a/lib/views/pages/profile/components/profile_app_bar.dart b/lib/views/pages/profile/components/profile_app_bar.dart index 6ebfd2b9..3c2a76bf 100644 --- a/lib/views/pages/profile/components/profile_app_bar.dart +++ b/lib/views/pages/profile/components/profile_app_bar.dart @@ -1,28 +1,20 @@ import "package:flutter/material.dart"; -import "package:proxima/models/database/user/user_data.dart"; -import "package:proxima/models/database/user/user_id_firestore.dart"; +import "package:proxima/models/database/user/user_firestore.dart"; import "package:proxima/views/navigation/leading_back_button/leading_back_button.dart"; import "package:proxima/views/pages/profile/components/logout_button.dart"; import "package:proxima/views/pages/profile/components/user_account.dart"; // This widget displays the profile of a user as an app bar. class ProfileAppBar extends AppBar { - // The user data of the user to display - final UserData userData; - - // The user id of the user to display - final UserIdFirestore userID; + // The user to display + final UserFirestore user; ProfileAppBar({ super.key, - required this.userData, - required this.userID, + required this.user, }) : super( leading: const LeadingBackButton(), - title: UserAccount( - userData: userData, - userID: userID, - ), + title: UserAccount(user: user), actions: [ const LogoutButton(), ], diff --git a/lib/views/pages/profile/components/user_account.dart b/lib/views/pages/profile/components/user_account.dart index 8eb70e25..086d1144 100644 --- a/lib/views/pages/profile/components/user_account.dart +++ b/lib/views/pages/profile/components/user_account.dart @@ -1,6 +1,5 @@ import "package:flutter/material.dart"; -import "package:proxima/models/database/user/user_data.dart"; -import "package:proxima/models/database/user/user_id_firestore.dart"; +import "package:proxima/models/database/user/user_firestore.dart"; import "package:proxima/models/ui/user_avatar_details.dart"; import "package:proxima/views/components/content/user_avatar/user_avatar.dart"; @@ -11,20 +10,18 @@ class UserAccount extends StatelessWidget { const UserAccount({ super.key, - required this.userData, - required this.userID, + required this.user, }); - // The user data of the user to display - final UserData userData; - - // The user id of the user to display - final UserIdFirestore userID; + // The user to display + final UserFirestore user; @override Widget build(BuildContext context) { final textStyle = Theme.of(context).textTheme.titleSmall; + final userData = user.data; + final displayName = Text( userData.displayName, style: textStyle, @@ -38,10 +35,7 @@ class UserAccount extends StatelessWidget { ); final profilePicture = UserAvatar( - details: UserAvatarDetails.fromUserData( - userData, - userID, - ), + details: UserAvatarDetails.fromUser(user), radius: 20, ); diff --git a/lib/views/pages/profile/profile_page.dart b/lib/views/pages/profile/profile_page.dart index 2f4bae74..113119bb 100644 --- a/lib/views/pages/profile/profile_page.dart +++ b/lib/views/pages/profile/profile_page.dart @@ -47,10 +47,7 @@ class ProfilePage extends ConsumerWidget { return DefaultTabController( length: 2, child: Scaffold( - appBar: ProfileAppBar( - userData: user.data, - userID: user.uid, - ), + appBar: ProfileAppBar(user: user), body: Container( padding: const EdgeInsets.only(left: 8, right: 8, bottom: 8), child: const Column( diff --git a/test/models/ui/user_avatar_details_test.dart b/test/models/ui/user_avatar_details_test.dart index e8f733ad..dcee6377 100644 --- a/test/models/ui/user_avatar_details_test.dart +++ b/test/models/ui/user_avatar_details_test.dart @@ -8,10 +8,7 @@ void main() { late UserAvatarDetails userAvatarDetails; setUp(() { - userAvatarDetails = UserAvatarDetails.fromUserData( - testingUserData, - testingUserFirestoreId, - ); + userAvatarDetails = UserAvatarDetails.fromUser(testingUserFirestore); }); test("Hash overrides correctly", () {