Update status screen
This commit is contained in:
parent
5394f0f2e7
commit
61ce0a0653
4 changed files with 21 additions and 22 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
"mainTitle": "Traccar Client",
|
"mainTitle": "Traccar Client",
|
||||||
"trackingTitle": "Tracking",
|
"trackingTitle": "Tracking",
|
||||||
"settingsTitle": "Settings",
|
"settingsTitle": "Settings",
|
||||||
|
"statusTitle": "Logs",
|
||||||
"saveButton": "Save",
|
"saveButton": "Save",
|
||||||
"cancelButton": "Cancel",
|
"cancelButton": "Cancel",
|
||||||
"locationButton": "Send location",
|
"locationButton": "Send location",
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,10 @@ class Preferences {
|
||||||
"device_id": preferences.getString(id),
|
"device_id": preferences.getString(id),
|
||||||
},
|
},
|
||||||
distanceFilter: preferences.getInt(distance)?.toDouble(),
|
distanceFilter: preferences.getInt(distance)?.toDouble(),
|
||||||
locationUpdateInterval: preferences.getInt(interval),
|
locationUpdateInterval: (preferences.getInt(interval) ?? 0) * 1000,
|
||||||
maxRecordsToPersist: preferences.getBool(buffer) != false ? -1 : 0,
|
maxRecordsToPersist: preferences.getBool(buffer) != false ? -1 : 0,
|
||||||
|
logLevel: bg.Config.LOG_LEVEL_INFO,
|
||||||
|
logMaxDays: 1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_background_geolocation/flutter_background_geolocation.dart' as bg;
|
import 'package:flutter_background_geolocation/flutter_background_geolocation.dart' as bg;
|
||||||
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
class StatusScreen extends StatefulWidget {
|
class StatusScreen extends StatefulWidget {
|
||||||
const StatusScreen({super.key});
|
const StatusScreen({super.key});
|
||||||
|
|
@ -14,14 +15,14 @@ class _StatusScreenState extends State<StatusScreen> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_loadLogs();
|
_refreshLogs();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadLogs() async {
|
Future<void> _refreshLogs() async {
|
||||||
final logs = await bg.Logger.getLog(); // Fetch logs
|
final logs = await bg.Logger.getLog();
|
||||||
setState(() {
|
setState(() {
|
||||||
_logs.clear();
|
_logs.clear();
|
||||||
_logs.addAll(logs.split('\n').reversed); // Latest logs first
|
_logs.addAll(logs.split('\n'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,11 +35,11 @@ class _StatusScreenState extends State<StatusScreen> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Background Geolocation Logs'),
|
title: Text(AppLocalizations.of(context)!.statusTitle),
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.refresh),
|
icon: const Icon(Icons.refresh),
|
||||||
onPressed: _loadLogs,
|
onPressed: _refreshLogs,
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.delete),
|
icon: const Icon(Icons.delete),
|
||||||
|
|
@ -46,17 +47,12 @@ class _StatusScreenState extends State<StatusScreen> {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: _logs.isEmpty
|
body: ListView.builder(
|
||||||
? const Center(child: Text('No logs available.'))
|
reverse: true,
|
||||||
: ListView.builder(
|
|
||||||
itemCount: _logs.length,
|
itemCount: _logs.length,
|
||||||
itemBuilder: (_, index) => Padding(
|
itemBuilder: (_, index) => Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||||
vertical: 2.0, horizontal: 8.0),
|
child: Text(_logs[index]),
|
||||||
child: Text(
|
|
||||||
_logs[index],
|
|
||||||
style: const TextStyle(fontSize: 12.0),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue