Adding Bottom Navigation bar
This commit is contained in:
+100
-6
@@ -1,13 +1,107 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:le_kiosque_by_gcs/services/auth/auth.dart';
|
||||
|
||||
class AuthView extends StatefulWidget {
|
||||
@override
|
||||
_AuthViewState createState() => _AuthViewState();
|
||||
}
|
||||
import 'custom/custom_elevated_button.dart';
|
||||
|
||||
class AuthView extends StatelessWidget {
|
||||
const AuthView({Key key, this.auth}) : super(key: key);
|
||||
final Auth auth;
|
||||
|
||||
Future<void> _signWithGoogle() async {
|
||||
try {
|
||||
await auth.signInWithGoogle();
|
||||
} catch (e) {
|
||||
print("Error $e");
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _signInWithFacebook() async {
|
||||
try {
|
||||
await auth.signInWithFacebook();
|
||||
} catch (e) {
|
||||
print("Error $e");
|
||||
}
|
||||
}
|
||||
|
||||
class _AuthViewState extends State<AuthView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 550,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage("assets/images/login_back.png"),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Transform.translate(
|
||||
offset: Offset(0, -50),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[200],
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(30),
|
||||
topRight: Radius.circular(30),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 32,
|
||||
left: 24,
|
||||
right: 24,
|
||||
bottom: 24,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(
|
||||
"S'identifier",
|
||||
style: TextStyle(
|
||||
fontSize: 26,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
inherit: false),
|
||||
),
|
||||
SizedBox(height: 32),
|
||||
CustomElevatedButton(
|
||||
imageAsset: "assets/images/google_logo.png",
|
||||
color: Colors.white,
|
||||
textColor: Colors.black,
|
||||
onPressed: _signWithGoogle,
|
||||
text: "Se connecter avec Google",
|
||||
),
|
||||
SizedBox(height: 24),
|
||||
CustomElevatedButton(
|
||||
imageAsset: "assets/images/facebook_logo.png",
|
||||
color: Color(0xFF334D92),
|
||||
textColor: Colors.white,
|
||||
onPressed: _signInWithFacebook,
|
||||
text: "Se connecter avec Facebook",
|
||||
),
|
||||
SizedBox(
|
||||
height: 48,
|
||||
),
|
||||
Text(
|
||||
"En vous connectant, vous acceptez nos conditions et termes d'utilisation.",
|
||||
style: TextStyle(
|
||||
inherit: false,
|
||||
color: Colors.black87,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CustomElevatedButton extends StatelessWidget {
|
||||
CustomElevatedButton({
|
||||
this.onPressed,
|
||||
this.color,
|
||||
this.height: 50,
|
||||
this.textColor,
|
||||
this.text,
|
||||
this.imageAsset: "",
|
||||
});
|
||||
|
||||
final VoidCallback onPressed;
|
||||
final Color color;
|
||||
final double height;
|
||||
final Color textColor;
|
||||
final String text;
|
||||
final String imageAsset;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: height,
|
||||
child: ElevatedButton(
|
||||
style: ButtonStyle(
|
||||
backgroundColor: MaterialStateProperty.all(color),
|
||||
shape: MaterialStateProperty.all(
|
||||
RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(16),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
onPressed: onPressed,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: Image.asset(imageAsset),
|
||||
),
|
||||
Text(
|
||||
text,
|
||||
style: TextStyle(fontSize: 15, color: textColor),
|
||||
),
|
||||
Opacity(
|
||||
child: Image.asset(imageAsset),
|
||||
opacity: 0,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:le_kiosque_by_gcs/services/auth/auth.dart';
|
||||
import 'package:le_kiosque_by_gcs/ui/auth.dart';
|
||||
import 'package:le_kiosque_by_gcs/ui/main.dart';
|
||||
|
||||
class LandingPageView extends StatelessWidget {
|
||||
final Auth auth;
|
||||
|
||||
const LandingPageView({Key key, this.auth}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StreamBuilder<User>(
|
||||
stream: auth.authStateChanges(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.active) {
|
||||
if (snapshot.data == null) {
|
||||
return AuthView(auth: auth);
|
||||
} else {
|
||||
return MainView();
|
||||
}
|
||||
}
|
||||
else {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class MainView extends StatefulWidget {
|
||||
@override
|
||||
_MainViewState createState() => _MainViewState();
|
||||
}
|
||||
|
||||
class _MainViewState extends State<MainView> {
|
||||
int _selectedIndex = 0;
|
||||
|
||||
void _onItemTapped(int index) {
|
||||
setState(() {
|
||||
_selectedIndex = index;
|
||||
});
|
||||
}
|
||||
|
||||
void _showSearchView(BuildContext context) {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => Scaffold(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
"Le Kiosque By GC&S",
|
||||
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: Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Color(0xFFF1F1F1),
|
||||
),
|
||||
child: TextButton(
|
||||
onPressed: () => _showSearchView(context),
|
||||
child: Icon(
|
||||
Icons.search,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
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',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user