Send single location

This commit is contained in:
Anton Tananaev 2025-05-08 22:10:56 -07:00
parent a41bb061ec
commit 5394f0f2e7
2 changed files with 34 additions and 10 deletions

View file

@ -4,6 +4,7 @@
"settingsTitle": "Settings", "settingsTitle": "Settings",
"saveButton": "Save", "saveButton": "Save",
"cancelButton": "Cancel", "cancelButton": "Cancel",
"locationButton": "Send location",
"statusButton": "Show status", "statusButton": "Show status",
"settingsButton": "Change settings", "settingsButton": "Change settings",
"idLabel": "Device identifier", "idLabel": "Device identifier",

View file

@ -1,3 +1,5 @@
import 'dart:developer' as developer;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@ -72,6 +74,20 @@ class _MainScreenState extends State<MainScreen> {
}, },
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
OverflowBar(
spacing: 8,
children: [
FilledButton.tonal(
onPressed: () async {
try {
await bg.BackgroundGeolocation.getCurrentPosition(samples: 1);
await bg.BackgroundGeolocation.sync();
} catch (error) {
developer.log('Failed to fetch location', error: error);
}
},
child: Text(AppLocalizations.of(context)!.locationButton),
),
FilledButton.tonal( FilledButton.tonal(
onPressed: () { onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (_) => const StatusScreen())); Navigator.push(context, MaterialPageRoute(builder: (_) => const StatusScreen()));
@ -80,6 +96,8 @@ class _MainScreenState extends State<MainScreen> {
), ),
], ],
), ),
],
),
), ),
); );
} }
@ -103,12 +121,17 @@ class _MainScreenState extends State<MainScreen> {
leadingAndTrailingTextStyle: Theme.of(context).textTheme.bodyLarge, leadingAndTrailingTextStyle: Theme.of(context).textTheme.bodyLarge,
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
OverflowBar(
spacing: 8,
children: [
FilledButton.tonal( FilledButton.tonal(
onPressed: () { onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (_) => const SettingsScreen())); Navigator.push(context, MaterialPageRoute(builder: (_) => const SettingsScreen()));
}, },
child: Text(AppLocalizations.of(context)!.settingsButton), child: Text(AppLocalizations.of(context)!.settingsButton),
), ),
],
),
] ]
), ),
), ),