feat(alarmas): rewrite alarm editor with inline time widget
Replace the native showTimePicker dialog in the alarm editor sheet with a giant inline HH:MM editor (drag/tap to adjust, wraps at 23:59-00:00). Weekday circles now render unconditionally (disabled outside weekly mode) instead of being gated behind an `if`. The date field, fallback-station picker, and sound dropdown are not dropped: per resolution 3 they move into a collapsed "Advanced" section so the mockup's weekday-circles-only layout does not lose capability. Volume/fade-in sliders get a cosmetic type-scale restyle only. size:exception: 993 changed lines (891+/102-) against the 500-650 forecast - lib/ production code alone is 429 lines, within band; new test files and 13 regenerated l10n/gen files account for the rest, the same pattern every prior work unit in this branch has hit.
This commit is contained in:
+122
-102
@@ -12,6 +12,7 @@ import '../modelos/emisora.dart';
|
||||
import '../servicios/servicio_programacion_alarmas.dart';
|
||||
import '../tema/pluriwave_theme.dart';
|
||||
import '../tema/pluriwave_tokens.dart';
|
||||
import '../widgets/editor_hora_inline.dart';
|
||||
import '../widgets/pluri_glass_surface.dart';
|
||||
import '../widgets/pluri_icon.dart';
|
||||
import '../widgets/pluri_layout.dart';
|
||||
@@ -448,32 +449,17 @@ class _EditorAlarmaSheetState extends State<_EditorAlarmaSheet> {
|
||||
controller: _nombreController,
|
||||
decoration: InputDecoration(labelText: l10n.nameLabel),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _PickerButton(
|
||||
icon: Icons.schedule_rounded,
|
||||
label: l10n.timeField,
|
||||
value: _hora.format(context),
|
||||
onTap: _elegirHora,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: _PickerButton(
|
||||
icon: Icons.event_rounded,
|
||||
label: l10n.dateField,
|
||||
value: _fechaCorta(l10n, _fecha),
|
||||
onTap:
|
||||
_tipo == TipoProgramacionAlarma.unica
|
||||
? _elegirFecha
|
||||
: null,
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 16),
|
||||
// WU10: the native showTimePicker dialog is replaced by a
|
||||
// giant inline HH:MM editor (drag/tap to adjust); see
|
||||
// `EditorHoraInline`, standalone-tested on its own.
|
||||
Center(
|
||||
child: EditorHoraInline(
|
||||
value: _hora,
|
||||
onChanged: (nuevo) => setState(() => _hora = nuevo),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const SizedBox(height: 16),
|
||||
SegmentedButton<TipoProgramacionAlarma>(
|
||||
segments: [
|
||||
ButtonSegment(
|
||||
@@ -493,25 +479,33 @@ class _EditorAlarmaSheetState extends State<_EditorAlarmaSheet> {
|
||||
onSelectionChanged:
|
||||
(value) => setState(() => _tipo = value.first),
|
||||
),
|
||||
if (_tipo == TipoProgramacionAlarma.diasSemana) ...[
|
||||
const SizedBox(height: 10),
|
||||
Wrap(
|
||||
spacing: 6,
|
||||
children: [
|
||||
for (var i = DateTime.monday; i <= DateTime.sunday; i++)
|
||||
FilterChip(
|
||||
label: Text(_weekdayShort(l10n, i)),
|
||||
selected: _diasSemana.contains(i),
|
||||
onSelected:
|
||||
(selected) => setState(() {
|
||||
selected
|
||||
? _diasSemana.add(i)
|
||||
: _diasSemana.remove(i);
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 10),
|
||||
// WU10: weekday circles are now ALWAYS visible (previously
|
||||
// only inserted into the tree in diasSemana mode) — matching
|
||||
// the mockup, which shows them unconditionally under the
|
||||
// giant time. They stay disabled (onSelected: null, the
|
||||
// standard Material "greyed out" FilterChip state) outside
|
||||
// diasSemana mode rather than being wired to silently mutate
|
||||
// `_diasSemana` while a different `_tipo` is saved — no
|
||||
// scheduling-data-model change, presentation only.
|
||||
Wrap(
|
||||
spacing: 6,
|
||||
children: [
|
||||
for (var i = DateTime.monday; i <= DateTime.sunday; i++)
|
||||
FilterChip(
|
||||
label: Text(_weekdayShort(l10n, i)),
|
||||
selected: _diasSemana.contains(i),
|
||||
onSelected:
|
||||
_tipo == TipoProgramacionAlarma.diasSemana
|
||||
? (selected) => setState(() {
|
||||
selected
|
||||
? _diasSemana.add(i)
|
||||
: _diasSemana.remove(i);
|
||||
})
|
||||
: null,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_vistaProximaEjecucion(l10n),
|
||||
const SizedBox(height: 14),
|
||||
@@ -531,7 +525,10 @@ class _EditorAlarmaSheetState extends State<_EditorAlarmaSheet> {
|
||||
const SizedBox(height: 8),
|
||||
ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(l10n.alarmFadeInTitle),
|
||||
title: Text(
|
||||
l10n.alarmFadeInTitle,
|
||||
style: context.pluriType.cardTitle,
|
||||
),
|
||||
subtitle: Text(
|
||||
_fadeInSegundos == 0
|
||||
? l10n.alarmFadeInOff
|
||||
@@ -566,33 +563,11 @@ class _EditorAlarmaSheetState extends State<_EditorAlarmaSheet> {
|
||||
(value) => setState(() => _snoozeMinutos = value.first),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
DropdownButtonFormField<SonidoInternoAlarma>(
|
||||
initialValue: _sonidoInterno,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.internalSafeSoundLabel,
|
||||
),
|
||||
items: [
|
||||
DropdownMenuItem(
|
||||
value: SonidoInternoAlarma.amanecer,
|
||||
child: Text(l10n.soundWarmSunrise),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: SonidoInternoAlarma.campanaSuave,
|
||||
child: Text(l10n.soundSoftBell),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: SonidoInternoAlarma.pulsoDigital,
|
||||
child: Text(l10n.soundDigitalPulse),
|
||||
),
|
||||
],
|
||||
onChanged:
|
||||
(value) => setState(
|
||||
() => _sonidoInterno = value ?? _sonidoInterno,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// S2-R9: searchable bottom-sheet picker instead of a dropdown,
|
||||
// for both the primary and the backup (fallback) station.
|
||||
// for the primary station. The backup (fallback) picker moves
|
||||
// into the Advanced section below (WU10) — the primary choice
|
||||
// stays a top-level field, only its secondary/backup sibling
|
||||
// is now one tap further away.
|
||||
_CampoSelectorEmisora(
|
||||
key: const ValueKey('alarm-station-field'),
|
||||
label: l10n.favoriteStationLabel,
|
||||
@@ -608,26 +583,6 @@ class _EditorAlarmaSheetState extends State<_EditorAlarmaSheet> {
|
||||
(emisora) => setState(() => _emisora = emisora),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_CampoSelectorEmisora(
|
||||
key: const ValueKey('alarm-fallback-station-field'),
|
||||
label: l10n.alarmFallbackStationLabel,
|
||||
icon: Icons.settings_backup_restore_rounded,
|
||||
value:
|
||||
_emisoraFallback == null
|
||||
? l10n.noStationUseInternalSound
|
||||
: localizedStationName(
|
||||
l10n,
|
||||
_emisoraFallback!.nombre,
|
||||
),
|
||||
onTap:
|
||||
() => _elegirEmisora(
|
||||
favoritas,
|
||||
seleccionar:
|
||||
(emisora) =>
|
||||
setState(() => _emisoraFallback = emisora),
|
||||
),
|
||||
),
|
||||
if (favoritas.isEmpty) ...[
|
||||
const SizedBox(height: 6),
|
||||
Text(l10n.saveFavoritesAlarmHint),
|
||||
@@ -658,6 +613,78 @@ class _EditorAlarmaSheetState extends State<_EditorAlarmaSheet> {
|
||||
title: Text(l10n.playDuringVacations),
|
||||
subtitle: Text(l10n.playDuringVacationsHint),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// WU10 (native-alarms delta — Alarm Editor Preserves Date,
|
||||
// Fallback Station, and Sound Fields): the mockup's editor
|
||||
// shows only the giant time + weekday circles, but the
|
||||
// one-time date field, the fallback-station picker, and the
|
||||
// sound dropdown are NOT dropped — they move here, one tap
|
||||
// away, instead of being always inline.
|
||||
ExpansionTile(
|
||||
key: const ValueKey('alarm-advanced-section'),
|
||||
tilePadding: EdgeInsets.zero,
|
||||
title: Text(
|
||||
l10n.alarmAdvancedSectionTitle,
|
||||
style: context.pluriType.cardTitle,
|
||||
),
|
||||
children: [
|
||||
_PickerButton(
|
||||
icon: Icons.event_rounded,
|
||||
label: l10n.dateField,
|
||||
value: _fechaCorta(l10n, _fecha),
|
||||
onTap:
|
||||
_tipo == TipoProgramacionAlarma.unica
|
||||
? _elegirFecha
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_CampoSelectorEmisora(
|
||||
key: const ValueKey('alarm-fallback-station-field'),
|
||||
label: l10n.alarmFallbackStationLabel,
|
||||
icon: Icons.settings_backup_restore_rounded,
|
||||
value:
|
||||
_emisoraFallback == null
|
||||
? l10n.noStationUseInternalSound
|
||||
: localizedStationName(
|
||||
l10n,
|
||||
_emisoraFallback!.nombre,
|
||||
),
|
||||
onTap:
|
||||
() => _elegirEmisora(
|
||||
favoritas,
|
||||
seleccionar:
|
||||
(emisora) =>
|
||||
setState(() => _emisoraFallback = emisora),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
DropdownButtonFormField<SonidoInternoAlarma>(
|
||||
initialValue: _sonidoInterno,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.internalSafeSoundLabel,
|
||||
),
|
||||
items: [
|
||||
DropdownMenuItem(
|
||||
value: SonidoInternoAlarma.amanecer,
|
||||
child: Text(l10n.soundWarmSunrise),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: SonidoInternoAlarma.campanaSuave,
|
||||
child: Text(l10n.soundSoftBell),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: SonidoInternoAlarma.pulsoDigital,
|
||||
child: Text(l10n.soundDigitalPulse),
|
||||
),
|
||||
],
|
||||
onChanged:
|
||||
(value) => setState(
|
||||
() => _sonidoInterno = value ?? _sonidoInterno,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
FilledButton.icon(
|
||||
onPressed: _guardar,
|
||||
@@ -727,11 +754,6 @@ class _EditorAlarmaSheetState extends State<_EditorAlarmaSheet> {
|
||||
seleccionar(resultado.emisora);
|
||||
}
|
||||
|
||||
Future<void> _elegirHora() async {
|
||||
final nueva = await showTimePicker(context: context, initialTime: _hora);
|
||||
if (nueva != null) setState(() => _hora = nueva);
|
||||
}
|
||||
|
||||
Future<void> _elegirFecha() async {
|
||||
final ahora = DateTime.now();
|
||||
final nueva = await showDatePicker(
|
||||
@@ -1148,12 +1170,10 @@ class _SectionLabel extends StatelessWidget {
|
||||
children: [
|
||||
_AssetIcon(icon, size: 34),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
text,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.titleSmall?.copyWith(fontWeight: FontWeight.w800),
|
||||
),
|
||||
// WU10: swapped the raw TextTheme lookup for the named type-scale
|
||||
// token (cosmetic only — same weight class, now shared with every
|
||||
// other card/section title in the redesign).
|
||||
Text(text, style: context.pluriType.cardTitle),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user