NUEVA GESTIÓN DE USUARIOS Y PARTIDAS
This commit is contained in:
@@ -16,7 +16,14 @@ import 'pantalla_principal.dart';
|
||||
import 'pantalla_ver_palabra.dart';
|
||||
|
||||
class PantallaCrearPartida extends StatefulWidget {
|
||||
const PantallaCrearPartida({super.key});
|
||||
final bool modoInicial;
|
||||
final bool bloquearModo;
|
||||
|
||||
const PantallaCrearPartida({
|
||||
super.key,
|
||||
this.modoInicial = false,
|
||||
this.bloquearModo = false,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PantallaCrearPartida> createState() => _PantallaCrearPartidaState();
|
||||
@@ -33,7 +40,14 @@ class _PantallaCrearPartidaState extends State<PantallaCrearPartida> {
|
||||
|
||||
final _opcionesTiempo = <int?>[null, 60, 120, 180, 300];
|
||||
|
||||
int get _maxImpostores => (_jugadores.length / 3).floor().clamp(1, 4);
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_modoMultimovil = widget.modoInicial;
|
||||
}
|
||||
|
||||
int get _maxImpostores =>
|
||||
_modoMultimovil ? 4 : (_jugadores.length / 3).floor().clamp(1, 4);
|
||||
|
||||
List<String> _etiquetasTiempo(AppLocalizations l10n) => [
|
||||
l10n.noLimit,
|
||||
@@ -295,42 +309,70 @@ class _PantallaCrearPartidaState extends State<PantallaCrearPartida> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
// Modo de juego
|
||||
Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
if (!widget.bloquearModo) ...[
|
||||
// Modo de juego
|
||||
Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
l10n.gameMode,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SegmentedButton<bool>(
|
||||
segments: [
|
||||
ButtonSegment(
|
||||
value: false,
|
||||
label: Text(l10n.singleDevice),
|
||||
icon: const Icon(Icons.phone_android),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: true,
|
||||
label: Text(l10n.multiDevice),
|
||||
icon: const Icon(Icons.devices),
|
||||
),
|
||||
],
|
||||
selected: {_modoMultimovil},
|
||||
onSelectionChanged: (valor) {
|
||||
setState(() {
|
||||
_modoMultimovil = valor.first;
|
||||
if (_numImpostores > _maxImpostores) {
|
||||
_numImpostores = _maxImpostores;
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
] else ...[
|
||||
PanelFarolero(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
l10n.gameMode,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
Icon(
|
||||
_modoMultimovil ? Icons.devices : Icons.phone_android,
|
||||
color: TemaApp.colorNaranja,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SegmentedButton<bool>(
|
||||
segments: [
|
||||
ButtonSegment(
|
||||
value: false,
|
||||
label: Text(l10n.singleDevice),
|
||||
icon: const Icon(Icons.phone_android),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: true,
|
||||
label: Text(l10n.multiDevice),
|
||||
icon: const Icon(Icons.devices),
|
||||
),
|
||||
],
|
||||
selected: {_modoMultimovil},
|
||||
onSelectionChanged: (valor) {
|
||||
setState(() => _modoMultimovil = valor.first);
|
||||
},
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
_modoMultimovil
|
||||
? 'Partida multidispositivo'
|
||||
: 'Partida en este dispositivo',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
// Categoría
|
||||
Card(
|
||||
child: Padding(
|
||||
@@ -367,13 +409,14 @@ class _PantallaCrearPartidaState extends State<PantallaCrearPartida> {
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Jugadores
|
||||
Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (!_modoMultimovil) ...[
|
||||
// Jugadores
|
||||
Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@@ -429,11 +472,12 @@ class _PantallaCrearPartidaState extends State<PantallaCrearPartida> {
|
||||
dense: true,
|
||||
);
|
||||
}),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
|
||||
// Configuración de partida
|
||||
Card(
|
||||
|
||||
Reference in New Issue
Block a user