137 lines
4.6 KiB
Dart
137 lines
4.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_osm_plugin/flutter_osm_plugin.dart';
|
|
|
|
class settingsPage extends StatefulWidget {
|
|
const settingsPage({
|
|
Key? key,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
State<settingsPage> createState() => _settingsPageState();
|
|
}
|
|
|
|
class TextGeoPoint extends GeoPoint {
|
|
TextGeoPoint({required double latitude, required double longitude})
|
|
: super(latitude: latitude, longitude: longitude);
|
|
|
|
TextGeoPoint.fromGeoPoint(GeoPoint p)
|
|
: super(latitude: p.latitude, longitude: p.longitude);
|
|
|
|
@override
|
|
String toString() {
|
|
return latitude.toStringAsFixed(3) + ', ' + longitude.toStringAsFixed(3);
|
|
}
|
|
}
|
|
|
|
class _settingsPageState extends State<settingsPage> {
|
|
TextGeoPoint _homeLocation = TextGeoPoint(latitude: 48.8, longitude: 9.9);
|
|
TextGeoPoint _workLocation = TextGeoPoint(latitude: 48.8, longitude: 9.9);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final ButtonStyle updateStyle = ElevatedButton.styleFrom(
|
|
primary: Colors.green, textStyle: const TextStyle(fontSize: 20));
|
|
final ButtonStyle deleteStyle = ElevatedButton.styleFrom(
|
|
primary: Colors.redAccent, textStyle: const TextStyle(fontSize: 20));
|
|
|
|
final textHeadStyle =
|
|
TextStyle(fontSize: 30.0, fontWeight: FontWeight.bold);
|
|
|
|
final textGPSStyle = TextStyle(fontSize: 24.0, fontStyle: FontStyle.italic);
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
// Here we take the value from the MyHomePage object that was created by
|
|
// the App.build method, and use it to set our appbar title.
|
|
title: Text('Settings Page'),
|
|
),
|
|
body: Column(
|
|
children: [
|
|
Text('Home', style: textHeadStyle),
|
|
Text('$_homeLocation', style: textGPSStyle),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: ElevatedButton(
|
|
style: updateStyle,
|
|
onPressed: () async {
|
|
var p = await showSimplePickerLocation(
|
|
context: context,
|
|
isDismissible: true,
|
|
title: "Home Location Picker",
|
|
textConfirmPicker: "pick",
|
|
initCurrentUserPosition: false,
|
|
initZoom: 8,
|
|
initPosition: _homeLocation,
|
|
radius: 8.0,
|
|
);
|
|
if (p != null) {
|
|
setState(() {
|
|
_homeLocation = TextGeoPoint.fromGeoPoint(p);
|
|
});
|
|
}
|
|
},
|
|
child: const Text('Update'),
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: ElevatedButton(
|
|
style: deleteStyle,
|
|
onPressed: () {},
|
|
child: const Text('Delete'),
|
|
),
|
|
),
|
|
Text('Work', style: textHeadStyle),
|
|
Text('$_workLocation', style: textGPSStyle),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: ElevatedButton(
|
|
style: updateStyle,
|
|
onPressed: () async {
|
|
var p = await showSimplePickerLocation(
|
|
context: context,
|
|
isDismissible: true,
|
|
title: "Work Location Picker",
|
|
textConfirmPicker: "pick",
|
|
initCurrentUserPosition: false,
|
|
initZoom: 8,
|
|
initPosition: _workLocation,
|
|
radius: 8.0,
|
|
);
|
|
if (p != null) {
|
|
setState(() {
|
|
_workLocation = TextGeoPoint.fromGeoPoint(p);
|
|
});
|
|
}
|
|
},
|
|
child: const Text('Update'),
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: ElevatedButton(
|
|
style: deleteStyle,
|
|
onPressed: () {},
|
|
child: const Text('Delete'),
|
|
),
|
|
),
|
|
Text('Display Name', style: textHeadStyle),
|
|
const TextField(
|
|
decoration: InputDecoration(
|
|
border: OutlineInputBorder(),
|
|
labelText: 'Donny',
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: ElevatedButton(
|
|
style: updateStyle,
|
|
onPressed: () {},
|
|
child: const Text('Update'),
|
|
),
|
|
),
|
|
],
|
|
));
|
|
}
|
|
}
|