Commit 83ec685b authored by Ester Alfonzo's avatar Ester Alfonzo

utilizacion de clean architecture para vistas

parent 290c7207
import 'dart:io'; import 'dart:io';
import 'package:etramite_flutter/clases/SharedPref.dart';
import '../data/SharedPref.dart';
class ConectionApi { class ConectionApi {
List<Cookie> cookies = []; List<Cookie> cookies = [];
......
import 'dart:io'; import 'dart:io';
import 'package:dio/adapter.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:etramite_flutter/clases/ConectionApi.dart';
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
import 'package:cookie_jar/cookie_jar.dart'; import 'package:cookie_jar/cookie_jar.dart';
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
import 'ConectionApi.dart';
class ApiService { class Api {
String apiUrl = "https://tramites.una.py/etramite-backend/"; String apiUrl = "https://tramites.una.py/etramite-backend/";
ConectionApi conection = ConectionApi(); ConectionApi conection = ConectionApi();
......
import 'package:ealu_flutter/core/api.dart';
import 'package:ealu_flutter/data/models/LoginModel.dart';
class LoginRemote {
Api api;
LoginRemote(this.api);
Future<LoginModel> requestloginUser(dynamic params, dynamic body) async {
var response = await api.post('', params, body);
if (response != null) {
return LoginModelFromJson(response.data);
} else {}
}
}
import 'dart:convert';
import '../../domain/entities/login.dart';
import 'UserModel.dart';
LoginModel LoginModelFromJson(String str) =>
LoginModel.fromJson(json.decode(str));
String LoginModelToJson(LoginModel data) => json.encode(data.toJson());
class LoginModel extends Login {
bool logged;
dynamic csrf;
UserModel user;
List<String> permissionList;
dynamic msg;
String appVersion;
dynamic error;
LoginModel({
required this.logged,
this.csrf,
required this.user,
required this.permissionList,
this.msg,
required this.appVersion,
this.error,
}) : super(
logged: logged,
csrf: csrf,
user: user,
permissionList: permissionList,
msg: msg,
appVersion: appVersion,
);
factory LoginModel.fromJson(Map<String, dynamic> json) => LoginModel(
logged: json["logged"],
csrf: json["csrf"],
user: UserModel.fromJson(json["user"]),
permissionList: List<String>.from(json["permissionList"].map((x) => x)),
msg: json["msg"],
appVersion: json["appVersion"],
error: json["error"],
);
Map<String, dynamic> toJson() => {
"logged": logged,
"csrf": csrf,
"user": user.toJson(),
"permissionList": List<dynamic>.from(permissionList.map((x) => x)),
"msg": msg,
"appVersion": appVersion,
"error": error,
};
}
import '../../domain/entities/user.dart';
class UserModel extends User {
int id;
String username;
String name;
String surname;
dynamic image;
String nameAndSurname;
UserModel({
required this.id,
required this.username,
required this.name,
required this.surname,
this.image,
required this.nameAndSurname,
}) : super(
id: id,
username: username,
name: name,
surname: surname,
nameAndSurname: nameAndSurname,
);
factory UserModel.fromJson(Map<String, dynamic> json) => UserModel(
id: json["id"],
username: json["username"],
name: json["name"],
surname: json["surname"],
image: json["image"],
nameAndSurname: json["nameAndSurname"],
);
Map<String, dynamic> toJson() => {
"id": id,
"username": username,
"name": name,
"surname": surname,
"image": image,
"nameAndSurname": nameAndSurname,
};
}
import 'dart:convert'; import 'package:equatable/equatable.dart';
import 'user.dart'; import 'user.dart';
Login loginFromJson(String str) => Login.fromJson(json.decode(str)); class Login extends Equatable {
String loginToJson(Login data) => json.encode(data.toJson());
class Login {
Login({ Login({
required this.logged, required this.logged,
this.csrf, this.csrf,
...@@ -25,23 +21,6 @@ class Login { ...@@ -25,23 +21,6 @@ class Login {
String appVersion; String appVersion;
dynamic error; dynamic error;
factory Login.fromJson(Map<String, dynamic> json) => Login( @override
logged: json["logged"], List<Object?> get props => [logged, permissionList, msg, user];
csrf: json["csrf"],
user: User.fromJson(json["user"]),
permissionList: List<String>.from(json["permissionList"].map((x) => x)),
msg: json["msg"],
appVersion: json["appVersion"],
error: json["error"],
);
Map<String, dynamic> toJson() => {
"logged": logged,
"csrf": csrf,
"user": user.toJson(),
"permissionList": List<dynamic>.from(permissionList.map((x) => x)),
"msg": msg,
"appVersion": appVersion,
"error": error,
};
} }
class User { import 'package:equatable/equatable.dart';
class User extends Equatable {
User({ User({
required this.id, required this.id,
required this.username, required this.username,
...@@ -15,21 +17,6 @@ class User { ...@@ -15,21 +17,6 @@ class User {
dynamic image; dynamic image;
String nameAndSurname; String nameAndSurname;
factory User.fromJson(Map<String, dynamic> json) => User( @override
id: json["id"], List<Object> get props => [id, username, name];
username: json["username"],
name: json["name"],
surname: json["surname"],
image: json["image"],
nameAndSurname: json["nameAndSurname"],
);
Map<String, dynamic> toJson() => {
"id": id,
"username": username,
"name": name,
"surname": surname,
"image": image,
"nameAndSurname": nameAndSurname,
};
} }
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../core/customStyles.dart'; import '../../core/customStyles.dart';
Widget textInput(BuildContext context, dynamic titulo, dynamic cuerpo, Widget textInput(BuildContext context, dynamic titulo, dynamic cuerpo,
bool negrita, bool dense) { bool negrita, bool dense) {
......
...@@ -49,6 +49,14 @@ packages: ...@@ -49,6 +49,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.17.0" version: "1.17.0"
cookie_jar:
dependency: "direct main"
description:
name: cookie_jar
sha256: "253920541bf248e4eda6eac5df6aa00c19c183e1fe333629925d8df666a27815"
url: "https://pub.dev"
source: hosted
version: "4.0.1"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
...@@ -57,6 +65,38 @@ packages: ...@@ -57,6 +65,38 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.5" version: "1.0.5"
dartz:
dependency: "direct main"
description:
name: dartz
sha256: e6acf34ad2e31b1eb00948692468c30ab48ac8250e0f0df661e29f12dd252168
url: "https://pub.dev"
source: hosted
version: "0.10.1"
dio:
dependency: "direct main"
description:
name: dio
sha256: "0894a098594263fe1caaba3520e3016d8a855caeb010a882273189cca10f11e9"
url: "https://pub.dev"
source: hosted
version: "5.1.1"
dio_cookie_manager:
dependency: "direct main"
description:
name: dio_cookie_manager
sha256: ff1755fd56d02485146d95a589fb4ace1f0ae0c0f3ca702a817de2dc1fbb835e
url: "https://pub.dev"
source: hosted
version: "3.0.0"
equatable:
dependency: "direct main"
description:
name: equatable
sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2
url: "https://pub.dev"
source: hosted
version: "2.0.5"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
...@@ -112,6 +152,14 @@ packages: ...@@ -112,6 +152,14 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
http_parser:
dependency: transitive
description:
name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
intl: intl:
dependency: "direct main" dependency: "direct main"
description: description:
......
...@@ -39,6 +39,11 @@ dependencies: ...@@ -39,6 +39,11 @@ dependencies:
intl: ^0.18.0 intl: ^0.18.0
sizer: ^2.0.15 sizer: ^2.0.15
shared_preferences: ^2.1.0 shared_preferences: ^2.1.0
dartz: ^0.10.1
equatable: ^2.0.5
cookie_jar: ^4.0.1
dio: ^5.1.1
dio_cookie_manager: ^3.0.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment