aggiunto schermate login e register

This commit is contained in:
saphi
2023-09-28 13:38:12 +02:00
parent e0a8559cd1
commit 11b10b7587
8 changed files with 344 additions and 7 deletions

View File

@@ -1,8 +1,13 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:progetto_m335_flutter/pages/LoginView.dart';
import 'package:progetto_m335_flutter/pages/RegisterView.dart';
import 'pages/TodayView.dart';
import 'pages/InboxView.dart';
import 'pages/NotesView.dart';
class Navigation extends StatefulWidget {
const Navigation({super.key});
@@ -12,12 +17,15 @@ class Navigation extends StatefulWidget {
class _NavigationState extends State<Navigation> {
int _selectedIndex = 0;
int _selectedIndex = 1;
static const List<Widget> _widgetOptions = <Widget>[
LoginView(),
RegisterView(),
TodayView(),
InboxView(),
NotesView(),
];
FirebaseAuth auth = FirebaseAuth.instance;
void _onItemTapped(int index) {
setState(() {
@@ -25,6 +33,20 @@ class _NavigationState extends State<Navigation> {
});
}
@override
void initState() {
FirebaseAuth.instance
.authStateChanges()
.listen((User? user) {
if (user == null) {
print('User is currently signed out!');
} else {
print('User is signed in!');
}
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -34,6 +56,8 @@ class _NavigationState extends State<Navigation> {
body: Center(child: _widgetOptions.elementAt(_selectedIndex)),
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(icon: Icon(Icons.login), label: "Login"),
BottomNavigationBarItem(icon: Icon(Icons.app_registration), label: "Register"),
BottomNavigationBarItem(
icon: Icon(Icons.calendar_today), label: "today"),
BottomNavigationBarItem(icon: Icon(Icons.inbox), label: "Inbox"),
@@ -41,6 +65,7 @@ class _NavigationState extends State<Navigation> {
],
currentIndex: _selectedIndex,
onTap: _onItemTapped,
type: BottomNavigationBarType.fixed,
),
);
}