ManageAccountPage #42
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -50,7 +50,7 @@
|
|||
</data>
|
||||
<key>flutter_assets/kernel_blob.bin</key>
|
||||
<data>
|
||||
SHTxJ8fMkVyfUd6I+OY6IBI9xPs=
|
||||
GJLNBMtVbFJeMdRS4+gMkd2BPpI=
|
||||
</data>
|
||||
<key>flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf</key>
|
||||
<data>
|
||||
|
@ -233,11 +233,11 @@
|
|||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
SHTxJ8fMkVyfUd6I+OY6IBI9xPs=
|
||||
GJLNBMtVbFJeMdRS4+gMkd2BPpI=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
n7iU4LdL05ehp1IEF87FldiFm9DDHYeJ9YYEkfnIG9c=
|
||||
hsYA3eg+UkH1zL2HkZqKO81oZ3m4AtLyawDShJxds0A=
|
||||
</data>
|
||||
</dict>
|
||||
<key>flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf</key>
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -50,7 +50,7 @@
|
|||
</data>
|
||||
<key>flutter_assets/kernel_blob.bin</key>
|
||||
<data>
|
||||
SHTxJ8fMkVyfUd6I+OY6IBI9xPs=
|
||||
GJLNBMtVbFJeMdRS4+gMkd2BPpI=
|
||||
</data>
|
||||
<key>flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf</key>
|
||||
<data>
|
||||
|
@ -233,11 +233,11 @@
|
|||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
SHTxJ8fMkVyfUd6I+OY6IBI9xPs=
|
||||
GJLNBMtVbFJeMdRS4+gMkd2BPpI=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
n7iU4LdL05ehp1IEF87FldiFm9DDHYeJ9YYEkfnIG9c=
|
||||
hsYA3eg+UkH1zL2HkZqKO81oZ3m4AtLyawDShJxds0A=
|
||||
</data>
|
||||
</dict>
|
||||
<key>flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf</key>
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -110,7 +110,7 @@
|
|||
</data>
|
||||
<key>Frameworks/App.framework/App</key>
|
||||
<data>
|
||||
TFVIrl9XvbIfIm8v/FoOrVPH8H4=
|
||||
Hrp+3lXoQX1UhHY5S3K1iH4t5ZM=
|
||||
</data>
|
||||
<key>Frameworks/App.framework/Info.plist</key>
|
||||
<data>
|
||||
|
@ -118,7 +118,7 @@
|
|||
</data>
|
||||
<key>Frameworks/App.framework/_CodeSignature/CodeResources</key>
|
||||
<data>
|
||||
ZVjdczQOxN/PvGmCEudi/ruwxi4=
|
||||
I2RvlTXB8M/P/E1q0Iok/w4FEvI=
|
||||
</data>
|
||||
<key>Frameworks/App.framework/flutter_assets/AssetManifest.json</key>
|
||||
<data>
|
||||
|
@ -162,7 +162,7 @@
|
|||
</data>
|
||||
<key>Frameworks/App.framework/flutter_assets/kernel_blob.bin</key>
|
||||
<data>
|
||||
SHTxJ8fMkVyfUd6I+OY6IBI9xPs=
|
||||
GJLNBMtVbFJeMdRS4+gMkd2BPpI=
|
||||
</data>
|
||||
<key>Frameworks/App.framework/flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf</key>
|
||||
<data>
|
||||
|
@ -2366,11 +2366,11 @@
|
|||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
TFVIrl9XvbIfIm8v/FoOrVPH8H4=
|
||||
Hrp+3lXoQX1UhHY5S3K1iH4t5ZM=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
BlFT97OgUpSDK4KbhKPj9GtmIVrphDOlx0paZF/KKRs=
|
||||
LjljhR4TWwp5U1vd0v5XKsdz2IeRqWff/Yq/eOS10Do=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Frameworks/App.framework/Info.plist</key>
|
||||
|
@ -2388,11 +2388,11 @@
|
|||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
ZVjdczQOxN/PvGmCEudi/ruwxi4=
|
||||
I2RvlTXB8M/P/E1q0Iok/w4FEvI=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
LaPE4/QfhbRJKex52LbpdQknZPGSIYjpSOAp0E0bBHw=
|
||||
G/hs7sYm9JJHOze8KiZhJ5XrHfoig2iuJwyK/VZo5Nw=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Frameworks/App.framework/flutter_assets/AssetManifest.json</key>
|
||||
|
@ -2509,11 +2509,11 @@
|
|||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
SHTxJ8fMkVyfUd6I+OY6IBI9xPs=
|
||||
GJLNBMtVbFJeMdRS4+gMkd2BPpI=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
n7iU4LdL05ehp1IEF87FldiFm9DDHYeJ9YYEkfnIG9c=
|
||||
hsYA3eg+UkH1zL2HkZqKO81oZ3m4AtLyawDShJxds0A=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Frameworks/App.framework/flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf</key>
|
||||
|
|
Binary file not shown.
|
@ -50,7 +50,7 @@
|
|||
</data>
|
||||
<key>flutter_assets/kernel_blob.bin</key>
|
||||
<data>
|
||||
SHTxJ8fMkVyfUd6I+OY6IBI9xPs=
|
||||
GJLNBMtVbFJeMdRS4+gMkd2BPpI=
|
||||
</data>
|
||||
<key>flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf</key>
|
||||
<data>
|
||||
|
@ -233,11 +233,11 @@
|
|||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
SHTxJ8fMkVyfUd6I+OY6IBI9xPs=
|
||||
GJLNBMtVbFJeMdRS4+gMkd2BPpI=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
n7iU4LdL05ehp1IEF87FldiFm9DDHYeJ9YYEkfnIG9c=
|
||||
hsYA3eg+UkH1zL2HkZqKO81oZ3m4AtLyawDShJxds0A=
|
||||
</data>
|
||||
</dict>
|
||||
<key>flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf</key>
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -110,7 +110,7 @@
|
|||
</data>
|
||||
<key>Frameworks/App.framework/App</key>
|
||||
<data>
|
||||
TFVIrl9XvbIfIm8v/FoOrVPH8H4=
|
||||
Hrp+3lXoQX1UhHY5S3K1iH4t5ZM=
|
||||
</data>
|
||||
<key>Frameworks/App.framework/Info.plist</key>
|
||||
<data>
|
||||
|
@ -118,7 +118,7 @@
|
|||
</data>
|
||||
<key>Frameworks/App.framework/_CodeSignature/CodeResources</key>
|
||||
<data>
|
||||
ZVjdczQOxN/PvGmCEudi/ruwxi4=
|
||||
I2RvlTXB8M/P/E1q0Iok/w4FEvI=
|
||||
</data>
|
||||
<key>Frameworks/App.framework/flutter_assets/AssetManifest.json</key>
|
||||
<data>
|
||||
|
@ -162,7 +162,7 @@
|
|||
</data>
|
||||
<key>Frameworks/App.framework/flutter_assets/kernel_blob.bin</key>
|
||||
<data>
|
||||
SHTxJ8fMkVyfUd6I+OY6IBI9xPs=
|
||||
GJLNBMtVbFJeMdRS4+gMkd2BPpI=
|
||||
</data>
|
||||
<key>Frameworks/App.framework/flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf</key>
|
||||
<data>
|
||||
|
@ -2366,11 +2366,11 @@
|
|||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
TFVIrl9XvbIfIm8v/FoOrVPH8H4=
|
||||
Hrp+3lXoQX1UhHY5S3K1iH4t5ZM=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
BlFT97OgUpSDK4KbhKPj9GtmIVrphDOlx0paZF/KKRs=
|
||||
LjljhR4TWwp5U1vd0v5XKsdz2IeRqWff/Yq/eOS10Do=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Frameworks/App.framework/Info.plist</key>
|
||||
|
@ -2388,11 +2388,11 @@
|
|||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
ZVjdczQOxN/PvGmCEudi/ruwxi4=
|
||||
I2RvlTXB8M/P/E1q0Iok/w4FEvI=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
LaPE4/QfhbRJKex52LbpdQknZPGSIYjpSOAp0E0bBHw=
|
||||
G/hs7sYm9JJHOze8KiZhJ5XrHfoig2iuJwyK/VZo5Nw=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Frameworks/App.framework/flutter_assets/AssetManifest.json</key>
|
||||
|
@ -2509,11 +2509,11 @@
|
|||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
SHTxJ8fMkVyfUd6I+OY6IBI9xPs=
|
||||
GJLNBMtVbFJeMdRS4+gMkd2BPpI=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
n7iU4LdL05ehp1IEF87FldiFm9DDHYeJ9YYEkfnIG9c=
|
||||
hsYA3eg+UkH1zL2HkZqKO81oZ3m4AtLyawDShJxds0A=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Frameworks/App.framework/flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf</key>
|
||||
|
|
|
@ -10,6 +10,7 @@ import 'mysql.dart';
|
|||
import 'package:flutter_applicationdemo/login/User.dart' as User;
|
||||
import 'login/user.dart';
|
||||
import 'globals.dart' as globals;
|
||||
import 'ManageAccountPage.dart';
|
||||
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
|
@ -103,7 +104,7 @@ class _HomePageState extends State<HomePage> {
|
|||
),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
context, //SignInPage()
|
||||
MaterialPageRoute(builder: (context) => SignInPage()), //Replace Container() with call to Map-page.
|
||||
);
|
||||
},
|
||||
|
|
|
@ -1,10 +1,137 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_applicationdemo/reusables/InputField.dart';
|
||||
|
||||
import 'package:flutter_applicationdemo/mysql.dart';
|
||||
import 'UpdatePassword.dart';
|
||||
|
||||
class ManageAccountPage extends StatefulWidget {
|
||||
@override
|
||||
State<ManageAccountPage> createState() => ManageAccountPageState();
|
||||
}
|
||||
|
||||
class ManageAccountPageState extends State<ManageAccountPage> {
|
||||
var db = mysql();
|
||||
TextEditingController userNameController = TextEditingController();
|
||||
TextEditingController emailController = TextEditingController();
|
||||
|
||||
Widget _buildNameFiled() {
|
||||
return InputField(
|
||||
text: "UserName",
|
||||
isPassword: false,
|
||||
icon: const Icon(Icons.person),
|
||||
controller: userNameController
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEmailFiled() {
|
||||
return InputField(
|
||||
text: "Email",
|
||||
isPassword: false,
|
||||
icon: const Icon(Icons.email),
|
||||
controller: emailController
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPasswordFiled() {
|
||||
return ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => UpdatePassword()), //Replace Container() with call to Map-page.
|
||||
);
|
||||
},
|
||||
child: const Text('Update password'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: const Color.fromARGB(255, 190, 146, 160)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class ManageAccountPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Center(child: Text('ManageAccountPage',style: TextStyle(fontSize: 60),)),
|
||||
appBar: AppBar(
|
||||
title: const Text('ManageAccountPage'),
|
||||
backgroundColor: const Color.fromARGB(255, 190, 146, 160),
|
||||
),
|
||||
body: Container(
|
||||
margin: EdgeInsets.all(24),
|
||||
child: Form(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const Text('Change user data' ,style: TextStyle(fontWeight: FontWeight.bold, fontSize: 25)),
|
||||
const SizedBox(height: 50),
|
||||
_buildNameFiled(),
|
||||
_buildEmailFiled(),
|
||||
_buildPasswordFiled(),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
UserInput userInput = UserInput(isValid: false, errorMessage: "");
|
||||
await verifyUserInput(userNameController.text, emailController.text, userInput);
|
||||
if(userInput.isValid) {
|
||||
//update user data...
|
||||
print(userNameController.text);
|
||||
print(emailController.text);
|
||||
} else {
|
||||
createUserError(userInput.errorMessage);
|
||||
}
|
||||
},
|
||||
child: const Text('Update'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: const Color.fromARGB(255, 190, 146, 160)
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
verifyUserInput(String userName, String email,userInput) {
|
||||
if (email!= '' && (email.contains("'") || !email.contains("@") || email.length < 5)) {
|
||||
userInput.errorMessage = "Incorrect email format";
|
||||
return;
|
||||
} else if (userName != '' && (userName.contains("'") || userName.length < 6)) {
|
||||
userInput.errorMessage =
|
||||
"Incorrect username. \nCharacters limited to a-z, A-Z, 0-9.";
|
||||
return;
|
||||
} else {
|
||||
userInput.isValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
void createUserError(String stringContext) {
|
||||
showDialog<String>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text("Couldn't update user data"),
|
||||
content: Text(stringContext),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, 'OK'),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> updateUserInSQL(String email, String username) async {
|
||||
await db.getConnection().then((conn) async {
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class UserInput {
|
||||
bool isValid;
|
||||
String errorMessage;
|
||||
UserInput({required this.isValid, required this.errorMessage});
|
||||
bool getIsValid() {
|
||||
return isValid;
|
||||
}
|
||||
}
|
||||
|
|
125
lib/UpdatePassword.dart
Normal file
125
lib/UpdatePassword.dart
Normal file
|
@ -0,0 +1,125 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_applicationdemo/Form.dart';
|
||||
import 'package:flutter_applicationdemo/reusables/InputField.dart';
|
||||
import 'package:flutter_applicationdemo/mysql.dart';
|
||||
import 'package:flutter_applicationdemo/login/User.dart';
|
||||
|
||||
class UpdatePassword extends StatefulWidget {
|
||||
@override
|
||||
State<UpdatePassword> createState() => UpdatePasswordState();
|
||||
}
|
||||
|
||||
class UpdatePasswordState extends State<UpdatePassword> {
|
||||
var db = mysql();
|
||||
TextEditingController passwordController = TextEditingController();
|
||||
TextEditingController currentPasswordController = TextEditingController();
|
||||
|
||||
Widget _currentPasswordFiled() {
|
||||
return InputField(
|
||||
text: "Current Password",
|
||||
isPassword: true,
|
||||
icon: const Icon(Icons.lock),
|
||||
controller: currentPasswordController
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPasswordFiled() {
|
||||
return InputField(
|
||||
text: "new Password",
|
||||
isPassword: true,
|
||||
icon: const Icon(Icons.lock),
|
||||
controller: passwordController
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Update Password'),
|
||||
backgroundColor: const Color.fromARGB(255, 190, 146, 160),
|
||||
),
|
||||
body: Container(
|
||||
margin: EdgeInsets.all(24),
|
||||
child: Form(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
_currentPasswordFiled(),
|
||||
_buildPasswordFiled(),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
UserInput userInput = UserInput(isValid: false, errorMessage: "");
|
||||
await verifyUserInput(currentPasswordController.text, passwordController.text, userInput);
|
||||
if(userInput.isValid) {
|
||||
//update user data...
|
||||
print(currentPasswordController.text);
|
||||
print(passwordController.text);
|
||||
} else {
|
||||
createUserError(userInput.errorMessage);
|
||||
}
|
||||
},
|
||||
child: const Text('Update'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: const Color.fromARGB(255, 190, 146, 160)
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Future<void> verifyUserInput(String currentPassword, String newPassword, userInput) async {
|
||||
userInput.isValid = false;
|
||||
await db.getConnection().then((conn) async {
|
||||
|
||||
});
|
||||
|
||||
if (newPassword.contains("'") || newPassword.length < 6) {
|
||||
userInput.errorMessage =
|
||||
"Incorrect password. \nPassword can't contain ' and needs to be atleast 6 characters long";
|
||||
return;
|
||||
} else {
|
||||
userInput.isValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateUserInSQL(String password) async {
|
||||
await db.getConnection().then((conn) async {
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void createUserError(String stringContext) {
|
||||
showDialog<String>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text("Couldn't update user data"),
|
||||
content: Text(stringContext),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, 'OK'),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class UserInput {
|
||||
bool isValid;
|
||||
String errorMessage;
|
||||
UserInput({required this.isValid, required this.errorMessage});
|
||||
bool getIsValid() {
|
||||
return isValid;
|
||||
|
||||
}
|
||||
}
|
|
@ -19,8 +19,8 @@ import 'globals.dart' as globals;
|
|||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await Firebase.initializeApp();
|
||||
await loadAllVenues();
|
||||
// await Firebase.initializeApp();
|
||||
// await loadAllVenues();
|
||||
|
||||
runApp(MyApp());
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ class InputField extends StatelessWidget {
|
|||
required this.text,
|
||||
required this.isPassword,
|
||||
required this.icon,
|
||||
required this.controller})
|
||||
required this.controller, ontap})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
|
|
Loading…
Reference in New Issue
Block a user