Simple NavigationBar and placeholder map view
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:provider/provider.dart';
|
|||||||
|
|
||||||
import 'pages/flood_station_page.dart';
|
import 'pages/flood_station_page.dart';
|
||||||
import 'pages/landing_page.dart';
|
import 'pages/landing_page.dart';
|
||||||
|
import 'pages/main_navigation_scaffold.dart';
|
||||||
import 'services/flood_station_provider.dart';
|
import 'services/flood_station_provider.dart';
|
||||||
import 'package:timezone/data/latest.dart' as tz;
|
import 'package:timezone/data/latest.dart' as tz;
|
||||||
|
|
||||||
@@ -27,9 +28,9 @@ class MyApp extends StatelessWidget {
|
|||||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
),
|
),
|
||||||
initialRoute: LandingPage.routeName,
|
initialRoute: MainNavigationScaffold.routeName,
|
||||||
routes: {
|
routes: {
|
||||||
LandingPage.routeName: (context) => LandingPage(),
|
MainNavigationScaffold.routeName: (context) => MainNavigationScaffold(),
|
||||||
FloodStationPage.routeName: (context) => FloodStationPage(),
|
FloodStationPage.routeName: (context) => FloodStationPage(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ import 'flood_station_page.dart';
|
|||||||
class LandingPage extends StatefulWidget {
|
class LandingPage extends StatefulWidget {
|
||||||
const LandingPage({super.key});
|
const LandingPage({super.key});
|
||||||
|
|
||||||
static const routeName = '/';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<LandingPage> createState() => _LandingPageState();
|
State<LandingPage> createState() => _LandingPageState();
|
||||||
}
|
}
|
||||||
@@ -24,8 +22,7 @@ class _LandingPageState extends State<LandingPage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
floodStationProvider = context.watch<FloodStationProvider>();
|
floodStationProvider = context.watch<FloodStationProvider>();
|
||||||
return Scaffold(
|
return Column(
|
||||||
body: Column(
|
|
||||||
children: [
|
children: [
|
||||||
StationFilter(
|
StationFilter(
|
||||||
onChanged: (filterText) {
|
onChanged: (filterText) {
|
||||||
@@ -49,8 +46,7 @@ class _LandingPageState extends State<LandingPage> {
|
|||||||
: floodStationProvider.allStations,
|
: floodStationProvider.allStations,
|
||||||
onItemTapped: (station) {
|
onItemTapped: (station) {
|
||||||
floodStationProvider.selectedStation = station;
|
floodStationProvider.selectedStation = station;
|
||||||
Navigator.of(context)
|
Navigator.of(context).pushNamed(FloodStationPage.routeName);
|
||||||
.pushNamed(FloodStationPage.routeName);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -58,8 +54,7 @@ class _LandingPageState extends State<LandingPage> {
|
|||||||
child: Center(
|
child: Center(
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showLoadingNotifier(
|
showLoadingNotifier(context: context, message: 'Loading');
|
||||||
context: context, message: 'Loading');
|
|
||||||
floodStationProvider
|
floodStationProvider
|
||||||
.loadAllStations()
|
.loadAllStations()
|
||||||
.whenComplete(() => removeLoadingNotifier());
|
.whenComplete(() => removeLoadingNotifier());
|
||||||
@@ -69,7 +64,6 @@ class _LandingPageState extends State<LandingPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
41
lib/pages/main_navigation_scaffold.dart
Normal file
41
lib/pages/main_navigation_scaffold.dart
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'landing_page.dart';
|
||||||
|
import 'map_page.dart';
|
||||||
|
|
||||||
|
class MainNavigationScaffold extends StatefulWidget {
|
||||||
|
const MainNavigationScaffold({super.key});
|
||||||
|
static const routeName = '/';
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MainNavigationScaffold> createState() => _MainNavigationScaffoldState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MainNavigationScaffoldState extends State<MainNavigationScaffold> {
|
||||||
|
int _selectedPageIndex = 0;
|
||||||
|
|
||||||
|
final List<Widget> _pages = [
|
||||||
|
const LandingPage(),
|
||||||
|
const MapPage(),
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
bottomNavigationBar: NavigationBar(
|
||||||
|
selectedIndex: _selectedPageIndex,
|
||||||
|
onDestinationSelected: (value) => setState(() {
|
||||||
|
_selectedPageIndex = value;
|
||||||
|
}),
|
||||||
|
destinations: [
|
||||||
|
NavigationDestination(icon: Icon(Icons.list), label: 'List'),
|
||||||
|
NavigationDestination(icon: Icon(Icons.map_outlined), label: 'Map'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: IndexedStack(
|
||||||
|
index: _selectedPageIndex,
|
||||||
|
children: _pages,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
lib/pages/map_page.dart
Normal file
11
lib/pages/map_page.dart
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class MapPage extends StatelessWidget {
|
||||||
|
const MapPage({super.key});
|
||||||
|
static const routeName = '/map';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return const Placeholder();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@ dependencies:
|
|||||||
provider: ^6.1.2
|
provider: ^6.1.2
|
||||||
timezone: ^0.10.0
|
timezone: ^0.10.0
|
||||||
async: ^2.11.0
|
async: ^2.11.0
|
||||||
|
flutter_osm_plugin: ^1.3.6
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user