mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-08-17 16:37:31 +02:00
finish localizations. prev commit also fixed client id / deflockapp auth
This commit is contained in:
@@ -176,5 +176,40 @@
|
|||||||
"mapTiles": {
|
"mapTiles": {
|
||||||
"title": "Karten-Kacheln",
|
"title": "Karten-Kacheln",
|
||||||
"manageProviders": "Anbieter Verwalten"
|
"manageProviders": "Anbieter Verwalten"
|
||||||
|
},
|
||||||
|
"profileEditor": {
|
||||||
|
"viewProfile": "Profil Anzeigen",
|
||||||
|
"newProfile": "Neues Profil",
|
||||||
|
"editProfile": "Profil Bearbeiten",
|
||||||
|
"profileName": "Profil-Name",
|
||||||
|
"profileNameHint": "z.B. Benutzerdefinierte ALPR-Kamera",
|
||||||
|
"profileNameRequired": "Profil-Name ist erforderlich",
|
||||||
|
"requiresDirection": "Benötigt Richtung",
|
||||||
|
"requiresDirectionSubtitle": "Ob Kameras dieses Typs ein Richtungs-Tag benötigen",
|
||||||
|
"submittable": "Übertragbar",
|
||||||
|
"submittableSubtitle": "Ob dieses Profil für Kamera-Übertragungen verwendet werden kann",
|
||||||
|
"osmTags": "OSM-Tags",
|
||||||
|
"addTag": "Tag Hinzufügen",
|
||||||
|
"saveProfile": "Profil Speichern",
|
||||||
|
"keyHint": "Schlüssel",
|
||||||
|
"valueHint": "Wert",
|
||||||
|
"atLeastOneTagRequired": "Mindestens ein Tag ist erforderlich",
|
||||||
|
"profileSaved": "Profil \"{}\" gespeichert"
|
||||||
|
},
|
||||||
|
"operatorProfileEditor": {
|
||||||
|
"newOperatorProfile": "Neues Betreiber-Profil",
|
||||||
|
"editOperatorProfile": "Betreiber-Profil Bearbeiten",
|
||||||
|
"operatorName": "Betreiber-Name",
|
||||||
|
"operatorNameHint": "z.B. Polizei Austin",
|
||||||
|
"operatorNameRequired": "Betreiber-Name ist erforderlich",
|
||||||
|
"operatorProfileSaved": "Betreiber-Profil \"{}\" gespeichert"
|
||||||
|
},
|
||||||
|
"operatorProfiles": {
|
||||||
|
"title": "Betreiber-Profile",
|
||||||
|
"noProfilesMessage": "Keine Betreiber-Profile definiert. Erstellen Sie eines, um Betreiber-Tags auf Knoten-Übertragungen anzuwenden.",
|
||||||
|
"tagsCount": "{} Tags",
|
||||||
|
"deleteOperatorProfile": "Betreiber-Profil Löschen",
|
||||||
|
"deleteOperatorProfileConfirm": "Sind Sie sicher, dass Sie \"{}\" löschen möchten?",
|
||||||
|
"operatorProfileDeleted": "Betreiber-Profil gelöscht"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,5 +176,40 @@
|
|||||||
"mapTiles": {
|
"mapTiles": {
|
||||||
"title": "Map Tiles",
|
"title": "Map Tiles",
|
||||||
"manageProviders": "Manage Providers"
|
"manageProviders": "Manage Providers"
|
||||||
|
},
|
||||||
|
"profileEditor": {
|
||||||
|
"viewProfile": "View Profile",
|
||||||
|
"newProfile": "New Profile",
|
||||||
|
"editProfile": "Edit Profile",
|
||||||
|
"profileName": "Profile name",
|
||||||
|
"profileNameHint": "e.g., Custom ALPR Camera",
|
||||||
|
"profileNameRequired": "Profile name is required",
|
||||||
|
"requiresDirection": "Requires Direction",
|
||||||
|
"requiresDirectionSubtitle": "Whether cameras of this type need a direction tag",
|
||||||
|
"submittable": "Submittable",
|
||||||
|
"submittableSubtitle": "Whether this profile can be used for camera submissions",
|
||||||
|
"osmTags": "OSM Tags",
|
||||||
|
"addTag": "Add tag",
|
||||||
|
"saveProfile": "Save Profile",
|
||||||
|
"keyHint": "key",
|
||||||
|
"valueHint": "value",
|
||||||
|
"atLeastOneTagRequired": "At least one tag is required",
|
||||||
|
"profileSaved": "Profile \"{}\" saved"
|
||||||
|
},
|
||||||
|
"operatorProfileEditor": {
|
||||||
|
"newOperatorProfile": "New Operator Profile",
|
||||||
|
"editOperatorProfile": "Edit Operator Profile",
|
||||||
|
"operatorName": "Operator name",
|
||||||
|
"operatorNameHint": "e.g., Austin Police Department",
|
||||||
|
"operatorNameRequired": "Operator name is required",
|
||||||
|
"operatorProfileSaved": "Operator profile \"{}\" saved"
|
||||||
|
},
|
||||||
|
"operatorProfiles": {
|
||||||
|
"title": "Operator Profiles",
|
||||||
|
"noProfilesMessage": "No operator profiles defined. Create one to apply operator tags to node submissions.",
|
||||||
|
"tagsCount": "{} tags",
|
||||||
|
"deleteOperatorProfile": "Delete Operator Profile",
|
||||||
|
"deleteOperatorProfileConfirm": "Are you sure you want to delete \"{}\"?",
|
||||||
|
"operatorProfileDeleted": "Operator profile deleted"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,5 +176,40 @@
|
|||||||
"mapTiles": {
|
"mapTiles": {
|
||||||
"title": "Tiles de Mapa",
|
"title": "Tiles de Mapa",
|
||||||
"manageProviders": "Gestionar Proveedores"
|
"manageProviders": "Gestionar Proveedores"
|
||||||
|
},
|
||||||
|
"profileEditor": {
|
||||||
|
"viewProfile": "Ver Perfil",
|
||||||
|
"newProfile": "Nuevo Perfil",
|
||||||
|
"editProfile": "Editar Perfil",
|
||||||
|
"profileName": "Nombre del perfil",
|
||||||
|
"profileNameHint": "ej., Cámara ALPR Personalizada",
|
||||||
|
"profileNameRequired": "El nombre del perfil es requerido",
|
||||||
|
"requiresDirection": "Requiere Dirección",
|
||||||
|
"requiresDirectionSubtitle": "Si las cámaras de este tipo necesitan una etiqueta de dirección",
|
||||||
|
"submittable": "Envíable",
|
||||||
|
"submittableSubtitle": "Si este perfil puede usarse para envíos de cámaras",
|
||||||
|
"osmTags": "Etiquetas OSM",
|
||||||
|
"addTag": "Agregar Etiqueta",
|
||||||
|
"saveProfile": "Guardar Perfil",
|
||||||
|
"keyHint": "clave",
|
||||||
|
"valueHint": "valor",
|
||||||
|
"atLeastOneTagRequired": "Se requiere al menos una etiqueta",
|
||||||
|
"profileSaved": "Perfil \"{}\" guardado"
|
||||||
|
},
|
||||||
|
"operatorProfileEditor": {
|
||||||
|
"newOperatorProfile": "Nuevo Perfil de Operador",
|
||||||
|
"editOperatorProfile": "Editar Perfil de Operador",
|
||||||
|
"operatorName": "Nombre del operador",
|
||||||
|
"operatorNameHint": "ej., Departamento de Policía de Austin",
|
||||||
|
"operatorNameRequired": "El nombre del operador es requerido",
|
||||||
|
"operatorProfileSaved": "Perfil de operador \"{}\" guardado"
|
||||||
|
},
|
||||||
|
"operatorProfiles": {
|
||||||
|
"title": "Perfiles de Operador",
|
||||||
|
"noProfilesMessage": "No hay perfiles de operador definidos. Cree uno para aplicar etiquetas de operador a los envíos de nodos.",
|
||||||
|
"tagsCount": "{} etiquetas",
|
||||||
|
"deleteOperatorProfile": "Eliminar Perfil de Operador",
|
||||||
|
"deleteOperatorProfileConfirm": "¿Está seguro de que desea eliminar \"{}\"?",
|
||||||
|
"operatorProfileDeleted": "Perfil de operador eliminado"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,5 +176,40 @@
|
|||||||
"mapTiles": {
|
"mapTiles": {
|
||||||
"title": "Tuiles de Carte",
|
"title": "Tuiles de Carte",
|
||||||
"manageProviders": "Gérer Fournisseurs"
|
"manageProviders": "Gérer Fournisseurs"
|
||||||
|
},
|
||||||
|
"profileEditor": {
|
||||||
|
"viewProfile": "Voir Profil",
|
||||||
|
"newProfile": "Nouveau Profil",
|
||||||
|
"editProfile": "Modifier Profil",
|
||||||
|
"profileName": "Nom du profil",
|
||||||
|
"profileNameHint": "ex., Caméra ALPR Personnalisée",
|
||||||
|
"profileNameRequired": "Le nom du profil est requis",
|
||||||
|
"requiresDirection": "Nécessite Direction",
|
||||||
|
"requiresDirectionSubtitle": "Si les caméras de ce type ont besoin d'une balise de direction",
|
||||||
|
"submittable": "Soumissible",
|
||||||
|
"submittableSubtitle": "Si ce profil peut être utilisé pour les soumissions de caméras",
|
||||||
|
"osmTags": "Balises OSM",
|
||||||
|
"addTag": "Ajouter Balise",
|
||||||
|
"saveProfile": "Sauvegarder Profil",
|
||||||
|
"keyHint": "clé",
|
||||||
|
"valueHint": "valeur",
|
||||||
|
"atLeastOneTagRequired": "Au moins une balise est requise",
|
||||||
|
"profileSaved": "Profil \"{}\" sauvegardé"
|
||||||
|
},
|
||||||
|
"operatorProfileEditor": {
|
||||||
|
"newOperatorProfile": "Nouveau Profil d'Opérateur",
|
||||||
|
"editOperatorProfile": "Modifier Profil d'Opérateur",
|
||||||
|
"operatorName": "Nom de l'opérateur",
|
||||||
|
"operatorNameHint": "ex., Département de Police d'Austin",
|
||||||
|
"operatorNameRequired": "Le nom de l'opérateur est requis",
|
||||||
|
"operatorProfileSaved": "Profil d'opérateur \"{}\" sauvegardé"
|
||||||
|
},
|
||||||
|
"operatorProfiles": {
|
||||||
|
"title": "Profils d'Opérateur",
|
||||||
|
"noProfilesMessage": "Aucun profil d'opérateur défini. Créez-en un pour appliquer des balises d'opérateur aux soumissions de nœuds.",
|
||||||
|
"tagsCount": "{} balises",
|
||||||
|
"deleteOperatorProfile": "Supprimer Profil d'Opérateur",
|
||||||
|
"deleteOperatorProfileConfirm": "Êtes-vous sûr de vouloir supprimer \"{}\"?",
|
||||||
|
"operatorProfileDeleted": "Profil d'opérateur supprimé"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ import 'package:uuid/uuid.dart';
|
|||||||
|
|
||||||
import '../models/operator_profile.dart';
|
import '../models/operator_profile.dart';
|
||||||
import '../app_state.dart';
|
import '../app_state.dart';
|
||||||
|
import '../services/localization_service.dart';
|
||||||
|
|
||||||
class OperatorProfileEditor extends StatefulWidget {
|
class OperatorProfileEditor extends StatefulWidget {
|
||||||
const OperatorProfileEditor({super.key, required this.profile});
|
const OperatorProfileEditor({super.key, required this.profile});
|
||||||
@@ -45,46 +46,55 @@ class _OperatorProfileEditorState extends State<OperatorProfileEditor> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return AnimatedBuilder(
|
||||||
appBar: AppBar(
|
animation: LocalizationService.instance,
|
||||||
title: Text(widget.profile.name.isEmpty ? 'New Operator Profile' : 'Edit Operator Profile'),
|
builder: (context, child) {
|
||||||
),
|
final locService = LocalizationService.instance;
|
||||||
body: ListView(
|
|
||||||
padding: const EdgeInsets.all(16),
|
return Scaffold(
|
||||||
children: [
|
appBar: AppBar(
|
||||||
TextField(
|
title: Text(widget.profile.name.isEmpty ? locService.t('operatorProfileEditor.newOperatorProfile') : locService.t('operatorProfileEditor.editOperatorProfile')),
|
||||||
controller: _nameCtrl,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: 'Operator name',
|
|
||||||
hintText: 'e.g., Austin Police Department',
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
body: ListView(
|
||||||
Row(
|
padding: const EdgeInsets.all(16),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
children: [
|
||||||
const Text('OSM Tags',
|
TextField(
|
||||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16)),
|
controller: _nameCtrl,
|
||||||
TextButton.icon(
|
decoration: InputDecoration(
|
||||||
onPressed: () => setState(() => _tags.add(const MapEntry('', ''))),
|
labelText: locService.t('operatorProfileEditor.operatorName'),
|
||||||
icon: const Icon(Icons.add),
|
hintText: locService.t('operatorProfileEditor.operatorNameHint'),
|
||||||
label: const Text('Add tag'),
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(locService.t('profileEditor.osmTags'),
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16)),
|
||||||
|
TextButton.icon(
|
||||||
|
onPressed: () => setState(() => _tags.add(const MapEntry('', ''))),
|
||||||
|
icon: const Icon(Icons.add),
|
||||||
|
label: Text(locService.t('profileEditor.addTag')),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
..._buildTagRows(),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: _save,
|
||||||
|
child: Text(locService.t('profileEditor.saveProfile')),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
);
|
||||||
..._buildTagRows(),
|
},
|
||||||
const SizedBox(height: 24),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: _save,
|
|
||||||
child: const Text('Save Profile'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _buildTagRows() {
|
List<Widget> _buildTagRows() {
|
||||||
|
final locService = LocalizationService.instance;
|
||||||
|
|
||||||
return List.generate(_tags.length, (i) {
|
return List.generate(_tags.length, (i) {
|
||||||
final keyController = TextEditingController(text: _tags[i].key);
|
final keyController = TextEditingController(text: _tags[i].key);
|
||||||
final valueController = TextEditingController(text: _tags[i].value);
|
final valueController = TextEditingController(text: _tags[i].value);
|
||||||
@@ -96,9 +106,9 @@ class _OperatorProfileEditorState extends State<OperatorProfileEditor> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
decoration: const InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'key',
|
hintText: locService.t('profileEditor.keyHint'),
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
),
|
),
|
||||||
controller: keyController,
|
controller: keyController,
|
||||||
@@ -109,9 +119,9 @@ class _OperatorProfileEditorState extends State<OperatorProfileEditor> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 3,
|
flex: 3,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
decoration: const InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'value',
|
hintText: locService.t('profileEditor.valueHint'),
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
),
|
),
|
||||||
controller: valueController,
|
controller: valueController,
|
||||||
@@ -129,10 +139,12 @@ class _OperatorProfileEditorState extends State<OperatorProfileEditor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _save() {
|
void _save() {
|
||||||
|
final locService = LocalizationService.instance;
|
||||||
final name = _nameCtrl.text.trim();
|
final name = _nameCtrl.text.trim();
|
||||||
|
|
||||||
if (name.isEmpty) {
|
if (name.isEmpty) {
|
||||||
ScaffoldMessenger.of(context)
|
ScaffoldMessenger.of(context)
|
||||||
.showSnackBar(const SnackBar(content: Text('Operator name is required')));
|
.showSnackBar(SnackBar(content: Text(locService.t('operatorProfileEditor.operatorNameRequired'))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +164,7 @@ class _OperatorProfileEditorState extends State<OperatorProfileEditor> {
|
|||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text('Operator profile "${newProfile.name}" saved')),
|
SnackBar(content: Text(locService.t('operatorProfileEditor.operatorProfileSaved', params: [newProfile.name]))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ import 'package:uuid/uuid.dart';
|
|||||||
|
|
||||||
import '../models/node_profile.dart';
|
import '../models/node_profile.dart';
|
||||||
import '../app_state.dart';
|
import '../app_state.dart';
|
||||||
|
import '../services/localization_service.dart';
|
||||||
|
|
||||||
class ProfileEditor extends StatefulWidget {
|
class ProfileEditor extends StatefulWidget {
|
||||||
const ProfileEditor({super.key, required this.profile});
|
const ProfileEditor({super.key, required this.profile});
|
||||||
@@ -54,68 +55,77 @@ class _ProfileEditorState extends State<ProfileEditor> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return AnimatedBuilder(
|
||||||
appBar: AppBar(
|
animation: LocalizationService.instance,
|
||||||
title: Text(!widget.profile.editable
|
builder: (context, child) {
|
||||||
? 'View Profile'
|
final locService = LocalizationService.instance;
|
||||||
: (widget.profile.name.isEmpty ? 'New Profile' : 'Edit Profile')),
|
|
||||||
),
|
return Scaffold(
|
||||||
body: ListView(
|
appBar: AppBar(
|
||||||
padding: const EdgeInsets.all(16),
|
title: Text(!widget.profile.editable
|
||||||
children: [
|
? locService.t('profileEditor.viewProfile')
|
||||||
TextField(
|
: (widget.profile.name.isEmpty ? locService.t('profileEditor.newProfile') : locService.t('profileEditor.editProfile'))),
|
||||||
controller: _nameCtrl,
|
|
||||||
readOnly: !widget.profile.editable,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: 'Profile name',
|
|
||||||
hintText: 'e.g., Custom ALPR Camera',
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
body: ListView(
|
||||||
if (widget.profile.editable) ...[
|
padding: const EdgeInsets.all(16),
|
||||||
CheckboxListTile(
|
children: [
|
||||||
title: const Text('Requires Direction'),
|
TextField(
|
||||||
subtitle: const Text('Whether cameras of this type need a direction tag'),
|
controller: _nameCtrl,
|
||||||
value: _requiresDirection,
|
readOnly: !widget.profile.editable,
|
||||||
onChanged: (value) => setState(() => _requiresDirection = value ?? true),
|
decoration: InputDecoration(
|
||||||
controlAffinity: ListTileControlAffinity.leading,
|
labelText: locService.t('profileEditor.profileName'),
|
||||||
),
|
hintText: locService.t('profileEditor.profileNameHint'),
|
||||||
CheckboxListTile(
|
),
|
||||||
title: const Text('Submittable'),
|
),
|
||||||
subtitle: const Text('Whether this profile can be used for camera submissions'),
|
const SizedBox(height: 16),
|
||||||
value: _submittable,
|
if (widget.profile.editable) ...[
|
||||||
onChanged: (value) => setState(() => _submittable = value ?? true),
|
CheckboxListTile(
|
||||||
controlAffinity: ListTileControlAffinity.leading,
|
title: Text(locService.t('profileEditor.requiresDirection')),
|
||||||
),
|
subtitle: Text(locService.t('profileEditor.requiresDirectionSubtitle')),
|
||||||
],
|
value: _requiresDirection,
|
||||||
const SizedBox(height: 8),
|
onChanged: (value) => setState(() => _requiresDirection = value ?? true),
|
||||||
Row(
|
controlAffinity: ListTileControlAffinity.leading,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
),
|
||||||
children: [
|
CheckboxListTile(
|
||||||
const Text('OSM Tags',
|
title: Text(locService.t('profileEditor.submittable')),
|
||||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16)),
|
subtitle: Text(locService.t('profileEditor.submittableSubtitle')),
|
||||||
if (widget.profile.editable)
|
value: _submittable,
|
||||||
TextButton.icon(
|
onChanged: (value) => setState(() => _submittable = value ?? true),
|
||||||
onPressed: () => setState(() => _tags.add(const MapEntry('', ''))),
|
controlAffinity: ListTileControlAffinity.leading,
|
||||||
icon: const Icon(Icons.add),
|
),
|
||||||
label: const Text('Add tag'),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
const SizedBox(height: 8),
|
||||||
const SizedBox(height: 8),
|
Row(
|
||||||
..._buildTagRows(),
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
const SizedBox(height: 24),
|
children: [
|
||||||
if (widget.profile.editable)
|
Text(locService.t('profileEditor.osmTags'),
|
||||||
ElevatedButton(
|
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16)),
|
||||||
onPressed: _save,
|
if (widget.profile.editable)
|
||||||
child: const Text('Save Profile'),
|
TextButton.icon(
|
||||||
),
|
onPressed: () => setState(() => _tags.add(const MapEntry('', ''))),
|
||||||
],
|
icon: const Icon(Icons.add),
|
||||||
),
|
label: Text(locService.t('profileEditor.addTag')),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
..._buildTagRows(),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
if (widget.profile.editable)
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: _save,
|
||||||
|
child: Text(locService.t('profileEditor.saveProfile')),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _buildTagRows() {
|
List<Widget> _buildTagRows() {
|
||||||
|
final locService = LocalizationService.instance;
|
||||||
|
|
||||||
return List.generate(_tags.length, (i) {
|
return List.generate(_tags.length, (i) {
|
||||||
final keyController = TextEditingController(text: _tags[i].key);
|
final keyController = TextEditingController(text: _tags[i].key);
|
||||||
final valueController = TextEditingController(text: _tags[i].value);
|
final valueController = TextEditingController(text: _tags[i].value);
|
||||||
@@ -127,9 +137,9 @@ class _ProfileEditorState extends State<ProfileEditor> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
decoration: const InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'key',
|
hintText: locService.t('profileEditor.keyHint'),
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
),
|
),
|
||||||
controller: keyController,
|
controller: keyController,
|
||||||
@@ -143,9 +153,9 @@ class _ProfileEditorState extends State<ProfileEditor> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 3,
|
flex: 3,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
decoration: const InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'value',
|
hintText: locService.t('profileEditor.valueHint'),
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
),
|
),
|
||||||
controller: valueController,
|
controller: valueController,
|
||||||
@@ -167,10 +177,12 @@ class _ProfileEditorState extends State<ProfileEditor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _save() {
|
void _save() {
|
||||||
|
final locService = LocalizationService.instance;
|
||||||
final name = _nameCtrl.text.trim();
|
final name = _nameCtrl.text.trim();
|
||||||
|
|
||||||
if (name.isEmpty) {
|
if (name.isEmpty) {
|
||||||
ScaffoldMessenger.of(context)
|
ScaffoldMessenger.of(context)
|
||||||
.showSnackBar(const SnackBar(content: Text('Profile name is required')));
|
.showSnackBar(SnackBar(content: Text(locService.t('profileEditor.profileNameRequired'))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +194,7 @@ class _ProfileEditorState extends State<ProfileEditor> {
|
|||||||
|
|
||||||
if (tagMap.isEmpty) {
|
if (tagMap.isEmpty) {
|
||||||
ScaffoldMessenger.of(context)
|
ScaffoldMessenger.of(context)
|
||||||
.showSnackBar(const SnackBar(content: Text('At least one tag is required')));
|
.showSnackBar(SnackBar(content: Text(locService.t('profileEditor.atLeastOneTagRequired'))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +212,7 @@ class _ProfileEditorState extends State<ProfileEditor> {
|
|||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text('Profile "${newProfile.name}" saved')),
|
SnackBar(content: Text(locService.t('profileEditor.profileSaved', params: [newProfile.name]))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:uuid/uuid.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import '../../app_state.dart';
|
import '../../app_state.dart';
|
||||||
import '../../models/operator_profile.dart';
|
import '../../models/operator_profile.dart';
|
||||||
|
import '../../services/localization_service.dart';
|
||||||
import '../operator_profile_editor.dart';
|
import '../operator_profile_editor.dart';
|
||||||
|
|
||||||
class OperatorProfileListSection extends StatelessWidget {
|
class OperatorProfileListSection extends StatelessWidget {
|
||||||
@@ -10,110 +11,117 @@ class OperatorProfileListSection extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final appState = context.watch<AppState>();
|
return AnimatedBuilder(
|
||||||
|
animation: LocalizationService.instance,
|
||||||
|
builder: (context, child) {
|
||||||
|
final locService = LocalizationService.instance;
|
||||||
|
final appState = context.watch<AppState>();
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
children: [
|
||||||
const Text('Operator Profiles', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
|
Row(
|
||||||
TextButton.icon(
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
onPressed: () => Navigator.push(
|
children: [
|
||||||
context,
|
Text(locService.t('operatorProfiles.title'), style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
|
||||||
MaterialPageRoute(
|
TextButton.icon(
|
||||||
builder: (_) => OperatorProfileEditor(
|
onPressed: () => Navigator.push(
|
||||||
profile: OperatorProfile(
|
context,
|
||||||
id: const Uuid().v4(),
|
MaterialPageRoute(
|
||||||
name: '',
|
builder: (_) => OperatorProfileEditor(
|
||||||
tags: const {},
|
profile: OperatorProfile(
|
||||||
|
id: const Uuid().v4(),
|
||||||
|
name: '',
|
||||||
|
tags: const {},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
icon: const Icon(Icons.add),
|
||||||
|
label: Text(locService.t('profiles.newProfile')),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (appState.operatorProfiles.isEmpty)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Text(
|
||||||
|
locService.t('operatorProfiles.noProfilesMessage'),
|
||||||
|
style: const TextStyle(color: Colors.grey),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
...appState.operatorProfiles.map(
|
||||||
|
(p) => ListTile(
|
||||||
|
title: Text(p.name),
|
||||||
|
subtitle: Text(locService.t('operatorProfiles.tagsCount', params: [p.tags.length.toString()])),
|
||||||
|
trailing: PopupMenuButton(
|
||||||
|
itemBuilder: (context) => [
|
||||||
|
PopupMenuItem(
|
||||||
|
value: 'edit',
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.edit),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(locService.t('actions.edit')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
value: 'delete',
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.delete, color: Colors.red),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(locService.t('operatorProfiles.deleteOperatorProfile'), style: const TextStyle(color: Colors.red)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
onSelected: (value) {
|
||||||
|
if (value == 'edit') {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (_) => OperatorProfileEditor(profile: p),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else if (value == 'delete') {
|
||||||
|
_showDeleteProfileDialog(context, p);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
icon: const Icon(Icons.add),
|
|
||||||
label: const Text('New Profile'),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
);
|
||||||
if (appState.operatorProfiles.isEmpty)
|
},
|
||||||
const Padding(
|
|
||||||
padding: EdgeInsets.all(16.0),
|
|
||||||
child: Text(
|
|
||||||
'No operator profiles defined. Create one to apply operator tags to node submissions.',
|
|
||||||
style: TextStyle(color: Colors.grey),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
else
|
|
||||||
...appState.operatorProfiles.map(
|
|
||||||
(p) => ListTile(
|
|
||||||
title: Text(p.name),
|
|
||||||
subtitle: Text('${p.tags.length} tags'),
|
|
||||||
trailing: PopupMenuButton(
|
|
||||||
itemBuilder: (context) => [
|
|
||||||
PopupMenuItem(
|
|
||||||
value: 'edit',
|
|
||||||
child: const Row(
|
|
||||||
children: [
|
|
||||||
Icon(Icons.edit),
|
|
||||||
SizedBox(width: 8),
|
|
||||||
Text('Edit'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
PopupMenuItem(
|
|
||||||
value: 'delete',
|
|
||||||
child: const Row(
|
|
||||||
children: [
|
|
||||||
Icon(Icons.delete, color: Colors.red),
|
|
||||||
SizedBox(width: 8),
|
|
||||||
Text('Delete', style: TextStyle(color: Colors.red)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
onSelected: (value) {
|
|
||||||
if (value == 'edit') {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (_) => OperatorProfileEditor(profile: p),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else if (value == 'delete') {
|
|
||||||
_showDeleteProfileDialog(context, p);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _showDeleteProfileDialog(BuildContext context, OperatorProfile profile) {
|
void _showDeleteProfileDialog(BuildContext context, OperatorProfile profile) {
|
||||||
|
final locService = LocalizationService.instance;
|
||||||
final appState = context.read<AppState>();
|
final appState = context.read<AppState>();
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => AlertDialog(
|
builder: (context) => AlertDialog(
|
||||||
title: const Text('Delete Operator Profile'),
|
title: Text(locService.t('operatorProfiles.deleteOperatorProfile')),
|
||||||
content: Text('Are you sure you want to delete "${profile.name}"?'),
|
content: Text(locService.t('operatorProfiles.deleteOperatorProfileConfirm', params: [profile.name])),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () => Navigator.pop(context),
|
||||||
child: const Text('Cancel'),
|
child: Text(locService.t('actions.cancel')),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
appState.deleteOperatorProfile(profile);
|
appState.deleteOperatorProfile(profile);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(content: Text('Operator profile deleted')),
|
SnackBar(content: Text(locService.t('operatorProfiles.operatorProfileDeleted'))),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
style: TextButton.styleFrom(foregroundColor: Colors.red),
|
style: TextButton.styleFrom(foregroundColor: Colors.red),
|
||||||
child: const Text('Delete'),
|
child: Text(locService.t('operatorProfiles.deleteOperatorProfile')),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user