diff --git a/lib/presentation/settings/viewModels/settings_view_model.dart b/lib/presentation/settings/viewModels/settings_view_model.dart index 783531c..af71206 100644 --- a/lib/presentation/settings/viewModels/settings_view_model.dart +++ b/lib/presentation/settings/viewModels/settings_view_model.dart @@ -23,6 +23,8 @@ class SettingsViewModel extends ChangeNotifier { String version = ''; User? user; String submission = ''; + bool isExpert = false; + int _tapCount = 0; @@ -60,7 +62,8 @@ class SettingsViewModel extends ChangeNotifier { Future fetchUser() async { try { user = await userUserCase.fetchMe(); - isLoggedIn = true; // Ensure isLoggedIn is updated correctly + isLoggedIn = true; + isExpert = user!.isCompositeExpert;// Ensure isLoggedIn is updated correctly } catch (e) { if (kDebugMode) { print(e); diff --git a/lib/presentation/settings/views/settings_page.dart b/lib/presentation/settings/views/settings_page.dart index 317bef8..6f3eca8 100644 --- a/lib/presentation/settings/views/settings_page.dart +++ b/lib/presentation/settings/views/settings_page.dart @@ -95,7 +95,7 @@ class _SettingsPageState extends State { fontWeight: FontWeight.bold, ), ), - /*if (viewModel.user?.isCompositeExpert == true) // Check if the user is verified + if (viewModel.user?.isCompositeExpert == true) // Check if the user is verified Padding( padding: const EdgeInsets.only(left: 4.0), // Add spacing between name and icon child: Icon( @@ -103,7 +103,7 @@ class _SettingsPageState extends State { color: Colors.blue, // Make it blue to represent verification size: 16, // Adjust the size to fit nicely ), - ),*/ + ), ], ), @@ -118,7 +118,7 @@ class _SettingsPageState extends State { await _fetchAuthSession(); }, ), - if (viewModel.isLoggedIn) + if (viewModel.isLoggedIn && !viewModel.isExpert) MoreRow(leadingIcon: Icons.account_box_outlined, title: "Request to Become an Expert", onTap: () async { diff --git a/lib/presentation/settings/views/user_profile_page.dart b/lib/presentation/settings/views/user_profile_page.dart index 1344779..ed7f299 100644 --- a/lib/presentation/settings/views/user_profile_page.dart +++ b/lib/presentation/settings/views/user_profile_page.dart @@ -71,14 +71,27 @@ class UserProfilePage extends StatelessWidget { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - viewModel.user?.name ?? '', - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - color: Colors.black, - ), + Row( + children: [ + Text( + viewModel.user?.name ?? "", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + if (viewModel.user?.isCompositeExpert == true) // Check if the user is verified + Padding( + padding: const EdgeInsets.only(left: 4.0), // Add spacing between name and icon + child: Icon( + Icons.verified, // Use a verified checkmark icon + color: Colors.blue, // Make it blue to represent verification + size: 16, // Adjust the size to fit nicely + ), + ), + ], ), + SizedBox(height: 8), Text( viewModel.user?.email ?? '', diff --git a/packages/data/lib/repositories/user_repository_impl.dart b/packages/data/lib/repositories/user_repository_impl.dart index 12e7dae..3c4f294 100644 --- a/packages/data/lib/repositories/user_repository_impl.dart +++ b/packages/data/lib/repositories/user_repository_impl.dart @@ -28,6 +28,7 @@ class UserRepositoryImpl implements UserRepository { // Check the response status and handle accordingly if (response.statusCode == 200) { final data = jsonDecode(response.body); + print(User.fromJson(data)); return User.fromJson(data); } else { diff --git a/packages/domain/lib/entities/user.dart b/packages/domain/lib/entities/user.dart index 9100657..47428fb 100644 --- a/packages/domain/lib/entities/user.dart +++ b/packages/domain/lib/entities/user.dart @@ -4,22 +4,28 @@ class User { String? name; final String? description; final String? avatarUrl; + final bool isAdmin; // Value from the database + bool isCompositeExpert; - User( - {this.username, - required this.email, - this.name, - this.description, - this.avatarUrl}); + User({ + this.username, + required this.email, + this.name, + this.description, + this.avatarUrl, + this.isAdmin = false, // Optional: Provide a default in Dart + this.isCompositeExpert = false, + }); // Factory constructor to create a User instance from JSON factory User.fromJson(Map json) { return User( - username: json['username'] ?? '', - email: json['email'] ?? '', - name: json['name'], - description: json['description'], - avatarUrl: json['avatarUrl'], - ); + username: json['username'] ?? '', + email: json['email'] ?? '', + name: json['name'], + description: json['description'], + avatarUrl: json['avatarUrl'], + isAdmin: json['isAdmin'], + isCompositeExpert: json['isCompositeExpert']); } }