-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from fga-eps-mds/feat#59/Navbar
feat(#59) NavBar inicial
- Loading branch information
Showing
5 changed files
with
88 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class NavbarViewModel extends ChangeNotifier { | ||
int _selectedIndex = 0; | ||
|
||
int get selectedIndex => _selectedIndex; | ||
|
||
void changeTab(int index) { | ||
_selectedIndex = index; | ||
notifyListeners(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'package:aranduapp/ui/home/view/HomeView.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:aranduapp/ui/navbar/model/navBarViewModel.dart'; | ||
|
||
class NavbarView extends StatelessWidget { | ||
const NavbarView({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
body: ChangeNotifierProvider( | ||
create: (context) => NavbarViewModel(), | ||
builder: (context, child) { | ||
return page(context); | ||
}), | ||
); | ||
} | ||
} | ||
|
||
Widget page(BuildContext context) { | ||
NavbarViewModel viewModel = Provider.of<NavbarViewModel>(context); | ||
|
||
final List<Widget> pages = [ | ||
const HomeView(), | ||
const Center(child: Text('Friends', style: TextStyle(fontSize: 20))), | ||
const Center(child: Text('Dashbord', style: TextStyle(fontSize: 20))), | ||
const Center(child: Text('Profile', style: TextStyle(fontSize: 20))), | ||
]; | ||
|
||
return Scaffold( | ||
body: pages[viewModel.selectedIndex], | ||
bottomNavigationBar: BottomNavigationBar( | ||
currentIndex: viewModel.selectedIndex, | ||
onTap: viewModel.changeTab, | ||
selectedItemColor: Theme.of(context).colorScheme.primary, | ||
unselectedItemColor:Theme.of(context).colorScheme.onSurface, | ||
items: const [ | ||
BottomNavigationBarItem( | ||
icon: Icon(Icons.home_outlined), | ||
label: "Home", | ||
), | ||
BottomNavigationBarItem( | ||
icon: Icon(Icons.groups_outlined), | ||
label: "Amigos", | ||
), | ||
BottomNavigationBarItem( | ||
icon: Icon(Icons.bar_chart), | ||
label: "Dashboard", | ||
), | ||
BottomNavigationBarItem( | ||
icon: Icon(Icons.person_outline), | ||
label: "Perfil", | ||
), | ||
], | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters