LoginPage #60

Merged
maen0574 merged 6 commits from LoginPage into master 2022-06-01 22:50:13 +02:00
12 changed files with 59 additions and 648 deletions
Showing only changes of commit 4ba0c3341c - Show all commits

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'Map.dart';
import 'FavoritePage.dart';
import 'SettingsPage.dart';
import 'globals.dart' as globals;
import 'ListViewPage.dart';

View File

@ -87,11 +87,12 @@ class _FavoritePageState extends State<FavoritePage> {
primary: globals.BUTTONCOLOR,
elevation: 100,
),
onPressed: () {
Navigator.push(
onPressed: () async{
await Navigator.push(
context, //SignInPage()
MaterialPageRoute(builder: (context) =>SignInPage()), //Replace Container() with call to Map-page.
);
(context as Element).reassemble();
},
child: Text('Sign in',
style: TextStyle(

View File

@ -76,25 +76,6 @@ class FormForFeedbackState extends State<FormForFeedback> {
resizeToAvoidBottomInset: true, //för att undvika RenderFlex overflow när man får upp skrivbordet
appBar: AppBar(
backgroundColor: buttonColor,
title: Row(
children: <Widget>[
FlatButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => BottomNavPage()),
);
},
child: Text("Close",
style: TextStyle(
fontSize: 25,
color: appBarColor),
),
),
],
),
),
body: SingleChildScrollView(

View File

@ -1,150 +0,0 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'BottomNavPage.dart';
import 'login/CreateAccountPage.dart';
import 'login/signInPage.dart';
import 'package:flutter_applicationdemo/login/User.dart' as User;
import 'globals.dart' as globals;
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: globals.PINKBACKGROUND,
body: SafeArea(
child: Center(
child: Column(children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(80, 80, 80, 0),
child: Text(
'Sun Chasers',
style: GoogleFonts.roboto(
fontSize: 52,
color: globals.TEXTCOLOR,
),
textAlign: TextAlign.center,
),
),
const SizedBox(height: 10),
Container(
margin: EdgeInsets.fromLTRB(80, 80, 80, 80),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
fixedSize: const Size(200, 200),
primary: globals.BUTTONCOLOR,
elevation: globals.elevation,
shape: const CircleBorder(),
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => BottomNavPage()), //Replace Container() with call to account-page.
);
},
child: Text(
(globals.LOGGED_IN_USER.userID == 0 ? '\nFIND SPOT BY LOCATION \n \n as guest' : 'FIND SPOT BY LOCATION'),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 18,
color: Colors.white,
),
),
),
),
globals.LOGGED_IN_USER.userID == 0 ?
buildLoginAndCreateUserButton() : buildLogOutButton()
]),
),
),
);
}
Container buildLoginAndCreateUserButton() {
return Container(
child: Column(
children: <Widget> [
ElevatedButton(
style: ElevatedButton.styleFrom(
fixedSize: const Size(200, 50),
primary: globals.BUTTONCOLOR,
elevation: globals.elevation,
),
onPressed: () {
Navigator.push(
context, //SignInPage()
MaterialPageRoute(builder: (context) =>SignInPage()), //Replace Container() with call to Map-page.
);
},
child: Text('Sign in',
style: TextStyle(
fontSize: 18,
color: Colors.white,
)
),
),
Padding(padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5)),
ElevatedButton(
style: ElevatedButton.styleFrom(
fixedSize: const Size(200, 50),
primary: globals.BUTTONCOLOR,
elevation: globals.elevation,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => CreateAccountPage()), //Replace Container() with call to Map-page.
);
},
child: const Text('Create account',
style: TextStyle(
fontSize: 18,
color: Colors.white,
)
),
)
]
),
);
}
ElevatedButton buildLogOutButton() {
return ElevatedButton(
style: ElevatedButton.styleFrom(
fixedSize: const Size(200, 50),
primary: globals.BUTTONCOLOR,
elevation: globals.elevation,
),
onPressed: () {
globals.LOGGED_IN_USER = User.User(0, "", "");
Navigator.push(
context,
MaterialPageRoute(builder: (context) => HomePage()), //Replace Container() with call to Map-page.
);
},
child: Text('Log out',
style: TextStyle(
fontSize: 18,
color: Colors.white,
shadows: <Shadow> [
Shadow(
offset: Offset(2, 2),
blurRadius: 10.0,
color: globals.SHADOWCOLOR,
),
])
),
);
}
}

View File

