flutter fixes and pipeline speedup
This commit is contained in:
@@ -86,8 +86,8 @@ class _NewEntryPageState extends State<NewEntryPage> {
|
||||
final tripIds = sorted.map((t) => t.tripId).toSet();
|
||||
final selectedValue =
|
||||
(_selectedTripId != null && tripIds.contains(_selectedTripId))
|
||||
? _selectedTripId
|
||||
: null;
|
||||
? _selectedTripId
|
||||
: null;
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -100,8 +100,10 @@ class _NewEntryPageState extends State<NewEntryPage> {
|
||||
items: [
|
||||
const DropdownMenuItem(value: null, child: Text('No trip')),
|
||||
...sorted.map(
|
||||
(t) =>
|
||||
DropdownMenuItem<int?>(value: t.tripId, child: Text(t.tripName)),
|
||||
(t) => DropdownMenuItem<int?>(
|
||||
value: t.tripId,
|
||||
child: Text(t.tripName),
|
||||
),
|
||||
),
|
||||
],
|
||||
onChanged: (val) {
|
||||
@@ -304,7 +306,7 @@ class _NewEntryPageState extends State<NewEntryPage> {
|
||||
|
||||
if (_useManualMileage) {
|
||||
final body = {
|
||||
"leg_trip": _selectedTripId ?? null,
|
||||
"leg_trip": _selectedTripId,
|
||||
"leg_start": startVal,
|
||||
"leg_end": endVal,
|
||||
"leg_begin_time": _legDateTime.toIso8601String(),
|
||||
@@ -318,7 +320,7 @@ class _NewEntryPageState extends State<NewEntryPage> {
|
||||
await api.post('/add/manual', body);
|
||||
} else {
|
||||
final body = {
|
||||
"leg_trip": _selectedTripId ?? null,
|
||||
"leg_trip": _selectedTripId,
|
||||
"leg_begin_time": _legDateTime.toIso8601String(),
|
||||
"leg_route": routeStations,
|
||||
"leg_notes": _notesController.text.trim(),
|
||||
@@ -429,14 +431,15 @@ class _NewEntryPageState extends State<NewEntryPage> {
|
||||
_useManualMileage = data['useManualMileage'] ?? _useManualMileage;
|
||||
_selectedTripId = data['selectedTripId'];
|
||||
if (data['routeResult'] is Map<String, dynamic>) {
|
||||
_routeResult =
|
||||
RouteResult.fromJson(Map<String, dynamic>.from(data['routeResult']));
|
||||
_routeResult = RouteResult.fromJson(
|
||||
Map<String, dynamic>.from(data['routeResult']),
|
||||
);
|
||||
_mileageController.text = _routeResult!.distance.toStringAsFixed(2);
|
||||
}
|
||||
if (data['tractionItems'] is List) {
|
||||
_restoreTractionItems(List<Map<String, dynamic>>.from(
|
||||
data['tractionItems'].cast<Map>(),
|
||||
));
|
||||
_restoreTractionItems(
|
||||
List<Map<String, dynamic>>.from(data['tractionItems'].cast<Map>()),
|
||||
);
|
||||
}
|
||||
});
|
||||
_startController.text = data['start'] ?? '';
|
||||
@@ -609,34 +612,34 @@ class _NewEntryPageState extends State<NewEntryPage> {
|
||||
final mileagePanel = _section(
|
||||
'Mileage',
|
||||
[
|
||||
if (_useManualMileage)
|
||||
TextFormField(
|
||||
controller: _mileageController,
|
||||
keyboardType: const TextInputType.numberWithOptions(
|
||||
decimal: true,
|
||||
if (_useManualMileage)
|
||||
TextFormField(
|
||||
controller: _mileageController,
|
||||
keyboardType: const TextInputType.numberWithOptions(
|
||||
decimal: true,
|
||||
),
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Mileage (mi)',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
)
|
||||
else if (_routeResult != null)
|
||||
ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: const Text('Calculated mileage'),
|
||||
subtitle: Text(
|
||||
'${_routeResult!.distance.toStringAsFixed(2)} mi',
|
||||
),
|
||||
),
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Mileage (mi)',
|
||||
border: OutlineInputBorder(),
|
||||
if (!_useManualMileage)
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: _openCalculator,
|
||||
icon: const Icon(Icons.calculate),
|
||||
label: const Text('Open mileage calculator'),
|
||||
),
|
||||
),
|
||||
)
|
||||
else if (_routeResult != null)
|
||||
ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: const Text('Calculated mileage'),
|
||||
subtitle: Text(
|
||||
'${_routeResult!.distance.toStringAsFixed(2)} mi',
|
||||
),
|
||||
),
|
||||
if (!_useManualMileage)
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: _openCalculator,
|
||||
icon: const Icon(Icons.calculate),
|
||||
label: const Text('Open mileage calculator'),
|
||||
),
|
||||
),
|
||||
],
|
||||
trailing: FilterChip(
|
||||
label: Text(_useManualMileage ? 'Manual' : 'Automatic'),
|
||||
@@ -793,9 +796,9 @@ class _NewEntryPageState extends State<NewEntryPage> {
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.bold),
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
if (trailing != null) trailing,
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user