LoginPage #60
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'map.dart';
|
import 'package:flutter_applicationdemo/map.dart';
|
||||||
import 'favorite_page.dart';
|
import 'favorite_page.dart';
|
||||||
import 'settings_page.dart';
|
|
||||||
import 'globals.dart' as globals;
|
import 'globals.dart' as globals;
|
||||||
import 'list_view_page.dart';
|
import 'list_view_page.dart';
|
||||||
|
|
||||||
|
|
|
@ -87,11 +87,12 @@ class _FavoritePageState extends State<FavoritePage> {
|
||||||
primary: globals.BUTTONCOLOR,
|
primary: globals.BUTTONCOLOR,
|
||||||
elevation: 100,
|
elevation: 100,
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () async{
|
||||||
Navigator.push(
|
await Navigator.push(
|
||||||
context, //SignInPage()
|
context, //SignInPage()
|
||||||
MaterialPageRoute(builder: (context) =>SignInPage()), //Replace Container() with call to Map-page.
|
MaterialPageRoute(builder: (context) =>SignInPage()), //Replace Container() with call to Map-page.
|
||||||
);
|
);
|
||||||
|
(context as Element).reassemble();
|
||||||
},
|
},
|
||||||
child: Text('Sign in',
|
child: Text('Sign in',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
|
|
@ -76,25 +76,6 @@ class FormForFeedbackState extends State<FormForFeedback> {
|
||||||
resizeToAvoidBottomInset: true, //för att undvika RenderFlex overflow när man får upp skrivbordet
|
resizeToAvoidBottomInset: true, //för att undvika RenderFlex overflow när man får upp skrivbordet
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: buttonColor,
|
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(
|
body: SingleChildScrollView(
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
import 'package:flutter_applicationdemo/weather_data.dart';
|
import 'package:flutter_applicationdemo/weather_data.dart';
|
||||||
|
|
||||||
import 'venue.dart';
|
import 'venue.dart';
|
||||||
import 'package:flutter_applicationdemo/login/user.dart';
|
import 'package:flutter_applicationdemo/login/user.dart';
|
||||||
import '../login/user.dart';
|
import '../login/user.dart';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'home_page.dart';
|
|
||||||
import 'venue.dart';
|
|
||||||
import 'main.dart';
|
|
||||||
|
|
||||||
User LOGGED_IN_USER = User(0, "", "");
|
User LOGGED_IN_USER = User(0, "", "");
|
||||||
Color BACKGROUNDCOLOR = const Color.fromARGB(255, 190, 146, 160);
|
Color BACKGROUNDCOLOR = const Color.fromARGB(255, 190, 146, 160);
|
||||||
|
|
|
@ -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,
|
|
||||||
),
|
|
||||||
])
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +1,5 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
|
||||||
|
|
||||||
import 'globals.dart' as globals;
|
import 'globals.dart' as globals;
|
||||||
import 'package:flutter_applicationdemo/venue.dart';
|
import 'package:flutter_applicationdemo/venue.dart';
|
||||||
import 'venue_page.dart';
|
import 'venue_page.dart';
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
// ignore_for_file: prefer_const_constructors
|
// ignore_for_file: prefer_const_constructors
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_applicationdemo/bottom_nav_page.dart';
|
|
||||||
import 'package:flutter_applicationdemo/login/encrypt_data.dart';
|
import 'package:flutter_applicationdemo/login/encrypt_data.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:flutter_applicationdemo/mysql.dart';
|
import 'package:flutter_applicationdemo/mysql.dart';
|
||||||
|
|
||||||
import 'package:flutter_applicationdemo/home_page.dart';
|
|
||||||
import '../globals.dart' as globals;
|
import '../globals.dart' as globals;
|
||||||
import '../reusables/input_field.dart';
|
import '../reusables/input_field.dart';
|
||||||
import 'user.dart';
|
import 'user.dart';
|
||||||
|
@ -29,15 +26,7 @@ class _CreateAccountPageState extends State<CreateAccountPage> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: globals.PINKBACKGROUND,
|
backgroundColor: const Color.fromARGB(204, 172, 123, 132),
|
||||||
leading: ReturnButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => BottomNavPage()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
backgroundColor: pinkBackgroundColor,
|
backgroundColor: pinkBackgroundColor,
|
||||||
|
|
||||||
|
@ -115,9 +104,8 @@ class _CreateAccountPageState extends State<CreateAccountPage> {
|
||||||
if (userInput.isValid) {
|
if (userInput.isValid) {
|
||||||
await createUserInSQL(emailController.text, userNameController.text,
|
await createUserInSQL(emailController.text, userNameController.text,
|
||||||
passwordController.text);
|
passwordController.text);
|
||||||
Navigator.push(
|
Navigator.pop(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(builder: (context) => BottomNavPage()),
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
createUserError(userInput.errorMessage);
|
createUserError(userInput.errorMessage);
|
||||||
|
@ -140,7 +128,6 @@ class _CreateAccountPageState extends State<CreateAccountPage> {
|
||||||
String sql =
|
String sql =
|
||||||
"INSERT INTO maen0574.user (id, email, password, username) VALUES (null, '$email', '$password', '$username');";
|
"INSERT INTO maen0574.user (id, email, password, username) VALUES (null, '$email', '$password', '$username');";
|
||||||
await conn.query(sql);
|
await conn.query(sql);
|
||||||
|
|
||||||
sql =
|
sql =
|
||||||
"Select id, email, username from maen0574.user where email = '$email'";
|
"Select id, email, username from maen0574.user where email = '$email'";
|
||||||
await conn.query(sql).then((results) {
|
await conn.query(sql).then((results) {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'package:firebase_auth/firebase_auth.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:google_sign_in/google_sign_in.dart';
|
import 'package:google_sign_in/google_sign_in.dart';
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
import 'dart:io';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_applicationdemo/login/encrypt_data.dart';
|
import 'package:flutter_applicationdemo/login/encrypt_data.dart';
|
||||||
import 'package:flutter_applicationdemo/bottom_nav_page.dart';
|
import 'package:flutter_applicationdemo/bottom_nav_page.dart';
|
||||||
import '../mysql.dart';
|
import '../mysql.dart';
|
||||||
import '../home_page.dart';
|
|
||||||
import '../main.dart';
|
|
||||||
import 'user.dart';
|
import 'user.dart';
|
||||||
import '../reusables/input_field.dart';
|
import '../reusables/input_field.dart';
|
||||||
import '../reusables/return_button.dart';
|
import '../reusables/return_button.dart';
|
||||||
|
@ -48,15 +44,7 @@ class _SignInPageState extends State<SignInPage> {
|
||||||
backgroundColor: globals.PINKBACKGROUND,
|
backgroundColor: globals.PINKBACKGROUND,
|
||||||
resizeToAvoidBottomInset: true,
|
resizeToAvoidBottomInset: true,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: globals.PINKBACKGROUND,
|
backgroundColor: const Color.fromARGB(204, 172, 123, 132),
|
||||||
leading: ReturnButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => BottomNavPage()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
body: Center(child: SingleChildScrollView(
|
body: Center(child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
@ -144,21 +132,16 @@ class _SignInPageState extends State<SignInPage> {
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (emailController.text.contains("'") ||
|
if (emailController.text.contains("'") ||
|
||||||
passwordController.text.contains("'")) {
|
passwordController.text.contains("'")) {
|
||||||
print("1");
|
|
||||||
loginError();
|
loginError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await loginVerification(emailController.text, passwordController.text);
|
await loginVerification(emailController.text, passwordController.text);
|
||||||
if (globals.LOGGED_IN_USER.userID != 0) {
|
if (globals.LOGGED_IN_USER.userID != 0) {
|
||||||
globals.LOGGED_IN_USER = loggedInUser;
|
globals.LOGGED_IN_USER = loggedInUser;
|
||||||
Navigator.push(
|
Navigator.pop(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) =>
|
|
||||||
BottomNavPage()), //Replace Container() with call to account-page.
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
print(globals.LOGGED_IN_USER.userID);
|
|
||||||
loginError();
|
loginError();
|
||||||
}
|
}
|
||||||
//print(loggedInUser.email + " " + loggedInUser.userID.toString());
|
//print(loggedInUser.email + " " + loggedInUser.userID.toString());
|
||||||
|
|
|
@ -33,9 +33,6 @@ class User{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
for(Venue venue in likedVenuesList){
|
|
||||||
print(venue.venueName);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,23 +2,18 @@ import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:firebase_auth/firebase_auth.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:firebase_core/firebase_core.dart';
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
import 'package:flutter_applicationdemo/shadow_detector.dart';
|
import 'package:flutter_applicationdemo/shadow_detector.dart';
|
||||||
import 'package:flutter_applicationdemo/login/google_sign_in_provider.dart';
|
import 'package:flutter_applicationdemo/login/google_sign_in_provider.dart';
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.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:provider/provider.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
import 'bottom_nav_page.dart';
|
import 'bottom_nav_page.dart';
|
||||||
import 'map.dart';
|
|
||||||
import 'weather_data.dart';
|
import 'weather_data.dart';
|
||||||
import 'venue.dart';
|
import 'venue.dart';
|
||||||
import 'mysql.dart';
|
import 'mysql.dart';
|
||||||
import 'package:flutter_applicationdemo/login/user.dart';
|
|
||||||
import 'login/user.dart';
|
|
||||||
import 'globals.dart' as globals;
|
import 'globals.dart' as globals;
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_applicationdemo/login/encrypt_data.dart';
|
import 'package:flutter_applicationdemo/login/encrypt_data.dart';
|
||||||
import 'package:flutter_applicationdemo/reusables/input_field.dart';
|
import 'package:flutter_applicationdemo/reusables/input_field.dart';
|
||||||
|
import 'package:flutter_applicationdemo/globals.dart' as globals;
|
||||||
import 'package:flutter_applicationdemo/mysql.dart';
|
import 'package:flutter_applicationdemo/mysql.dart';
|
||||||
import 'home_page.dart';
|
|
||||||
|
import 'bottom_nav_page.dart';
|
||||||
|
|
||||||
class ManageAccountPage extends StatefulWidget {
|
class ManageAccountPage extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
|
@ -12,35 +13,26 @@ class ManageAccountPage extends StatefulWidget {
|
||||||
|
|
||||||
class ManageAccountPageState extends State<ManageAccountPage> {
|
class ManageAccountPageState extends State<ManageAccountPage> {
|
||||||
var db = mysql();
|
var db = mysql();
|
||||||
TextEditingController userNameController = TextEditingController();
|
TextEditingController previousPasswordController = TextEditingController();
|
||||||
TextEditingController emailController = TextEditingController();
|
|
||||||
TextEditingController passwordController = TextEditingController();
|
TextEditingController passwordController = TextEditingController();
|
||||||
|
TextEditingController confirmPasswordController = TextEditingController();
|
||||||
|
|
||||||
UserInput userInput = UserInput(isValid: false, errorMessage: "");
|
UserInput userInput = UserInput(isValid: false, errorMessage: "");
|
||||||
|
|
||||||
Widget _buildNameFiled() {
|
Widget _buildPasswordFiled(TextEditingController controller) {
|
||||||
return InputField(
|
return InputField(
|
||||||
text: "new UserName",
|
text: "New password",
|
||||||
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",
|
|
||||||
isPassword: true,
|
isPassword: true,
|
||||||
icon: const Icon(Icons.lock),
|
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'),
|
//title: const Text('ManageAccountPage'),
|
||||||
backgroundColor: const Color.fromARGB(255, 190, 146, 160),
|
backgroundColor: const Color.fromARGB(255, 190, 146, 160),
|
||||||
),
|
),
|
||||||
body: Container(
|
body: Center(
|
||||||
margin: EdgeInsets.all(24),
|
child: SingleChildScrollView(
|
||||||
child: Form(
|
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
const Text('Update user data' ,style: TextStyle(fontWeight: FontWeight.bold, fontSize: 25)),
|
const Text('Update user data' ,style: TextStyle(fontWeight: FontWeight.bold, fontSize: 25)),
|
||||||
const SizedBox(height: 50),
|
const SizedBox(height: 50),
|
||||||
_buildEmailFiled(),
|
_buildOldPasswordFiled(),
|
||||||
_buildNameFiled(),
|
_buildPasswordFiled(passwordController),
|
||||||
_buildPasswordFiled(),
|
_buildPasswordFiled(confirmPasswordController),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await verifyUserInput(userNameController.text, emailController.text,passwordController.text, userInput);
|
await verifyUserInput(previousPasswordController.text, passwordController.text, confirmPasswordController.text);
|
||||||
if(userInput.isValid) {
|
if(userInput.isValid) {
|
||||||
await updateUserInSQL(emailController.text, userNameController.text, passwordController.text);
|
await updateUserInSQL(previousPasswordController.text, confirmPasswordController.text);
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(builder: (context) => HomePage()),
|
MaterialPageRoute(builder: (context) => BottomNavPage()),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
createUserError(userInput.errorMessage);
|
createUserError(userInput.errorMessage);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Text('Update'),
|
child: const Text('Change password'),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
primary: const Color.fromARGB(255, 190, 146, 160)
|
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 {
|
Future<void> verifyUserInput(String previous, String newPassword , String confirmedPassword) async {
|
||||||
var result = false;
|
String result = userInputResult(previous, newPassword, confirmedPassword);
|
||||||
await db.getConnection().then((conn) async {
|
if(result.isNotEmpty){
|
||||||
String sql = "SELECT email from maen0574.user where email = '$email';";
|
userInput = UserInput(isValid: false, errorMessage: result);
|
||||||
var results = await conn.query(sql);
|
return;
|
||||||
|
}else{
|
||||||
if(results.toString() == "()") {
|
userInput = UserInput(isValid: true, errorMessage: "");
|
||||||
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";
|
|
||||||
return;
|
|
||||||
}else {
|
|
||||||
userInput.isValid = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String userInputResult(String userName, String email , String password) {
|
String userInputResult(String previousPassword, String newPassword, String confirmedPassword) {
|
||||||
String message = userInput.errorMessage;
|
String message = userInput.errorMessage;
|
||||||
|
|
||||||
if (email.contains("'") || !email.contains("@") || email.length < 5) {
|
if (previousPassword.contains("'") ){
|
||||||
message = "Incorrect email format";
|
message = "Incorrect previous password";
|
||||||
return message;
|
return message;
|
||||||
} else if (userName.contains("'") || userName.length < 6) {
|
} else if (newPassword.contains("'") || newPassword.length < 6) {
|
||||||
message =
|
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;
|
return message;
|
||||||
} else if (password.contains("'") || password.length < 6) {
|
} else if (confirmedPassword.contains("'") || confirmedPassword.length < 6) {
|
||||||
message =
|
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;
|
return message;
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
|
@ -155,11 +125,28 @@ void createUserError(String stringContext) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateUserInSQL(String email, String username, String password) async {
|
Future<void> updateUserInSQL(String previousPassword, String newPassword) async {
|
||||||
password = EncryptData.encryptAES(password);
|
previousPassword = EncryptData.encryptAES(previousPassword);
|
||||||
|
newPassword = EncryptData.encryptAES(newPassword);
|
||||||
await db.getConnection().then((conn) async {
|
await db.getConnection().then((conn) async {
|
||||||
String sql = "UPDATE maen0574.user set password = '$password', username = '$username' where email = '$email';";
|
String sql =
|
||||||
await conn.query(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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
62
lib/map.dart
62
lib/map.dart
|
@ -1,19 +1,15 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_applicationdemo/bottom_nav_page.dart';
|
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'login/user.dart';
|
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
import 'package:flutter_google_places/flutter_google_places.dart';
|
import 'package:flutter_google_places/flutter_google_places.dart';
|
||||||
import 'package:location/location.dart';
|
import 'package:location/location.dart';
|
||||||
import 'package:flutter_applicationdemo/login/user.dart';
|
|
||||||
import 'settings_page.dart';
|
|
||||||
import 'venue_page.dart';
|
import 'venue_page.dart';
|
||||||
import 'venue.dart';
|
import 'venue.dart';
|
||||||
|
import 'login/user.dart';
|
||||||
import 'globals.dart' as globals;
|
import 'globals.dart' as globals;
|
||||||
|
|
||||||
import 'package:syncfusion_flutter_sliders/sliders.dart';
|
import 'package:syncfusion_flutter_sliders/sliders.dart';
|
||||||
|
import 'package:flutter_applicationdemo/manage_account_page.dart';
|
||||||
import 'feedback_page.dart';
|
import 'feedback_page.dart';
|
||||||
import 'login/create_account_page.dart';
|
import 'login/create_account_page.dart';
|
||||||
import 'login/sign_in_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,
|
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),
|
giveFeedbackTile(context),
|
||||||
settingsTile(context),
|
settingsTile(context),
|
||||||
|
signOutTile(context),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -575,7 +548,6 @@ Widget buildDrawerSignedOut(BuildContext context) {
|
||||||
createAccountTile(context),
|
createAccountTile(context),
|
||||||
logInTile(context),
|
logInTile(context),
|
||||||
giveFeedbackTile(context),
|
giveFeedbackTile(context),
|
||||||
settingsTile(context),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -599,18 +571,32 @@ DrawerHeader drawerHeader() {
|
||||||
ListTile settingsTile(BuildContext context) {
|
ListTile settingsTile(BuildContext context) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: Icon(Icons.settings),
|
leading: Icon(Icons.settings),
|
||||||
title: Text('Settings'),
|
title: Text('Change password'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
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) {
|
ListTile giveFeedbackTile(BuildContext context) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: Icon(Icons.thumb_up_alt),
|
leading: Icon(Icons.thumb_up_alt),
|
||||||
|
@ -630,13 +616,14 @@ ListTile logInTile(BuildContext context) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: Icon(Icons.login),
|
leading: Icon(Icons.login),
|
||||||
title: Text('Sign in'),
|
title: Text('Sign in'),
|
||||||
onTap: () {
|
onTap: () async{
|
||||||
Navigator.push(
|
await Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => SignInPage(),
|
builder: (context) => SignInPage(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
(context as Element).reassemble();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -645,13 +632,14 @@ ListTile createAccountTile(BuildContext context) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: Icon(Icons.account_box_rounded),
|
leading: Icon(Icons.account_box_rounded),
|
||||||
title: Text('Create account'),
|
title: Text('Create account'),
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
Navigator.push(
|
await Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => CreateAccountPage(),
|
builder: (context) => CreateAccountPage(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
(context as Element).reassemble();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:html/dom.dart' as dom;
|
import 'package:html/dom.dart' as dom;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_applicationdemo/home_page.dart';
|
|
||||||
|
|
||||||
class ReturnButton extends StatelessWidget {
|
class ReturnButton extends StatelessWidget {
|
||||||
final onPressed;
|
final onPressed;
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,9 +8,8 @@ class ShadowDetector {
|
||||||
|
|
||||||
List<Venue> venuesInShade = [];
|
List<Venue> venuesInShade = [];
|
||||||
|
|
||||||
ShadowDetector() {
|
ShadowDetector();
|
||||||
|
|
||||||
}
|
|
||||||
//Called like "new ShadowDetector.fromShadowDetector(List of venues here);"
|
//Called like "new ShadowDetector.fromShadowDetector(List of venues here);"
|
||||||
ShadowDetector.fromShadowDetector(venues) {
|
ShadowDetector.fromShadowDetector(venues) {
|
||||||
evaluateShadowsForAllVenues(venues);
|
evaluateShadowsForAllVenues(venues);
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_applicationdemo/shadow_detector.dart';
|
import 'package:flutter_applicationdemo/shadow_detector.dart';
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
|
import 'package:flutter_applicationdemo/globals.dart' as globals;
|
||||||
|
|
||||||
|
import 'mysql.dart';
|
||||||
|
|
||||||
class Venue {
|
class Venue {
|
||||||
int venueID;
|
int venueID;
|
||||||
|
@ -29,22 +31,6 @@ class Venue {
|
||||||
LatLng tempPosition = LatLng(double.parse(splitArr[1]), double.parse(splitArr[0]));
|
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 &&
|
if (tempName != null &&
|
||||||
tempAddress != null &&
|
tempAddress != null &&
|
||||||
tempStreetNo != null &&
|
tempStreetNo != null &&
|
||||||
|
@ -120,6 +106,25 @@ class Venue {
|
||||||
'coordinates: ' +
|
'coordinates: ' +
|
||||||
position.toString();
|
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 {
|
class OutdoorSeatingArea {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:html/dom.dart' as dom;
|
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
import 'package:flutter_applicationdemo/venue.dart';
|
import 'package:flutter_applicationdemo/venue.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -138,7 +137,7 @@ class VenuePageState extends State<VenuePage> {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(4.0),
|
padding: EdgeInsets.all(4.0),
|
||||||
child:
|
child:
|
||||||
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
|
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
|
||||||
Column(
|
Column(
|
||||||
|
@ -188,7 +187,7 @@ class _AboutTheSpotTableState extends State<AboutTheSpotTable> {
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
)))),
|
)))),
|
||||||
const DataColumn(label: Text('', style: TextStyle())),
|
DataColumn(label: Text('', style: TextStyle())),
|
||||||
],
|
],
|
||||||
rows: [
|
rows: [
|
||||||
DataRow(cells: [
|
DataRow(cells: [
|
||||||
|
@ -240,7 +239,7 @@ class LikeVenueButton extends StatelessWidget {
|
||||||
return alreadyLiked? Expanded(
|
return alreadyLiked? Expanded(
|
||||||
child: TextButton.icon(
|
child: TextButton.icon(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
globals.LOGGED_IN_USER.likedVenuesList.remove(venue);
|
venue.unlikeVenue();
|
||||||
(context as Element).reassemble();
|
(context as Element).reassemble();
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
|
@ -252,10 +251,10 @@ class LikeVenueButton extends StatelessWidget {
|
||||||
primary: const Color(0xff4f6272),
|
primary: const Color(0xff4f6272),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
) : Expanded(
|
) : globals.LOGGED_IN_USER.userID != 0 ? Expanded(
|
||||||
child: TextButton.icon(
|
child: TextButton.icon(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
globals.LOGGED_IN_USER.likedVenuesList.add(venue);
|
venue.likeVenue();
|
||||||
(context as Element).reassemble();
|
(context as Element).reassemble();
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
|
@ -266,8 +265,43 @@ class LikeVenueButton extends StatelessWidget {
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
primary: const Color(0xff4f6272),
|
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 {
|
class ShareButton extends StatelessWidget {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user