@ -4,7 +4,6 @@ import 'package:flutter_applicationdemo/login/EncryptData.dart';
import 'package:flutter_applicationdemo/reusables/InputField.dart';
import 'package:flutter_applicationdemo/globals.dart' as globals;
import 'package:flutter_applicationdemo/mysql.dart';
import 'HomePage.dart';
class ManageAccountPage extends StatefulWidget {
@override
@ -43,9 +42,8 @@ class ManageAccountPageState extends State<ManageAccountPage> {
//title: const Text('ManageAccountPage'),
backgroundColor: const Color.fromARGB(255, 190, 146, 160),
),
body: Container(
margin: EdgeInsets.all(24),
child: Form(
body: Center(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[

View File

@ -2,11 +2,11 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/BottomNavPage.dart';
import 'package:flutter_applicationdemo/ListViewPage.dart';
import 'package:flutter_applicationdemo/ManageAccountPage.dart';
import 'package:flutter_applicationdemo/WeatherData.dart';
import 'package:flutter_applicationdemo/WebScraper.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:flutter_applicationdemo/HomePage.dart';
import 'dart:async';
import 'login/User.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
@ -18,14 +18,10 @@ import 'package:location/location.dart';
import 'package:geolocator/geolocator.dart';
import 'package:intl/intl.dart';
import 'package:flutter_applicationdemo/login/User.dart';
import 'SettingsPage.dart';
import 'venuePage.dart';
import 'Venue.dart';
import 'globals.dart' as globals;
import 'package:syncfusion_flutter_sliders/sliders.dart';
import 'HomePage.dart';
import 'FeedbackPage.dart';
import 'login/CreateAccountPage.dart';
import 'login/signInPage.dart';
@ -631,17 +627,6 @@ Widget buildDrawerSignedIn(BuildContext context) {
],
),
),
ListTile(
leading: Icon(Icons.logout),
title: Text('Sign out'),
onTap: () {
globals.LOGGED_IN_USER = User(0, "", "");
Navigator.push(
context,
MaterialPageRoute(builder: (context) => BottomNavPage()), //Replace Container() with call to Map-page.
);
},
),
ListTile(
leading: Icon(Icons.thumb_up_alt),
title: Text('Give feedback'),
@ -656,16 +641,27 @@ Widget buildDrawerSignedIn(BuildContext context) {
),
ListTile(
leading: Icon(Icons.settings),
title: Text('Settings'),
title: Text('Change password'),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SettingsPage(),
builder: (context) => ManageAccountPage(),
),
);
},
),
ListTile(
leading: Icon(Icons.logout),
title: Text('Sign out'),
onTap: () {
globals.LOGGED_IN_USER = User(0, "", "");
Navigator.pop(
context,
);
(context as Element).reassemble();
},
),
],
),
);
@ -692,25 +688,27 @@ Widget buildDrawerSignedOut(BuildContext context) {
ListTile(
leading: Icon(Icons.account_box_rounded),
title: Text('Create account'),
onTap: () {
Navigator.push(
onTap: () async{
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CreateAccountPage(),
),
);
(context as Element).reassemble();
},
),
ListTile(
leading: Icon(Icons.login),
title: Text('Sign in'),
onTap: () {
Navigator.push(
onTap: () async {
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SignInPage(),
),
);
(context as Element).reassemble();
},
),
ListTile(
@ -725,18 +723,6 @@ Widget buildDrawerSignedOut(BuildContext context) {
);
},
),
ListTile(
leading: Icon(Icons.settings),
title: Text('Settings'),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SettingsPage(),
),
);
},
),
],
),
);

View File

