Skip to content

Commit

Permalink
capitalize aircraft input, trim spaces from plan input
Browse files Browse the repository at this point in the history
  • Loading branch information
apps4av committed Jun 6, 2024
1 parent 7ca4ecf commit c1086a9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 39 deletions.
60 changes: 30 additions & 30 deletions lib/aircraft.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,41 +53,41 @@ class Aircraft {

factory Aircraft.fromMap(Map<String, dynamic> 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<String, dynamic> 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(),
};
}
}
20 changes: 12 additions & 8 deletions lib/plan_create_widget.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -35,7 +34,7 @@ class PlanCreateWidgetState extends State<PlanCreateWidget> {
onChanged: (value) {
_route = value;
},
initialValue: _route,
initialValue: _route.trim(),
decoration: const InputDecoration(border: UnderlineInputBorder(), labelText: 'Route',)
)
),
Expand All @@ -54,9 +53,11 @@ class PlanCreateWidgetState extends State<PlanCreateWidget> {
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;});
Expand All @@ -67,12 +68,13 @@ class PlanCreateWidgetState extends State<PlanCreateWidget> {
PopupMenuItem<String>(
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;});
Expand All @@ -86,10 +88,12 @@ class PlanCreateWidgetState extends State<PlanCreateWidget> {
if(_getting) {
return;
}
Storage().settings.setLastRouteEntry(_route);
String input = _route.trim();

Storage().settings.setLastRouteEntry(input);
setState(() {_getting = true;});
LmfsInterface interface = LmfsInterface();
List<String> wps = _route.split(" ");
List<String> wps = input.split(" ");
if(wps.length < 2) {
setState(() {_getting = false;});
return;
Expand Down
1 change: 0 additions & 1 deletion lib/plan_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c1086a9

Please sign in to comment.