LoginPage #60

Merged
maen0574 merged 6 commits from LoginPage into master 2022-06-01 22:50:13 +02:00
21 changed files with 181 additions and 768 deletions

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 'package:flutter_applicationdemo/map.dart';
import 'favorite_page.dart';
import 'settings_page.dart';
import 'globals.dart' as globals;
import 'list_view_page.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,15 +1,10 @@
import 'package:flutter_applicationdemo/weather_data.dart';
import 'venue.dart';
import 'package:flutter_applicationdemo/login/user.dart';
import '../login/user.dart';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'home_page.dart';
import 'venue.dart';
import 'main.dart';
User LOGGED_IN_USER = User(0, "", "");
Color BACKGROUNDCOLOR = const Color.fromARGB(255, 190, 146, 160);

View File

@ -1,150 +0,0 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'bottom_nav_page.dart';
import 'login/create_account_page.dart';
import 'login/sign_in_page.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

@ -1,8 +1,5 @@
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'globals.dart' as globals;
import 'package:flutter_applicationdemo/venue.dart';
import 'venue_page.dart';

View File

@ -1,12 +1,9 @@
// ignore_for_file: prefer_const_constructors
import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/bottom_nav_page.dart';
import 'package:flutter_applicationdemo/login/encrypt_data.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:flutter_applicationdemo/mysql.dart';
import 'package:flutter_applicationdemo/home_page.dart';
import '../globals.dart' as globals;
import '../reusables/input_field.dart';
import 'user.dart';
@ -29,15 +26,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 +104,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);
@ -140,7 +128,6 @@ class _CreateAccountPageState extends State<CreateAccountPage> {
String sql =
"INSERT INTO maen0574.user (id, email, password, username) VALUES (null, '$email', '$password', '$username');";
await conn.query(sql);
sql =
"Select id, email, username from maen0574.user where email = '$email'";
await conn.query(sql).then((results) {

View File

@ -1,4 +1,3 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';

View File

@ -1,11 +1,7 @@
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/login/encrypt_data.dart';
import 'package:flutter_applicationdemo/bottom_nav_page.dart';
import '../mysql.dart';
import '../home_page.dart';
import '../main.dart';
import 'user.dart';
import '../reusables/input_field.dart';
import '../reusables/return_button.dart';
@ -48,15 +44,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(
@ -144,21 +132,16 @@ class _SignInPageState extends State<SignInPage> {
onPressed: () async {
if (emailController.text.contains("'") ||
passwordController.text.contains("'")) {
print("1");
loginError();
return;
}
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);
loginError();
}
//print(loggedInUser.email + " " + loggedInUser.userID.toString());

View File

@ -33,9 +33,6 @@ class User{
}
}
});
for(Venue venue in likedVenuesList){
print(venue.venueName);
}
});
}
}

View File