@ -1,380 +0,0 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/BottomNavPage.dart';
import 'package:flutter_applicationdemo/login/GoogleSignInProvider.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:settings_ui/settings_ui.dart';
import 'ManageAccountPage.dart';
import 'login/GoogleSignInProvider.dart';
import 'package:provider/provider.dart';
import 'FeedbackPage.dart';
// Standard color of app
Color _backgroundColor = const Color.fromARGB(255, 190, 146, 160);
// Color status of priceRange
Color _colorContainerLow = Colors.purple;
Color _colorContainerMedium = _backgroundColor;
Color _colorContainerHigh = _backgroundColor;
// Logic status of priceRange
Map<String, bool> _priceRangeBool = {
"LowPriceRange": true,
"MediumPriceRange": false,
"HighPriceRange": false
};
// Status of switches
bool _cafeSwitch = true;
bool _barSwitch = true;
bool _restaurantSwitch = true;
// Standard
@override
class SettingsPage extends StatefulWidget {
const SettingsPage({Key? key}) : super(key: key);
@override
_SettingsPageState createState() => _SettingsPageState();
}
class _SettingsPageState extends State<SettingsPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
//leading: IconButton(icon: Icon(Icons.search), onPressed:() {},),
centerTitle: true,
title: const Text(
'Settings',
style: TextStyle(
fontSize: 30,
color: Colors.white,
shadows: <Shadow>[
Shadow(
offset: Offset(2, 2),
blurRadius: 10.0,
color: Color.fromARGB(255, 0, 0, 0),
),
],
),
),
backgroundColor: _backgroundColor,
),
body: SettingsList(
sections: [
SettingsSection(
title: const Text(
'Filter preferences',
style: TextStyle(
fontSize: 20,
color: Color.fromARGB(255, 0, 0, 0),
),
),
tiles: <SettingsTile>[
SettingsTile.switchTile(
onToggle: (value) {
setState(() {
_cafeSwitch = value;
});
},
initialValue: _cafeSwitch,
leading: const Icon(Icons.local_cafe),
title: const Text('Cafe'),
),
SettingsTile.switchTile(
onToggle: (value) {
setState(() {
_barSwitch = value;
});
},
initialValue: _barSwitch,
leading: const Icon(Icons.local_bar),
title: const Text('Bar'),
),
SettingsTile.switchTile(
onToggle: (value) {
setState(() {
_restaurantSwitch = value;
});
},
initialValue: _restaurantSwitch,
leading: const Icon(Icons.local_restaurant),
title: const Text('Restaurant'),
),
SettingsTile(
title: const Text("Price"),
value: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Expanded(
child: InkWell(
onTap: () {
setState(() {
onClickPriceColor("LowPriceRange");
if (_priceRangeBool["LowPriceRange"] == true) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
duration: Duration(milliseconds: 1000),
behavior: SnackBarBehavior.floating,
content: Text('Selected £'),
),);
}else{
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
duration: Duration(milliseconds: 1000),
content: Text('Unselected £'),
behavior: SnackBarBehavior.floating,
),);
}
});
},
child: Container(
color: _colorContainerLow,
height: 60,
width: 75,
margin:
const EdgeInsets.only(left: 20.0, right: 20.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: const <Widget>[
Icon(
Icons.attach_money,
size: 27,
),
],
),
),
),
),
Expanded(
child: InkWell(
onTap: () {
setState(() {
onClickPriceColor("MediumPriceRange");
if (_priceRangeBool["MediumPriceRange"] == true) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
duration: Duration(milliseconds: 1000),
behavior: SnackBarBehavior.floating,
content: Text('Selected ££'),
));
}else{
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
duration: Duration(milliseconds: 1000),
content: Text('Unselected ££'),
behavior: SnackBarBehavior.floating,
));
}
});
print("Tapped double dollarSign");
},
child: Container(
color: _colorContainerMedium,
height: 60,
width: 75,
margin:
const EdgeInsets.only(left: 20.0, right: 20.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: const <Widget>[
Icon(
Icons.attach_money,
size: 27,
),
Icon(
Icons.attach_money,
size: 27,
),
],
),
),
),
),
Expanded(
child: InkWell(
onTap: () {
setState(() {
onClickPriceColor("HighPriceRange");
if (_priceRangeBool["HighPriceRange"] == true) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
duration: Duration(milliseconds: 1000),
behavior: SnackBarBehavior.floating,
content: Text('Selected £££'),
));
}else{
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
duration: Duration(milliseconds: 1000),
content: Text('Unselected £££'),
behavior: SnackBarBehavior.floating,
));
}
});
print("Tapped Tripple dollarSign");
},
child: Container(
color: _colorContainerHigh,
height: 60,
width: 75,
margin:
const EdgeInsets.only(left: 20.0, right: 20.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
Icon(
Icons.attach_money,
size: 27,
),
Icon(
Icons.attach_money,
size: 27,
),
Icon(
Icons.attach_money,
size: 27,
),
],
),
),
),
),
],
),
),
],
),
CustomSettingsSection(
child: Column(children: [
SizedBox(
width: double.infinity,
child: Container(
margin: const EdgeInsets.only(left: 25.0, top: 10),
child: const Text(
'Account',
style: TextStyle(
fontSize: 25,
color: Color.fromARGB(255, 0, 0, 0),
),
),
),
),
Column(
children: [
Row(
children: [
InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ManageAccountPage()),
);
},
child: Container(
margin: const EdgeInsets.only(left: 15.0, top: 10),
color: _backgroundColor,
height: 60,
width: 175,
child: const Center(
child: Text(
'Change password',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight. bold,
color: Colors.black,
),
),
),
),
),
InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => FormForFeedback()),
);
},
child: Container(
margin: const EdgeInsets.only(left: 15.0, top: 10),
color: _backgroundColor,
height: 60,
width: 175,
child: const Center(
child: Text(
'Leave feedback',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight. bold,
color: Colors.black,
),
),
),
),
),
],
),
Center(
child: InkWell(
onTap: () async {
final provider = Provider.of<GoogleSignInProvider>(context, listen: false);
provider.logOut();
},
child: Container(
margin: const EdgeInsets.only(top: 10, right: 15),
color: _backgroundColor,
height: 60,
width: 175,
child: const Center(
child: Text(
'Log out',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight. bold,
color: Colors.black,
),
),
),
),
),
)
],
),
]))
],
));
}
}
void onClickPriceColor(String priceRange) {
if (priceRange == "LowPriceRange") {
if (_priceRangeBool["LowPriceRange"] == true) {
_priceRangeBool["LowPriceRange"] = false;
_colorContainerLow = _backgroundColor;
} else {
_priceRangeBool["LowPriceRange"] = true;
_colorContainerLow = Colors.purple;
}
} else if (priceRange == "MediumPriceRange") {
if (_priceRangeBool["MediumPriceRange"] == true) {
_priceRangeBool["MediumPriceRange"] = false;
_colorContainerMedium = _backgroundColor;
} else {
_priceRangeBool["MediumPriceRange"] = true;
_colorContainerMedium = Colors.purple;
}
} else {
if (_priceRangeBool["HighPriceRange"] == true) {
_priceRangeBool["HighPriceRange"] = false;
_colorContainerHigh = _backgroundColor;
} else {
_priceRangeBool["HighPriceRange"] = true;
_colorContainerHigh = Colors.purple;
}
}
}

