luc sitzung
This commit is contained in:
@@ -7,6 +7,7 @@ import 'package:geolocator/geolocator.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:geocoding/geocoding.dart';
|
||||
|
||||
// * Collection of All widgets displayed in the add_cam section
|
||||
|
||||
@@ -16,31 +17,48 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
// * Step 1 place, camera, terretory
|
||||
//
|
||||
|
||||
class RequiredVarTextField extends StatefulWidget {
|
||||
class VarTextField extends StatefulWidget {
|
||||
final TextEditingController textController;
|
||||
final String localization;
|
||||
final String dbName;
|
||||
final String? default_value;
|
||||
final bool required;
|
||||
|
||||
const RequiredVarTextField(
|
||||
const VarTextField(
|
||||
{super.key,
|
||||
required this.textController,
|
||||
required this.localization,
|
||||
required this.dbName, required this.required});
|
||||
required this.dbName,
|
||||
required this.required,
|
||||
this.default_value});
|
||||
|
||||
@override
|
||||
State<RequiredVarTextField> createState() => _RequiredVarTextFieldState();
|
||||
State<VarTextField> createState() => _VarTextFieldState();
|
||||
}
|
||||
|
||||
class _RequiredVarTextFieldState extends State<RequiredVarTextField> {
|
||||
class _VarTextFieldState extends State<VarTextField> {
|
||||
late Future<List<Map<String, dynamic>>> dbVar;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
if (widget.textController.text == "" && widget.default_value != null)
|
||||
_loadPref();
|
||||
|
||||
dbVar = DBHelper().getPlace();
|
||||
}
|
||||
|
||||
void _loadPref() {
|
||||
Future.delayed(Duration.zero, () async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
String bLand = prefs.getString(widget.default_value!) ?? "";
|
||||
setState(() {
|
||||
widget.textController.text = bLand;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
@@ -51,23 +69,29 @@ class _RequiredVarTextFieldState extends State<RequiredVarTextField> {
|
||||
controller: widget.textController,
|
||||
keyboardType: TextInputType.multiline,
|
||||
maxLines: null,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
widget.textController.text = value;
|
||||
});
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
hintText: widget.localization,
|
||||
enabledBorder: widget.required
|
||||
? (widget.textController.text.isEmpty
|
||||
? const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.red))
|
||||
: const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.green)))
|
||||
: const UnderlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
|
||||
focusedBorder: widget.required
|
||||
? (widget.textController.text.isEmpty
|
||||
? const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.red))
|
||||
: const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.green)))
|
||||
: const UnderlineInputBorder(borderSide: BorderSide(color: Colors.grey))
|
||||
),
|
||||
hintText: widget.localization,
|
||||
enabledBorder: widget.required
|
||||
? (widget.textController.text.isEmpty
|
||||
? const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.red))
|
||||
: const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.green)))
|
||||
: const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.grey)),
|
||||
focusedBorder: widget.required
|
||||
? (widget.textController.text.isEmpty
|
||||
? const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.red))
|
||||
: const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.green)))
|
||||
: const UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.grey))),
|
||||
)),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
@@ -123,10 +147,10 @@ class Standort extends StatefulWidget {
|
||||
{super.key, required this.standortC, required this.localization});
|
||||
|
||||
@override
|
||||
State<RequiredVarTextField> createState() => _RequiredVarTextFieldState();
|
||||
State<VarTextField> createState() => _StandortState();
|
||||
}
|
||||
|
||||
class _StandortState extends State<RequiredVarTextField> {
|
||||
class _StandortState extends State<VarTextField> {
|
||||
late Future<List<Map<String, dynamic>>> Standort;
|
||||
|
||||
@override
|
||||
@@ -426,6 +450,9 @@ class KarteState extends State<Karte> {
|
||||
Position? updatedPosition;
|
||||
bool saveVisible = false;
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -452,8 +479,13 @@ class KarteState extends State<Karte> {
|
||||
children: [
|
||||
Text(AppLocalizations.of(context)!.saveMap),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
onPressed: () async {
|
||||
|
||||
List<Placemark> placemarks = await placemarkFromCoordinates(selectedPosition!.latitude, selectedPosition!.longitude);
|
||||
print(placemarks);
|
||||
|
||||
if (selectedPosition != null) {
|
||||
|
||||
setState(() {
|
||||
updatedPosition = Position(
|
||||
longitude: selectedPosition!.longitude,
|
||||
@@ -1935,16 +1967,12 @@ class _AbbauDatState extends State<AbbauDat> {
|
||||
Future<DateTime?> pickDate() async {
|
||||
final date = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: abbauDat!,
|
||||
initialDate: DateTime.now(),
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(5000));
|
||||
if (date == null) return null;
|
||||
setState(() => abbauDat = date);
|
||||
|
||||
var place = {'AbbauDat': DateFormat('yyyy-MM-dd').format(abbauDat!)};
|
||||
|
||||
await DBHelper().addPlace(place);
|
||||
|
||||
return abbauDat;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user