@ -2,23 +2,18 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter_applicationdemo/shadow_detector.dart';
import 'package:flutter_applicationdemo/login/google_sign_in_provider.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:flutter_applicationdemo/login/google_sign_in_provider.dart';
import 'package:provider/provider.dart';
import 'package:http/http.dart' as http;
import 'bottom_nav_page.dart';
import 'map.dart';
import 'weather_data.dart';
import 'venue.dart';
import 'mysql.dart';
import 'package:flutter_applicationdemo/login/user.dart';
import 'login/user.dart';
import 'globals.dart' as globals;
void main() async {

View File

@ -1,9 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/login/encrypt_data.dart';
import 'package:flutter_applicationdemo/reusables/input_field.dart';
import 'package:flutter_applicationdemo/globals.dart' as globals;
import 'package:flutter_applicationdemo/mysql.dart';
import 'home_page.dart';
import 'bottom_nav_page.dart';
class ManageAccountPage extends StatefulWidget {
@override
@ -12,35 +13,26 @@ class ManageAccountPage extends StatefulWidget {
class ManageAccountPageState extends State<ManageAccountPage> {
var db = mysql();
TextEditingController userNameController = TextEditingController();
TextEditingController emailController = TextEditingController();
TextEditingController previousPasswordController = TextEditingController();
TextEditingController passwordController = TextEditingController();
TextEditingController confirmPasswordController = TextEditingController();
UserInput userInput = UserInput(isValid: false, errorMessage: "");
Widget _buildNameFiled() {
Widget _buildPasswordFiled(TextEditingController controller) {
return InputField(
text: "new UserName",
isPassword: false,
icon: const Icon(Icons.person),
controller: userNameController
);
}
Widget _buildEmailFiled() {
return InputField(
text: "current Email",
isPassword: false,
icon: const Icon(Icons.email),
controller: emailController
);
}
Widget _buildPasswordFiled() {
return InputField(
text: "new Password",
text: "New password",
isPassword: true,
icon: const Icon(Icons.lock),
controller: passwordController
controller: controller
);
}
Widget _buildOldPasswordFiled() {
return InputField(
text: "Previous password",
isPassword: true,
icon: const Icon(Icons.lock),
controller: previousPasswordController
);
}
@ -51,31 +43,30 @@ 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>[
const Text('Update user data' ,style: TextStyle(fontWeight: FontWeight.bold, fontSize: 25)),
const SizedBox(height: 50),
_buildEmailFiled(),
_buildNameFiled(),
_buildPasswordFiled(),
_buildOldPasswordFiled(),
_buildPasswordFiled(passwordController),
_buildPasswordFiled(confirmPasswordController),
ElevatedButton(
onPressed: () async {
await verifyUserInput(userNameController.text, emailController.text,passwordController.text, userInput);
await verifyUserInput(previousPasswordController.text, passwordController.text, confirmPasswordController.text);
if(userInput.isValid) {
await updateUserInSQL(emailController.text, userNameController.text, passwordController.text);
await updateUserInSQL(previousPasswordController.text, confirmPasswordController.text);
Navigator.push(
context,
MaterialPageRoute(builder: (context) => HomePage()),
MaterialPageRoute(builder: (context) => BottomNavPage()),
);
} else {
createUserError(userInput.errorMessage);
}
},
child: const Text('Update'),
child: const Text('Change password'),
style: ElevatedButton.styleFrom(
primary: const Color.fromARGB(255, 190, 146, 160)
),
@ -87,51 +78,30 @@ class ManageAccountPageState extends State<ManageAccountPage> {
);
}
Future<void> verifyUserInput(String userName, String email , String password,userInput) async {
var result = false;
await db.getConnection().then((conn) async {
String sql = "SELECT email from maen0574.user where email = '$email';";
var results = await conn.query(sql);
if(results.toString() == "()") {
result = true;
}
});
if (result == true) {
userInput.errorMessage = "email incorrect!";
return;
} else if (email.contains("'") || !email.contains("@") || email.length < 5) {
userInput.errorMessage = "Incorrect email format";
return;
} else if (userName.contains("'") || userName.length < 6) {
userInput.errorMessage =
"Incorrect username. \nCharacters limited to a-z, A-Z, 0-9.";
return;
} else if (password.contains("'") || password.length < 6) {
userInput.errorMessage =
"Incorrect password. \nPassword can't contain ' and needs to be atleast 6 characters long";
Future<void> verifyUserInput(String previous, String newPassword , String confirmedPassword) async {
String result = userInputResult(previous, newPassword, confirmedPassword);
if(result.isNotEmpty){
userInput = UserInput(isValid: false, errorMessage: result);
return;
}else{
userInput.isValid = true;
userInput = UserInput(isValid: true, errorMessage: "");
}
}
String userInputResult(String userName, String email , String password) {
String userInputResult(String previousPassword, String newPassword, String confirmedPassword) {
String message = userInput.errorMessage;
if (email.contains("'") || !email.contains("@") || email.length < 5) {
message = "Incorrect email format";
if (previousPassword.contains("'") ){
message = "Incorrect previous password";
return message;
} else if (userName.contains("'") || userName.length < 6) {
} else if (newPassword.contains("'") || newPassword.length < 6) {
message =
"Incorrect username. \nCharacters limited to a-z, A-Z, 0-9.";
"Incorrect new password. \nCharacters limited to a-z, A-Z, 0-9 and needs to be atleast 6 characters long";
return message;
} else if (password.contains("'") || password.length < 6) {
} else if (confirmedPassword.contains("'") || confirmedPassword.length < 6) {
message =
"Incorrect password. \nPassword can't contain ' and needs to be atleast 6 characters long";
"Incorrect confirmed password. \nPassword can't contain ' and needs to be atleast 6 characters long";
return message;
} else {
return "";
@ -155,11 +125,28 @@ void createUserError(String stringContext) {
);
}
Future<void> updateUserInSQL(String email, String username, String password) async {
password = EncryptData.encryptAES(password);
Future<void> updateUserInSQL(String previousPassword, String newPassword) async {
previousPassword = EncryptData.encryptAES(previousPassword);
newPassword = EncryptData.encryptAES(newPassword);
await db.getConnection().then((conn) async {
String sql = "UPDATE maen0574.user set password = '$password', username = '$username' where email = '$email';";
await conn.query(sql);
String sql =
"Select id from maen0574.user where id = ${globals.LOGGED_IN_USER.userID} and password = '$previousPassword'";
userInput = UserInput(isValid: false, errorMessage: "Incorrect previous password");
await conn.query(sql).then((results) {
for (var row in results) {
setState(() {});
userInput = UserInput(isValid: true, errorMessage: "");
}
});
});
if(!userInput.isValid){
createUserError(userInput.errorMessage);
return;
}
await db.getConnection().then((conn) async {
String sql =
"UPDATE maen0574.user SET password = $newPassword WHERE id = ${globals.LOGGED_IN_USER.userID}";
conn.query(sql);
});
}

View File

@ -1,19 +1,15 @@
import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/bottom_nav_page.dart';
import 'package:google_fonts/google_fonts.dart';
import 'dart:async';
import 'login/user.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:flutter_google_places/flutter_google_places.dart';
import 'package:location/location.dart';
import 'package:flutter_applicationdemo/login/user.dart';
import 'settings_page.dart';
import 'venue_page.dart';
import 'venue.dart';
import 'login/user.dart';
import 'globals.dart' as globals;
import 'package:syncfusion_flutter_sliders/sliders.dart';
import 'package:flutter_applicationdemo/manage_account_page.dart';
import 'feedback_page.dart';
import 'login/create_account_page.dart';
import 'login/sign_in_page.dart';
@ -152,17 +148,6 @@ class MapState extends State<Map> {
),
],
),
floatingActionButton: Padding(
padding: const EdgeInsets.only(top: 100.0),
child: FloatingActionButton(
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => const SettingsPage()));
},
backgroundColor: Colors.purple,
child: const Icon(Icons.filter_alt),
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
);
}
@ -546,21 +531,9 @@ 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.
);
},
),
giveFeedbackTile(context),
settingsTile(context),
signOutTile(context),
],
),
);
@ -575,7 +548,6 @@ Widget buildDrawerSignedOut(BuildContext context) {
createAccountTile(context),
logInTile(context),
giveFeedbackTile(context),
settingsTile(context),
],
),
);
@ -599,18 +571,32 @@ DrawerHeader drawerHeader() {
ListTile settingsTile(BuildContext context) {
return ListTile(
leading: Icon(Icons.settings),
title: Text('Settings'),
title: Text('Change password'),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SettingsPage(),
builder: (context) => ManageAccountPage(),
),
);
},
);
}
ListTile signOutTile(BuildContext context) {
return ListTile(
leading: Icon(Icons.logout),
title: Text('Sign out'),
onTap: () {
globals.LOGGED_IN_USER = User(0, "", "");
Navigator.pop(
context,
);
(context as Element).reassemble();
},
);
}
ListTile giveFeedbackTile(BuildContext context) {
return ListTile(
leading: Icon(Icons.thumb_up_alt),
@ -630,13 +616,14 @@ ListTile logInTile(BuildContext context) {
return 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();
},
);
}
@ -645,13 +632,14 @@ ListTile createAccountTile(BuildContext context) {
return 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();
},
);
}

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:html/dom.dart' as dom;

