From b3eb71b4e8cdd510a6f246ae7dbc637cfd8f26e0 Mon Sep 17 00:00:00 2001 From: Eric Ampire Date: Thu, 18 Mar 2021 01:21:17 +0200 Subject: [PATCH] Bottom Navigation Destination --- lib/ui/main.dart | 120 +++++++++++++++++++++++++++----------------- lib/ui/profile.dart | 28 +++++++++++ 2 files changed, 101 insertions(+), 47 deletions(-) create mode 100644 lib/ui/profile.dart diff --git a/lib/ui/main.dart b/lib/ui/main.dart index 03f71e1..27cbb3e 100644 --- a/lib/ui/main.dart +++ b/lib/ui/main.dart @@ -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 { int _selectedIndex = 0; + List _widgetOptions = [ + Text('Index 0: Home'), + Text('Index 1: Business'), + Text('Index 2: School'), + ProfileView() + ]; + + List _labels = ["Accueil", "A la une", "Abonnement", "Mon profil"]; + void _onItemTapped(int index) { setState(() { _selectedIndex = index; @@ -29,7 +39,7 @@ class _MainViewState extends State { 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 { 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 { ], 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) {} } diff --git a/lib/ui/profile.dart b/lib/ui/profile.dart new file mode 100644 index 0000000..6c07cbc --- /dev/null +++ b/lib/ui/profile.dart @@ -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 { + @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(), + ); + } +}