feat(ui): 스피드 부스트 버튼 위젯 추가
- 5배속 버프 활성화 버튼 - 광고 시청으로 버프 획득 - 남은 시간 표시
This commit is contained in:
156
lib/src/features/game/widgets/speed_boost_button.dart
Normal file
156
lib/src/features/game/widgets/speed_boost_button.dart
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:asciineverdie/data/game_text_l10n.dart' as l10n;
|
||||||
|
import 'package:asciineverdie/src/core/engine/iap_service.dart';
|
||||||
|
import 'package:asciineverdie/src/shared/retro_colors.dart';
|
||||||
|
|
||||||
|
/// 속도 부스트 버튼 위젯 (Phase 6)
|
||||||
|
///
|
||||||
|
/// 게임 화면에 표시되는 속도 부스트 활성화 버튼
|
||||||
|
class SpeedBoostButton extends StatelessWidget {
|
||||||
|
const SpeedBoostButton({
|
||||||
|
super.key,
|
||||||
|
required this.isActive,
|
||||||
|
required this.remainingSeconds,
|
||||||
|
required this.onActivate,
|
||||||
|
this.boostMultiplier = 10,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// 부스트 활성화 여부
|
||||||
|
final bool isActive;
|
||||||
|
|
||||||
|
/// 남은 시간 (초)
|
||||||
|
final int remainingSeconds;
|
||||||
|
|
||||||
|
/// 부스트 배율
|
||||||
|
final int boostMultiplier;
|
||||||
|
|
||||||
|
/// 활성화 콜백
|
||||||
|
final VoidCallback onActivate;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final isPaidUser = IAPService.instance.isAdRemovalPurchased;
|
||||||
|
final gold = RetroColors.goldOf(context);
|
||||||
|
final goldDark = RetroColors.goldDarkOf(context);
|
||||||
|
final expColor = RetroColors.expOf(context);
|
||||||
|
|
||||||
|
// 부스트 활성화 중일 때
|
||||||
|
if (isActive) {
|
||||||
|
return _buildActiveButton(context, expColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 부스트 비활성화 상태
|
||||||
|
return _buildInactiveButton(context, gold, goldDark, isPaidUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildActiveButton(BuildContext context, Color expColor) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: expColor.withValues(alpha: 0.3),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
border: Border.all(color: expColor, width: 2),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: expColor.withValues(alpha: 0.5),
|
||||||
|
blurRadius: 8,
|
||||||
|
spreadRadius: 1,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'⚡',
|
||||||
|
style: TextStyle(fontSize: 18, color: expColor),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Text(
|
||||||
|
'${boostMultiplier}x',
|
||||||
|
style: TextStyle(
|
||||||
|
fontFamily: 'PressStart2P',
|
||||||
|
fontSize: 14,
|
||||||
|
color: expColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
l10n.speedBoostRemaining(remainingSeconds),
|
||||||
|
style: TextStyle(
|
||||||
|
fontFamily: 'PressStart2P',
|
||||||
|
fontSize: 10,
|
||||||
|
color: expColor.withValues(alpha: 0.8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildInactiveButton(
|
||||||
|
BuildContext context,
|
||||||
|
Color gold,
|
||||||
|
Color goldDark,
|
||||||
|
bool isPaidUser,
|
||||||
|
) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: onActivate,
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: gold.withValues(alpha: 0.2),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
border: Border.all(color: gold, width: 2),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'⚡',
|
||||||
|
style: TextStyle(fontSize: 18, color: gold),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Text(
|
||||||
|
'${boostMultiplier}x',
|
||||||
|
style: TextStyle(
|
||||||
|
fontFamily: 'PressStart2P',
|
||||||
|
fontSize: 12,
|
||||||
|
color: gold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 광고 아이콘 (무료 유저만)
|
||||||
|
if (!isPaidUser) ...[
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 4,
|
||||||
|
vertical: 2,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white.withValues(alpha: 0.2),
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
child: const Text(
|
||||||
|
'AD',
|
||||||
|
style: TextStyle(
|
||||||
|
fontFamily: 'PressStart2P',
|
||||||
|
fontSize: 8,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user