Compare commits
2 Commits
82786b3577
...
6ed36dba75
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ed36dba75 | |||
| 4deb263c7e |
@@ -73,11 +73,9 @@ class LocationScreen extends ConsumerWidget {
|
||||
.read(legacyDeviceViewModelProvider.notifier)
|
||||
.setSelectedDevice(device);
|
||||
},
|
||||
onRefreshPosition: () {
|
||||
ref
|
||||
.read(legacyDeviceViewModelProvider.notifier)
|
||||
.refreshPositions();
|
||||
},
|
||||
onRefreshPosition: () => ref
|
||||
.read(legacyDeviceViewModelProvider.notifier)
|
||||
.refreshPositions(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
import 'package:legacy_device_state/legacy_device_state.dart';
|
||||
import 'package:legacy_theme/legacy_theme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
@@ -63,12 +63,11 @@ class _DeviceBannerState extends ConsumerState<DeviceBanner> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final primaryColor = context.sfColors.legacyPrimary;
|
||||
|
||||
return Container(
|
||||
width: SizeUtils.getByScreen(small: 340, big: 338),
|
||||
margin: EdgeInsets.only(
|
||||
bottom: SizeUtils.getByScreen(small: 16, big: 14),
|
||||
left: 16,
|
||||
right: 16,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
@@ -85,24 +84,26 @@ class _DeviceBannerState extends ConsumerState<DeviceBanner> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 72,
|
||||
height: 150,
|
||||
child: PageView.builder(
|
||||
controller: _pageController,
|
||||
itemCount: widget.devices.length,
|
||||
onPageChanged: (index) =>
|
||||
widget.onDeviceChanged(widget.devices[index]),
|
||||
itemBuilder: (context, index) {
|
||||
final dev = widget.devices[index];
|
||||
final pos = widget.positions
|
||||
.where((p) => p.deviceIdentificator == dev.identificator)
|
||||
final device = widget.devices[index];
|
||||
final position = widget.positions
|
||||
.where(
|
||||
(p) =>
|
||||
p.deviceIdentificator == device.identificator,
|
||||
)
|
||||
.firstOrNull;
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: widget.onTap,
|
||||
child: _DeviceCard(
|
||||
device: dev,
|
||||
position: pos,
|
||||
primaryColor: primaryColor,
|
||||
device: device,
|
||||
position: position,
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -123,7 +124,7 @@ class _DeviceBannerState extends ConsumerState<DeviceBanner> {
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
color: i == _currentPage
|
||||
? primaryColor
|
||||
? context.sfColors.legacyPrimary
|
||||
: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
@@ -139,137 +140,148 @@ class _DeviceBannerState extends ConsumerState<DeviceBanner> {
|
||||
class _DeviceCard extends StatelessWidget {
|
||||
final DeviceEntity device;
|
||||
final PositionEntity? position;
|
||||
final Color primaryColor;
|
||||
|
||||
const _DeviceCard({
|
||||
required this.device,
|
||||
required this.position,
|
||||
required this.primaryColor,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final name = device.carrierName;
|
||||
final deviceName = name != null && name.isNotEmpty
|
||||
? name
|
||||
: device.identificator;
|
||||
final initial = deviceName.isNotEmpty ? deviceName[0].toUpperCase() : '?';
|
||||
final primaryColor = context.sfColors.legacyPrimary;
|
||||
final valueStyle = TextStyle(
|
||||
fontSize: 13,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
);
|
||||
final labelStyle = TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: primaryColor,
|
||||
);
|
||||
|
||||
final addressText = position != null
|
||||
final name = device.carrierName;
|
||||
final deviceName =
|
||||
name != null && name.isNotEmpty ? name : device.identificator;
|
||||
|
||||
final address = position != null
|
||||
? [
|
||||
position!.address?.street,
|
||||
position!.address?.city,
|
||||
position!.address?.province,
|
||||
].whereType<String>().where((s) => s.isNotEmpty).join(', ')
|
||||
position!.address?.country,
|
||||
]
|
||||
.whereType<String>()
|
||||
.where((s) => s.isNotEmpty && s != 'Unknown')
|
||||
.join(', ')
|
||||
: '';
|
||||
|
||||
final dateText =
|
||||
position != null ? formatPositionDate(position!.positionDate) : '';
|
||||
|
||||
final positionType = position?.type ?? '';
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 42,
|
||||
height: 42,
|
||||
decoration: BoxDecoration(
|
||||
color: primaryColor.withValues(alpha: 0.12),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
initial,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
Image.asset(
|
||||
'assets/shared/images/iso_sf.png',
|
||||
width: 60,
|
||||
height: 60,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
deviceName,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: primaryColor,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
if (addressText.isNotEmpty)
|
||||
const SizedBox(height: 8),
|
||||
if (address.isNotEmpty)
|
||||
_InfoRow(
|
||||
label: context.translate(I18n.locationBannerAddress),
|
||||
labelStyle: labelStyle,
|
||||
child: Text(
|
||||
address,
|
||||
style: valueStyle,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
if (dateText.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 2),
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: _InfoRow(
|
||||
label: context.translate(I18n.locationBannerDateTime),
|
||||
labelStyle: labelStyle,
|
||||
child: Text(dateText, style: valueStyle),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: _InfoRow(
|
||||
label: context.translate(I18n.locationBannerBattery),
|
||||
labelStyle: labelStyle,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.location_on,
|
||||
size: 12,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
const SizedBox(width: 3),
|
||||
Expanded(
|
||||
child: Text(
|
||||
addressText,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
if (device.battery != null) ...[
|
||||
Text('${device.battery}%', style: valueStyle),
|
||||
const SizedBox(width: 6),
|
||||
Icon(
|
||||
toBatteryIcon(device.battery!),
|
||||
size: 18,
|
||||
color: device.battery! > 20
|
||||
? Colors.green
|
||||
: Colors.orange,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (positionType.isNotEmpty) ...[
|
||||
const SizedBox(width: 12),
|
||||
Text(positionType, style: valueStyle),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (position != null || device.battery != null)
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
if (device.battery != null)
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
toBatteryIcon(device.battery!),
|
||||
size: 16,
|
||||
color: device.battery! > 20
|
||||
? primaryColor
|
||||
: Colors.orange,
|
||||
),
|
||||
const SizedBox(width: 3),
|
||||
Text(
|
||||
'${device.battery}%',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: device.battery! > 20
|
||||
? primaryColor
|
||||
: Colors.orange,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (position != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 3),
|
||||
child: Text(
|
||||
formatPositionDate(position!.positionDate),
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _InfoRow extends StatelessWidget {
|
||||
final String label;
|
||||
final TextStyle labelStyle;
|
||||
final Widget child;
|
||||
|
||||
const _InfoRow({
|
||||
required this.label,
|
||||
required this.labelStyle,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 80,
|
||||
child: Text(label, style: labelStyle),
|
||||
),
|
||||
Expanded(child: child),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class LocationMap extends ConsumerStatefulWidget {
|
||||
final bool showRouteTrail;
|
||||
final bool isLoadingHistory;
|
||||
final ValueChanged<DeviceEntity> onDeviceChanged;
|
||||
final VoidCallback onRefreshPosition;
|
||||
final Future<void> Function() onRefreshPosition;
|
||||
|
||||
const LocationMap({
|
||||
super.key,
|
||||
@@ -685,9 +685,14 @@ class _LocationMapState extends ConsumerState<LocationMap>
|
||||
unawaited(
|
||||
ref.read(sfTrackingProvider).legacyLocationMapRefreshTapped(),
|
||||
);
|
||||
widget.onRefreshPosition();
|
||||
if (!mounted) return;
|
||||
await showInfoDialog(context, I18n.locationMapRefreshRequested);
|
||||
try {
|
||||
await widget.onRefreshPosition();
|
||||
if (!mounted) return;
|
||||
await showSuccessDialog(context, I18n.positionUpdated);
|
||||
} catch (_) {
|
||||
if (!mounted) return;
|
||||
await showErrorDialog(context, I18n.errorPositions);
|
||||
}
|
||||
},
|
||||
onCenterTap: _centerOnDevice,
|
||||
onToggleFollow: () async {
|
||||
|
||||
@@ -664,6 +664,9 @@
|
||||
"locationMapStyleStandard": "Standard",
|
||||
"locationMapStyleVoyager": "Reisender",
|
||||
"locationFrequencyManual": "Manuell",
|
||||
"locationBannerAddress": "ADRESSE",
|
||||
"locationBannerDateTime": "DATUM/UHRZEIT",
|
||||
"locationBannerBattery": "BATTERIE",
|
||||
"positionUpdated": "Letzte verfügbare Position aktualisiert",
|
||||
"locationMapStyleLight": "Hell",
|
||||
"locationMapStyleDark": "Dunkel",
|
||||
|
||||
@@ -844,6 +844,9 @@
|
||||
"locationMapStyleStandard": "Standard",
|
||||
"locationMapStyleVoyager": "Voyager",
|
||||
"locationFrequencyManual": "Manual",
|
||||
"locationBannerAddress": "ADDRESS",
|
||||
"locationBannerDateTime": "DATE/TIME",
|
||||
"locationBannerBattery": "BATTERY",
|
||||
"positionUpdated": "Updated to latest available position",
|
||||
"locationMapStyleLight": "Light",
|
||||
"locationMapStyleDark": "Dark",
|
||||
|
||||
@@ -845,6 +845,9 @@
|
||||
"locationMapStyleStandard": "Estándar",
|
||||
"locationMapStyleVoyager": "Viajero",
|
||||
"locationFrequencyManual": "Manual",
|
||||
"locationBannerAddress": "DIRECCIÓN",
|
||||
"locationBannerDateTime": "FECHA/HORA",
|
||||
"locationBannerBattery": "BATERÍA",
|
||||
"positionUpdated": "Última posición disponible actualizada",
|
||||
"locationMapStyleLight": "Claro",
|
||||
"locationMapStyleDark": "Oscuro",
|
||||
|
||||
@@ -664,6 +664,9 @@
|
||||
"locationMapStyleStandard": "Standard",
|
||||
"locationMapStyleVoyager": "Voyageur",
|
||||
"locationFrequencyManual": "Manuel",
|
||||
"locationBannerAddress": "ADRESSE",
|
||||
"locationBannerDateTime": "DATE/HEURE",
|
||||
"locationBannerBattery": "BATTERIE",
|
||||
"positionUpdated": "Dernière position disponible mise à jour",
|
||||
"locationMapStyleLight": "Clair",
|
||||
"locationMapStyleDark": "Sombre",
|
||||
|
||||
@@ -664,6 +664,9 @@
|
||||
"locationMapStyleStandard": "Standard",
|
||||
"locationMapStyleVoyager": "Viaggiatore",
|
||||
"locationFrequencyManual": "Manuale",
|
||||
"locationBannerAddress": "INDIRIZZO",
|
||||
"locationBannerDateTime": "DATA/ORA",
|
||||
"locationBannerBattery": "BATTERIA",
|
||||
"positionUpdated": "Ultima posizione disponibile aggiornata",
|
||||
"locationMapStyleLight": "Chiaro",
|
||||
"locationMapStyleDark": "Scuro",
|
||||
|
||||
@@ -664,6 +664,9 @@
|
||||
"locationMapStyleStandard": "Padrão",
|
||||
"locationMapStyleVoyager": "Viajante",
|
||||
"locationFrequencyManual": "Manual",
|
||||
"locationBannerAddress": "ENDEREÇO",
|
||||
"locationBannerDateTime": "DATA/HORA",
|
||||
"locationBannerBattery": "BATERIA",
|
||||
"positionUpdated": "Última posição disponível atualizada",
|
||||
"locationMapStyleLight": "Claro",
|
||||
"locationMapStyleDark": "Escuro",
|
||||
|
||||
@@ -620,6 +620,9 @@ class I18n {
|
||||
static const String locationMapStyleStandard = 'locationMapStyleStandard';
|
||||
static const String locationMapStyleVoyager = 'locationMapStyleVoyager';
|
||||
static const String locationFrequencyManual = 'locationFrequencyManual';
|
||||
static const String locationBannerAddress = 'locationBannerAddress';
|
||||
static const String locationBannerDateTime = 'locationBannerDateTime';
|
||||
static const String locationBannerBattery = 'locationBannerBattery';
|
||||
static const String positionUpdated = 'positionUpdated';
|
||||
static const String locationNewFrequentPlace = 'locationNewFrequentPlace';
|
||||
static const String locationNewGeofence = 'locationNewGeofence';
|
||||
|
||||
@@ -37,7 +37,7 @@ abstract class GetDevicesItemResponseModel with _$GetDevicesItemResponseModel {
|
||||
String? simId,
|
||||
String? simStatus,
|
||||
Map<String, dynamic>? paymentOptions,
|
||||
required bool queueCommands,
|
||||
@Default(false) bool queueCommands,
|
||||
required Map<String, dynamic> settings,
|
||||
required String connectionServer,
|
||||
required String protocol,
|
||||
|
||||
@@ -506,7 +506,7 @@ return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.co
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetDevicesItemResponseModel implements GetDevicesItemResponseModel {
|
||||
const _GetDevicesItemResponseModel({required this.id, required this.identificator, this.battery, this.userId, this.companyId, this.delegationId, this.groupId, required final Map<String, dynamic> flags, final List<String>? tags, this.lastConnection, this.carrierGenre, this.carrierBirthday, this.carrierWeight, this.carrierStepLength, required this.carrierName, this.comment, this.phone, this.simId, this.simStatus, final Map<String, dynamic>? paymentOptions, required this.queueCommands, required final Map<String, dynamic> settings, required this.connectionServer, required this.protocol, required this.type, final Map<String, dynamic>? capabilities, this.backgroundImageId, required this.createdAt, this.updatedAt}): _flags = flags,_tags = tags,_paymentOptions = paymentOptions,_settings = settings,_capabilities = capabilities;
|
||||
const _GetDevicesItemResponseModel({required this.id, required this.identificator, this.battery, this.userId, this.companyId, this.delegationId, this.groupId, required final Map<String, dynamic> flags, final List<String>? tags, this.lastConnection, this.carrierGenre, this.carrierBirthday, this.carrierWeight, this.carrierStepLength, required this.carrierName, this.comment, this.phone, this.simId, this.simStatus, final Map<String, dynamic>? paymentOptions, this.queueCommands = false, required final Map<String, dynamic> settings, required this.connectionServer, required this.protocol, required this.type, final Map<String, dynamic>? capabilities, this.backgroundImageId, required this.createdAt, this.updatedAt}): _flags = flags,_tags = tags,_paymentOptions = paymentOptions,_settings = settings,_capabilities = capabilities;
|
||||
factory _GetDevicesItemResponseModel.fromJson(Map<String, dynamic> json) => _$GetDevicesItemResponseModelFromJson(json);
|
||||
|
||||
@override final String id;
|
||||
@@ -551,7 +551,7 @@ class _GetDevicesItemResponseModel implements GetDevicesItemResponseModel {
|
||||
return EqualUnmodifiableMapView(value);
|
||||
}
|
||||
|
||||
@override final bool queueCommands;
|
||||
@override@JsonKey() final bool queueCommands;
|
||||
final Map<String, dynamic> _settings;
|
||||
@override Map<String, dynamic> get settings {
|
||||
if (_settings is EqualUnmodifiableMapView) return _settings;
|
||||
|
||||
@@ -43,7 +43,7 @@ _GetDevicesItemResponseModel _$GetDevicesItemResponseModelFromJson(
|
||||
simId: json['simId'] as String?,
|
||||
simStatus: json['simStatus'] as String?,
|
||||
paymentOptions: json['paymentOptions'] as Map<String, dynamic>?,
|
||||
queueCommands: json['queueCommands'] as bool,
|
||||
queueCommands: json['queueCommands'] as bool? ?? false,
|
||||
settings: json['settings'] as Map<String, dynamic>,
|
||||
connectionServer: json['connectionServer'] as String,
|
||||
protocol: json['protocol'] as String,
|
||||
|
||||
Reference in New Issue
Block a user