From 11be91593da180d2b3e4c5ab970b5162d1f6b1ee Mon Sep 17 00:00:00 2001 From: Pete Gregory Date: Sun, 24 Aug 2025 23:34:14 +0100 Subject: [PATCH] general minor modifications --- lib/components/calculator/calculator.dart | 3 ++- lib/components/login/login.dart | 6 ++++-- lib/components/pages/traction.dart | 20 +++++++++++++++++++- lib/main.dart | 7 ++----- lib/objects/objects.dart | 4 ++-- 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/lib/components/calculator/calculator.dart b/lib/components/calculator/calculator.dart index 3fd3e90..ed45a0a 100644 --- a/lib/components/calculator/calculator.dart +++ b/lib/components/calculator/calculator.dart @@ -187,6 +187,7 @@ class _RouteCalculatorState extends State { children: [ Expanded( child: ReorderableListView( + buildDefaultDragHandles: false, padding: const EdgeInsets.symmetric(vertical: 8), onReorder: (oldIndex, newIndex) { if (newIndex > oldIndex) newIndex -= 1; @@ -205,7 +206,7 @@ class _RouteCalculatorState extends State { ReorderableDragStartListener( index: index, child: const Padding( - padding: EdgeInsets.only(top: 16), + padding: EdgeInsets.only(top: 28), child: Icon(Icons.drag_indicator), ), ), diff --git a/lib/components/login/login.dart b/lib/components/login/login.dart index 194803e..3db5461 100644 --- a/lib/components/login/login.dart +++ b/lib/components/login/login.dart @@ -172,20 +172,22 @@ class _LoginPanelContentState extends State { style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), ), - TextField( + TextFormField( controller: _usernameController, decoration: InputDecoration( border: OutlineInputBorder(), labelText: "Username", ), + onFieldSubmitted: (_) => login(), ), - TextField( + TextFormField( controller: _passwordController, obscureText: true, decoration: InputDecoration( border: OutlineInputBorder(), labelText: "Password", ), + onFieldSubmitted: (_) => login(), ), Row( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/components/pages/traction.dart b/lib/components/pages/traction.dart index eceaa7a..253ed29 100644 --- a/lib/components/pages/traction.dart +++ b/lib/components/pages/traction.dart @@ -14,7 +14,25 @@ class TractionPage extends StatelessWidget { margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8), child: Padding( padding: EdgeInsets.all(16), - child: Text('${loco.locoClass} ${loco.number}'), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [Text('${loco.locoClass} ${loco.number}')], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '${loco.name}', + style: TextStyle(fontStyle: FontStyle.italic), + ), + Text('${loco.mileage} mi'), + ], + ), + ], + ), ), ); }, diff --git a/lib/main.dart b/lib/main.dart index 789cb6f..0f22107 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -160,6 +160,7 @@ class _MyHomePageState extends State { "/legs", "/traction", "/trips", + "/add", ]; int _getIndexFromLocation(String location) { @@ -263,14 +264,10 @@ class _MyHomePageState extends State { NavigationDestination(icon: Icon(Icons.list), label: "Entries"), NavigationDestination(icon: Icon(Icons.train), label: "Traction"), NavigationDestination(icon: Icon(Icons.book), label: "Trips"), + NavigationDestination(icon: Icon(Icons.add), label: "Add"), ], ), body: currentPage, - floatingActionButton: FloatingActionButton( - onPressed: () => {context.push("/add")}, - tooltip: 'New Entry', - child: const Icon(Icons.add), - ), // This trailing comma makes auto-formatting nicer for build methods. ); } } diff --git a/lib/objects/objects.dart b/lib/objects/objects.dart index 80a9e6c..f0e7377 100644 --- a/lib/objects/objects.dart +++ b/lib/objects/objects.dart @@ -144,8 +144,8 @@ class LocoSummary extends Loco { locoOperator: json['loco_operator'], locoNotes: json['loco_notes'], locoEvn: json['loco_evn'], - mileage: (json['loco_mileage'] as num?)?.toDouble(), - journeys: json['loco_journeys'], + mileage: (json['loco_mileage'] as num?)?.toDouble() ?? 0, + journeys: json['loco_journeys'] ?? 0, ); }