Fixed bugs: overflows on location view, made location view scrollable
This commit is contained in:
@@ -67,8 +67,12 @@ class _AddLocationBySearchFormState extends State<AddLocationBySearchForm> {
|
||||
children: [_singleResult(name: "No result")],
|
||||
);
|
||||
}
|
||||
Iterable<LocationModel> locationsToShow = _locations!;
|
||||
if (locationsToShow.length > 3) {
|
||||
locationsToShow = _locations!.getRange(0, 3);
|
||||
}
|
||||
return Column(children: [
|
||||
for (LocationModel location in _locations!.getRange(0, 3))
|
||||
for (LocationModel location in locationsToShow)
|
||||
_singleResult(name: location.name, location: location)
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -45,26 +45,27 @@ class AddLocationsFormState extends State<AddLocationsForm> {
|
||||
return Form(
|
||||
key: _formKey,
|
||||
child: Column(children: [
|
||||
Flexible(
|
||||
flex: 4,
|
||||
child: TextFormField(
|
||||
//Location Name
|
||||
onSaved: (input) {
|
||||
newLocationName = input;
|
||||
},
|
||||
controller: locationFormController,
|
||||
validator: ((value) {
|
||||
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";
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
decoration: const InputDecoration(
|
||||
border: UnderlineInputBorder(), labelText: "Location Name"),
|
||||
)),
|
||||
// Flexible(
|
||||
// flex: 4,
|
||||
// child:
|
||||
TextFormField(
|
||||
//Location Name
|
||||
onSaved: (input) {
|
||||
newLocationName = input;
|
||||
},
|
||||
controller: locationFormController,
|
||||
validator: ((value) {
|
||||
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";
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
decoration: const InputDecoration(
|
||||
border: UnderlineInputBorder(), labelText: "Location Name"),
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
|
||||
@@ -13,8 +13,11 @@ class ManageSingleLocation extends StatelessWidget {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Row(children: [
|
||||
Text(name, style: Theme.of(context).textTheme.headline5),
|
||||
const Spacer(),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 12),
|
||||
child: Text(name,
|
||||
style: Theme.of(context).textTheme.headline5))),
|
||||
GestureDetector(
|
||||
onTap: () => delete(name),
|
||||
child: const Icon(Icons.delete_sharp))
|
||||
|
||||
+21
-20
@@ -37,26 +37,27 @@ class _LocationsState extends State<Locations> {
|
||||
appBar: AppBar(
|
||||
title: const Text('Locations'),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
for (String name in locations)
|
||||
ManageSingleLocation(name: name, delete: deleteLocation),
|
||||
...[
|
||||
const SizedBox(height: 20),
|
||||
const Text("Add location by search"),
|
||||
AddLocationBySearchForm(saveNewLocation: saveNewLocation),
|
||||
const SizedBox(height: 20),
|
||||
const Text("Add location by coordinates"),
|
||||
Flexible(
|
||||
fit: FlexFit.loose,
|
||||
child: AddLocationsForm(
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
for (String name in locations)
|
||||
ManageSingleLocation(
|
||||
name: name, delete: deleteLocation),
|
||||
...[
|
||||
const SizedBox(height: 20),
|
||||
const Text("Add location by search"),
|
||||
AddLocationBySearchForm(
|
||||
saveNewLocation: saveNewLocation),
|
||||
const SizedBox(height: 20),
|
||||
const Text("Add location by coordinates"),
|
||||
AddLocationsForm(
|
||||
saveNewLocation: saveNewLocation,
|
||||
savedLocations: locations)),
|
||||
],
|
||||
]))));
|
||||
savedLocations: locations),
|
||||
],
|
||||
])))));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user