Fix formatting
This commit is contained in:
parent
4018983b51
commit
c1fa40e492
@ -4,10 +4,9 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'variables.dart';
|
import 'variables.dart';
|
||||||
|
|
||||||
|
|
||||||
class SideMenu extends StatefulWidget {
|
class SideMenu extends StatefulWidget {
|
||||||
final Widget body;
|
final Widget body;
|
||||||
final int selectedIndex ;
|
final int selectedIndex;
|
||||||
|
|
||||||
const SideMenu({super.key, required this.body, required this.selectedIndex});
|
const SideMenu({super.key, required this.body, required this.selectedIndex});
|
||||||
|
|
||||||
@ -29,17 +28,15 @@ class _SideMenuState extends State<SideMenu> {
|
|||||||
|
|
||||||
prefs.remove('token');
|
prefs.remove('token');
|
||||||
prefs.remove('id');
|
prefs.remove('id');
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
loggedIn = false;
|
loggedIn = false;
|
||||||
user = null;
|
user = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Successfully logged out')));
|
||||||
const SnackBar(content: Text('Successfully logged out')));
|
Navigator.pushReplacementNamed(context, '/login');
|
||||||
Navigator.pushReplacementNamed(context, '/login');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,13 +44,11 @@ class _SideMenuState extends State<SideMenu> {
|
|||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
|
|
||||||
api
|
api.isLoggedIn(context).then((value) {
|
||||||
.isLoggedIn(context).then((value) {
|
setState(() {
|
||||||
setState(() {
|
loggedIn = value; // Update the second variable here
|
||||||
loggedIn = value; // Update the second variable here
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -79,20 +74,17 @@ Widget build(BuildContext context) {
|
|||||||
children: [
|
children: [
|
||||||
DrawerHeader(
|
DrawerHeader(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
const Image(
|
const Image(image: AssetImage('assets/logo.png'), height: 100),
|
||||||
image: AssetImage('assets/logo.png'),
|
Text(
|
||||||
height: 100,
|
'SkanTravels',
|
||||||
),
|
style: GoogleFonts.jacquesFrancois(
|
||||||
Text(
|
fontSize: 20,
|
||||||
'SkanTravels',
|
color: const Color(0xFF1862E7),
|
||||||
style: GoogleFonts.jacquesFrancois(
|
),
|
||||||
fontSize: 20,
|
|
||||||
color: Color(0xFF1862E7),
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
)
|
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: const Text('Home'),
|
title: const Text('Home'),
|
||||||
@ -124,32 +116,33 @@ Widget build(BuildContext context) {
|
|||||||
indent: 40,
|
indent: 40,
|
||||||
),
|
),
|
||||||
...(loggedIn
|
...(loggedIn
|
||||||
? [
|
? [
|
||||||
ListTile(
|
ListTile(
|
||||||
title: const Text('Log out'),
|
title: const Text('Log out'),
|
||||||
leading: const Icon(Icons.logout),
|
leading: const Icon(Icons.logout),
|
||||||
selected: false,
|
selected: false,
|
||||||
onTap: _logout,
|
onTap: _logout,
|
||||||
)
|
),
|
||||||
]
|
]
|
||||||
: [
|
: [
|
||||||
ListTile(
|
ListTile(
|
||||||
title: const Text('Register'),
|
title: const Text('Register'),
|
||||||
leading: const Icon(Icons.add_box_outlined),
|
leading: const Icon(Icons.add_box_outlined),
|
||||||
selected: _selectedIndex == 3,
|
selected: _selectedIndex == 3,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pushReplacementNamed(context, '/register');
|
Navigator.pushReplacementNamed(context, '/register');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: const Text('Login'),
|
title: const Text('Login'),
|
||||||
leading: const Icon(Icons.login),
|
leading: const Icon(Icons.login),
|
||||||
selected: _selectedIndex == 4,
|
selected: _selectedIndex == 4,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pushReplacementNamed(context, '/login');
|
Navigator.pushReplacementNamed(context, '/login');
|
||||||
},
|
},
|
||||||
)
|
),
|
||||||
])
|
]
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -34,9 +34,9 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
prefs.setString('token', jsonUser.token);
|
prefs.setString('token', jsonUser.token);
|
||||||
prefs.setString('id', jsonUser.id);
|
prefs.setString('id', jsonUser.id);
|
||||||
|
|
||||||
setState(()
|
setState(() {
|
||||||
{loggedIn == true;});
|
loggedIn == true;
|
||||||
|
});
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Successfully logged in')));
|
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Successfully logged in')));
|
||||||
@ -50,14 +50,11 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
selectedIndex: 4,
|
selectedIndex: 4,
|
||||||
body: Scaffold(
|
body: Scaffold(
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
constraints: const BoxConstraints(minWidth: 100, maxWidth: 400),
|
constraints: const BoxConstraints(minWidth: 100, maxWidth: 400),
|
||||||
child: Column(children: [
|
child: Column(children: [
|
||||||
const Image(
|
const Image(image: AssetImage('assets/logo.png'), height: 200),
|
||||||
image: AssetImage('assets/logo.png'),
|
|
||||||
height: 200,
|
|
||||||
),
|
|
||||||
Text(
|
Text(
|
||||||
'SkanTravels',
|
'SkanTravels',
|
||||||
style: GoogleFonts.jacquesFrancois(
|
style: GoogleFonts.jacquesFrancois(
|
||||||
@ -65,29 +62,29 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
color: const Color(0xFF1862E7),
|
color: const Color(0xFF1862E7),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 40),
|
const SizedBox(height: 40),
|
||||||
const Text('Email'),
|
const Text('Email'),
|
||||||
TextField(controller: emailInput),
|
TextField(controller: emailInput),
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
const Text('Password'),
|
const Text('Password'),
|
||||||
TextField(
|
TextField(
|
||||||
controller: passwordInput,
|
controller: passwordInput,
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
enableSuggestions: false,
|
enableSuggestions: false,
|
||||||
autocorrect: false,
|
autocorrect: false,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
ElevatedButton(onPressed: _login, child: const Text('Login')),
|
ElevatedButton(onPressed: _login, child: const Text('Login')),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
const Text('or'),
|
const Text('or'),
|
||||||
TextButton(
|
TextButton(
|
||||||
child: const Text('Register account'),
|
child: const Text('Register account'),
|
||||||
onPressed: () => Navigator.pushReplacementNamed(context, '/register')
|
onPressed: () => Navigator.pushReplacementNamed(context, '/register')
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user