feat: add reshuffle for ticket
This commit is contained in:
@@ -11,6 +11,7 @@ import '../../../../core/service/app_sounds.dart';
|
||||
import '../../../../core/theme/app_theme.dart';
|
||||
import '../../../wallet/presentation/bloc/wallet_bloc.dart';
|
||||
import '../../../wallet/presentation/bloc/wallet_event.dart';
|
||||
import '../../../wallet/presentation/bloc/wallet_state.dart';
|
||||
import '../../../wallet/presentation/bloc/wallet_status.dart';
|
||||
import '../../domain/entities/game_entities.dart';
|
||||
import '../bloc/game_bloc.dart';
|
||||
@@ -446,6 +447,53 @@ class _GameScreenState extends State<GameScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Divider(color: Color(0x33E9B949), height: 1),
|
||||
const SizedBox(height: 12),
|
||||
// بُرِ مجدد با مصرفِ یک بلیت (۵ کارتِ تازه، سپس باز هم انتخابِ حکم).
|
||||
BlocBuilder<WalletBloc, WalletBlocState>(
|
||||
builder: (context, ws) {
|
||||
final tickets = ws.walletStatus is WalletLoaded
|
||||
? (ws.walletStatus as WalletLoaded).wallet.tickets
|
||||
: 0;
|
||||
final canReshuffle = tickets > 0;
|
||||
return Column(
|
||||
children: [
|
||||
ElevatedButton.icon(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF8E1B7A),
|
||||
disabledBackgroundColor: const Color(0xFF3A2233),
|
||||
minimumSize: const Size(220, 48),
|
||||
),
|
||||
onPressed: canReshuffle
|
||||
? () {
|
||||
AppSounds.button();
|
||||
context.read<GameBloc>().reshuffle();
|
||||
// پس از مصرفِ بلیت، موجودی را تازه کن (بدون نگهداشتنِ context).
|
||||
final wallet = context.read<WalletBloc>();
|
||||
Future.delayed(const Duration(milliseconds: 500),
|
||||
() => wallet.add(LoadWalletEvent()));
|
||||
}
|
||||
: null,
|
||||
icon: const Icon(Icons.casino, color: Colors.white),
|
||||
label: const Text(
|
||||
'بُر مجدد (۱ بلیت)',
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
canReshuffle
|
||||
? 'بلیتهای شما: $tickets'
|
||||
: 'بلیت کافی ندارید',
|
||||
style: const TextStyle(
|
||||
color: Colors.white60, fontSize: 12),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user