feat: add steak
This commit is contained in:
@@ -13,6 +13,7 @@ import '../bloc/wallet_bloc.dart';
|
||||
import '../bloc/wallet_event.dart';
|
||||
import '../bloc/wallet_state.dart';
|
||||
import '../bloc/wallet_status.dart';
|
||||
import '../widgets/streak_dialog.dart';
|
||||
|
||||
/// لابی اصلی: کیفپول، دکمه بازی/دورهمی/فروشگاه/سکه روزانه.
|
||||
class LobbyScreen extends StatefulWidget {
|
||||
@@ -120,9 +121,17 @@ class _LobbyScreenState extends State<LobbyScreen> {
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
_DailyCard(
|
||||
onTap: () => context
|
||||
.read<WalletBloc>()
|
||||
.add(ClaimDailyEvent()),
|
||||
wallet: wallet,
|
||||
onTap: () => StreakDialog.show(
|
||||
context,
|
||||
streak: wallet?.dailyStreak ?? 0,
|
||||
best: wallet?.bestStreak ?? 0,
|
||||
ready: wallet?.dailyReady ?? true,
|
||||
nextReward: wallet?.nextDaily ?? 200,
|
||||
onClaim: () => context
|
||||
.read<WalletBloc>()
|
||||
.add(ClaimDailyEvent()),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -305,46 +314,101 @@ class _ActionTile extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// کارتِ سکهی روزانه (اکشنِ برجستهی سبز-طلایی).
|
||||
/// کارتِ هدیهی روزانه با استریک (مثلِ دولینگو): شعله + تعدادِ روزهای پیاپی و
|
||||
/// وضعیتِ قابلِدریافت/دریافتشده.
|
||||
class _DailyCard extends StatelessWidget {
|
||||
final WalletEntity? wallet;
|
||||
final VoidCallback onTap;
|
||||
const _DailyCard({required this.onTap});
|
||||
const _DailyCard({required this.wallet, required this.onTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: InkWell(
|
||||
final w = wallet;
|
||||
final streak = w?.dailyStreak ?? 0;
|
||||
final ready = w?.dailyReady ?? true;
|
||||
final next = w?.nextDaily ?? 200;
|
||||
|
||||
final colors = ready
|
||||
? const [AppColors.success, AppColors.successDark]
|
||||
: const [AppColors.lapisHi, AppColors.lapisLo];
|
||||
|
||||
return Opacity(
|
||||
opacity: ready ? 1 : 0.75,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
onTap: onTap,
|
||||
child: Ink(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
colors: [AppColors.success, AppColors.successDark],
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
onTap: onTap, // همیشه دیالوگِ استریک را باز میکند
|
||||
child: Ink(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 13),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(colors: colors),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: AppColors.gold, width: 1.4),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
// شعلهی استریک با عددِ روز.
|
||||
Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Icon(Icons.local_fire_department,
|
||||
color: streak > 0 ? const Color(0xFFFF7A1A) : Colors.white54,
|
||||
size: 40),
|
||||
if (streak > 0)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Text('$streak',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.bold)),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('هدیهی روزانه',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold)),
|
||||
Text(
|
||||
streak > 0 ? '$streak روز پیاپی 🔥' : 'زنجیرهات رو شروع کن!',
|
||||
style: const TextStyle(color: Colors.white70, fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
if (ready)
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Row(mainAxisSize: MainAxisSize.min, children: [
|
||||
const Icon(Icons.monetization_on,
|
||||
color: AppColors.gold, size: 16),
|
||||
const SizedBox(width: 3),
|
||||
Text('+$next',
|
||||
style: const TextStyle(
|
||||
color: AppColors.gold,
|
||||
fontWeight: FontWeight.bold)),
|
||||
]),
|
||||
const Text('دریافت',
|
||||
style: TextStyle(color: Colors.white70, fontSize: 11)),
|
||||
],
|
||||
)
|
||||
else
|
||||
const Row(mainAxisSize: MainAxisSize.min, children: [
|
||||
Icon(Icons.check_circle, color: AppColors.gold, size: 18),
|
||||
SizedBox(width: 4),
|
||||
Text('امروز گرفتی',
|
||||
style: TextStyle(color: Colors.white70, fontSize: 12)),
|
||||
]),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: AppColors.gold, width: 1.4),
|
||||
),
|
||||
child: Row(
|
||||
children: const [
|
||||
Icon(Icons.card_giftcard, color: Colors.white, size: 26),
|
||||
SizedBox(width: 12),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('هدیهی روزانه',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold)),
|
||||
Text('هر روز سکهی رایگان بگیر',
|
||||
style: TextStyle(color: Colors.white70, fontSize: 12)),
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
Icon(Icons.redeem, color: AppColors.gold, size: 22),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user