Compare commits

...

4 Commits

Author SHA1 Message Date
e1ad1ea685 remove windows
All checks were successful
Release / meta (push) Successful in 8s
Release / linux-build (push) Successful in 6m55s
Release / android-build (push) Successful in 22m33s
Release / release-dev (push) Successful in 26s
Release / release-master (push) Successful in 25s
2025-12-30 12:18:37 +00:00
9b307ab56b add windows build
Some checks failed
Release / meta (push) Successful in 18s
Release / windows-build (push) Has been cancelled
Release / release-dev (push) Has been cancelled
Release / release-master (push) Has been cancelled
Release / linux-build (push) Has been cancelled
Release / android-build (push) Has been cancelled
2025-12-30 12:12:17 +00:00
8cf43c76e2 re add calculator page
Some checks failed
Release / meta (push) Successful in 11s
Release / linux-build (push) Successful in 8m31s
Release / release-dev (push) Has been cancelled
Release / release-master (push) Has been cancelled
Release / android-build (push) Has been cancelled
2025-12-30 11:55:46 +00:00
2600e90efa adjust loggin in indicator
All checks were successful
Release / meta (push) Successful in 8s
Release / linux-build (push) Successful in 7m20s
Release / android-build (push) Successful in 25m10s
Release / release-dev (push) Successful in 30s
Release / release-master (push) Successful in 28s
2025-12-27 15:00:57 +00:00
7 changed files with 192 additions and 156 deletions

View File

@@ -10,7 +10,7 @@ env:
JAVA_VERSION: "17" JAVA_VERSION: "17"
ANDROID_SDK_ROOT: "${{ github.workspace }}/android-sdk" ANDROID_SDK_ROOT: "${{ github.workspace }}/android-sdk"
FLUTTER_VERSION: "3.38.5" FLUTTER_VERSION: "3.38.5"
BUILD_WINDOWS: "false" # set to "true" when you actually want Windows builds BUILD_WINDOWS: "false" # Windows build disabled (no runner available)
GITEA_BASE_URL: https://git.tgj.services GITEA_BASE_URL: https://git.tgj.services
jobs: jobs:

View File

@@ -51,7 +51,7 @@ class _LatestLocoChangesPanelState extends State<LatestLocoChangesPanel> {
const SizedBox(width: 8), const SizedBox(width: 8),
Expanded( Expanded(
child: Text( child: Text(
'Latest loco changes', 'Latest Loco Changes',
style: textTheme.titleMedium?.copyWith( style: textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w800, fontWeight: FontWeight.w800,
), ),

View File

@@ -17,7 +17,9 @@ class _LoginScreenState extends State<LoginScreen> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) => _checkExistingSession()); WidgetsBinding.instance.addPostFrameCallback(
(_) => _checkExistingSession(),
);
} }
Future<void> _checkExistingSession() async { Future<void> _checkExistingSession() async {
@@ -71,15 +73,6 @@ class _LoginScreenState extends State<LoginScreen> {
), ),
), ),
), ),
if (_checkingSession)
const Padding(
padding: EdgeInsets.only(top: 12),
child: SizedBox(
height: 24,
width: 24,
child: CircularProgressIndicator(strokeWidth: 2),
),
),
const SizedBox(height: 50), const SizedBox(height: 50),
const LoginPanel(), const LoginPanel(),
const SizedBox(height: 16), const SizedBox(height: 16),
@@ -95,6 +88,24 @@ class _LoginScreenState extends State<LoginScreen> {
); );
}, },
), ),
if (_checkingSession) ...[
const SizedBox(height: 12),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(
height: 24,
width: 24,
child: CircularProgressIndicator(strokeWidth: 2),
),
const SizedBox(width: 8),
Text(
'Trying to log in',
style: Theme.of(context).textTheme.bodyMedium,
),
],
),
],
], ],
), ),
), ),
@@ -193,9 +204,9 @@ class _LoginPanelContentState extends State<LoginPanelContent> {
setState(() { setState(() {
_loggingIn = false; _loggingIn = false;
}); });
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(
SnackBar(content: Text('Login failed: $e')), context,
); ).showSnackBar(SnackBar(content: Text('Login failed: $e')));
} }
} }
@@ -306,14 +317,16 @@ class _RegisterPanelContentState extends State<RegisterPanelContent> {
); );
if (!mounted) return; if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Registration successful. Please log in.')), const SnackBar(
content: Text('Registration successful. Please log in.'),
),
); );
widget.onBack(); widget.onBack();
} catch (e) { } catch (e) {
if (!mounted) return; if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(
SnackBar(content: Text('Registration failed: $e')), context,
); ).showSnackBar(SnackBar(content: Text('Registration failed: $e')));
} finally { } finally {
if (mounted) setState(() => _registering = false); if (mounted) setState(() => _registering = false);
} }

