143 lines
3.7 KiB
Dart
143 lines
3.7 KiB
Dart
import 'package:firebase_auth/firebase_auth.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
import 'package:le_kiosque_by_gcs/ui/view/home.dart';
|
|
import 'package:le_kiosque_by_gcs/ui/view/news.dart';
|
|
import 'package:le_kiosque_by_gcs/ui/view/profile.dart';
|
|
import 'package:le_kiosque_by_gcs/ui/view/search.dart';
|
|
import 'package:le_kiosque_by_gcs/ui/view/setting/setting.dart';
|
|
import 'package:le_kiosque_by_gcs/ui/view/subscription/subscription.dart';
|
|
|
|
class MainView extends StatefulWidget {
|
|
@override
|
|
_MainViewState createState() => _MainViewState();
|
|
}
|
|
|
|
class _MainViewState extends State<MainView> {
|
|
int _selectedIndex = 0;
|
|
|
|
List<Widget> _widgetOptions = [
|
|
HomeView(),
|
|
NewsView(),
|
|
SubscriptionView(),
|
|
ProfileView()
|
|
];
|
|
|
|
List<String> _labels = ["Accueil", "A la une", "Abonnement", "Mon profil"];
|
|
|
|
void _onItemTapped(int index) {
|
|
setState(() {
|
|
_selectedIndex = index;
|
|
});
|
|
}
|
|
|
|
_showSettingView(BuildContext context) {
|
|
Navigator.of(context).push(
|
|
MaterialPageRoute(
|
|
builder: (_) => SettingView(),
|
|
),
|
|
);
|
|
}
|
|
|
|
void _showSearchView(BuildContext context) {
|
|
Navigator.of(context).push(
|
|
MaterialPageRoute(
|
|
builder: (_) => SearchView(),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
centerTitle: false,
|
|
title: Text(
|
|
_labels[_selectedIndex],
|
|
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"),
|
|
);
|
|
},
|
|
),
|
|
elevation: 4,
|
|
actions: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
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,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
backgroundColor: Colors.white,
|
|
),
|
|
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],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|