i8n과 광고 수정
This commit is contained in:
@@ -525,7 +525,7 @@ class AddSubscriptionController {
|
||||
if (context.mounted) {
|
||||
AppSnackBar.showInfo(
|
||||
context: context,
|
||||
message: '다음 결제 예정일로 저장됨',
|
||||
message: AppLocalizations.of(context).nextBillingDateAdjusted,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,7 +454,7 @@ class DetailScreenController extends ChangeNotifier {
|
||||
if (adjustedNext.isAfter(originalDateOnly)) {
|
||||
AppSnackBar.showInfo(
|
||||
context: context,
|
||||
message: '다음 결제 예정일로 저장됨',
|
||||
message: AppLocalizations.of(context).nextBillingDateAdjusted,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ import '../providers/navigation_provider.dart';
|
||||
import '../providers/category_provider.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../providers/payment_card_provider.dart';
|
||||
import 'package:google_mobile_ads/google_mobile_ads.dart';
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
class SmsScanController extends ChangeNotifier {
|
||||
// 상태 관리
|
||||
@@ -47,6 +49,8 @@ class SmsScanController extends ChangeNotifier {
|
||||
final SubscriptionFilter _filter = SubscriptionFilter();
|
||||
bool _forceServiceNameEditing = false;
|
||||
bool get isServiceNameEditable => _forceServiceNameEditing;
|
||||
bool _isAdInProgress = false;
|
||||
bool get isAdInProgress => _isAdInProgress;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
@@ -73,15 +77,79 @@ class SmsScanController extends ChangeNotifier {
|
||||
serviceNameController.text = '';
|
||||
}
|
||||
|
||||
void updateCurrentServiceName(String value) {
|
||||
void updateCurrentServiceName(BuildContext context, String value) {
|
||||
if (_currentIndex >= _scannedSubscriptions.length) return;
|
||||
final trimmed = value.trim();
|
||||
final unknownLabel = _unknownServiceLabel(context);
|
||||
final updated = _scannedSubscriptions[_currentIndex]
|
||||
.copyWith(serviceName: trimmed.isEmpty ? '알 수 없는 서비스' : trimmed);
|
||||
.copyWith(serviceName: trimmed.isEmpty ? unknownLabel : trimmed);
|
||||
_scannedSubscriptions[_currentIndex] = updated;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> startScan(BuildContext context) async {
|
||||
if (_isLoading) return;
|
||||
_isAdInProgress = true;
|
||||
notifyListeners();
|
||||
// 웹/비지원 플랫폼은 바로 스캔
|
||||
if (kIsWeb || !(Platform.isAndroid || Platform.isIOS)) {
|
||||
_isAdInProgress = false;
|
||||
notifyListeners();
|
||||
await scanSms(context);
|
||||
return;
|
||||
}
|
||||
|
||||
// 전면 광고 로드 및 노출 후 스캔 진행
|
||||
try {
|
||||
await InterstitialAd.load(
|
||||
adUnitId: _interstitialAdUnitId(),
|
||||
request: const AdRequest(),
|
||||
adLoadCallback: InterstitialAdLoadCallback(
|
||||
onAdLoaded: (ad) {
|
||||
ad.fullScreenContentCallback = FullScreenContentCallback(
|
||||
onAdDismissedFullScreenContent: (ad) {
|
||||
ad.dispose();
|
||||
_startSmsScanIfMounted(context);
|
||||
},
|
||||
onAdFailedToShowFullScreenContent: (ad, error) {
|
||||
ad.dispose();
|
||||
_fallbackAfterDelay(context);
|
||||
},
|
||||
);
|
||||
ad.show();
|
||||
},
|
||||
onAdFailedToLoad: (error) {
|
||||
_fallbackAfterDelay(context);
|
||||
},
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
Log.e('전면 광고 로드 중 오류, 바로 스캔 진행', e);
|
||||
if (!context.mounted) return;
|
||||
_fallbackAfterDelay(context);
|
||||
}
|
||||
}
|
||||
|
||||
String _interstitialAdUnitId() {
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
return 'ca-app-pub-6691216385521068~6638409932';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
Future<void> _startSmsScanIfMounted(BuildContext context) async {
|
||||
if (!context.mounted) return;
|
||||
_isAdInProgress = false;
|
||||
notifyListeners();
|
||||
await scanSms(context);
|
||||
}
|
||||
|
||||
Future<void> _fallbackAfterDelay(BuildContext context) async {
|
||||
await Future.delayed(const Duration(seconds: 5));
|
||||
if (!context.mounted) return;
|
||||
await _startSmsScanIfMounted(context);
|
||||
}
|
||||
|
||||
Future<void> scanSms(BuildContext context) async {
|
||||
_isLoading = true;
|
||||
_errorMessage = null;
|
||||
@@ -366,8 +434,10 @@ class SmsScanController extends ChangeNotifier {
|
||||
}
|
||||
|
||||
final current = _scannedSubscriptions[_currentIndex];
|
||||
_forceServiceNameEditing = _shouldEnableServiceNameEditing(current);
|
||||
if (_forceServiceNameEditing && current.serviceName == '알 수 없는 서비스') {
|
||||
final unknownLabel = _unknownServiceLabel(context);
|
||||
_forceServiceNameEditing =
|
||||
_shouldEnableServiceNameEditing(current, unknownLabel);
|
||||
if (_forceServiceNameEditing && current.serviceName == unknownLabel) {
|
||||
serviceNameController.clear();
|
||||
} else {
|
||||
serviceNameController.text = current.serviceName;
|
||||
@@ -429,8 +499,13 @@ class SmsScanController extends ChangeNotifier {
|
||||
return null;
|
||||
}
|
||||
|
||||
bool _shouldEnableServiceNameEditing(Subscription subscription) {
|
||||
bool _shouldEnableServiceNameEditing(
|
||||
Subscription subscription, String unknownLabel) {
|
||||
final name = subscription.serviceName.trim();
|
||||
return name.isEmpty || name == '알 수 없는 서비스';
|
||||
return name.isEmpty || name == unknownLabel;
|
||||
}
|
||||
|
||||
String _unknownServiceLabel(BuildContext context) {
|
||||
return AppLocalizations.of(context).unknownService;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user