Simple NavigationBar and placeholder map view
This commit is contained in:
@@ -10,8 +10,6 @@ import 'flood_station_page.dart';
|
||||
class LandingPage extends StatefulWidget {
|
||||
const LandingPage({super.key});
|
||||
|
||||
static const routeName = '/';
|
||||
|
||||
@override
|
||||
State<LandingPage> createState() => _LandingPageState();
|
||||
}
|
||||
@@ -24,52 +22,48 @@ class _LandingPageState extends State<LandingPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
floodStationProvider = context.watch<FloodStationProvider>();
|
||||
return Scaffold(
|
||||
body: Column(
|
||||
children: [
|
||||
StationFilter(
|
||||
onChanged: (filterText) {
|
||||
if (filterText.isEmpty) {
|
||||
floodStationProvider.filtered = false;
|
||||
setState(() {});
|
||||
return;
|
||||
}
|
||||
showLoadingNotifier(context: context, message: 'Loading');
|
||||
floodStationProvider.loadFilteredStations(filterText);
|
||||
floodStationProvider.filteredStationsFuture
|
||||
?.then((_) => removeLoadingNotifier());
|
||||
floodStationProvider.filtered = true;
|
||||
},
|
||||
),
|
||||
_shouldShowList()
|
||||
? Expanded(
|
||||
child: FloodStationListView(
|
||||
stations: floodStationProvider.filtered
|
||||
? floodStationProvider.filteredStations
|
||||
: floodStationProvider.allStations,
|
||||
onItemTapped: (station) {
|
||||
floodStationProvider.selectedStation = station;
|
||||
Navigator.of(context)
|
||||
.pushNamed(FloodStationPage.routeName);
|
||||
return Column(
|
||||
children: [
|
||||
StationFilter(
|
||||
onChanged: (filterText) {
|
||||
if (filterText.isEmpty) {
|
||||
floodStationProvider.filtered = false;
|
||||
setState(() {});
|
||||
return;
|
||||
}
|
||||
showLoadingNotifier(context: context, message: 'Loading');
|
||||
floodStationProvider.loadFilteredStations(filterText);
|
||||
floodStationProvider.filteredStationsFuture
|
||||
?.then((_) => removeLoadingNotifier());
|
||||
floodStationProvider.filtered = true;
|
||||
},
|
||||
),
|
||||
_shouldShowList()
|
||||
? Expanded(
|
||||
child: FloodStationListView(
|
||||
stations: floodStationProvider.filtered
|
||||
? floodStationProvider.filteredStations
|
||||
: floodStationProvider.allStations,
|
||||
onItemTapped: (station) {
|
||||
floodStationProvider.selectedStation = station;
|
||||
Navigator.of(context).pushNamed(FloodStationPage.routeName);
|
||||
},
|
||||
),
|
||||
)
|
||||
: Expanded(
|
||||
child: Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
showLoadingNotifier(context: context, message: 'Loading');
|
||||
floodStationProvider
|
||||
.loadAllStations()
|
||||
.whenComplete(() => removeLoadingNotifier());
|
||||
},
|
||||
),
|
||||
)
|
||||
: Expanded(
|
||||
child: Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
showLoadingNotifier(
|
||||
context: context, message: 'Loading');
|
||||
floodStationProvider
|
||||
.loadAllStations()
|
||||
.whenComplete(() => removeLoadingNotifier());
|
||||
},
|
||||
child: Text('Load all Stations'),
|
||||
),
|
||||
child: Text('Load all Stations'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user