-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from fga-eps-mds/feature/89-apagar-conta
#89 [US02] - Apagar Conta
- Loading branch information
Showing
21 changed files
with
707 additions
and
126 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:dio/dio.dart'; | ||
import 'package:hortum_mobile/globals.dart'; | ||
|
||
class UserAPI { | ||
Dio dio; | ||
|
||
UserAPI([Dio client]) { | ||
if (client == null) { | ||
this.dio = Dio(); | ||
} else { | ||
this.dio = client; | ||
} | ||
} | ||
|
||
Future updateUser({String username, String email}) async { | ||
//Trocar o IPLOCAL pelo ip de sua máquina | ||
String url = 'http://$ip:8000/users/update/'; | ||
|
||
var header = { | ||
"Content-Type": "application/json", | ||
"Authorization": "Bearer " + actualUser.tokenAccess, | ||
}; | ||
|
||
Map params = { | ||
"username": username, | ||
"email": email, | ||
}; | ||
params.removeWhere((key, value) => value == null); | ||
|
||
String _body = json.encode(params); | ||
Response response = await dio.patch(url, | ||
data: _body, | ||
options: Options( | ||
headers: header, | ||
validateStatus: (status) { | ||
return status <= 500; | ||
}, | ||
)); | ||
return response.statusCode; | ||
} | ||
|
||
Future changePassword(String actualPassword, String newPassword) async { | ||
//Trocar o IPLOCAL pelo ip de sua máquina | ||
var url = 'http://$ip:8000/users/change-password/'; | ||
var header = { | ||
"Content-Type": "application/json", | ||
"Authorization": "Bearer " + actualUser.tokenAccess, | ||
}; | ||
|
||
Map params = { | ||
"old_password": actualPassword, | ||
"new_password": newPassword, | ||
}; | ||
|
||
String _body = json.encode(params); | ||
Response response = await dio.patch(url, | ||
data: _body, | ||
options: Options( | ||
headers: header, | ||
validateStatus: (status) { | ||
return status <= 500; | ||
}, | ||
)); | ||
return response.statusCode; | ||
} | ||
|
||
Future deleteUser(String password) async { | ||
String url = 'http://$ip:8000/users/delete/'; | ||
|
||
var header = { | ||
"Content-Type": "application/json", | ||
"Authorization": "Bearer " + actualUser.tokenAccess, | ||
}; | ||
|
||
Map params = { | ||
"password": password, | ||
}; | ||
|
||
String _body = json.encode(params); | ||
Response response = await dio.delete(url, | ||
data: _body, | ||
options: Options( | ||
headers: header, | ||
validateStatus: (status) { | ||
return status <= 500; | ||
}, | ||
)); | ||
return response; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
hortum_mobile/lib/views/advanced_settings/advanced_settings_page.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:hortum_mobile/components/circle_style.dart'; | ||
import 'package:hortum_mobile/components/footer.dart'; | ||
import 'package:hortum_mobile/views/advanced_settings/components/change_password_button.dart'; | ||
import 'package:hortum_mobile/views/advanced_settings/components/delete_account_button.dart'; | ||
import 'package:hortum_mobile/views/advanced_settings/components/logout_button.dart'; | ||
|
||
class AdvancedSettingsPage extends StatefulWidget { | ||
final Dio dio; | ||
|
||
const AdvancedSettingsPage({this.dio, Key key}) : super(key: key); | ||
@override | ||
_AdvancedSettingsStatePage createState() => _AdvancedSettingsStatePage(); | ||
} | ||
|
||
class _AdvancedSettingsStatePage extends State<AdvancedSettingsPage> { | ||
@override | ||
Widget build(BuildContext context) { | ||
Size size = MediaQuery.of(context).size; | ||
return Scaffold( | ||
body: Stack(children: [ | ||
SingleChildScrollView( | ||
child: Column( | ||
children: [ | ||
CircleStyle(color: Color(0xff478C5C), opacity: 0.2), | ||
Text( | ||
'AVANÇADO', | ||
style: TextStyle( | ||
color: Colors.black, | ||
fontSize: 40, | ||
fontFamily: 'Comfortaa-Regular', | ||
letterSpacing: -0.33, | ||
fontWeight: FontWeight.w300), | ||
), | ||
Container( | ||
padding: EdgeInsets.only(top: size.height * 0.1), | ||
child: Column( | ||
children: [ | ||
ChangePasswordButton(), | ||
DeleteAccountButton(), | ||
LogoutButton(), | ||
], | ||
)), | ||
Container( | ||
margin: EdgeInsets.only(top: size.height * 0.05), | ||
height: size.height / 5, | ||
child: Image.asset("assets/images/logo.png"), | ||
), | ||
], | ||
), | ||
), | ||
Footer(), | ||
]), | ||
); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
hortum_mobile/lib/views/advanced_settings/components/change_password_button.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:hortum_mobile/views/change_password/change_password_page.dart'; | ||
|
||
class ChangePasswordButton extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
Size size = MediaQuery.of(context).size; | ||
return TextButton( | ||
key: Key('changePasswordButton'), | ||
onPressed: () { | ||
Navigator.push( | ||
context, | ||
MaterialPageRoute(builder: (context) => ChangePasswordPage()), | ||
); | ||
}, | ||
style: ButtonStyle( | ||
padding: MaterialStateProperty.all<EdgeInsets>((EdgeInsets.only( | ||
left: size.width * 0.125, right: size.width * 0.125))), | ||
backgroundColor: MaterialStateProperty.all<Color>(Color(0xff75CE90)), | ||
shape: MaterialStateProperty.all<RoundedRectangleBorder>( | ||
RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(20.0), | ||
))), | ||
child: Text( | ||
"MUDAR SENHA", | ||
style: TextStyle( | ||
fontSize: 15.0, | ||
color: Colors.white, | ||
), | ||
), | ||
); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
hortum_mobile/lib/views/advanced_settings/components/delete_account_button.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:hortum_mobile/views/delete_account/delete_account_page.dart'; | ||
|
||
class DeleteAccountButton extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
Size size = MediaQuery.of(context).size; | ||
return TextButton( | ||
key: Key('deleteAccountButton'), | ||
onPressed: () { | ||
Navigator.push( | ||
context, | ||
MaterialPageRoute(builder: (context) => DeleteAccountPage()), | ||
); | ||
}, | ||
style: ButtonStyle( | ||
padding: MaterialStateProperty.all<EdgeInsets>((EdgeInsets.only( | ||
left: size.width * 0.125, right: size.width * 0.125))), | ||
backgroundColor: MaterialStateProperty.all<Color>(Color(0xff75CE90)), | ||
shape: MaterialStateProperty.all<RoundedRectangleBorder>( | ||
RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(20.0), | ||
))), | ||
child: Text( | ||
"EXCLUIR CONTA", | ||
style: TextStyle( | ||
fontSize: 15.0, | ||
color: Colors.white, | ||
), | ||
), | ||
); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
hortum_mobile/lib/views/advanced_settings/components/logout_button.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:hortum_mobile/globals.dart'; | ||
import 'package:hortum_mobile/views/login/login_page.dart'; | ||
|
||
class LogoutButton extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
Size size = MediaQuery.of(context).size; | ||
return Container( | ||
child: TextButton( | ||
key: Key('logoutButton'), | ||
onPressed: () { | ||
actualUser.deleteUser(); | ||
Navigator.pushAndRemoveUntil( | ||
context, | ||
MaterialPageRoute(builder: (context) => LoginPage()), | ||
(route) => false); | ||
}, | ||
style: ButtonStyle( | ||
padding: MaterialStateProperty.all<EdgeInsets>(EdgeInsets.only( | ||
left: size.width * 0.21, right: size.width * 0.21)), | ||
backgroundColor: MaterialStateProperty.all<Color>(Color(0xff75CE90)), | ||
shape: MaterialStateProperty.all<RoundedRectangleBorder>( | ||
RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(20.0), | ||
))), | ||
child: Text( | ||
"SAIR", | ||
style: TextStyle( | ||
fontSize: 15.0, | ||
color: Colors.white, | ||
), | ||
), | ||
)); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
hortum_mobile/lib/views/change_password/services/change_password_services.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.