Fixed bugs: overflows on location view, made location view scrollable

This commit is contained in:
Konstantin Kollar
2022-09-06 12:53:53 +02:00
parent e93dc0f771
commit 9f4b99c5f9
4 changed files with 52 additions and 43 deletions
@@ -67,8 +67,12 @@ class _AddLocationBySearchFormState extends State<AddLocationBySearchForm> {
children: [_singleResult(name: "No result")], children: [_singleResult(name: "No result")],
); );
} }
Iterable<LocationModel> locationsToShow = _locations!;
if (locationsToShow.length > 3) {
locationsToShow = _locations!.getRange(0, 3);
}
return Column(children: [ return Column(children: [
for (LocationModel location in _locations!.getRange(0, 3)) for (LocationModel location in locationsToShow)
_singleResult(name: location.name, location: location) _singleResult(name: location.name, location: location)
]); ]);
} }
+21 -20
View File
@@ -45,26 +45,27 @@ class AddLocationsFormState extends State<AddLocationsForm> {
return Form( return Form(
key: _formKey, key: _formKey,
child: Column(children: [ child: Column(children: [
Flexible( // Flexible(
flex: 4, // flex: 4,
child: TextFormField( // child:
//Location Name TextFormField(
onSaved: (input) { //Location Name
newLocationName = input; onSaved: (input) {
}, newLocationName = input;
controller: locationFormController, },
validator: ((value) { controller: locationFormController,
if (value == null || value.isEmpty) { validator: ((value) {
return "Please enter a name for the new location"; if (value == null || value.isEmpty) {
} return "Please enter a name for the new location";
if (widget.savedLocations.contains(value)) { }
return "Location name already in use"; if (widget.savedLocations.contains(value)) {
} return "Location name already in use";
return null; }
}), return null;
decoration: const InputDecoration( }),
border: UnderlineInputBorder(), labelText: "Location Name"), decoration: const InputDecoration(
)), border: UnderlineInputBorder(), labelText: "Location Name"),
),
Row( Row(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
@@ -13,8 +13,11 @@ class ManageSingleLocation extends StatelessWidget {
child: Padding( child: Padding(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
child: Row(children: [ child: Row(children: [
Text(name, style: Theme.of(context).textTheme.headline5), Expanded(
const Spacer(), child: Padding(
padding: const EdgeInsets.only(right: 12),
child: Text(name,
style: Theme.of(context).textTheme.headline5))),
GestureDetector( GestureDetector(
onTap: () => delete(name), onTap: () => delete(name),
child: const Icon(Icons.delete_sharp)) child: const Icon(Icons.delete_sharp))
+21 -20
View File
@@ -37,26 +37,27 @@ class _LocationsState extends State<Locations> {
appBar: AppBar( appBar: AppBar(
title: const Text('Locations'), title: const Text('Locations'),
), ),
body: Padding( body: SingleChildScrollView(
padding: const EdgeInsets.all(20), child: Padding(
child: Center( padding: const EdgeInsets.all(20),
child: Column( child: Center(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, child: Column(
children: [ mainAxisAlignment: MainAxisAlignment.spaceEvenly,
for (String name in locations) children: [
ManageSingleLocation(name: name, delete: deleteLocation), for (String name in locations)
...[ ManageSingleLocation(
const SizedBox(height: 20), name: name, delete: deleteLocation),
const Text("Add location by search"), ...[
AddLocationBySearchForm(saveNewLocation: saveNewLocation), const SizedBox(height: 20),
const SizedBox(height: 20), const Text("Add location by search"),
const Text("Add location by coordinates"), AddLocationBySearchForm(
Flexible( saveNewLocation: saveNewLocation),
fit: FlexFit.loose, const SizedBox(height: 20),
child: AddLocationsForm( const Text("Add location by coordinates"),
AddLocationsForm(
saveNewLocation: saveNewLocation, saveNewLocation: saveNewLocation,
savedLocations: locations)), savedLocations: locations),
], ],
])))); ])))));
} }
} }