Skip to content
Merged

main #55

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,31 @@
"description": "Block command action button label"
},

"unblock": "Unblock",
"@unblock": {
"description": "Unblock command action button label"
},

"unblockCommandConfirmTitle": "Unblock vehicle?",
"@unblockCommandConfirmTitle": {
"description": "Title for unblock command confirmation dialog"
},

"unblockCommandConfirmMessage": "This will resume the engine remotely. Are you sure?",
"@unblockCommandConfirmMessage": {
"description": "Body text for unblock command confirmation dialog"
},

"unblockCommandSent": "Unblock command sent",
"@unblockCommandSent": {
"description": "Snackbar message when unblock command is sent"
},

"unblockCommandFailed": "Failed to send unblock command",
"@unblockCommandFailed": {
"description": "Snackbar message when unblock command fails"
},

"locationCopied": "Location copied to clipboard",
"@locationCopied": {
"description": "Snackbar message when location is copied"
Expand Down
10 changes: 10 additions & 0 deletions lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@

"block": "Bloquer",

"unblock": "Débloquer",

"unblockCommandConfirmTitle": "Débloquer le véhicule ?",

"unblockCommandConfirmMessage": "Cela relancera le moteur à distance. Êtes-vous sûr ?",

"unblockCommandSent": "Commande de déblocage envoyée",

"unblockCommandFailed": "Échec de l'envoi de la commande de déblocage",

"locationCopied": "Emplacement copié dans le presse-papiers",

"blockCommandConfirmTitle": "Bloquer le véhicule ?",
Expand Down
10 changes: 10 additions & 0 deletions lib/l10n/app_pt.arb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@

"block": "Bloquear",

"unblock": "Desbloquear",

"unblockCommandConfirmTitle": "Desbloquear veículo?",

"unblockCommandConfirmMessage": "Isto irá retomar o motor remotamente. Tem a certeza?",

"unblockCommandSent": "Comando de desbloqueio enviado",

"unblockCommandFailed": "Falha ao enviar comando de desbloqueio",

"locationCopied": "Localização copiada para a área de transferência",

"blockCommandConfirmTitle": "Bloquear veículo?",
Expand Down
8 changes: 4 additions & 4 deletions lib/map/styles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ class MapStyles {
static const List<MapStyleConfig> configs = [
MapStyleConfig(
nameKey: 'roads',
urlTemplate: 'https://mt{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}&scale=2&gl=MA&hl={lang}',
urlTemplate: 'https://mt{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}&gl=MA&hl={lang}',
subdomains: ['0', '1', '2', '3'],
attribution: '© Google Maps',
),
MapStyleConfig(
nameKey: 'satellite',
urlTemplate: 'https://mt{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}&scale=2&gl=MA&hl={lang}',
urlTemplate: 'https://mt{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}&gl=MA&hl={lang}',
subdomains: ['0', '1', '2', '3'],
attribution: '© Google Maps',
isDark: true,
),
MapStyleConfig(
nameKey: 'hybrid',
urlTemplate: 'https://mt{s}.google.com/vt/lyrs=y&x={x}&y={y}&z={z}&scale=2&gl=MA&hl={lang}',
urlTemplate: 'https://mt{s}.google.com/vt/lyrs=y&x={x}&y={y}&z={z}&gl=MA&hl={lang}',
subdomains: ['0', '1', '2', '3'],
attribution: '© Google Maps',
isDark: true,
),
MapStyleConfig(
nameKey: 'traffic',
urlTemplate: 'https://mt{s}.google.com/vt/lyrs=m,traffic&x={x}&y={y}&z={z}&scale=2&gl=MA&hl={lang}',
urlTemplate: 'https://mt{s}.google.com/vt/lyrs=m,traffic&x={x}&y={y}&z={z}&gl=MA&hl={lang}',
subdomains: ['0', '1', '2', '3'],
attribution: '© Google Maps',
),
Expand Down
28 changes: 18 additions & 10 deletions lib/widgets/device_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -206,22 +206,25 @@ class DeviceDetail extends StatelessWidget {
}
}

bool get _isBlocked => position?.attributes?['blocked'] == true;

Future<void> _sendBlockCommand(BuildContext context) async {
final l10n = AppLocalizations.of(context)!;
final isBlocked = _isBlocked;

final confirmed = await showDialog<bool>(
context: context,
builder: (ctx) => AlertDialog(
title: Text(l10n.blockCommandConfirmTitle),
content: Text(l10n.blockCommandConfirmMessage),
title: Text(isBlocked ? l10n.unblockCommandConfirmTitle : l10n.blockCommandConfirmTitle),
content: Text(isBlocked ? l10n.unblockCommandConfirmMessage : l10n.blockCommandConfirmMessage),
actions: [
TextButton(
onPressed: () => Navigator.of(ctx).pop(false),
child: Text(l10n.cancel),
),
TextButton(
onPressed: () => Navigator.of(ctx).pop(true),
child: Text(l10n.block),
child: Text(isBlocked ? l10n.unblock : l10n.block),
),
],
),
Expand All @@ -232,7 +235,7 @@ class DeviceDetail extends StatelessWidget {
final canCheck = await auth.canCheckBiometrics || await auth.isDeviceSupported();
if (canCheck) {
final authenticated = await auth.authenticate(
localizedReason: 'Authenticate to send the block command',
localizedReason: 'Authenticate to send the ${isBlocked ? 'unblock' : 'block'} command',
options: const AuthenticationOptions(biometricOnly: false),
);
if (!authenticated) return;
Expand All @@ -241,22 +244,27 @@ class DeviceDetail extends StatelessWidget {
final apiService = ApiService();

try {
final success = await apiService.sendCommand(device.id, 'engineStop');
final success = await apiService.sendCommand(
device.id,
isBlocked ? 'engineResume' : 'engineStop',
);

if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(success ? l10n.blockCommandSent : l10n.blockCommandFailed),
content: Text(isBlocked
? (success ? l10n.unblockCommandSent : l10n.unblockCommandFailed)
: (success ? l10n.blockCommandSent : l10n.blockCommandFailed)),
duration: const Duration(seconds: 2),
),
);
}
} catch (e) {
dev.log('Error sending block command: $e');
dev.log('Error sending ${isBlocked ? 'unblock' : 'block'} command: $e');
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(l10n.blockCommandFailed),
content: Text(isBlocked ? l10n.unblockCommandFailed : l10n.blockCommandFailed),
duration: const Duration(seconds: 2),
),
);
Expand Down Expand Up @@ -428,8 +436,8 @@ class DeviceDetail extends StatelessWidget {
const SizedBox(width: 12),
Expanded(
child: _ActionButton(
icon: Icons.lock,
label: l10n.block,
icon: _isBlocked ? Icons.lock_open : Icons.lock,
label: _isBlocked ? l10n.unblock : l10n.block,
onPressed: () => _sendBlockCommand(context),
),
),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: manager
description: "Track Fleet"
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 3.18.8+1
version: 3.18.9+1

environment:
sdk: ^3.9.2
Expand Down
30 changes: 0 additions & 30 deletions test/widget_test.dart

This file was deleted.

Loading