Fix formatting

This commit is contained in:
Reimar 2024-08-26 20:53:47 +02:00
parent 4018983b51
commit c1fa40e492
Signed by: Reimar
GPG Key ID: 93549FA07F0AE268
2 changed files with 76 additions and 86 deletions

View File

@ -4,10 +4,9 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:google_fonts/google_fonts.dart';
import 'variables.dart';
class SideMenu extends StatefulWidget {
final Widget body;
final int selectedIndex ;
final int 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('id');
setState(() {
loggedIn = false;
user = null;
});
});
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Successfully logged out')));
Navigator.pushReplacementNamed(context, '/login');
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Successfully logged out')));
Navigator.pushReplacementNamed(context, '/login');
}
}
@ -47,13 +44,11 @@ class _SideMenuState extends State<SideMenu> {
void didChangeDependencies() {
super.didChangeDependencies();
api
.isLoggedIn(context).then((value) {
setState(() {
loggedIn = value; // Update the second variable here
});
});
api.isLoggedIn(context).then((value) {
setState(() {
loggedIn = value; // Update the second variable here
});
});
}
@override
@ -79,20 +74,17 @@ Widget build(BuildContext context) {
children: [
DrawerHeader(
child: Column(
children: [
const Image(
image: AssetImage('assets/logo.png'),
height: 100,
),
Text(
'SkanTravels',
style: GoogleFonts.jacquesFrancois(
fontSize: 20,
color: Color(0xFF1862E7),
children: [
const Image(image: AssetImage('assets/logo.png'), height: 100),
Text(
'SkanTravels',
style: GoogleFonts.jacquesFrancois(
fontSize: 20,
color: const Color(0xFF1862E7),
),
),
),
],
)
],
),
),
ListTile(
title: const Text('Home'),
@ -124,32 +116,33 @@ Widget build(BuildContext context) {
indent: 40,
),
...(loggedIn
? [
ListTile(
title: const Text('Log out'),
leading: const Icon(Icons.logout),
selected: false,
onTap: _logout,
)
]
: [
ListTile(
title: const Text('Register'),
leading: const Icon(Icons.add_box_outlined),
selected: _selectedIndex == 3,
onTap: () {
Navigator.pushReplacementNamed(context, '/register');
},
),
ListTile(
title: const Text('Login'),
leading: const Icon(Icons.login),
selected: _selectedIndex == 4,
onTap: () {
Navigator.pushReplacementNamed(context, '/login');
},
)
])
? [
ListTile(
title: const Text('Log out'),
leading: const Icon(Icons.logout),
selected: false,
onTap: _logout,
),
]
: [
ListTile(
title: const Text('Register'),
leading: const Icon(Icons.add_box_outlined),
selected: _selectedIndex == 3,
onTap: () {
Navigator.pushReplacementNamed(context, '/register');
},
),
ListTile(
title: const Text('Login'),
leading: const Icon(Icons.login),
selected: _selectedIndex == 4,
onTap: () {
Navigator.pushReplacementNamed(context, '/login');
},
),
]
),
],
),
),

View File

@ -34,9 +34,9 @@ class _LoginPageState extends State<LoginPage> {
prefs.setString('token', jsonUser.token);
prefs.setString('id', jsonUser.id);
setState(()
{loggedIn == true;});
setState(() {
loggedIn == true;
});
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Successfully logged in')));
@ -50,14 +50,11 @@ class _LoginPageState extends State<LoginPage> {
selectedIndex: 4,
body: Scaffold(
body: SingleChildScrollView(
child: Center(
child: Container(
constraints: const BoxConstraints(minWidth: 100, maxWidth: 400),
child: Column(children: [
const Image(
image: AssetImage('assets/logo.png'),
height: 200,
),
child: Center(
child: Container(
constraints: const BoxConstraints(minWidth: 100, maxWidth: 400),
child: Column(children: [
const Image(image: AssetImage('assets/logo.png'), height: 200),
Text(
'SkanTravels',
style: GoogleFonts.jacquesFrancois(
@ -65,29 +62,29 @@ class _LoginPageState extends State<LoginPage> {
color: const Color(0xFF1862E7),
),
),
const SizedBox(height: 40),
const Text('Email'),
TextField(controller: emailInput),
const SizedBox(height: 30),
const Text('Password'),
TextField(
controller: passwordInput,
obscureText: true,
enableSuggestions: false,
autocorrect: false,
),
const SizedBox(height: 30),
ElevatedButton(onPressed: _login, child: const Text('Login')),
const SizedBox(height: 10),
const Text('or'),
TextButton(
child: const Text('Register account'),
onPressed: () => Navigator.pushReplacementNamed(context, '/register')
),
]),
const SizedBox(height: 40),
const Text('Email'),
TextField(controller: emailInput),
const SizedBox(height: 30),
const Text('Password'),
TextField(
controller: passwordInput,
obscureText: true,
enableSuggestions: false,
autocorrect: false,
),
const SizedBox(height: 30),
ElevatedButton(onPressed: _login, child: const Text('Login')),
const SizedBox(height: 10),
const Text('or'),
TextButton(
child: const Text('Register account'),
onPressed: () => Navigator.pushReplacementNamed(context, '/register')
),
]),
),
),
),
),
),
);
}