fix(sms-scan): 에러 메시지를 토스트로 변경
- 구독 정보를 찾지 못한 경우 상단 붉은색 텍스트 대신 하단 토스트 메시지 출력 - ScanInitialWidget에서 errorMessage 파라미터 제거 - SmsScanController에서 AppSnackBar.showError() 사용 - 불필요한 _errorMessage 상태 변수 제거
This commit is contained in:
@@ -17,15 +17,13 @@ import '../providers/category_provider.dart';
|
|||||||
import '../providers/payment_card_provider.dart';
|
import '../providers/payment_card_provider.dart';
|
||||||
import '../l10n/app_localizations.dart';
|
import '../l10n/app_localizations.dart';
|
||||||
import '../utils/logger.dart';
|
import '../utils/logger.dart';
|
||||||
|
import '../widgets/common/snackbar/app_snackbar.dart';
|
||||||
|
|
||||||
class SmsScanController extends ChangeNotifier {
|
class SmsScanController extends ChangeNotifier {
|
||||||
// 상태 관리
|
// 상태 관리
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
bool get isLoading => _isLoading;
|
bool get isLoading => _isLoading;
|
||||||
|
|
||||||
String? _errorMessage;
|
|
||||||
String? get errorMessage => _errorMessage;
|
|
||||||
|
|
||||||
List<Subscription> _scannedSubscriptions = [];
|
List<Subscription> _scannedSubscriptions = [];
|
||||||
List<Subscription> get scannedSubscriptions => _scannedSubscriptions;
|
List<Subscription> get scannedSubscriptions => _scannedSubscriptions;
|
||||||
PaymentCardSuggestion? _currentSuggestion;
|
PaymentCardSuggestion? _currentSuggestion;
|
||||||
@@ -109,7 +107,6 @@ class SmsScanController extends ChangeNotifier {
|
|||||||
|
|
||||||
Future<void> scanSms(BuildContext context) async {
|
Future<void> scanSms(BuildContext context) async {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
_errorMessage = null;
|
|
||||||
_scannedSubscriptions = [];
|
_scannedSubscriptions = [];
|
||||||
_currentIndex = 0;
|
_currentIndex = 0;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@@ -137,9 +134,12 @@ class SmsScanController extends ChangeNotifier {
|
|||||||
final req = await permission.Permission.sms.request();
|
final req = await permission.Permission.sms.request();
|
||||||
if (!ctx.mounted) return;
|
if (!ctx.mounted) return;
|
||||||
if (!req.isGranted) {
|
if (!req.isGranted) {
|
||||||
// 거부됨: 안내 후 종료
|
// 거부됨: 토스트 표시 후 종료
|
||||||
if (!ctx.mounted) return;
|
if (!ctx.mounted) return;
|
||||||
_errorMessage = AppLocalizations.of(ctx).smsPermissionRequired;
|
AppSnackBar.showError(
|
||||||
|
context: ctx,
|
||||||
|
message: AppLocalizations.of(ctx).smsPermissionRequired,
|
||||||
|
);
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
return;
|
return;
|
||||||
@@ -162,7 +162,10 @@ class SmsScanController extends ChangeNotifier {
|
|||||||
|
|
||||||
if (scanResults.isEmpty) {
|
if (scanResults.isEmpty) {
|
||||||
Log.i('스캔된 구독이 없음');
|
Log.i('스캔된 구독이 없음');
|
||||||
_errorMessage = AppLocalizations.of(context).subscriptionNotFound;
|
AppSnackBar.showError(
|
||||||
|
context: context,
|
||||||
|
message: AppLocalizations.of(context).subscriptionNotFound,
|
||||||
|
);
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
return;
|
return;
|
||||||
@@ -184,7 +187,10 @@ class SmsScanController extends ChangeNotifier {
|
|||||||
|
|
||||||
if (repeatSubscriptions.isEmpty) {
|
if (repeatSubscriptions.isEmpty) {
|
||||||
Log.i('반복 결제된 구독이 없음');
|
Log.i('반복 결제된 구독이 없음');
|
||||||
_errorMessage = AppLocalizations.of(context).repeatSubscriptionNotFound;
|
AppSnackBar.showError(
|
||||||
|
context: context,
|
||||||
|
message: AppLocalizations.of(context).repeatSubscriptionNotFound,
|
||||||
|
);
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
return;
|
return;
|
||||||
@@ -223,8 +229,10 @@ class SmsScanController extends ChangeNotifier {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
Log.e('SMS 스캔 중 오류 발생', e);
|
Log.e('SMS 스캔 중 오류 발생', e);
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
_errorMessage =
|
AppSnackBar.showError(
|
||||||
AppLocalizations.of(context).smsScanErrorWithMessage(e.toString());
|
context: context,
|
||||||
|
message: AppLocalizations.of(context).smsScanErrorWithMessage(e.toString()),
|
||||||
|
);
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
@@ -343,7 +351,6 @@ class SmsScanController extends ChangeNotifier {
|
|||||||
void resetState() {
|
void resetState() {
|
||||||
_scannedSubscriptions = [];
|
_scannedSubscriptions = [];
|
||||||
_currentIndex = 0;
|
_currentIndex = 0;
|
||||||
_errorMessage = null;
|
|
||||||
_selectedPaymentCardId = null;
|
_selectedPaymentCardId = null;
|
||||||
_currentSuggestion = null;
|
_currentSuggestion = null;
|
||||||
_shouldSuggestCardCreation = false;
|
_shouldSuggestCardCreation = false;
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ class _SmsScanScreenState extends State<SmsScanScreen> {
|
|||||||
if (_controller.scannedSubscriptions.isEmpty) {
|
if (_controller.scannedSubscriptions.isEmpty) {
|
||||||
return ScanInitialWidget(
|
return ScanInitialWidget(
|
||||||
onScanPressed: () => _controller.startScan(context),
|
onScanPressed: () => _controller.startScan(context),
|
||||||
errorMessage: _controller.errorMessage,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +76,6 @@ class _SmsScanScreenState extends State<SmsScanScreen> {
|
|||||||
});
|
});
|
||||||
return ScanInitialWidget(
|
return ScanInitialWidget(
|
||||||
onScanPressed: () => _controller.startScan(context),
|
onScanPressed: () => _controller.startScan(context),
|
||||||
errorMessage: _controller.errorMessage,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,10 @@ import '../../l10n/app_localizations.dart';
|
|||||||
|
|
||||||
class ScanInitialWidget extends StatelessWidget {
|
class ScanInitialWidget extends StatelessWidget {
|
||||||
final VoidCallback onScanPressed;
|
final VoidCallback onScanPressed;
|
||||||
final String? errorMessage;
|
|
||||||
|
|
||||||
const ScanInitialWidget({
|
const ScanInitialWidget({
|
||||||
super.key,
|
super.key,
|
||||||
required this.onScanPressed,
|
required this.onScanPressed,
|
||||||
this.errorMessage,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -24,15 +22,6 @@ class ScanInitialWidget extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
if (errorMessage != null)
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 24.0),
|
|
||||||
child: ThemedText(
|
|
||||||
errorMessage!,
|
|
||||||
color: Theme.of(context).colorScheme.error,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ThemedText(
|
ThemedText(
|
||||||
AppLocalizations.of(context).findRepeatSubscriptions,
|
AppLocalizations.of(context).findRepeatSubscriptions,
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
|
|||||||
Reference in New Issue
Block a user