이벤트 가져오기 위젯 테스트 추가 및 테스트 훅 도입
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:provider/provider.dart';
|
||||
import '../../models/subscription_model.dart';
|
||||
import '../../services/subscription_service.dart';
|
||||
import 'subscription_details_screen.dart';
|
||||
import '../../widgets/dialog_actions.dart';
|
||||
|
||||
class SubscriptionScreen extends StatefulWidget {
|
||||
const SubscriptionScreen({super.key});
|
||||
@@ -24,7 +25,7 @@ class _SubscriptionScreenState extends State<SubscriptionScreen> {
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
subscriptionService.fetchCurrentSubscription();
|
||||
subscriptionService.loadCurrentSubscription();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -49,7 +50,7 @@ class _SubscriptionScreenState extends State<SubscriptionScreen> {
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton(
|
||||
onPressed: () =>
|
||||
subscriptionService.fetchCurrentSubscription(),
|
||||
subscriptionService.loadCurrentSubscription(),
|
||||
child: const Text('다시 시도'),
|
||||
),
|
||||
],
|
||||
@@ -121,8 +122,8 @@ class _SubscriptionScreenState extends State<SubscriptionScreen> {
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: subscription.isActive
|
||||
? Colors.green.withOpacity(0.1)
|
||||
: Colors.grey.withOpacity(0.1),
|
||||
? Colors.green.withValues(alpha: 0.1)
|
||||
: Colors.grey.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: subscription.isActive
|
||||
@@ -222,7 +223,7 @@ class _SubscriptionScreenState extends State<SubscriptionScreen> {
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
// 플랜 선택 화면으로 전환
|
||||
subscriptionService.fetchCurrentSubscription();
|
||||
subscriptionService.loadCurrentSubscription();
|
||||
});
|
||||
},
|
||||
icon: const Icon(Icons.upgrade),
|
||||
@@ -271,7 +272,7 @@ class _SubscriptionScreenState extends State<SubscriptionScreen> {
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.green.withOpacity(0.1),
|
||||
color: Colors.green.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.green),
|
||||
),
|
||||
@@ -340,7 +341,7 @@ class _SubscriptionScreenState extends State<SubscriptionScreen> {
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.amber.withOpacity(0.1),
|
||||
color: Colors.amber.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: Colors.amber),
|
||||
),
|
||||
@@ -441,42 +442,40 @@ class _SubscriptionScreenState extends State<SubscriptionScreen> {
|
||||
}
|
||||
|
||||
void _showCancelDialog(SubscriptionService subscriptionService) {
|
||||
final messenger = ScaffoldMessenger.of(context);
|
||||
final navigator = Navigator.of(context);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: const Text('구독 취소'),
|
||||
content: const Text(
|
||||
'정말로 구독을 취소하시겠습니까?\n'
|
||||
'취소하면 현재 구독 기간이 끝날 때까지만 서비스를 이용할 수 있습니다.',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('아니오'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final success = await subscriptionService.cancelSubscription();
|
||||
if (success && mounted) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(const SnackBar(content: Text('구독이 취소되었습니다')));
|
||||
}
|
||||
},
|
||||
style: TextButton.styleFrom(foregroundColor: Colors.red),
|
||||
child: const Text('예, 취소합니다'),
|
||||
),
|
||||
],
|
||||
actions: DialogActions.confirm(
|
||||
onCancel: () => Navigator.of(dialogContext).pop(),
|
||||
onConfirm: () async {
|
||||
navigator.pop();
|
||||
final success = await subscriptionService.cancelSubscription();
|
||||
if (success && mounted) {
|
||||
messenger.showSnackBar(
|
||||
const SnackBar(content: Text('구독이 취소되었습니다')),
|
||||
);
|
||||
}
|
||||
},
|
||||
destructive: true,
|
||||
confirmText: '예, 취소합니다',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _toggleAutoRenew(SubscriptionService subscriptionService) async {
|
||||
final messenger = ScaffoldMessenger.of(context);
|
||||
final success = await subscriptionService.toggleAutoRenew();
|
||||
if (success && mounted) {
|
||||
final isAutoRenew = subscriptionService.currentSubscription!.autoRenew;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
messenger.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(isAutoRenew ? '자동 갱신이 활성화되었습니다' : '자동 갱신이 비활성화되었습니다'),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user