View File

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

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/bottom_nav_page.dart';
import 'package:flutter_applicationdemo/login/google_sign_in_provider.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:settings_ui/settings_ui.dart';
import 'manage_account_page.dart';
import 'login/google_sign_in_provider.dart';
import 'package:provider/provider.dart';
import 'feedback_page.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) => BottomNavPage()),
);
},
child: Container(
margin: const EdgeInsets.only(left: 15.0, top: 10),
color: _backgroundColor,
height: 60,
width: 175,
child: const Center(
child: Text(
'Manage account',
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

@ -8,9 +8,8 @@ class ShadowDetector {
List<Venue> venuesInShade = [];
ShadowDetector() {
ShadowDetector();
}
//Called like "new ShadowDetector.fromShadowDetector(List of venues here);"
ShadowDetector.fromShadowDetector(venues) {
evaluateShadowsForAllVenues(venues);

View File

@ -1,7 +1,9 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/shadow_detector.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:flutter_applicationdemo/globals.dart' as globals;
import 'mysql.dart';
class Venue {
int venueID;
@ -29,22 +31,6 @@ class Venue {
LatLng tempPosition = LatLng(double.parse(splitArr[1]), double.parse(splitArr[0]));
/* print(splitArr[0].toString() + ' : ' + splitArr[1].toString());
print('Coordinates: ' + tempCoordinates);
print('Parsed: ' + double.parse(splitArr[0]).toString());
print(LatLng(double.parse(splitArr[1]), double.parse(splitArr[0])));
print(tempAddress + tempName);
print(tempPosition.latitude.toString() + " " + splitArr[0]);*/
// print('Json-Object:');
// print(json);
// print(venues);
// print(json['name']);
// print(json['address']);
// print(json['streetNo']);
// print(json['coordinates']);
if (tempName != null &&
tempAddress != null &&
tempStreetNo != null &&
@ -120,6 +106,25 @@ class Venue {
'coordinates: ' +
position.toString();
}
void likeVenue() {
globals.LOGGED_IN_USER.likedVenuesList.add(this);
var db = mysql();
db.getConnection().then((conn) {
String sql =
"INSERT INTO maen0574.userFavorites (user_id, venue_id) VALUES (${globals.LOGGED_IN_USER.userID}, $venueID);";
conn.query(sql);
});
}
void unlikeVenue(){
globals.LOGGED_IN_USER.likedVenuesList.remove(this);
var db = mysql();
db.getConnection().then((conn) {
String sql =
"DELETE FROM maen0574.userFavorites WHERE user_id = '${globals.LOGGED_IN_USER.userID}' and venue_id = $venueID;";
conn.query(sql);
});
}
}
class OutdoorSeatingArea {

View File

@ -1,7 +1,6 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:html/dom.dart' as dom;
import 'package:intl/intl.dart';
import 'dart:io';

View File

@ -1,6 +1,5 @@
import 'dart:convert';
import 'dart:io';
import 'package:share_plus/share_plus.dart';
import 'package:flutter_applicationdemo/venue.dart';
import 'package:flutter/material.dart';
@ -138,7 +137,7 @@ class VenuePageState extends State<VenuePage> {
return Column(
children: [
Padding(
padding: const EdgeInsets.all(4.0),
padding: EdgeInsets.all(4.0),
child:
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
Column(
@ -188,7 +187,7 @@ class _AboutTheSpotTableState extends State<AboutTheSpotTable> {
fontSize: 14,
fontWeight: FontWeight.bold,
)))),
const DataColumn(label: Text('', style: TextStyle())),
DataColumn(label: Text('', style: TextStyle())),
],
rows: [
DataRow(cells: [
@ -240,7 +239,7 @@ class LikeVenueButton extends StatelessWidget {
return alreadyLiked? Expanded(
child: TextButton.icon(
onPressed: () {
globals.LOGGED_IN_USER.likedVenuesList.remove(venue);
venue.unlikeVenue();
(context as Element).reassemble();
},
icon: const Icon(
@ -252,10 +251,10 @@ class LikeVenueButton extends StatelessWidget {
primary: const Color(0xff4f6272),
),
),
) : Expanded(
) : globals.LOGGED_IN_USER.userID != 0 ? Expanded(
child: TextButton.icon(
onPressed: () {
globals.LOGGED_IN_USER.likedVenuesList.add(venue);
venue.likeVenue();
(context as Element).reassemble();
},
icon: const Icon(
@ -266,8 +265,43 @@ class LikeVenueButton extends StatelessWidget {
style: TextButton.styleFrom(
primary: const Color(0xff4f6272),
),
)): Expanded(
child: TextButton.icon(
onPressed: () async{
await notLoggedInError(context);
},
icon: const Icon(
Icons.favorite_border_outlined,
color: Colors.grey,
),
label: const Text('Like place'),
style: TextButton.styleFrom(
primary: Color(0xff4f6272),
),
));
}
notLoggedInError(BuildContext context) {
Widget okButton = TextButton(
child: Text("OK"),
onPressed: () => Navigator.pop(context, 'OK'),
);
// set up the AlertDialog
AlertDialog alert = AlertDialog(
title: Text("Can\'t like venue"),
content: Text("You need to be logged in to like venues."),
actions: [
okButton,
],
);
// show the dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}
}
class ShareButton extends StatelessWidget {