Files
mileograph_flutter/lib/components/pages/logbook.dart
Pete Gregory 1c15546b66
All checks were successful
Release / meta (push) Successful in 9s
Release / linux-build (push) Successful in 6m54s
Release / android-build (push) Successful in 23m30s
Release / release-master (push) Successful in 30s
Release / release-dev (push) Successful in 32s
support new fields in adding
2025-12-31 18:23:37 +00:00

43 lines
1.2 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()]),
),
],
),
);
}
}