From c1086a90f8fb5d77b0003f4da60aa9af3b096502 Mon Sep 17 00:00:00 2001 From: zkhan Date: Wed, 5 Jun 2024 20:27:01 -0400 Subject: [PATCH] capitalize aircraft input, trim spaces from plan input --- lib/aircraft.dart | 60 ++++++++++++++++++------------------- lib/plan_create_widget.dart | 20 ++++++++----- lib/plan_screen.dart | 1 - 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/lib/aircraft.dart b/lib/aircraft.dart index 2542e31..a65e1f3 100644 --- a/lib/aircraft.dart +++ b/lib/aircraft.dart @@ -53,41 +53,41 @@ class Aircraft { factory Aircraft.fromMap(Map map) { return Aircraft( - map['tail'] as String, - map['type'] as String, - map['wake'] as String, - map['icao'] as String, - map['equipment'] as String, - map['cruiseTas'] as String, - map['surveillance'] as String, - map['fuelEndurance'] as String, - map['color'] as String, - map['pic'] as String, - map['picInfo'] as String, - map['sinkRate'] as String, - map['fuelBurn'] as String, - map['base'] as String, - map['other'] as String, + (map['tail'] as String).toUpperCase(), + (map['type'] as String).toUpperCase(), + (map['wake'] as String).toUpperCase(), + (map['icao'] as String).toUpperCase(), + (map['equipment'] as String).toUpperCase(), + (map['cruiseTas'] as String).toUpperCase(), + (map['surveillance'] as String).toUpperCase(), + (map['fuelEndurance'] as String).toUpperCase(), + (map['color'] as String).toUpperCase(), + (map['pic'] as String).toUpperCase(), + (map['picInfo'] as String).toUpperCase(), + (map['sinkRate'] as String).toUpperCase(), + (map['fuelBurn'] as String).toUpperCase(), + (map['base'] as String).toUpperCase(), + (map['other'] as String).toUpperCase(), ); } Map toMap() { return { - 'tail': tail, - 'type': type, - 'wake': wake, - 'icao': icao, - 'equipment': equipment, - 'cruiseTas': cruiseTas, - 'surveillance': surveillance, - 'fuelEndurance': fuelEndurance, - 'color': color, - 'pic': pic, - 'picInfo': picInfo, - 'sinkRate': sinkRate, - 'fuelBurn': fuelBurn, - 'base': base, - 'other': other, + 'tail': tail.toUpperCase(), + 'type': type.toUpperCase(), + 'wake': wake.toUpperCase(), + 'icao': icao.toUpperCase(), + 'equipment': equipment.toUpperCase(), + 'cruiseTas': cruiseTas.toUpperCase(), + 'surveillance': surveillance.toUpperCase(), + 'fuelEndurance': fuelEndurance.toUpperCase(), + 'color': color.toUpperCase(), + 'pic': pic.toUpperCase(), + 'picInfo': picInfo.toUpperCase(), + 'sinkRate': sinkRate.toUpperCase(), + 'fuelBurn': fuelBurn.toUpperCase(), + 'base': base.toUpperCase(), + 'other': other.toUpperCase(), }; } } \ No newline at end of file diff --git a/lib/plan_create_widget.dart b/lib/plan_create_widget.dart index 2b69a36..2baedf8 100644 --- a/lib/plan_create_widget.dart +++ b/lib/plan_create_widget.dart @@ -1,6 +1,5 @@ import 'package:avaremp/plan_lmfs.dart'; import 'package:avaremp/plan_route.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:avaremp/storage.dart'; import 'package:flutter/widgets.dart'; @@ -35,7 +34,7 @@ class PlanCreateWidgetState extends State { onChanged: (value) { _route = value; }, - initialValue: _route, + initialValue: _route.trim(), decoration: const InputDecoration(border: UnderlineInputBorder(), labelText: 'Route',) ) ), @@ -54,9 +53,11 @@ class PlanCreateWidgetState extends State { if(_getting) { return; } - Storage().settings.setLastRouteEntry(_route); + String input = _route.trim(); + + Storage().settings.setLastRouteEntry(input); setState(() {_getting = true;}); - PlanRoute.fromLine("New Plan", _route).then((value) { + PlanRoute.fromLine("New Plan", input).then((value) { Storage().route.copyFrom(value); Storage().route.setCurrentWaypoint(0); setState(() {_getting = false;}); @@ -67,12 +68,13 @@ class PlanCreateWidgetState extends State { PopupMenuItem( child: const Text('Create IFR Preferred Route'), onTap: () { + String input = _route.trim(); if(_getting) { return; } - Storage().settings.setLastRouteEntry(_route); + Storage().settings.setLastRouteEntry(input); setState(() {_getting = true;}); - PlanRoute.fromPreferred("New Plan", _route, Storage().route.altitude, Storage().route.altitude).then((value) { + PlanRoute.fromPreferred("New Plan", input, Storage().route.altitude, Storage().route.altitude).then((value) { Storage().route.copyFrom(value); Storage().route.setCurrentWaypoint(0); setState(() {_getting = false;}); @@ -86,10 +88,12 @@ class PlanCreateWidgetState extends State { if(_getting) { return; } - Storage().settings.setLastRouteEntry(_route); + String input = _route.trim(); + + Storage().settings.setLastRouteEntry(input); setState(() {_getting = true;}); LmfsInterface interface = LmfsInterface(); - List wps = _route.split(" "); + List wps = input.split(" "); if(wps.length < 2) { setState(() {_getting = false;}); return; diff --git a/lib/plan_screen.dart b/lib/plan_screen.dart index bb744b0..cb35b99 100644 --- a/lib/plan_screen.dart +++ b/lib/plan_screen.dart @@ -10,7 +10,6 @@ import 'package:avaremp/storage.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'package:dropdown_button2/dropdown_button2.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; import 'data/altitude_profile.dart'; class PlanScreen extends StatefulWidget {