Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lulin/optimize/optimize signin profile #66

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/presentation/settings/viewModels/login_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class LoginViewModel extends ChangeNotifier {
if (!isValid) {
throw Exception('Google token validation failed.');
}

// Sync the user data
await syncUser(user.displayName, user.email, user.photoUrl);
}
Expand Down Expand Up @@ -161,14 +160,15 @@ class LoginViewModel extends ChangeNotifier {
print('Apple credential: $credential');
// Get the identity token
final identityToken = credential.identityToken;
final String? name = credential.givenName;

if (identityToken == null) {
throw Exception('Identity token not available in Apple credentials');
}
// Validate the token with backend and retrieve email if valid
final email = await validateAppleToken(identityToken);

await syncUser(null, email, null);
await syncUser(name, email, null);

_isSigningIn = true;
// Notify listeners for UI update
Expand Down
7 changes: 6 additions & 1 deletion lib/presentation/settings/views/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ class _SettingsPageState extends State<SettingsPage> {
if (viewModel.isLoggedIn)
ListTile(
key: ValueKey(viewModel.user?.name ?? ""),
leading: Icon(
leading: viewModel.user?.avatarUrl != null
? CircleAvatar(
backgroundImage: NetworkImage(viewModel.user!.avatarUrl!),
radius: 22.5, // Adjust the radius to match the icon size
)
: Icon(
Icons.account_circle,
size: 45,
color: Colors.blueGrey,
Expand Down
7 changes: 6 additions & 1 deletion lib/presentation/settings/views/user_profile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ class UserProfilePage extends StatelessWidget {
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(
viewModel.user?.avatarUrl != null
? CircleAvatar(
backgroundImage: NetworkImage(viewModel.user!.avatarUrl!),
radius: 27.5, // Matches size of 55
)
: Icon(
Icons.account_circle,
size: 55,
color: Colors.blueGrey,
Expand Down