begin with using one widget for all the text fields
This commit is contained in:
1
Todo.txt
1
Todo.txt
@@ -10,6 +10,7 @@ nach koordinaten lkr auswählen (esri-leaflet-geocoder)
|
|||||||
fix ktage und nebeneinander positioniere
|
fix ktage und nebeneinander positioniere
|
||||||
textdateien auch an server senden
|
textdateien auch an server senden
|
||||||
error check wenn dateiauswahl abgebrochen wurde einfügen
|
error check wenn dateiauswahl abgebrochen wurde einfügen
|
||||||
|
save option einfügen nur zum speichern
|
||||||
|
|
||||||
keine ahnung obs funktioniert:
|
keine ahnung obs funktioniert:
|
||||||
eintrg in db wenn http response (in sent column)
|
eintrg in db wenn http response (in sent column)
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
child: Text(AppLocalizations.of(context)!.template)),
|
child: Text(AppLocalizations.of(context)!.template)),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
saveFile();
|
saveData();
|
||||||
_httpRequest();
|
_httpRequest();
|
||||||
Navigator.pushNamedAndRemoveUntil(
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
@@ -412,7 +412,12 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
children: [
|
children: [
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.bottomLeft,
|
alignment: Alignment.bottomLeft,
|
||||||
child: Standort(standortC: standortC),
|
child: RequiredVarTextField(
|
||||||
|
required: true,
|
||||||
|
dbName: "Standort",
|
||||||
|
textController: standortC,
|
||||||
|
localization: AppLocalizations.of(context)!.altstort,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 1,
|
height: 1,
|
||||||
@@ -447,6 +452,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
RequiredVarTextField(textController: betreuungC, localization: AppLocalizations.of(context)!.betreuung, dbName: "KontSum", required: false),
|
||||||
Betreuung(betreuungC: betreuungC),
|
Betreuung(betreuungC: betreuungC),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
@@ -510,7 +516,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
|
|
||||||
// Second step
|
// Second step
|
||||||
Step(
|
Step(
|
||||||
title: Text(AppLocalizations.of(context)!.secondstep),
|
title: Text(AppLocalizations.of(context)!.secondstep),
|
||||||
content: Column(
|
content: Column(
|
||||||
@@ -699,7 +705,7 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
))
|
))
|
||||||
];
|
];
|
||||||
|
|
||||||
// Here the site is built inclusive the steps from above
|
// Here the site is built with the steps from above
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: Text(AppLocalizations.of(context)!.addplace)),
|
appBar: AppBar(title: Text(AppLocalizations.of(context)!.addplace)),
|
||||||
body: PageTransitionSwitcher(
|
body: PageTransitionSwitcher(
|
||||||
|
|||||||
@@ -16,6 +16,192 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|||||||
// * Step 1 place, camera, terretory
|
// * Step 1 place, camera, terretory
|
||||||
//
|
//
|
||||||
|
|
||||||
|
class RequiredVarTextField extends StatefulWidget {
|
||||||
|
final TextEditingController textController;
|
||||||
|
final String localization;
|
||||||
|
final String dbName;
|
||||||
|
final bool required;
|
||||||
|
|
||||||
|
const RequiredVarTextField(
|
||||||
|
{super.key,
|
||||||
|
required this.textController,
|
||||||
|
required this.localization,
|
||||||
|
required this.dbName, required this.required});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<RequiredVarTextField> createState() => _RequiredVarTextFieldState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RequiredVarTextFieldState extends State<RequiredVarTextField> {
|
||||||
|
late Future<List<Map<String, dynamic>>> dbVar;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
dbVar = DBHelper().getPlace();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: TextField(
|
||||||
|
controller: widget.textController,
|
||||||
|
keyboardType: TextInputType.multiline,
|
||||||
|
maxLines: null,
|
||||||
|
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))
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.bottomLeft,
|
||||||
|
child: FutureBuilder<List<Map<String, dynamic>>>(
|
||||||
|
future: dbVar,
|
||||||
|
builder: (BuildContext context,
|
||||||
|
AsyncSnapshot<List<Map<String, dynamic>>> snapshot) {
|
||||||
|
if (snapshot.hasData) {
|
||||||
|
return PopupMenuButton<String>(
|
||||||
|
onSelected: (String value) {
|
||||||
|
setState(() {
|
||||||
|
widget.textController.text = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
itemBuilder: (BuildContext context) {
|
||||||
|
return snapshot.data!
|
||||||
|
.map((item) => PopupMenuItem<String>(
|
||||||
|
value: item[widget.dbName].toString(),
|
||||||
|
child: Text(item[widget.dbName].toString()),
|
||||||
|
))
|
||||||
|
.toList();
|
||||||
|
},
|
||||||
|
child: const Icon(Icons.arrow_drop_down),
|
||||||
|
);
|
||||||
|
} else if (snapshot.hasError) {
|
||||||
|
return Text('Fehler: ${snapshot.error}');
|
||||||
|
} else {
|
||||||
|
return const CircularProgressIndicator();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
DropdownMenuItem<String> buildMenuItem(String item) => DropdownMenuItem(
|
||||||
|
value: item,
|
||||||
|
child: Text(item),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Standort
|
||||||
|
|
||||||
|
class Standort extends StatefulWidget {
|
||||||
|
final TextEditingController standortC;
|
||||||
|
final String localization;
|
||||||
|
|
||||||
|
const Standort(
|
||||||
|
{super.key, required this.standortC, required this.localization});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<RequiredVarTextField> createState() => _RequiredVarTextFieldState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _StandortState extends State<RequiredVarTextField> {
|
||||||
|
late Future<List<Map<String, dynamic>>> Standort;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
Standort = DBHelper().getPlace();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: TextField(
|
||||||
|
keyboardType: TextInputType.multiline,
|
||||||
|
maxLines: null,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: widget.localization,
|
||||||
|
enabledBorder: widget.textController.text.isEmpty
|
||||||
|
? const UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.red))
|
||||||
|
: const UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.green)),
|
||||||
|
focusedBorder: widget.textController.text.isEmpty
|
||||||
|
? const UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.red))
|
||||||
|
: const UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.green)),
|
||||||
|
),
|
||||||
|
controller: widget.textController,
|
||||||
|
)),
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.bottomLeft,
|
||||||
|
child: FutureBuilder<List<Map<String, dynamic>>>(
|
||||||
|
future: Standort,
|
||||||
|
builder: (BuildContext context,
|
||||||
|
AsyncSnapshot<List<Map<String, dynamic>>> snapshot) {
|
||||||
|
if (snapshot.hasData) {
|
||||||
|
return DropdownButton<String>(
|
||||||
|
items: snapshot.data!
|
||||||
|
.map((item) =>
|
||||||
|
buildMenuItem(item['Standort'].toString()))
|
||||||
|
.toList(),
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(
|
||||||
|
() {
|
||||||
|
widget.textController.text = value ?? '';
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
value: null,
|
||||||
|
underline: const SizedBox(),
|
||||||
|
);
|
||||||
|
} else if (snapshot.hasError) {
|
||||||
|
return Text('Fehler: ${snapshot.error}');
|
||||||
|
} else {
|
||||||
|
return const CircularProgressIndicator();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
DropdownMenuItem<String> buildMenuItem(String item) => DropdownMenuItem(
|
||||||
|
value: item,
|
||||||
|
child: Text(item),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// CamId == ID of the camera
|
// CamId == ID of the camera
|
||||||
|
|
||||||
class CamId extends StatefulWidget {
|
class CamId extends StatefulWidget {
|
||||||
@@ -45,8 +231,8 @@ class _CamIdState extends State<CamId> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
keyboardType: TextInputType.multiline,
|
keyboardType: TextInputType.multiline,
|
||||||
maxLines: null,
|
maxLines: null,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: AppLocalizations.of(context)!.camLink,
|
hintText: AppLocalizations.of(context)!.camLink,
|
||||||
enabledBorder: widget.id.text.isEmpty
|
enabledBorder: widget.id.text.isEmpty
|
||||||
@@ -233,7 +419,9 @@ class Karte extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class KarteState extends State<Karte> {
|
class KarteState extends State<Karte> {
|
||||||
List<Marker> markers = [const Marker(point: LatLng(0, 0), child: Icon(Icons.location_on))];
|
List<Marker> markers = [
|
||||||
|
const Marker(point: LatLng(0, 0), child: Icon(Icons.location_on))
|
||||||
|
];
|
||||||
LatLng? selectedPosition;
|
LatLng? selectedPosition;
|
||||||
Position? updatedPosition;
|
Position? updatedPosition;
|
||||||
bool saveVisible = false;
|
bool saveVisible = false;
|
||||||
@@ -241,7 +429,15 @@ class KarteState extends State<Karte> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
markers = [Marker(point: LatLng(widget.currentPosition.latitude, widget.currentPosition.longitude), child: const Icon(Icons.location_on, color: Colors.red,))];
|
markers = [
|
||||||
|
Marker(
|
||||||
|
point: LatLng(widget.currentPosition.latitude,
|
||||||
|
widget.currentPosition.longitude),
|
||||||
|
child: const Icon(
|
||||||
|
Icons.location_on,
|
||||||
|
color: Colors.red,
|
||||||
|
))
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -283,9 +479,12 @@ class KarteState extends State<Karte> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: FlutterMap(
|
body: FlutterMap(
|
||||||
mapController: MapController(),
|
mapController: MapController(),
|
||||||
options: MapOptions(
|
options: MapOptions(
|
||||||
interactionOptions: const InteractionOptions(flags: InteractiveFlag.pinchZoom | InteractiveFlag.drag | InteractiveFlag.pinchMove),
|
interactionOptions: const InteractionOptions(
|
||||||
|
flags: InteractiveFlag.pinchZoom |
|
||||||
|
InteractiveFlag.drag |
|
||||||
|
InteractiveFlag.pinchMove),
|
||||||
initialCenter: LatLng(widget.currentPosition.latitude,
|
initialCenter: LatLng(widget.currentPosition.latitude,
|
||||||
widget.currentPosition.longitude),
|
widget.currentPosition.longitude),
|
||||||
initialZoom: 16.0,
|
initialZoom: 16.0,
|
||||||
@@ -406,7 +605,7 @@ class Adresse1 extends StatefulWidget {
|
|||||||
const Adresse1({super.key, required this.adresse1C});
|
const Adresse1({super.key, required this.adresse1C});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<Adresse1> createState() => _Adresse1State();
|
State<Adresse1> createState() => _Adresse1State();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _Adresse1State extends State<Adresse1> {
|
class _Adresse1State extends State<Adresse1> {
|
||||||
@@ -551,7 +750,8 @@ class _Adresse2State extends State<Adresse2> {
|
|||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
return DropdownButton<String>(
|
return DropdownButton<String>(
|
||||||
items: snapshot.data!
|
items: snapshot.data!
|
||||||
.map((item) => buildMenuItem(item['Adresse2'].toString()))
|
.map((item) =>
|
||||||
|
buildMenuItem(item['Adresse2'].toString()))
|
||||||
.toList(),
|
.toList(),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(
|
setState(
|
||||||
@@ -1721,7 +1921,8 @@ class _AbbauDatState extends State<AbbauDat> {
|
|||||||
),
|
),
|
||||||
Builder(builder: (context) {
|
Builder(builder: (context) {
|
||||||
if (abbauDat != null) {
|
if (abbauDat != null) {
|
||||||
return Text('${abbauDat?.day}. ${abbauDat?.month}. ${abbauDat?.year}');
|
return Text(
|
||||||
|
'${abbauDat?.day}. ${abbauDat?.month}. ${abbauDat?.year}');
|
||||||
} else {
|
} else {
|
||||||
return Text(AppLocalizations.of(context)!.nichts);
|
return Text(AppLocalizations.of(context)!.nichts);
|
||||||
}
|
}
|
||||||
@@ -2216,96 +2417,6 @@ class _FKontakt3State extends State<FKontakt3> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Standort
|
|
||||||
|
|
||||||
class Standort extends StatefulWidget {
|
|
||||||
final TextEditingController standortC;
|
|
||||||
|
|
||||||
const Standort({super.key, required this.standortC});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<Standort> createState() => _StandortState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _StandortState extends State<Standort> {
|
|
||||||
String? selectedRudel;
|
|
||||||
late Future<List<Map<String, dynamic>>> Standort;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
Standort = DBHelper().getPlace();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: TextField(
|
|
||||||
keyboardType: TextInputType.multiline,
|
|
||||||
maxLines: null,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
hintText: AppLocalizations.of(context)!.altstort,
|
|
||||||
enabledBorder: widget.standortC.text.isEmpty
|
|
||||||
? const UnderlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.red))
|
|
||||||
: const UnderlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.green)),
|
|
||||||
focusedBorder: widget.standortC.text.isEmpty
|
|
||||||
? const UnderlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.red))
|
|
||||||
: const UnderlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.green)),
|
|
||||||
),
|
|
||||||
controller: widget.standortC,
|
|
||||||
)),
|
|
||||||
Expanded(
|
|
||||||
flex: 1,
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.bottomLeft,
|
|
||||||
child: FutureBuilder<List<Map<String, dynamic>>>(
|
|
||||||
future: Standort,
|
|
||||||
builder: (BuildContext context,
|
|
||||||
AsyncSnapshot<List<Map<String, dynamic>>> snapshot) {
|
|
||||||
if (snapshot.hasData) {
|
|
||||||
return DropdownButton<String>(
|
|
||||||
items: snapshot.data!
|
|
||||||
.map((item) =>
|
|
||||||
buildMenuItem(item['Standort'].toString()))
|
|
||||||
.toList(),
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(
|
|
||||||
() {
|
|
||||||
selectedRudel = value;
|
|
||||||
widget.standortC.text = value ?? '';
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
value: null,
|
|
||||||
underline: const SizedBox(),
|
|
||||||
);
|
|
||||||
} else if (snapshot.hasError) {
|
|
||||||
return Text('Fehler: ${snapshot.error}');
|
|
||||||
} else {
|
|
||||||
return const CircularProgressIndicator();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
DropdownMenuItem<String> buildMenuItem(String item) => DropdownMenuItem(
|
|
||||||
value: item,
|
|
||||||
child: Text(item),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// KTage1
|
// KTage1
|
||||||
|
|
||||||
class KTage1 extends StatefulWidget {
|
class KTage1 extends StatefulWidget {
|
||||||
|
|||||||
Reference in New Issue
Block a user