View File

@ -7,7 +7,6 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'HomePage.dart';
import 'Venue.dart';
import 'main.dart';

View File

@ -5,8 +5,6 @@ import 'package:flutter_applicationdemo/BottomNavPage.dart';
import 'package:flutter_applicationdemo/login/EncryptData.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:flutter_applicationdemo/mysql.dart';
import 'package:flutter_applicationdemo/HomePage.dart';
import '../globals.dart' as globals;
import '../reusables/InputField.dart';
import 'User.dart';
@ -29,15 +27,7 @@ class _CreateAccountPageState extends State<CreateAccountPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: globals.PINKBACKGROUND,
leading: ReturnButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => BottomNavPage()),
);
},
),
backgroundColor: const Color.fromARGB(204, 172, 123, 132),
),
backgroundColor: pinkBackgroundColor,
@ -115,9 +105,8 @@ class _CreateAccountPageState extends State<CreateAccountPage> {
if (userInput.isValid) {
await createUserInSQL(emailController.text, userNameController.text,
passwordController.text);
Navigator.push(
Navigator.pop(
context,
MaterialPageRoute(builder: (context) => BottomNavPage()),
);
} else {
createUserError(userInput.errorMessage);

View File

@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/login/EncryptData.dart';
import 'package:flutter_applicationdemo/BottomNavPage.dart';
import '../mysql.dart';
import '../HomePage.dart';
import '../main.dart';
import 'User.dart';
import '../reusables/InputField.dart';
@ -13,6 +12,7 @@ import 'package:flutter_signin_button/flutter_signin_button.dart';
import 'GoogleSignInProvider.dart';
import 'CreateAccountPage.dart';
import 'package:provider/provider.dart';
import 'package:flutter_applicationdemo/Map.dart' as map;
import 'package:flutter_applicationdemo/globals.dart' as globals;
class SignInPage extends StatefulWidget {
@ -48,15 +48,7 @@ class _SignInPageState extends State<SignInPage> {
backgroundColor: globals.PINKBACKGROUND,
resizeToAvoidBottomInset: true,
appBar: AppBar(
backgroundColor: globals.PINKBACKGROUND,
leading: ReturnButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => BottomNavPage()),
);
},
),
backgroundColor: const Color.fromARGB(204, 172, 123, 132),
),
body: Center(child: SingleChildScrollView(
child: Column(
@ -151,11 +143,8 @@ class _SignInPageState extends State<SignInPage> {
await loginVerification(emailController.text, passwordController.text);
if (globals.LOGGED_IN_USER.userID != 0) {
globals.LOGGED_IN_USER = loggedInUser;
Navigator.push(
Navigator.pop(
context,
MaterialPageRoute(
builder: (context) =>
BottomNavPage()), //Replace Container() with call to account-page.
);
} else {
print(globals.LOGGED_IN_USER.userID);

View File

@ -1,6 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/HomePage.dart';
class ReturnButton extends StatelessWidget {
final onPressed;