Bottom Navigation Destination

This commit is contained in:
2021-03-18 01:21:17 +02:00
parent 6bf2b46059
commit b3eb71b4e8
2 changed files with 101 additions and 47 deletions
+73 -47
View File
@@ -1,6 +1,7 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:le_kiosque_by_gcs/ui/profile.dart';
class MainView extends StatefulWidget {
@override
@@ -10,6 +11,15 @@ class MainView extends StatefulWidget {
class _MainViewState extends State<MainView> {
int _selectedIndex = 0;
List<Widget> _widgetOptions = [
Text('Index 0: Home'),
Text('Index 1: Business'),
Text('Index 2: School'),
ProfileView()
];
List<String> _labels = ["Accueil", "A la une", "Abonnement", "Mon profil"];
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
@@ -29,7 +39,7 @@ class _MainViewState extends State<MainView> {
return Scaffold(
appBar: AppBar(
title: Text(
"Le Kiosque By GC&S",
_labels[_selectedIndex],
style: TextStyle(
color: Colors.black,
),
@@ -46,16 +56,25 @@ class _MainViewState extends State<MainView> {
actions: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Color(0xFFF1F1F1),
),
child: TextButton(
onPressed: () => _showSearchView(context),
child: Icon(
Icons.search,
color: Colors.grey,
child: Opacity(
opacity: _selectedIndex == 2 ? 0 : 1,
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Color(0xFFF1F1F1),
),
child: TextButton(
onPressed: () {
if (_selectedIndex == 3) {
_showSettingView(context);
} else {
_showSearchView(context);
}
},
child: Icon(
_selectedIndex == 3 ? Icons.settings : Icons.search,
color: Colors.grey,
),
),
),
),
@@ -63,42 +82,49 @@ class _MainViewState extends State<MainView> {
],
backgroundColor: Colors.white,
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _selectedIndex,
type: BottomNavigationBarType.fixed,
onTap: _onItemTapped,
selectedItemColor: Colors.grey,
items: [
BottomNavigationBarItem(
icon: Icon(
Icons.home_rounded,
color: Colors.grey,
),
label: 'Accueil',
),
BottomNavigationBarItem(
icon: Icon(
Icons.subscriptions_rounded,
color: Colors.grey,
),
label: 'A la une',
),
BottomNavigationBarItem(
icon: Icon(
Icons.amp_stories_rounded,
color: Colors.grey,
),
label: 'Abonnement',
),
BottomNavigationBarItem(
icon: Icon(
Icons.people_rounded,
color: Colors.grey,
),
label: 'Mon profil',
),
],
),
body: _widgetOptions[_selectedIndex],
bottomNavigationBar: _buildBottomNavigationBar(),
);
}
BottomNavigationBar _buildBottomNavigationBar() {
return BottomNavigationBar(
currentIndex: _selectedIndex,
type: BottomNavigationBarType.fixed,
onTap: _onItemTapped,
selectedItemColor: Colors.grey,
items: [
BottomNavigationBarItem(
icon: Icon(
Icons.home_rounded,
color: Colors.grey,
),
label: _labels[0],
),
BottomNavigationBarItem(
icon: Icon(
Icons.subscriptions_rounded,
color: Colors.grey,
),
label: _labels[1],
),
BottomNavigationBarItem(
icon: Icon(
Icons.amp_stories_rounded,
color: Colors.grey,
),
label: _labels[2],
),
BottomNavigationBarItem(
icon: Icon(
Icons.people_rounded,
color: Colors.grey,
),
label: _labels[3],
),
],
);
}
_showSettingView(BuildContext context) {}
}
+28
View File
@@ -0,0 +1,28 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class ProfileView extends StatefulWidget {
@override
_ProfileViewState createState() => _ProfileViewState();
}
class _ProfileViewState extends State<ProfileView> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
"Mon Profil",
style: TextStyle(color: Colors.black),
),
leading: Builder(builder: (BuildContext context) {
return Padding(
padding: const EdgeInsets.only(left: 16),
child: Image.asset("assets/images/kiosque_logo.png"),
);
}),
),
body: Container(),
);
}
}