Merge Loginpage to master #9

Merged
maen0574 merged 13 commits from LoginPage into master 2022-05-17 10:19:58 +02:00
8 changed files with 261 additions and 110 deletions
Showing only changes of commit 3e28e9022a - Show all commits

View File

@ -392,7 +392,7 @@
"languageVersion": "2.16"
}
],
"generated": "2022-05-06T11:52:10.005704Z",
"generated": "2022-05-10T10:03:49.292538Z",
"generator": "pub",
"generatorVersion": "2.16.2"
}

View File

@ -3,7 +3,7 @@
#
# For more info see: https://dart.dev/go/dot-packages-deprecation
#
# Generated by pub on 2022-05-06 13:52:09.986249.
# Generated by pub on 2022-05-10 12:03:49.275584.
archive:file:///C:/Users/morte/OneDrive/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/archive-3.3.0/lib/
args:file:///C:/Users/morte/OneDrive/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/args-2.3.0/lib/
async:file:///C:/Users/morte/OneDrive/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.8.2/lib/

View File

@ -4741,6 +4741,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
clock
fake_async
material_color_utilities
quiver
Apache License
@ -6699,37 +6700,42 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
flutter
Copyright 2014 The Flutter Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Copyright 2014 The Flutter Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
flutter_lints
flutter_plugin_android_lifecycle
google_maps_flutter
google_maps_flutter_platform_interface
google_sign_in
google_sign_in_android
google_sign_in_ios
google_sign_in_platform_interface
google_sign_in_web
path_provider
path_provider_android
path_provider_ios
@ -6815,6 +6821,55 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--------------------------------------------------------------------------------
flutter_signin_button
Copyright (C) 2018, Zayn Jarvis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--------------------------------------------------------------------------------
font_awesome_flutter
MIT License
Copyright (c) 2017 Brian Egan
Font Awesome Icons by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--------------------------------------------------------------------------------
freetype2
@ -11338,27 +11393,27 @@ written authorization of the copyright holder.
--------------------------------------------------------------------------------
image
The MIT License
Copyright (c) 2013-2021 Brendan Duncan.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
The MIT License
Copyright (c) 2013-2021 Brendan Duncan.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
--------------------------------------------------------------------------------
js
@ -16475,31 +16530,31 @@ THE SOFTWARE.
--------------------------------------------------------------------------------
win32
Copyright 2019, the Dart project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Copyright 2019, the Dart project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
xxhash

View File

@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'BottomNavPage.dart';
import 'signInPage.dart';
import 'user.dart';
import 'globals.dart' as globals;
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@ -15,6 +17,7 @@ class _HomePageState extends State<HomePage> {
Color textColor = const Color.fromARGB(255, 79, 98, 114);
@override
Widget build(BuildContext context) {
print(globals.LOGGED_IN_USER.userID);
return Scaffold(
backgroundColor: pinkBackgroundColor,
body: SafeArea(
@ -54,7 +57,7 @@ class _HomePageState extends State<HomePage> {
),
),
Container(
padding: EdgeInsets.fromLTRB(80, 100, 80, 80),
padding: EdgeInsets.fromLTRB(80, 40, 80, 80),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
fixedSize: const Size(200, 200),
@ -85,34 +88,100 @@ class _HomePageState extends State<HomePage> {
),
),
),
ElevatedButton(
style: ElevatedButton.styleFrom(
fixedSize: const Size(200, 50),
primary: buttonColor,
elevation: 100,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SignInPage()), //Replace Container() with call to Map-page.
);
},
child: const Text('Sign in',
style: TextStyle(
fontSize: 18,
color: Colors.white,
shadows: <Shadow> [
Shadow(
offset: Offset(2, 2),
blurRadius: 10.0,
color: Color.fromARGB(255, 0, 0, 0),
),
])
),
),
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: buttonColor,
elevation: 100,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SignInPage()), //Replace Container() with call to Map-page.
);
},
child: const Text('Sign in',
style: TextStyle(
fontSize: 18,
color: Colors.white,
shadows: <Shadow> [
Shadow(
offset: Offset(2, 2),
blurRadius: 10.0,
color: Color.fromARGB(255, 0, 0, 0),
),
])
),
),
Padding(padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5)),
ElevatedButton(
style: ElevatedButton.styleFrom(
fixedSize: const Size(200, 50),
primary: buttonColor,
elevation: 100,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SignInPage()), //Replace Container() with call to Map-page.
);
},
child: const Text('Create account',
style: TextStyle(
fontSize: 18,
color: Colors.white,
shadows: <Shadow> [
Shadow(
offset: Offset(2, 2),
blurRadius: 10.0,
color: Color.fromARGB(255, 0, 0, 0),
),
])
),
)
]
),
);
}
ElevatedButton buildLogOutButton() {
return ElevatedButton(
style: ElevatedButton.styleFrom(
fixedSize: const Size(200, 50),
primary: buttonColor,
elevation: 100,
),
onPressed: () {
globals.LOGGED_IN_USER = user(0, "", "");
Navigator.push(
context,
MaterialPageRoute(builder: (context) => HomePage()), //Replace Container() with call to Map-page.
);
},
child: const Text('Log out',
style: TextStyle(
fontSize: 18,
color: Colors.white,
shadows: <Shadow> [
Shadow(
offset: Offset(2, 2),
blurRadius: 10.0,
color: Color.fromARGB(255, 0, 0, 0),
),
])
),
);
}
}