View File

@@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:mileograph_flutter/services/authservice.dart';
import 'package:mileograph_flutter/services/api_service.dart'; import 'package:mileograph_flutter/services/api_service.dart';
import 'package:mileograph_flutter/services/endpoint_service.dart'; import 'package:mileograph_flutter/services/endpoint_service.dart';
import 'package:mileograph_flutter/services/data_service.dart'; import 'package:mileograph_flutter/services/data_service.dart';
@@ -174,6 +175,9 @@ class _SettingsPageState extends State<SettingsPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final endpointService = context.watch<EndpointService>(); final endpointService = context.watch<EndpointService>();
final loggedIn = context.select<AuthService, bool>(
(auth) => auth.isLoggedIn,
);
if (!endpointService.isLoaded) { if (!endpointService.isLoaded) {
return const Scaffold( return const Scaffold(
body: Center(child: CircularProgressIndicator()), body: Center(child: CircularProgressIndicator()),
@@ -251,97 +255,99 @@ class _SettingsPageState extends State<SettingsPage> {
'Current: ${endpointService.baseUrl}', 'Current: ${endpointService.baseUrl}',
style: Theme.of(context).textTheme.labelSmall, style: Theme.of(context).textTheme.labelSmall,
), ),
const SizedBox(height: 32), if (loggedIn) ...[
Text( const SizedBox(height: 32),
'Account', Text(
style: Theme.of(context).textTheme.titleMedium?.copyWith( 'Account',
fontWeight: FontWeight.w700, style: Theme.of(context).textTheme.titleMedium?.copyWith(
), fontWeight: FontWeight.w700,
),
const SizedBox(height: 8),
Text(
'Change your password for this account.',
style: Theme.of(context).textTheme.bodySmall,
),
const SizedBox(height: 12),
Form(
key: _passwordFormKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextFormField(
controller: _currentPasswordController,
decoration: const InputDecoration(
labelText: 'Current password',
border: OutlineInputBorder(),
), ),
obscureText: true,
enableSuggestions: false,
autocorrect: false,
autofillHints: const [AutofillHints.password],
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your current password.';
}
return null;
},
),
const SizedBox(height: 12),
TextFormField(
controller: _newPasswordController,
decoration: const InputDecoration(
labelText: 'New password',
border: OutlineInputBorder(),
),
obscureText: true,
enableSuggestions: false,
autocorrect: false,
autofillHints: const [AutofillHints.newPassword],
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter a new password.';
}
return null;
},
),
const SizedBox(height: 12),
TextFormField(
controller: _confirmPasswordController,
decoration: const InputDecoration(
labelText: 'Confirm new password',
border: OutlineInputBorder(),
),
obscureText: true,
enableSuggestions: false,
autocorrect: false,
autofillHints: const [AutofillHints.newPassword],
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please confirm the new password.';
}
if (value != _newPasswordController.text) {
return 'New passwords do not match.';
}
return null;
},
),
const SizedBox(height: 16),
FilledButton.icon(
onPressed: _changingPassword ? null : _changePassword,
icon: _changingPassword
? const SizedBox(
width: 18,
height: 18,
child: CircularProgressIndicator(strokeWidth: 2),
)
: const Icon(Icons.lock_reset),
label: Text(
_changingPassword ? 'Updating...' : 'Change password',
),
),
],
), ),
), const SizedBox(height: 8),
Text(
'Change your password for this account.',
style: Theme.of(context).textTheme.bodySmall,
),
const SizedBox(height: 12),
Form(
key: _passwordFormKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextFormField(
controller: _currentPasswordController,
decoration: const InputDecoration(
labelText: 'Current password',
border: OutlineInputBorder(),
),
obscureText: true,
enableSuggestions: false,
autocorrect: false,
autofillHints: const [AutofillHints.password],
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your current password.';
}
return null;
},
),
const SizedBox(height: 12),
TextFormField(
controller: _newPasswordController,
decoration: const InputDecoration(
labelText: 'New password',
border: OutlineInputBorder(),
),
obscureText: true,
enableSuggestions: false,
autocorrect: false,
autofillHints: const [AutofillHints.newPassword],
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter a new password.';
}
return null;
},
),
const SizedBox(height: 12),
TextFormField(
controller: _confirmPasswordController,
decoration: const InputDecoration(
labelText: 'Confirm new password',
border: OutlineInputBorder(),
),
obscureText: true,
enableSuggestions: false,
autocorrect: false,
autofillHints: const [AutofillHints.newPassword],
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please confirm the new password.';
}
if (value != _newPasswordController.text) {
return 'New passwords do not match.';
}
return null;
},
),
const SizedBox(height: 16),
FilledButton.icon(
onPressed: _changingPassword ? null : _changePassword,
icon: _changingPassword
? const SizedBox(
width: 18,
height: 18,
child: CircularProgressIndicator(strokeWidth: 2),
)
: const Icon(Icons.lock_reset),
label: Text(
_changingPassword ? 'Updating...' : 'Change password',
),
),
],
),
),
],
], ],
), ),
), ),

