feat: rotate table players
This commit is contained in:
@@ -45,7 +45,10 @@ class GameBloc extends Bloc<GameEvent, GameUiState> {
|
|||||||
on<PlayCardEvent>(
|
on<PlayCardEvent>(
|
||||||
(event, emit) => repository.send({'type': 'play_card', 'card': event.card}));
|
(event, emit) => repository.send({'type': 'play_card', 'card': event.card}));
|
||||||
on<LeaveGameEvent>((event, emit) => repository.send({'type': 'leave'}));
|
on<LeaveGameEvent>((event, emit) => repository.send({'type': 'leave'}));
|
||||||
on<StartTableEvent>((event, emit) => repository.send({'type': 'start_table'}));
|
on<StartTableEvent>((event, emit) =>
|
||||||
|
repository.send({'type': 'start_table', 'hands': event.hands}));
|
||||||
|
on<RotateTableEvent>((event, emit) =>
|
||||||
|
repository.send({'type': 'rotate_table', 'dir': event.dir}));
|
||||||
on<LeaveTableEvent>((event, emit) => repository.send({'type': 'leave_table'}));
|
on<LeaveTableEvent>((event, emit) => repository.send({'type': 'leave_table'}));
|
||||||
on<ClearNoticeEvent>((event, emit) => emit(state.copyWith(clearNotice: true)));
|
on<ClearNoticeEvent>((event, emit) => emit(state.copyWith(clearNotice: true)));
|
||||||
}
|
}
|
||||||
@@ -82,7 +85,8 @@ class GameBloc extends Bloc<GameEvent, GameUiState> {
|
|||||||
void chooseTrump(String suit) => add(ChooseTrumpEvent(suit));
|
void chooseTrump(String suit) => add(ChooseTrumpEvent(suit));
|
||||||
void playCard(String card) => add(PlayCardEvent(card));
|
void playCard(String card) => add(PlayCardEvent(card));
|
||||||
void leave() => add(LeaveGameEvent());
|
void leave() => add(LeaveGameEvent());
|
||||||
void startTable() => add(StartTableEvent());
|
void startTable(int hands) => add(StartTableEvent(hands));
|
||||||
|
void rotateTable(int dir) => add(RotateTableEvent(dir));
|
||||||
void leaveTable() => add(LeaveTableEvent());
|
void leaveTable() => add(LeaveTableEvent());
|
||||||
void clearNotice() => add(ClearNoticeEvent());
|
void clearNotice() => add(ClearNoticeEvent());
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,15 @@ class PlayCardEvent extends GameEvent {
|
|||||||
|
|
||||||
class LeaveGameEvent extends GameEvent {}
|
class LeaveGameEvent extends GameEvent {}
|
||||||
|
|
||||||
class StartTableEvent extends GameEvent {}
|
class StartTableEvent extends GameEvent {
|
||||||
|
final int hands; // تعداد دستِ انتخابی (۳/۵/۷)
|
||||||
|
StartTableEvent(this.hands);
|
||||||
|
}
|
||||||
|
|
||||||
|
class RotateTableEvent extends GameEvent {
|
||||||
|
final int dir; // +۱/−۱ جهتِ چرخشِ جایگاهها
|
||||||
|
RotateTableEvent(this.dir);
|
||||||
|
}
|
||||||
|
|
||||||
class LeaveTableEvent extends GameEvent {}
|
class LeaveTableEvent extends GameEvent {}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import '../../domain/entities/game_entities.dart';
|
|||||||
class LobbyPlayer {
|
class LobbyPlayer {
|
||||||
final String name;
|
final String name;
|
||||||
final bool host;
|
final bool host;
|
||||||
const LobbyPlayer(this.name, this.host);
|
final int seat; // جایگاهِ مطلق (۰..۳)
|
||||||
|
const LobbyPlayer(this.name, this.host, this.seat);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// وضعیت اتاق انتظارِ میز خصوصی (دورهمی).
|
/// وضعیت اتاق انتظارِ میز خصوصی (دورهمی).
|
||||||
@@ -15,12 +16,14 @@ class TableLobby {
|
|||||||
final String code;
|
final String code;
|
||||||
final List<LobbyPlayer> players;
|
final List<LobbyPlayer> players;
|
||||||
final bool isHost;
|
final bool isHost;
|
||||||
|
final int youSeat; // جایگاهِ مطلقِ خودِ کاربر (برای چیدمانِ صحنه)
|
||||||
final int remaining;
|
final int remaining;
|
||||||
final bool unlimited;
|
final bool unlimited;
|
||||||
const TableLobby({
|
const TableLobby({
|
||||||
required this.code,
|
required this.code,
|
||||||
required this.players,
|
required this.players,
|
||||||
required this.isHost,
|
required this.isHost,
|
||||||
|
required this.youSeat,
|
||||||
required this.remaining,
|
required this.remaining,
|
||||||
required this.unlimited,
|
required this.unlimited,
|
||||||
});
|
});
|
||||||
@@ -29,15 +32,19 @@ class TableLobby {
|
|||||||
code: (j['code'] ?? '') as String,
|
code: (j['code'] ?? '') as String,
|
||||||
players: ((j['players'] as List?) ?? [])
|
players: ((j['players'] as List?) ?? [])
|
||||||
.map((e) => LobbyPlayer(
|
.map((e) => LobbyPlayer(
|
||||||
(e['name'] ?? '') as String, (e['host'] ?? false) as bool))
|
(e['name'] ?? '') as String,
|
||||||
|
(e['host'] ?? false) as bool,
|
||||||
|
(e['seat'] ?? 0) as int,
|
||||||
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
isHost: (j['host'] ?? false) as bool,
|
isHost: (j['host'] ?? false) as bool,
|
||||||
|
youSeat: (j['you_seat'] ?? 0) as int,
|
||||||
remaining: (j['remaining'] ?? 0) as int,
|
remaining: (j['remaining'] ?? 0) as int,
|
||||||
unlimited: (j['unlimited'] ?? false) as bool,
|
unlimited: (j['unlimited'] ?? false) as bool,
|
||||||
);
|
);
|
||||||
|
|
||||||
String get sig => '$code|$isHost|$remaining|$unlimited|'
|
String get sig => '$code|$isHost|$youSeat|$remaining|$unlimited|'
|
||||||
'${players.map((p) => '${p.name}${p.host ? '*' : ''}').join(',')}';
|
'${players.map((p) => '${p.name}${p.host ? '*' : ''}@${p.seat}').join(',')}';
|
||||||
}
|
}
|
||||||
|
|
||||||
class GameUiState extends Equatable {
|
class GameUiState extends Equatable {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:random_avatar/random_avatar.dart';
|
||||||
|
|
||||||
import '../../../../core/network/ws_client.dart';
|
import '../../../../core/network/ws_client.dart';
|
||||||
import '../../../../core/theme/app_theme.dart';
|
import '../../../../core/theme/app_theme.dart';
|
||||||
@@ -44,21 +45,32 @@ class PrivateTableScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _LobbyView extends StatelessWidget {
|
class _LobbyView extends StatefulWidget {
|
||||||
final GameUiState state;
|
final GameUiState state;
|
||||||
const _LobbyView({required this.state});
|
const _LobbyView({required this.state});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_LobbyView> createState() => _LobbyViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LobbyViewState extends State<_LobbyView> {
|
||||||
|
int _hands = 3; // تعداد دستِ انتخابیِ میزبان
|
||||||
|
|
||||||
|
void _leave() {
|
||||||
|
context.read<GameBloc>().leaveTable();
|
||||||
|
if (context.canPop()) context.pop();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final state = widget.state;
|
||||||
final lobby = state.lobby;
|
final lobby = state.lobby;
|
||||||
final connecting = state.connection != WsStatus.connected || lobby == null;
|
final connecting = state.connection != WsStatus.connected || lobby == null;
|
||||||
|
|
||||||
return PopScope(
|
return PopScope(
|
||||||
canPop: false,
|
canPop: false,
|
||||||
onPopInvokedWithResult: (didPop, _) {
|
onPopInvokedWithResult: (didPop, _) {
|
||||||
if (didPop) return;
|
if (!didPop) _leave();
|
||||||
context.read<GameBloc>().leaveTable();
|
|
||||||
if (context.canPop()) context.pop();
|
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
body: GameBackground(
|
body: GameBackground(
|
||||||
@@ -67,30 +79,7 @@ class _LobbyView extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
Align(
|
_topBar(context, lobby),
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(10),
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
context.read<GameBloc>().leaveTable();
|
|
||||||
if (context.canPop()) context.pop();
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
width: 46,
|
|
||||||
height: 46,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: AppColors.panel,
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
border:
|
|
||||||
Border.all(color: AppColors.gold, width: 1.5),
|
|
||||||
),
|
|
||||||
child: const Icon(Icons.arrow_back,
|
|
||||||
color: AppColors.gold),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: connecting
|
child: connecting
|
||||||
? const Center(
|
? const Center(
|
||||||
@@ -110,42 +99,111 @@ class _LobbyView extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// نوار بالا: بازگشت (چپ) و اشتراکگذاریِ کد (راست).
|
||||||
|
Widget _topBar(BuildContext context, TableLobby? lobby) {
|
||||||
|
Widget btn(IconData icon, VoidCallback onTap) => GestureDetector(
|
||||||
|
onTap: onTap,
|
||||||
|
child: Container(
|
||||||
|
width: 46,
|
||||||
|
height: 46,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.panel,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(color: AppColors.gold, width: 1.5),
|
||||||
|
),
|
||||||
|
child: Icon(icon, color: AppColors.gold),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
child: Directionality(
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
btn(Icons.arrow_back, _leave),
|
||||||
|
if (lobby != null)
|
||||||
|
btn(Icons.share, () {
|
||||||
|
Clipboard.setData(ClipboardData(text: lobby.code));
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||||
|
content: Text('کد میز کپی شد؛ برای دوستانت بفرست')));
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _content(BuildContext context, TableLobby lobby) {
|
Widget _content(BuildContext context, TableLobby lobby) {
|
||||||
|
final youSeat = lobby.youSeat;
|
||||||
|
// نگاشتِ جایگاهِ مطلق → بازیکن (خالی = بات هنگام شروع).
|
||||||
|
final bySeat = <int, LobbyPlayer>{for (final p in lobby.players) p.seat: p};
|
||||||
|
// چیدمان از نگاهِ خودِ کاربر: «شما» پایین، همتیمی (روبهرو) بالا، بقیه کنار.
|
||||||
|
LobbyPlayer? seatAt(int rel) => bySeat[(youSeat + rel) % 4];
|
||||||
|
final me = seatAt(0);
|
||||||
|
final top = seatAt(2); // همتیمی (روبهرو)
|
||||||
|
final left = seatAt(1);
|
||||||
|
final right = seatAt(3);
|
||||||
|
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
const GlowText('میز دورهمی', size: 26),
|
const Text('شماره میز', style: TextStyle(color: Colors.white70)),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 4),
|
||||||
GamePanel(
|
GlowText(lobby.code, size: 36),
|
||||||
child: Column(children: [
|
const SizedBox(height: 8),
|
||||||
const Text('شماره میز', style: TextStyle(color: Colors.white70)),
|
// میز با چهار جایگاه.
|
||||||
const SizedBox(height: 6),
|
SizedBox(
|
||||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
height: 340,
|
||||||
SelectableText(lobby.code,
|
child: Stack(
|
||||||
style: const TextStyle(
|
children: [
|
||||||
color: AppColors.gold,
|
Padding(
|
||||||
fontSize: 40,
|
padding: const EdgeInsets.symmetric(
|
||||||
fontWeight: FontWeight.bold,
|
horizontal: 28, vertical: 36),
|
||||||
letterSpacing: 8)),
|
child: Container(
|
||||||
IconButton(
|
decoration: BoxDecoration(
|
||||||
onPressed: () {
|
gradient: const RadialGradient(
|
||||||
Clipboard.setData(ClipboardData(text: lobby.code));
|
colors: [Color(0xFF1E7E3A), Color(0xFF0C5022)],
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
radius: 0.9,
|
||||||
const SnackBar(content: Text('کد کپی شد')));
|
),
|
||||||
},
|
borderRadius: BorderRadius.circular(160),
|
||||||
icon: const Icon(Icons.copy, color: AppColors.gold),
|
border: Border.all(color: const Color(0xFF8A5A12), width: 6),
|
||||||
|
),
|
||||||
|
child: const Center(
|
||||||
|
child: GlowText('سلطان حکم', size: 18),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
]),
|
Align(alignment: Alignment.topCenter, child: _seat(top, false)),
|
||||||
const Text('این کد را برای دوستانت بفرست',
|
Align(alignment: Alignment.centerLeft, child: _seat(left, false)),
|
||||||
style: TextStyle(color: Colors.white54, fontSize: 12)),
|
Align(
|
||||||
]),
|
alignment: Alignment.centerRight, child: _seat(right, false)),
|
||||||
|
Align(alignment: Alignment.bottomCenter, child: _seat(me, true)),
|
||||||
|
// چرخشِ جایگاهها (فقط میزبان) — تغییرِ تیمبندی.
|
||||||
|
if (lobby.isHost) ...[
|
||||||
|
Align(
|
||||||
|
alignment: const Alignment(-1, -0.35),
|
||||||
|
child: _rotateBtn(Icons.rotate_left,
|
||||||
|
() => context.read<GameBloc>().rotateTable(-1)),
|
||||||
|
),
|
||||||
|
Align(
|
||||||
|
alignment: const Alignment(1, -0.35),
|
||||||
|
child: _rotateBtn(Icons.rotate_right,
|
||||||
|
() => context.read<GameBloc>().rotateTable(1)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 8),
|
||||||
GamePanel(
|
const Text('تعداد دست', style: TextStyle(color: Colors.white70)),
|
||||||
child: Column(children: [
|
const SizedBox(height: 10),
|
||||||
for (var i = 0; i < 4; i++) _seatRow(i, lobby),
|
Row(
|
||||||
]),
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
for (final h in [3, 5, 7]) _handChip(h, lobby.isHost),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
if (lobby.isHost)
|
if (lobby.isHost)
|
||||||
@@ -154,41 +212,127 @@ class _LobbyView extends StatelessWidget {
|
|||||||
icon: Icons.play_arrow,
|
icon: Icons.play_arrow,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
colors: const [Color(0xFF3FA34D), Color(0xFF1B5E20)],
|
colors: const [Color(0xFF3FA34D), Color(0xFF1B5E20)],
|
||||||
onTap: () => context.read<GameBloc>().startTable(),
|
onTap: () => context.read<GameBloc>().startTable(_hands),
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
const Text('در انتظار شروع توسط میزبان…',
|
const Text('در انتظار شروع توسط میزبان…',
|
||||||
style: TextStyle(color: AppColors.gold, fontSize: 15)),
|
style: TextStyle(color: AppColors.gold, fontSize: 15)),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 6),
|
||||||
if (lobby.isHost)
|
if (lobby.isHost)
|
||||||
const Text('جایهای خالی با ربات پر میشوند',
|
const Text('جایهای خالی با ربات پر میشوند',
|
||||||
style: TextStyle(color: Colors.white54, fontSize: 12)),
|
style: TextStyle(color: Colors.white54, fontSize: 12)),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 20),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _seatRow(int i, TableLobby lobby) {
|
// یک جایگاهِ بازیکن دورِ میز (آواتار + ستاره + نام).
|
||||||
final filled = i < lobby.players.length;
|
Widget _seat(LobbyPlayer? p, bool isYou) {
|
||||||
final p = filled ? lobby.players[i] : null;
|
final empty = p == null;
|
||||||
return Padding(
|
return Column(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
mainAxisSize: MainAxisSize.min,
|
||||||
child: Row(children: [
|
children: [
|
||||||
Icon(filled ? Icons.person : Icons.person_outline,
|
Stack(
|
||||||
color: filled ? AppColors.gold : Colors.white24, size: 24),
|
clipBehavior: Clip.none,
|
||||||
const SizedBox(width: 10),
|
children: [
|
||||||
Text(
|
Container(
|
||||||
filled ? p!.name : 'در انتظار بازیکن…',
|
width: 62,
|
||||||
style: TextStyle(
|
height: 62,
|
||||||
color: filled ? Colors.white : Colors.white38,
|
padding: const EdgeInsets.all(3),
|
||||||
fontSize: 15,
|
decoration: BoxDecoration(
|
||||||
fontWeight: filled ? FontWeight.bold : FontWeight.normal),
|
color: AppColors.bgDark,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(
|
||||||
|
color: isYou ? AppColors.gold : AppColors.goldDark,
|
||||||
|
width: 2),
|
||||||
|
),
|
||||||
|
child: empty
|
||||||
|
? const Icon(Icons.person_add_alt_1, color: Colors.white24)
|
||||||
|
: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(9),
|
||||||
|
child: RandomAvatar(p.name),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (!empty)
|
||||||
|
const Positioned(
|
||||||
|
bottom: -6,
|
||||||
|
left: -4,
|
||||||
|
child: Icon(Icons.star, color: AppColors.gold, size: 22),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
Text(
|
||||||
|
empty ? 'در انتظار' : (isYou ? 'شما' : p.name),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
color: empty ? Colors.white38 : Colors.white,
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: empty ? FontWeight.normal : FontWeight.bold,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
|
||||||
if (p?.host == true)
|
if (p?.host == true)
|
||||||
const Icon(Icons.star, color: AppColors.gold, size: 18),
|
const Text('میزبان',
|
||||||
]),
|
style: TextStyle(color: AppColors.gold, fontSize: 10)),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// دکمهی چرخشِ جایگاهها (کنارِ میز).
|
||||||
|
Widget _rotateBtn(IconData icon, VoidCallback onTap) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: onTap,
|
||||||
|
child: Container(
|
||||||
|
width: 44,
|
||||||
|
height: 44,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: const LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: [Color(0xFF8E1B2A), Color(0xFF5A0E18)],
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
border: Border.all(color: AppColors.gold, width: 1.5),
|
||||||
|
),
|
||||||
|
child: Icon(icon, color: AppColors.gold, size: 26),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _handChip(int h, bool editable) {
|
||||||
|
const fa = {3: '۳', 5: '۵', 7: '۷'};
|
||||||
|
final selected = _hands == h;
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: editable ? () => setState(() => _hands = h) : null,
|
||||||
|
child: Container(
|
||||||
|
width: 52,
|
||||||
|
height: 52,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
gradient: selected
|
||||||
|
? const LinearGradient(
|
||||||
|
colors: [Color(0xFFE9B949), Color(0xFFB8860B)])
|
||||||
|
: null,
|
||||||
|
color: selected ? null : AppColors.panel,
|
||||||
|
border: Border.all(
|
||||||
|
color: selected ? AppColors.gold : AppColors.goldDark,
|
||||||
|
width: 2),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
fa[h]!,
|
||||||
|
style: TextStyle(
|
||||||
|
color: selected ? const Color(0xFF3A0A12) : Colors.white,
|
||||||
|
fontSize: 22,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,28 +30,38 @@ class ProfileScreen extends StatelessWidget {
|
|||||||
if (s is ProfileSaveSuccess) {
|
if (s is ProfileSaveSuccess) {
|
||||||
context.read<WalletBloc>().add(LoadWalletEvent());
|
context.read<WalletBloc>().add(LoadWalletEvent());
|
||||||
} else if (s is ProfileSaveError) {
|
} else if (s is ProfileSaveError) {
|
||||||
ScaffoldMessenger.of(context)
|
ScaffoldMessenger.of(
|
||||||
.showSnackBar(SnackBar(content: Text(s.message)));
|
context,
|
||||||
|
).showSnackBar(SnackBar(content: Text(s.message)));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final st = state.loadStatus;
|
final st = state.loadStatus;
|
||||||
if (st is ProfileLoadError) {
|
if (st is ProfileLoadError) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
child: Column(
|
||||||
Text(st.message,
|
mainAxisSize: MainAxisSize.min,
|
||||||
style: const TextStyle(color: Colors.white70)),
|
children: [
|
||||||
const SizedBox(height: 12),
|
Text(
|
||||||
GameButton(
|
st.message,
|
||||||
|
style: const TextStyle(color: Colors.white70),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
GameButton(
|
||||||
label: 'تلاش دوباره',
|
label: 'تلاش دوباره',
|
||||||
onTap: () =>
|
onTap:
|
||||||
context.read<ProfileBloc>().add(LoadProfileEvent())),
|
() => context.read<ProfileBloc>().add(
|
||||||
]),
|
LoadProfileEvent(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (st is! ProfileLoadLoaded) {
|
if (st is! ProfileLoadLoaded) {
|
||||||
return const Center(
|
return const Center(
|
||||||
child: CircularProgressIndicator(color: AppColors.gold));
|
child: CircularProgressIndicator(color: AppColors.gold),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return _content(context, st.profile);
|
return _content(context, st.profile);
|
||||||
},
|
},
|
||||||
@@ -69,9 +79,9 @@ class ProfileScreen extends StatelessWidget {
|
|||||||
builder: (_) => _EditProfileSheet(name: d.name, avatar: d.avatar),
|
builder: (_) => _EditProfileSheet(name: d.name, avatar: d.avatar),
|
||||||
);
|
);
|
||||||
if (result == null || !context.mounted) return;
|
if (result == null || !context.mounted) return;
|
||||||
context
|
context.read<ProfileBloc>().add(
|
||||||
.read<ProfileBloc>()
|
SaveProfileEvent(result['name']!, result['avatar']!),
|
||||||
.add(SaveProfileEvent(result['name']!, result['avatar']!));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _content(BuildContext context, ProfileEntity d) {
|
Widget _content(BuildContext context, ProfileEntity d) {
|
||||||
@@ -79,87 +89,112 @@ class ProfileScreen extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Row(children: [
|
Row(
|
||||||
IconButton(
|
children: [
|
||||||
onPressed: () => context.pop(),
|
IconButton(
|
||||||
icon: const Icon(Icons.arrow_back, color: AppColors.gold),
|
onPressed: () => context.pop(),
|
||||||
),
|
icon: const Icon(Icons.arrow_back, color: AppColors.gold),
|
||||||
const Spacer(),
|
),
|
||||||
const GlowText('پروفایل', size: 24),
|
const Spacer(),
|
||||||
const Spacer(),
|
const GlowText('پروفایل', size: 24),
|
||||||
const SizedBox(width: 48),
|
const Spacer(),
|
||||||
]),
|
const SizedBox(width: 48),
|
||||||
|
],
|
||||||
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
GamePanel(
|
GamePanel(
|
||||||
child: Column(children: [
|
child: Column(
|
||||||
Stack(children: [
|
children: [
|
||||||
Container(
|
Stack(
|
||||||
padding: const EdgeInsets.all(6),
|
children: [
|
||||||
decoration: BoxDecoration(
|
Container(
|
||||||
shape: BoxShape.circle,
|
|
||||||
border: Border.all(color: AppColors.gold, width: 2.5),
|
|
||||||
),
|
|
||||||
child: RandomAvatar(d.avatar, height: 92, width: 92),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
bottom: 0,
|
|
||||||
right: 0,
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () => _editProfile(context, d),
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.all(6),
|
padding: const EdgeInsets.all(6),
|
||||||
decoration: const BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
gradient: LinearGradient(
|
border: Border.all(color: AppColors.gold, width: 2.5),
|
||||||
colors: [Color(0xFFFFD54F), Color(0xFFB8860B)]),
|
|
||||||
),
|
),
|
||||||
child: const Icon(Icons.edit,
|
child: RandomAvatar(d.avatar, height: 92, width: 92),
|
||||||
color: Color(0xFF3A0A12), size: 18),
|
|
||||||
),
|
),
|
||||||
),
|
Positioned(
|
||||||
|
bottom: 0,
|
||||||
|
right: 0,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () => _editProfile(context, d),
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(6),
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: [Color(0xFFFFD54F), Color(0xFFB8860B)],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: const Icon(
|
||||||
|
Icons.edit,
|
||||||
|
color: Color(0xFF3A0A12),
|
||||||
|
size: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
]),
|
const SizedBox(height: 10),
|
||||||
const SizedBox(height: 10),
|
Row(
|
||||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
Flexible(child: GlowText(d.name, size: 22)),
|
children: [
|
||||||
if (d.vip) ...[const SizedBox(width: 8), const _VipBadge()],
|
Flexible(child: GlowText(d.name, size: 22)),
|
||||||
]),
|
if (d.vip) ...[const SizedBox(width: 8), const _VipBadge()],
|
||||||
if (d.mobile.isNotEmpty)
|
],
|
||||||
Text(d.mobile,
|
),
|
||||||
style:
|
if (d.mobile.isNotEmpty)
|
||||||
const TextStyle(color: Colors.white38, fontSize: 12)),
|
Text(
|
||||||
const SizedBox(height: 14),
|
d.mobile,
|
||||||
Row(children: [
|
style: const TextStyle(color: Colors.white38, fontSize: 12),
|
||||||
Expanded(
|
),
|
||||||
child: _MiniStat(
|
const SizedBox(height: 14),
|
||||||
icon: Icons.star, label: 'سطح', value: '${d.level}')),
|
Row(
|
||||||
Expanded(
|
children: [
|
||||||
child: _MiniStat(
|
Expanded(
|
||||||
|
child: _MiniStat(
|
||||||
|
icon: Icons.star,
|
||||||
|
label: 'سطح',
|
||||||
|
value: '${d.level}',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: _MiniStat(
|
||||||
icon: Icons.emoji_events,
|
icon: Icons.emoji_events,
|
||||||
label: 'جام',
|
label: 'جام',
|
||||||
value: '${d.trophies}')),
|
value: '${d.trophies}',
|
||||||
]),
|
),
|
||||||
const SizedBox(height: 10),
|
),
|
||||||
ClipRRect(
|
],
|
||||||
borderRadius: BorderRadius.circular(5),
|
|
||||||
child: LinearProgressIndicator(
|
|
||||||
value: d.xpNext == 0 ? 0 : d.xpInto / d.xpNext,
|
|
||||||
minHeight: 8,
|
|
||||||
backgroundColor: Colors.white10,
|
|
||||||
valueColor: const AlwaysStoppedAnimation(AppColors.gold),
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 10),
|
||||||
Padding(
|
ClipRRect(
|
||||||
padding: const EdgeInsets.only(top: 4),
|
borderRadius: BorderRadius.circular(5),
|
||||||
child: Text('${d.xpInto} / ${d.xpNext} XP',
|
child: LinearProgressIndicator(
|
||||||
style: const TextStyle(color: Colors.white38, fontSize: 11)),
|
value: d.xpNext == 0 ? 0 : d.xpInto / d.xpNext,
|
||||||
),
|
minHeight: 8,
|
||||||
]),
|
backgroundColor: Colors.white10,
|
||||||
|
valueColor: const AlwaysStoppedAnimation(AppColors.gold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 4),
|
||||||
|
child: Text(
|
||||||
|
'${d.xpInto} / ${d.xpNext} XP',
|
||||||
|
style: const TextStyle(color: Colors.white38, fontSize: 11),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
const Align(
|
const Align(
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: GlowText('آمار بازی', size: 18)),
|
child: GlowText('آمار بازی', size: 18),
|
||||||
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
_statsSection(context, d),
|
_statsSection(context, d),
|
||||||
],
|
],
|
||||||
@@ -181,43 +216,47 @@ class ProfileScreen extends StatelessWidget {
|
|||||||
final panel = GamePanel(child: Column(children: rows));
|
final panel = GamePanel(child: Column(children: rows));
|
||||||
if (d.vip) return panel;
|
if (d.vip) return panel;
|
||||||
|
|
||||||
return Stack(children: [
|
return Stack(
|
||||||
Opacity(opacity: 0.35, child: IgnorePointer(child: panel)),
|
children: [
|
||||||
Positioned.fill(
|
Opacity(opacity: 0.35, child: IgnorePointer(child: panel)),
|
||||||
child: Container(
|
Positioned.fill(
|
||||||
decoration: BoxDecoration(
|
child: Container(
|
||||||
color: Colors.black.withValues(alpha: 0.45),
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(16),
|
color: Colors.black.withValues(alpha: 0.45),
|
||||||
border: Border.all(color: AppColors.goldDark),
|
borderRadius: BorderRadius.circular(16),
|
||||||
),
|
border: Border.all(color: AppColors.goldDark),
|
||||||
child: Column(
|
),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
child: Column(
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
const Icon(Icons.lock, color: AppColors.gold, size: 36),
|
children: [
|
||||||
const SizedBox(height: 8),
|
const Icon(Icons.lock, color: AppColors.gold, size: 36),
|
||||||
const Padding(
|
const SizedBox(height: 8),
|
||||||
padding: EdgeInsets.symmetric(horizontal: 24),
|
const Padding(
|
||||||
child: Text('مشاهدهی آمار ویژهی کاربران VIP است',
|
padding: EdgeInsets.symmetric(horizontal: 24),
|
||||||
|
child: Text(
|
||||||
|
'مشاهدهی آمار ویژهی کاربران VIP است',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(color: Colors.white, fontSize: 14)),
|
style: TextStyle(color: Colors.white, fontSize: 14),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
),
|
||||||
GameButton(
|
const SizedBox(height: 12),
|
||||||
label: 'تهیه اشتراک VIP',
|
GameButton(
|
||||||
icon: Icons.workspace_premium,
|
label: 'تهیه اشتراک VIP',
|
||||||
colors: const [Color(0xFFFFC107), Color(0xFFB8860B)],
|
icon: Icons.workspace_premium,
|
||||||
onTap: () async {
|
colors: const [Color(0xFFFFC107), Color(0xFFB8860B)],
|
||||||
await context.push('/vip');
|
onTap: () async {
|
||||||
if (context.mounted) {
|
await context.push('/vip');
|
||||||
context.read<ProfileBloc>().add(LoadProfileEvent());
|
if (context.mounted) {
|
||||||
}
|
context.read<ProfileBloc>().add(LoadProfileEvent());
|
||||||
},
|
}
|
||||||
),
|
},
|
||||||
],
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
]);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,17 +269,25 @@ class _StatRow extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 7),
|
padding: const EdgeInsets.symmetric(vertical: 7),
|
||||||
child: Row(children: [
|
child: Row(
|
||||||
Icon(icon, color: AppColors.gold, size: 20),
|
children: [
|
||||||
const SizedBox(width: 10),
|
Icon(icon, color: AppColors.gold, size: 20),
|
||||||
Text(label, style: const TextStyle(color: Colors.white, fontSize: 15)),
|
const SizedBox(width: 10),
|
||||||
const Spacer(),
|
Text(
|
||||||
Text('${value ?? '—'}',
|
label,
|
||||||
|
style: const TextStyle(color: Colors.white, fontSize: 15),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Text(
|
||||||
|
'${value ?? '—'}',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: AppColors.gold,
|
color: AppColors.gold,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.bold)),
|
fontWeight: FontWeight.bold,
|
||||||
]),
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,18 +296,31 @@ class _MiniStat extends StatelessWidget {
|
|||||||
final IconData icon;
|
final IconData icon;
|
||||||
final String label;
|
final String label;
|
||||||
final String value;
|
final String value;
|
||||||
const _MiniStat(
|
const _MiniStat({
|
||||||
{required this.icon, required this.label, required this.value});
|
required this.icon,
|
||||||
|
required this.label,
|
||||||
|
required this.value,
|
||||||
|
});
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(children: [
|
return Column(
|
||||||
Icon(icon, color: AppColors.gold, size: 22),
|
children: [
|
||||||
const SizedBox(height: 2),
|
Icon(icon, color: AppColors.gold, size: 22),
|
||||||
Text(value,
|
const SizedBox(height: 2),
|
||||||
|
Text(
|
||||||
|
value,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold)),
|
color: Colors.white,
|
||||||
Text(label, style: const TextStyle(color: Colors.white54, fontSize: 12)),
|
fontSize: 18,
|
||||||
]);
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
label,
|
||||||
|
style: const TextStyle(color: Colors.white54, fontSize: 12),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,15 +331,19 @@ class _VipBadge extends StatelessWidget {
|
|||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient:
|
gradient: const LinearGradient(
|
||||||
const LinearGradient(colors: [Color(0xFFFFD54F), Color(0xFFB8860B)]),
|
colors: [Color(0xFFFFD54F), Color(0xFFB8860B)],
|
||||||
|
),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: const Text('VIP',
|
child: const Text(
|
||||||
style: TextStyle(
|
'VIP',
|
||||||
color: Color(0xFF3A0A12),
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
color: Color(0xFF3A0A12),
|
||||||
fontSize: 12)),
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -318,81 +382,97 @@ class _EditProfileSheetState extends State<_EditProfileSheet> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Padding(
|
return SafeArea(
|
||||||
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
top: false,
|
||||||
child: Container(
|
child: Padding(
|
||||||
decoration: const BoxDecoration(
|
padding: EdgeInsets.only(
|
||||||
color: AppColors.bgDark,
|
bottom: MediaQuery.of(context).viewInsets.bottom,
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
|
||||||
border: Border(top: BorderSide(color: AppColors.gold, width: 2)),
|
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.all(18),
|
child: Container(
|
||||||
child: SingleChildScrollView(
|
decoration: const BoxDecoration(
|
||||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
color: AppColors.bgDark,
|
||||||
const GlowText('ویرایش پروفایل', size: 20),
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||||
const SizedBox(height: 14),
|
border: Border(top: BorderSide(color: AppColors.gold, width: 2)),
|
||||||
Container(
|
),
|
||||||
padding: const EdgeInsets.all(4),
|
padding: const EdgeInsets.all(18),
|
||||||
decoration: BoxDecoration(
|
child: SingleChildScrollView(
|
||||||
shape: BoxShape.circle,
|
child: Column(
|
||||||
border: Border.all(color: AppColors.gold, width: 2),
|
mainAxisSize: MainAxisSize.min,
|
||||||
),
|
|
||||||
child: RandomAvatar(_selected, height: 72, width: 72),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
TextField(
|
|
||||||
controller: _name,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
maxLength: 20,
|
|
||||||
inputFormatters: [LengthLimitingTextInputFormatter(20)],
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
hintText: 'نام نمایشی (۲ تا ۲۰ حرف)', counterText: ''),
|
|
||||||
onChanged: (_) => setState(() {}),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
const Align(
|
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child:
|
|
||||||
Text('انتخاب آواتار', style: TextStyle(color: AppColors.gold)),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
GridView.count(
|
|
||||||
crossAxisCount: 4,
|
|
||||||
shrinkWrap: true,
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
mainAxisSpacing: 10,
|
|
||||||
crossAxisSpacing: 10,
|
|
||||||
children: [
|
children: [
|
||||||
for (final s in _seeds)
|
const GlowText('ویرایش پروفایل', size: 20),
|
||||||
GestureDetector(
|
const SizedBox(height: 14),
|
||||||
onTap: () => setState(() => _selected = s),
|
Container(
|
||||||
child: Container(
|
padding: const EdgeInsets.all(4),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
color: AppColors.panel,
|
border: Border.all(color: AppColors.gold, width: 2),
|
||||||
border: Border.all(
|
),
|
||||||
color: _selected == s
|
child: RandomAvatar(_selected, height: 72, width: 72),
|
||||||
? AppColors.gold
|
),
|
||||||
: Colors.transparent,
|
const SizedBox(height: 12),
|
||||||
width: 2.5,
|
TextField(
|
||||||
|
controller: _name,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
maxLength: 20,
|
||||||
|
inputFormatters: [LengthLimitingTextInputFormatter(20)],
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
hintText: 'نام نمایشی (۲ تا ۲۰ حرف)',
|
||||||
|
counterText: '',
|
||||||
|
),
|
||||||
|
onChanged: (_) => setState(() {}),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
const Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: Text(
|
||||||
|
'انتخاب آواتار',
|
||||||
|
style: TextStyle(color: AppColors.gold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
GridView.count(
|
||||||
|
crossAxisCount: 4,
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
mainAxisSpacing: 10,
|
||||||
|
crossAxisSpacing: 10,
|
||||||
|
children: [
|
||||||
|
for (final s in _seeds)
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () => setState(() => _selected = s),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: AppColors.panel,
|
||||||
|
border: Border.all(
|
||||||
|
color:
|
||||||
|
_selected == s
|
||||||
|
? AppColors.gold
|
||||||
|
: Colors.transparent,
|
||||||
|
width: 2.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: RandomAvatar(s),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: RandomAvatar(s),
|
],
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 16),
|
||||||
|
GameButton(
|
||||||
|
label: 'تأیید',
|
||||||
|
width: double.infinity,
|
||||||
|
colors: const [Color(0xFF3FA34D), Color(0xFF1B5E20)],
|
||||||
|
onTap:
|
||||||
|
_valid
|
||||||
|
? () => Navigator.pop(context, {
|
||||||
|
'name': _name.text.trim(),
|
||||||
|
'avatar': _selected,
|
||||||
|
})
|
||||||
|
: null,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
),
|
||||||
GameButton(
|
|
||||||
label: 'تأیید',
|
|
||||||
width: double.infinity,
|
|
||||||
colors: const [Color(0xFF3FA34D), Color(0xFF1B5E20)],
|
|
||||||
onTap: _valid
|
|
||||||
? () => Navigator.pop(
|
|
||||||
context, {'name': _name.text.trim(), 'avatar': _selected})
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user