5
lib/globals.dart Normal file
View File

@ -0,0 +1,5 @@
import 'user.dart';
import 'HomePage.dart';
import 'main.dart';
user LOGGED_IN_USER = user(0, "", "");

View File

@ -2,8 +2,11 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'Map.dart';
import 'HomePage.dart';
import 'user.dart';
import 'globals.dart';
void main() => runApp(MyApp());
@ -15,7 +18,7 @@ class MyApp extends StatelessWidget {
primarySwatch: Colors.blue,
),
title: 'Flutter Google Maps Demo',
home: HomePage(),
home: const HomePage(),
debugShowCheckedModeBanner: false,
);
}

View File

@ -1,11 +1,11 @@
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'mysql.dart';
import 'HomePage.dart';
import 'main.dart';
import 'user.dart';
import 'package:flutter_applicationdemo/globals.dart';
class SignInPage extends StatefulWidget{
@override
@ -14,22 +14,20 @@ class SignInPage extends StatefulWidget{
class _SignInPageState extends State<SignInPage> {
var db = mysql();
int loggedId = 0;
int loggedInID = 0;
late user loggedInUser;
TextEditingController emailController = TextEditingController();
TextEditingController passwordController = TextEditingController();
Future<void> loginVerification(String email, String password) async{
bool isValid = false;
await db.getConnection().then((conn) async {
String sql = "select id from maen0574.user where email = '$email' and password = '$password'";
String sql = "select id, email, password from maen0574.user where email = '$email' and password = '$password'";
await conn.query(sql).then((results){
for(var row in results){
setState(() {
});
loggedId = row[0];
isValid = true;
//break;
loggedInUser = new user(row[0], row[1], row[2]);
loggedInID = loggedInUser.getID();
}
});
});
@ -37,6 +35,7 @@ class _SignInPageState extends State<SignInPage> {
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Scaffold(
appBar: AppBar(
title: Text("Login"),
@ -81,12 +80,14 @@ class _SignInPageState extends State<SignInPage> {
),
onPressed: () async {
await loginVerification(emailController.text, passwordController.text);
if(loggedId != 0){
if(loggedInID != 0){
LOGGED_IN_USER = loggedInUser;
Navigator.push(
context,
MaterialPageRoute(builder: (context) => HomePage()), //Replace Container() with call to account-page.
);
}
//print(loggedInUser.email + " " + loggedInUser.userID.toString());
},
child: Text('Sign In'),
),

18
lib/user.dart Normal file
View File

@ -0,0 +1,18 @@
class user{
late int userID;
late String username;
late String email;
user(int userID, String username, String email){
this.userID = userID;
this.username = username;
this.email = email;
}
user emptyUser(){
return user(0, "", "");
}
int getID(){
return userID;
}
}