Files
mileograph_flutter/lib/components/pages/logbook.dart
Pete Gregory 4bd6f0bbed
All checks were successful
Release / meta (push) Successful in 7s
Release / linux-build (push) Successful in 6m49s
Release / android-build (push) Successful in 15m55s
Release / release-master (push) Successful in 24s
Release / release-dev (push) Successful in 26s
add support for badges and notifications, adjust nav pages
2025-12-26 18:36:37 +00:00

49 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:mileograph_flutter/components/pages/legs.dart';
import 'package:mileograph_flutter/components/pages/trips.dart';
enum LogbookTab { entries, trips }
class LogbookPage extends StatelessWidget {
const LogbookPage({super.key, this.initialTab = LogbookTab.entries});
final LogbookTab initialTab;
@override
Widget build(BuildContext context) {
final initialIndex = initialTab == LogbookTab.trips ? 1 : 0;
return DefaultTabController(
key: ValueKey(initialTab),
initialIndex: initialIndex,
length: 2,
child: Column(
children: [
TabBar(
onTap: (index) {
final dest =
index == 0 ? '/logbook/entries' : '/logbook/trips';
final current = GoRouterState.of(context).uri.path;
if (current != dest) {
context.go(dest);
}
},
tabs: const [
Tab(text: 'Entries'),
Tab(text: 'Trips'),
],
),
Expanded(
child: TabBarView(
children: const [
LegsPage(),
TripsPage(),
],
),
),
],
),
);
}
}