show correct landmark types when fetching from api
This commit is contained in:
		| @@ -29,66 +29,64 @@ class _NewTripPageState extends State<NewTripPage> { | ||||
|       ), | ||||
|       body: Form( | ||||
|         key: _formKey, | ||||
|         child:  | ||||
|           Padding( | ||||
|             padding: const EdgeInsets.all(15.0), | ||||
|             child: Column( | ||||
|               crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                | ||||
|               children: <Widget>[ | ||||
|                 TextFormField( | ||||
|                   decoration: const InputDecoration(hintText: 'Lat'), | ||||
|                   controller: latController, | ||||
|                   validator: (String? value) { | ||||
|                     if (value == null || value.isEmpty || double.tryParse(value) == null){ | ||||
|                       return 'Please enter a floating point number'; | ||||
|                     } | ||||
|                     return null; | ||||
|                   }, | ||||
|                 ), | ||||
|                 TextFormField( | ||||
|                   decoration: const InputDecoration(hintText: 'Lon'), | ||||
|                   controller: lonController, | ||||
|         child: Padding( | ||||
|           padding: const EdgeInsets.all(15.0), | ||||
|           child: Column( | ||||
|             crossAxisAlignment: CrossAxisAlignment.start, | ||||
|              | ||||
|             children: <Widget>[ | ||||
|               TextFormField( | ||||
|                 decoration: const InputDecoration(hintText: 'Lat'), | ||||
|                 controller: latController, | ||||
|                 validator: (String? value) { | ||||
|                   if (value == null || value.isEmpty || double.tryParse(value) == null){ | ||||
|                     return 'Please enter a floating point number'; | ||||
|                   } | ||||
|                   return null; | ||||
|                 }, | ||||
|               ), | ||||
|               TextFormField( | ||||
|                 decoration: const InputDecoration(hintText: 'Lon'), | ||||
|                 controller: lonController, | ||||
|  | ||||
|                   validator: (String? value) { | ||||
|                     if (value == null || value.isEmpty || double.tryParse(value) == null){ | ||||
|                       return 'Please enter a floating point number'; | ||||
|                     } | ||||
|                     return null; | ||||
|                   }, | ||||
|                 ), | ||||
|                 Divider(height: 15, color: Colors.transparent), | ||||
|                 ElevatedButton( | ||||
|                   onPressed: () { | ||||
|                     if (_formKey.currentState!.validate()) { | ||||
|                       List<double> startPoint = [ | ||||
|                         double.parse(latController.text), | ||||
|                         double.parse(lonController.text) | ||||
|                       ]; | ||||
|                       Future<UserPreferences> preferences = loadUserPreferences(); | ||||
|                       Trip trip = Trip(); | ||||
|                       trip.landmarks.add( | ||||
|                         Landmark( | ||||
|                           location: startPoint, | ||||
|                           name: "start", | ||||
|                           type: LandmarkType(name: 'start'), | ||||
|                           uuid: "pending" | ||||
|                         ) | ||||
|                       ); | ||||
|                       fetchTrip(trip, preferences); | ||||
|                         Navigator.of(context).push( | ||||
|                           MaterialPageRoute( | ||||
|                             builder: (context) => BasePage(mainScreen: "map", trip: trip) | ||||
|                           ) | ||||
|                         ); | ||||
|                     } | ||||
|                   }, | ||||
|                   child: const Text('Create trip'), | ||||
|                 ), | ||||
|               ], | ||||
|             ), | ||||
|           ) | ||||
|          | ||||
|                 validator: (String? value) { | ||||
|                   if (value == null || value.isEmpty || double.tryParse(value) == null){ | ||||
|                     return 'Please enter a floating point number'; | ||||
|                   } | ||||
|                   return null; | ||||
|                 }, | ||||
|               ), | ||||
|               Divider(height: 15, color: Colors.transparent), | ||||
|               ElevatedButton( | ||||
|                 child: const Text('Create trip'), | ||||
|                 onPressed: () { | ||||
|                   if (_formKey.currentState!.validate()) { | ||||
|                     List<double> startPoint = [ | ||||
|                       double.parse(latController.text), | ||||
|                       double.parse(lonController.text) | ||||
|                     ]; | ||||
|                     Future<UserPreferences> preferences = loadUserPreferences(); | ||||
|                     Trip trip = Trip(); | ||||
|                     trip.landmarks.add( | ||||
|                       Landmark( | ||||
|                         location: startPoint, | ||||
|                         name: "Start", | ||||
|                         type: start, | ||||
|                         uuid: "pending" | ||||
|                       ) | ||||
|                     ); | ||||
|                     fetchTrip(trip, preferences); | ||||
|                     Navigator.of(context).push( | ||||
|                       MaterialPageRoute( | ||||
|                         builder: (context) => BasePage(mainScreen: "map", trip: trip) | ||||
|                       ) | ||||
|                     ); | ||||
|                   } | ||||
|                 }, | ||||
|               ), | ||||
|             ], | ||||
|           ), | ||||
|         ) | ||||
|       ) | ||||
|     ); | ||||
|   } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user