Files
bowlingManager/mobile/lib/widgets/subscription_alert_widget.dart

91 lines
2.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../services/subscription_notification_service.dart';
import '../services/subscription_service.dart';
/// 구독 알림 위젯
class SubscriptionAlertWidget extends StatelessWidget {
const SubscriptionAlertWidget({super.key});
@override
Widget build(BuildContext context) {
// 구독 알림 서비스 가져오기
final notificationService = Provider.of<SubscriptionNotificationService>(
context,
listen: true,
);
// 구독 서비스 가져오기 (현재 위젯에서는 직접 사용하지 않음)
Provider.of<SubscriptionService>(
context,
listen: false,
);
// 알림 메시지 가져오기
final message = notificationService.getNotificationMessage();
// 알림이 없으면 빈 컨테이너 반환
if (message == null) {
return const SizedBox.shrink();
}
// 알림 배너 표시
return Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
color: notificationService.hasExpired
? Colors.red.shade100
: Colors.orange.shade100,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(
notificationService.hasExpired
? Icons.error_outline
: Icons.warning_amber_outlined,
color: notificationService.hasExpired
? Colors.red.shade700
: Colors.orange.shade700,
),
const SizedBox(width: 8),
Expanded(
child: Text(
message,
style: TextStyle(
color: notificationService.hasExpired
? Colors.red.shade700
: Colors.orange.shade700,
fontWeight: FontWeight.bold,
),
),
),
],
),
const SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () {
// 구독 화면으로 이동
Navigator.of(context).pushNamed('/subscription');
},
style: TextButton.styleFrom(
backgroundColor: notificationService.hasExpired
? Colors.red.shade700
: Colors.orange.shade700,
foregroundColor: Colors.white,
),
child: const Text('구독 갱신하기'),
),
],
),
],
),
);
}
}