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)
]); ]);
} }
@@ -45,9 +45,10 @@ 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:
TextFormField(
//Location Name //Location Name
onSaved: (input) { onSaved: (input) {
newLocationName = input; newLocationName = input;
@@ -64,7 +65,7 @@ class AddLocationsFormState extends State<AddLocationsForm> {
}), }),
decoration: const InputDecoration( decoration: const InputDecoration(
border: UnderlineInputBorder(), labelText: "Location Name"), 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))
+9 -8
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(
child: Padding(
padding: const EdgeInsets.all(20), padding: const EdgeInsets.all(20),
child: Center( child: Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
for (String name in locations) for (String name in locations)
ManageSingleLocation(name: name, delete: deleteLocation), ManageSingleLocation(
name: name, delete: deleteLocation),
...[ ...[
const SizedBox(height: 20), const SizedBox(height: 20),
const Text("Add location by search"), const Text("Add location by search"),
AddLocationBySearchForm(saveNewLocation: saveNewLocation), AddLocationBySearchForm(
saveNewLocation: saveNewLocation),
const SizedBox(height: 20), const SizedBox(height: 20),
const Text("Add location by coordinates"), const Text("Add location by coordinates"),
Flexible( AddLocationsForm(
fit: FlexFit.loose,
child: AddLocationsForm(
saveNewLocation: saveNewLocation, saveNewLocation: saveNewLocation,
savedLocations: locations)), savedLocations: locations),
], ],
])))); ])))));
} }
} }