View File

@@ -3,6 +3,8 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:mileograph_flutter/components/pages/calculator.dart';
import 'package:mileograph_flutter/components/pages/calculator_details.dart';
import 'package:mileograph_flutter/components/login/login.dart'; import 'package:mileograph_flutter/components/login/login.dart';
import 'package:mileograph_flutter/components/pages/dashboard.dart'; import 'package:mileograph_flutter/components/pages/dashboard.dart';
import 'package:mileograph_flutter/components/pages/loco_legs.dart'; import 'package:mileograph_flutter/components/pages/loco_legs.dart';
@@ -19,10 +21,12 @@ import 'package:mileograph_flutter/services/data_service.dart';
import 'package:mileograph_flutter/services/navigation_guard.dart'; import 'package:mileograph_flutter/services/navigation_guard.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
final GlobalKey<NavigatorState> _shellNavigatorKey = GlobalKey<NavigatorState>(); final GlobalKey<NavigatorState> _shellNavigatorKey =
GlobalKey<NavigatorState>();
const List<String> _contentPages = [ const List<String> _contentPages = [
"/dashboard", "/dashboard",
"/calculator",
"/logbook", "/logbook",
"/traction", "/traction",
"/add", "/add",
@@ -31,13 +35,14 @@ const List<String> _contentPages = [
const List<String> _defaultTabDestinations = [ const List<String> _defaultTabDestinations = [
"/dashboard", "/dashboard",
"/calculator",
"/logbook/entries", "/logbook/entries",
"/traction", "/traction",
"/add", "/add",
"/more", "/more",
]; ];
const int _addTabIndex = 3; const int _addTabIndex = 4;
class _NavItem { class _NavItem {
final String label; final String label;
@@ -47,6 +52,7 @@ class _NavItem {
const List<_NavItem> _navItems = [ const List<_NavItem> _navItems = [
_NavItem("Home", Icons.home), _NavItem("Home", Icons.home),
_NavItem("Calculator", Icons.route),
_NavItem("Logbook", Icons.menu_book), _NavItem("Logbook", Icons.menu_book),
_NavItem("Traction", Icons.train), _NavItem("Traction", Icons.train),
_NavItem("Add", Icons.add), _NavItem("Add", Icons.add),
@@ -112,10 +118,7 @@ class _MyAppState extends State<MyApp> {
return null; return null;
}, },
routes: [ routes: [
GoRoute( GoRoute(path: '/', redirect: (context, state) => '/dashboard'),
path: '/',
redirect: (context, state) => '/dashboard',
),
ShellRoute( ShellRoute(
navigatorKey: _shellNavigatorKey, navigatorKey: _shellNavigatorKey,
builder: (context, state, child) => MyHomePage(child: child), builder: (context, state, child) => MyHomePage(child: child),
@@ -124,6 +127,17 @@ class _MyAppState extends State<MyApp> {
path: '/dashboard', path: '/dashboard',
builder: (context, state) => const Dashboard(), builder: (context, state) => const Dashboard(),
), ),
GoRoute(
path: '/calculator',
builder: (context, state) => const CalculatorPage(),
routes: [
GoRoute(
path: 'details',
builder: (context, state) =>
CalculatorDetailsPage(result: state.extra),
),
],
),
GoRoute( GoRoute(
path: '/logbook', path: '/logbook',
redirect: (context, state) => '/logbook/entries', redirect: (context, state) => '/logbook/entries',
@@ -212,7 +226,10 @@ class _MyAppState extends State<MyApp> {
), ),
], ],
), ),
GoRoute(path: '/login', builder: (context, state) => const LoginScreen()), GoRoute(
path: '/login',
builder: (context, state) => const LoginScreen(),
),
GoRoute( GoRoute(
path: '/settings', path: '/settings',
builder: (context, state) => const SettingsPage(), builder: (context, state) => const SettingsPage(),
@@ -373,7 +390,10 @@ class _MyHomePageState extends State<MyHomePage> {
TextSpan( TextSpan(
children: const [ children: const [
TextSpan(text: "Mile"), TextSpan(text: "Mile"),
TextSpan(text: "O", style: TextStyle(color: Colors.red)), TextSpan(
text: "O",
style: TextStyle(color: Colors.red),
),
TextSpan(text: "graph"), TextSpan(text: "graph"),
], ],
style: const TextStyle( style: const TextStyle(
@@ -390,7 +410,10 @@ class _MyHomePageState extends State<MyHomePage> {
onPressed: () => context.go('/more/settings'), onPressed: () => context.go('/more/settings'),
icon: const Icon(Icons.settings), icon: const Icon(Icons.settings),
), ),
IconButton(onPressed: auth.logout, icon: const Icon(Icons.logout)), IconButton(
onPressed: auth.logout,
icon: const Icon(Icons.logout),
),
], ],
), ),
bottomNavigationBar: isWide bottomNavigationBar: isWide
@@ -448,7 +471,8 @@ class _MyHomePageState extends State<MyHomePage> {
return Shortcuts( return Shortcuts(
shortcuts: <LogicalKeySet, Intent>{ shortcuts: <LogicalKeySet, Intent>{
LogicalKeySet(LogicalKeyboardKey.browserBack): const _BackIntent(), LogicalKeySet(LogicalKeyboardKey.browserBack): const _BackIntent(),
LogicalKeySet(LogicalKeyboardKey.browserForward): const _ForwardIntent(), LogicalKeySet(LogicalKeyboardKey.browserForward):
const _ForwardIntent(),
}, },
child: Actions( child: Actions(
actions: { actions: {
@@ -474,7 +498,10 @@ class _MyHomePageState extends State<MyHomePage> {
canPop: false, canPop: false,
onPopInvokedWithResult: (didPop, _) async { onPopInvokedWithResult: (didPop, _) async {
if (didPop) return; if (didPop) return;
await _handleBackNavigation(allowExit: true, recordForward: false); await _handleBackNavigation(
allowExit: true,
recordForward: false,
);
}, },
child: scaffold, child: scaffold,
), ),
@@ -494,7 +521,9 @@ class _MyHomePageState extends State<MyHomePage> {
} }
Widget _buildRailToggleButton(bool railExtended) { Widget _buildRailToggleButton(bool railExtended) {
final collapseIcon = railExtended ? Icons.chevron_left : Icons.chevron_right; final collapseIcon = railExtended
? Icons.chevron_left
: Icons.chevron_right;
final collapseLabel = railExtended ? 'Collapse' : 'Expand'; final collapseLabel = railExtended ? 'Collapse' : 'Expand';
if (railExtended) { if (railExtended) {
@@ -587,8 +616,9 @@ class _MyHomePageState extends State<MyHomePage> {
final data = context.watch<DataService>(); final data = context.watch<DataService>();
final notifications = data.notifications; final notifications = data.notifications;
final loading = data.isNotificationsLoading; final loading = data.isNotificationsLoading;
final listHeight = final listHeight = isWide
isWide ? 380.0 : MediaQuery.of(context).size.height * 0.6; ? 380.0
: MediaQuery.of(context).size.height * 0.6;
Widget body; Widget body;
if (loading && notifications.isEmpty) { if (loading && notifications.isEmpty) {
@@ -628,9 +658,7 @@ class _MyHomePageState extends State<MyHomePage> {
item.title.isNotEmpty item.title.isNotEmpty
? item.title ? item.title
: 'Notification', : 'Notification',
style: Theme.of(context) style: Theme.of(context).textTheme.titleMedium
.textTheme
.titleMedium
?.copyWith(fontWeight: FontWeight.w700), ?.copyWith(fontWeight: FontWeight.w700),
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
@@ -642,18 +670,15 @@ class _MyHomePageState extends State<MyHomePage> {
const SizedBox(height: 6), const SizedBox(height: 6),
Text( Text(
_formatNotificationTime(item.createdAt!), _formatNotificationTime(item.createdAt!),
style: Theme.of(context) style: Theme.of(context).textTheme.bodySmall
.textTheme
.bodySmall
?.copyWith( ?.copyWith(
color: () { color: () {
final baseColor = Theme.of(context) final baseColor = Theme.of(
.textTheme context,
.bodySmall ).textTheme.bodySmall?.color;
?.color;
if (baseColor == null) return null; if (baseColor == null) return null;
final newAlpha = final newAlpha = (baseColor.a * 0.7)
(baseColor.a * 0.7).clamp(0.0, 1.0); .clamp(0.0, 1.0);
return baseColor.withValues( return baseColor.withValues(
alpha: newAlpha, alpha: newAlpha,
); );
@@ -666,10 +691,8 @@ class _MyHomePageState extends State<MyHomePage> {
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
TextButton( TextButton(
onPressed: () => _dismissNotifications( onPressed: () =>
context, _dismissNotifications(context, [item.id]),
[item.id],
),
child: const Text('Dismiss'), child: const Text('Dismiss'),
), ),
], ],
@@ -695,19 +718,18 @@ class _MyHomePageState extends State<MyHomePage> {
children: [ children: [
Text( Text(
'Notifications', 'Notifications',
style: Theme.of(context) style: Theme.of(
.textTheme context,
.titleLarge ).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.bold),
?.copyWith(fontWeight: FontWeight.bold),
), ),
const Spacer(), const Spacer(),
TextButton( TextButton(
onPressed: notifications.isEmpty onPressed: notifications.isEmpty
? null ? null
: () => _dismissNotifications( : () => _dismissNotifications(
context, context,
notifications.map((e) => e.id).toList(), notifications.map((e) => e.id).toList(),
), ),
child: const Text('Dismiss all'), child: const Text('Dismiss all'),
), ),
], ],
@@ -729,9 +751,7 @@ class _MyHomePageState extends State<MyHomePage> {
try { try {
await context.read<DataService>().dismissNotifications(ids); await context.read<DataService>().dismissNotifications(ids);
} catch (e) { } catch (e) {
messenger?.showSnackBar( messenger?.showSnackBar(SnackBar(content: Text('Failed to dismiss: $e')));
SnackBar(content: Text('Failed to dismiss: $e')),
);
} }
} }
@@ -751,9 +771,7 @@ class _MyHomePageState extends State<MyHomePage> {
color: Colors.redAccent, color: Colors.redAccent,
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
), ),
constraints: const BoxConstraints( constraints: const BoxConstraints(minWidth: 20),
minWidth: 20,
),
child: Text( child: Text(
label, label,
style: const TextStyle( style: const TextStyle(

View File

@@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 0.4.2+1 version: 0.4.5+1
environment: environment:
sdk: ^3.8.1 sdk: ^3.8.1

View File

@@ -8,13 +8,12 @@ void main() {
expect(tabIndexForPath('/calculator/details'), 1); expect(tabIndexForPath('/calculator/details'), 1);
expect(tabIndexForPath('/legs'), 2); expect(tabIndexForPath('/legs'), 2);
expect(tabIndexForPath('/traction/12/timeline'), 3); expect(tabIndexForPath('/traction/12/timeline'), 3);
expect(tabIndexForPath('/trips'), 4); expect(tabIndexForPath('/trips'), 2);
expect(tabIndexForPath('/add'), 5); expect(tabIndexForPath('/add'), 4);
}); });
test('tabIndexForPath ignores query when parsing uri', () { test('tabIndexForPath ignores query when parsing uri', () {
expect(tabIndexForPath(Uri.parse('/trips?sort=desc').path), 4); expect(tabIndexForPath(Uri.parse('/trips?sort=desc').path), 2);
expect(tabIndexForPath(Uri.parse('/calculator/details?x=1').path), 1); expect(tabIndexForPath(Uri.parse('/calculator/details?x=1').path), 1);
}); });
} }