This commit is contained in:
2026-06-19 23:38:33 +03:30
parent 0c8fd22264
commit d837aca96e
@@ -31,11 +31,13 @@ class ShopScreen extends StatelessWidget {
final s = state.actionStatus; final s = state.actionStatus;
if (s is ActionSuccess) { if (s is ActionSuccess) {
context.read<WalletBloc>().add(LoadWalletEvent()); context.read<WalletBloc>().add(LoadWalletEvent());
ScaffoldMessenger.of(context) ScaffoldMessenger.of(
.showSnackBar(SnackBar(content: Text(s.message))); context,
).showSnackBar(SnackBar(content: Text(s.message)));
} else if (s is ActionError) { } else if (s is ActionError) {
ScaffoldMessenger.of(context) ScaffoldMessenger.of(
.showSnackBar(SnackBar(content: Text(s.message))); context,
).showSnackBar(SnackBar(content: Text(s.message)));
} }
}, },
builder: (context, state) { builder: (context, state) {
@@ -52,8 +54,10 @@ class ShopScreen extends StatelessWidget {
colors: [Color(0xFF4A0C16), Color(0xFF2A0710)], colors: [Color(0xFF4A0C16), Color(0xFF2A0710)],
), ),
borderRadius: BorderRadius.circular(16), borderRadius: BorderRadius.circular(16),
border: border: Border.all(
Border.all(color: AppColors.goldDark, width: 1.5), color: AppColors.goldDark,
width: 1.5,
),
), ),
child: Column( child: Column(
children: [ children: [
@@ -87,51 +91,65 @@ class ShopScreen extends StatelessWidget {
} }
if (status is ShopLoadError) { if (status is ShopLoadError) {
return Center( return Center(
child: Column(mainAxisSize: MainAxisSize.min, children: [ child: Column(
Text(status.message), mainAxisSize: MainAxisSize.min,
TextButton( children: [
onPressed: () => context.read<ShopBloc>().add(LoadShopEvent()), Text(status.message),
child: const Text('تلاش مجدد'), TextButton(
), onPressed: () => context.read<ShopBloc>().add(LoadShopEvent()),
]), child: const Text('تلاش مجدد'),
),
],
),
); );
} }
return const Center(child: CircularProgressIndicator(color: AppColors.gold)); return const Center(
child: CircularProgressIndicator(color: AppColors.gold),
);
} }
Widget _header(BuildContext context) { Widget _header(BuildContext context) {
return Padding( return Padding(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: Row(children: [ child: Row(
GestureDetector( children: [
onTap: () => context.pop(), GestureDetector(
child: Container( onTap: () => context.pop(),
width: 46, child: Container(
height: 46, width: 46,
decoration: BoxDecoration( height: 46,
color: AppColors.panel, decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12), color: AppColors.panel,
border: Border.all(color: AppColors.gold, width: 1.5), borderRadius: BorderRadius.circular(12),
border: Border.all(color: AppColors.gold, width: 1.5),
),
child: const Icon(Icons.arrow_back, color: AppColors.gold),
), ),
child: const Icon(Icons.arrow_back, color: AppColors.gold),
), ),
), const Spacer(),
const Spacer(), BlocBuilder<WalletBloc, WalletBlocState>(
BlocBuilder<WalletBloc, WalletBlocState>( builder: (context, s) {
builder: (context, s) { final w =
final w = s.walletStatus is WalletLoaded s.walletStatus is WalletLoaded
? (s.walletStatus as WalletLoaded).wallet ? (s.walletStatus as WalletLoaded).wallet
: null; : null;
return Row(children: [ return Row(
StatChip( children: [
icon: Icons.confirmation_number, StatChip(
value: '${w?.tickets ?? 0}'), icon: Icons.confirmation_number,
const SizedBox(width: 8), value: '${w?.tickets ?? 0}',
StatChip(icon: Icons.monetization_on, value: '${w?.coins ?? 0}'), ),
]); const SizedBox(width: 8),
}, StatChip(
), icon: Icons.monetization_on,
]), value: '${w?.coins ?? 0}',
),
],
);
},
),
],
),
); );
} }
} }
@@ -147,7 +165,7 @@ class _ShopTabs extends StatelessWidget {
end: Alignment.bottomCenter, end: Alignment.bottomCenter,
colors: [Color(0xFFC62828), Color(0xFF7B0E14)], colors: [Color(0xFFC62828), Color(0xFF7B0E14)],
), ),
borderRadius: BorderRadius.vertical(top: Radius.circular(12)), borderRadius: BorderRadius.vertical(bottom: Radius.circular(12)),
), ),
indicatorSize: TabBarIndicatorSize.tab, indicatorSize: TabBarIndicatorSize.tab,
labelColor: AppColors.gold, labelColor: AppColors.gold,
@@ -198,8 +216,9 @@ class _CoinsTab extends StatelessWidget {
'${p.coins} سکه${p.vipDays > 0 ? ' + ${p.vipDays} روز VIP' : ''}', '${p.coins} سکه${p.vipDays > 0 ? ' + ${p.vipDays} روز VIP' : ''}',
action: _PriceButton( action: _PriceButton(
label: '${p.priceToman} تومان', label: '${p.priceToman} تومان',
onTap: () => onTap:
context.read<ShopBloc>().add(PurchaseEvent('coin', p.id)), () =>
context.read<ShopBloc>().add(PurchaseEvent('coin', p.id)),
), ),
), ),
], ],
@@ -223,8 +242,10 @@ class _TicketsTab extends StatelessWidget {
subtitle: '${p.tickets} بلیط', subtitle: '${p.tickets} بلیط',
action: _PriceButton( action: _PriceButton(
label: '${p.priceToman} تومان', label: '${p.priceToman} تومان',
onTap: () => onTap:
context.read<ShopBloc>().add(PurchaseEvent('ticket', p.id)), () => context.read<ShopBloc>().add(
PurchaseEvent('ticket', p.id),
),
), ),
), ),
], ],
@@ -248,8 +269,10 @@ class _BoostersTab extends StatelessWidget {
subtitle: 'تجربه ×${b.multiplier}${b.hours} ساعت', subtitle: 'تجربه ×${b.multiplier}${b.hours} ساعت',
action: _PriceButton( action: _PriceButton(
label: '${b.priceToman} تومان', label: '${b.priceToman} تومان',
onTap: () => onTap:
context.read<ShopBloc>().add(PurchaseEvent('booster', b.id)), () => context.read<ShopBloc>().add(
PurchaseEvent('booster', b.id),
),
), ),
), ),
], ],
@@ -274,8 +297,9 @@ class _VipTab extends StatelessWidget {
subtitle: '${p.months} ماه اشتراک', subtitle: '${p.months} ماه اشتراک',
action: _PriceButton( action: _PriceButton(
label: '${p.priceToman} تومان', label: '${p.priceToman} تومان',
onTap: () => onTap:
context.read<ShopBloc>().add(PurchaseEvent('vip', p.id)), () =>
context.read<ShopBloc>().add(PurchaseEvent('vip', p.id)),
), ),
), ),
], ],
@@ -328,9 +352,11 @@ Widget _grid({required String note, required List<Widget> children}) {
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 6), padding: const EdgeInsets.fromLTRB(16, 12, 16, 6),
child: Text(note, child: Text(
textAlign: TextAlign.center, note,
style: const TextStyle(color: AppColors.gold, fontSize: 13)), textAlign: TextAlign.center,
style: const TextStyle(color: AppColors.gold, fontSize: 13),
),
), ),
Expanded( Expanded(
child: GridView.count( child: GridView.count(
@@ -382,43 +408,55 @@ class _ItemCard extends StatelessWidget {
), ),
child: Column( child: Column(
children: [ children: [
Text(title, Text(
maxLines: 1, title,
overflow: TextOverflow.ellipsis, maxLines: 1,
style: const TextStyle( overflow: TextOverflow.ellipsis,
color: AppColors.gold, fontWeight: FontWeight.bold)), style: const TextStyle(
color: AppColors.gold,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 6), const SizedBox(height: 6),
Expanded(child: _GlowArt(color: glowColor, icon: icon)), Expanded(child: _GlowArt(color: glowColor, icon: icon)),
const SizedBox(height: 4), const SizedBox(height: 4),
Text(subtitle, Text(
maxLines: 1, subtitle,
overflow: TextOverflow.ellipsis, maxLines: 1,
style: const TextStyle(color: Colors.white70, fontSize: 11)), overflow: TextOverflow.ellipsis,
style: const TextStyle(color: Colors.white70, fontSize: 11),
),
const SizedBox(height: 6), const SizedBox(height: 6),
SizedBox(width: double.infinity, child: action), SizedBox(width: double.infinity, child: action),
], ],
), ),
); );
if (ribbon == null) return card; if (ribbon == null) return card;
return Stack(clipBehavior: Clip.none, children: [ return Stack(
card, clipBehavior: Clip.none,
Positioned( children: [
top: 8, card,
left: -22, Positioned(
child: Transform.rotate( top: 8,
angle: -0.7, left: -22,
child: Container( child: Transform.rotate(
padding: const EdgeInsets.symmetric(horizontal: 26, vertical: 3), angle: -0.7,
color: const Color(0xFF2E7D32), child: Container(
child: Text(ribbon!, padding: const EdgeInsets.symmetric(horizontal: 26, vertical: 3),
color: const Color(0xFF2E7D32),
child: Text(
ribbon!,
style: const TextStyle( style: const TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 11, fontSize: 11,
fontWeight: FontWeight.bold)), fontWeight: FontWeight.bold,
),
),
),
), ),
), ),
), ],
]); );
} }
} }
@@ -460,9 +498,10 @@ class _PriceButton extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final busy = context.select((ShopBloc c) => c.state.busy); final busy = context.select((ShopBloc c) => c.state.busy);
final colors = disabled final colors =
? const [Color(0xFF555555), Color(0xFF333333)] disabled
: green ? const [Color(0xFF555555), Color(0xFF333333)]
: green
? const [Color(0xFF3FA34D), Color(0xFF1B5E20)] ? const [Color(0xFF3FA34D), Color(0xFF1B5E20)]
: const [Color(0xFFD83A4A), Color(0xFF8E0E1B)]; : const [Color(0xFFD83A4A), Color(0xFF8E0E1B)];
return Opacity( return Opacity(
@@ -482,21 +521,31 @@ class _PriceButton extends StatelessWidget {
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
border: Border.all(color: AppColors.gold, width: 1.2), border: Border.all(color: AppColors.gold, width: 1.2),
), ),
child: Row(mainAxisSize: MainAxisSize.min, children: [ child: Row(
if (coin) ...[ mainAxisSize: MainAxisSize.min,
const Icon(Icons.monetization_on, color: AppColors.gold, size: 16), children: [
const SizedBox(width: 4), if (coin) ...[
], const Icon(
Flexible( Icons.monetization_on,
child: Text(label, color: AppColors.gold,
size: 16,
),
const SizedBox(width: 4),
],
Flexible(
child: Text(
label,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: const TextStyle( style: const TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 13, fontSize: 13,
fontWeight: FontWeight.bold)), fontWeight: FontWeight.bold,
), ),
]), ),
),
],
),
), ),
), ),
); );