-
Notifications
You must be signed in to change notification settings - Fork 6
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 #30 from fga-eps-mds/devel
Atualização Release 1.2
- Loading branch information
Showing
26 changed files
with
1,268 additions
and
93 deletions.
There are no files selected for viewing
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
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
1 change: 1 addition & 0 deletions
1
android/app/src/main/kotlin/com/example/flutter_application_1/MainActivity.kt
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
package com.example.flutter_application_1 | ||
|
||
import io.flutter.embedding.android.FlutterActivity | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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,83 @@ | ||
import 'package:mobx/mobx.dart'; | ||
import 'package:dio/dio.dart'; | ||
import 'package:e_vacina/globals.dart'; | ||
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; | ||
|
||
part 'userController.g.dart'; | ||
|
||
class UserController = UserControllerBase with _$UserController; | ||
|
||
final _storage = new FlutterSecureStorage(); | ||
|
||
abstract class UserControllerBase with Store { | ||
@observable | ||
String email; | ||
|
||
@action | ||
changeEmail(String value) => email = value; | ||
|
||
@observable | ||
String password; | ||
|
||
@action | ||
changePassword(String value) => password = value; | ||
|
||
@observable | ||
dynamic userId; | ||
|
||
@action | ||
changeUserId(String value) => userId = value; | ||
|
||
@observable | ||
dynamic token; | ||
|
||
@action | ||
changeToken(String value) => token = value; | ||
|
||
@action | ||
login(String email, String password) async { | ||
Response response = await api.auth(email, password); | ||
|
||
changeToken(response.data['token']); | ||
changeUserId(response.data['user']['_id']); | ||
await _storage.write(key: 'token', value: token); | ||
await _storage.write(key: 'userId', value: userId); | ||
print('$token'); | ||
} | ||
|
||
@action | ||
logout() async { | ||
changeToken(''); | ||
changeUserId(''); | ||
await _storage.deleteAll(); | ||
} | ||
|
||
@action | ||
register(String email, String phoneNumber, String password) async { | ||
if (email.isEmpty || phoneNumber.isEmpty || password.isEmpty) { | ||
print("deu erro"); | ||
} | ||
print("teste"); | ||
Response response = await api.registerUser(email, phoneNumber, password); | ||
changeEmail(email); | ||
changePassword(password); | ||
changeUserId(response.data['savedUser']['_id']); | ||
login(email, password); | ||
print("deu certo"); | ||
} | ||
|
||
@action | ||
delete() async { | ||
Response response = await api.deleteUser(userId, token); | ||
print(response); | ||
print(response.statusCode); | ||
} | ||
|
||
@action | ||
update(String email, String phoneNumber, String password) async { | ||
Response response = | ||
await api.updateUser(email, phoneNumber, password, userId, token); | ||
print(response); | ||
print(response.statusCode); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,14 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:e_vacina/controllers/userController.dart'; | ||
import 'package:e_vacina/services/api.dart'; | ||
|
||
UserController userController = new UserController(); | ||
Api api = new Api(); | ||
|
||
var options = BaseOptions( | ||
baseUrl: 'http://localhost:3000', | ||
connectTimeout: 5000, | ||
receiveTimeout: 3000, | ||
); | ||
|
||
var dio = Dio(options); |
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.