Skip to content

Commit f44f987

Browse files
committed
fix: surface Apple sign-in failures
1 parent b54e01d commit f44f987

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

lib/presentation/login/components/google_sign_in_button/apple_sign_in_button_mobile.dart

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart' hide IconAlignment;
22
import 'package:on_time_front/core/di/di_setup.dart';
3+
import 'package:on_time_front/core/dio/api_error_message.dart';
34
import 'package:on_time_front/core/logging/app_logger.dart';
45
import 'package:on_time_front/domain/repositories/user_repository.dart';
56
import 'package:sign_in_with_apple/sign_in_with_apple.dart';
@@ -29,8 +30,9 @@ class AppleSignInButton extends StatelessWidget {
2930
final fullNameRaw =
3031
'${credential.givenName ?? ''} ${credential.familyName ?? ''}'
3132
.trim();
32-
final fullName =
33-
fullNameRaw.isNotEmpty ? fullNameRaw : 'Apple User';
33+
final fullName = fullNameRaw.isNotEmpty
34+
? fullNameRaw
35+
: 'Apple User';
3436

3537
final identityToken = credential.identityToken;
3638
final authorizationCode = credential.authorizationCode;
@@ -44,10 +46,20 @@ class AppleSignInButton extends StatelessWidget {
4446
fullName: fullName,
4547
email: credential.email,
4648
);
47-
} catch (error) {
49+
} catch (error, stackTrace) {
4850
AppLogger.debug(
49-
'Apple Sign-In button failed errorType=${error.runtimeType}',
51+
'Apple Sign-In button failed errorType=${error.runtimeType} '
52+
'message=$error stackTrace=$stackTrace',
5053
);
54+
if (!context.mounted) {
55+
return;
56+
}
57+
final message =
58+
ApiErrorMessage.fromException(error) ??
59+
'Apple 로그인에 실패했습니다. 잠시 후 다시 시도해 주세요.';
60+
ScaffoldMessenger.of(
61+
context,
62+
).showSnackBar(SnackBar(content: Text(message)));
5163
}
5264
},
5365
borderRadius: BorderRadius.circular(14),

0 commit comments

Comments
 (0)