feat : Adding bottomNav
This commit is contained in:
66
lib/ui/views/main/main_view.dart
Normal file
66
lib/ui/views/main/main_view.dart
Normal file
@@ -0,0 +1,66 @@
|
||||
import 'package:bahla_front/ui/views/home/home_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import 'main_viewmodel.dart';
|
||||
|
||||
class MainView extends StackedView<MainViewModel> {
|
||||
const MainView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget builder(
|
||||
BuildContext context,
|
||||
MainViewModel viewModel,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
backgroundColor: Theme.of(context).colorScheme.background,
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
type: BottomNavigationBarType.fixed,
|
||||
backgroundColor: Colors.grey[800],
|
||||
currentIndex: viewModel.currentIndex,
|
||||
onTap: viewModel.setIndex,
|
||||
items: [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.home),
|
||||
label: 'Home',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.search),
|
||||
label: 'Search',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.add),
|
||||
label: 'Add',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.account_circle),
|
||||
label: 'Profile',
|
||||
),
|
||||
],
|
||||
),
|
||||
body: getViewForIndex(viewModel.currentIndex),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getViewForIndex(int index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return HomeView();
|
||||
case 1:
|
||||
return Container();
|
||||
case 2:
|
||||
return Container();
|
||||
case 3:
|
||||
return Container();
|
||||
default:
|
||||
return HomeView();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
MainViewModel viewModelBuilder(
|
||||
BuildContext context,
|
||||
) =>
|
||||
MainViewModel();
|
||||
}
|
||||
Reference in New Issue
Block a user