Commit 973e0d79 by Mobile : Jetrin Phuekkaew (N'new)

Merge branch 'develop' of https://gitlab.2fellows.com/art/feelver into develop

# Conflicts:
#	lib/service/api.dart
parents ddd22785 02b8f551
import 'package:feelverapp/ui/booking/booking_detail.dart';
import 'package:feelverapp/ui/home/home.dart';
import 'package:feelverapp/ui/login/login.dart';
import 'package:feelverapp/ui/my_reviews/my_reviews_page.dart';
import 'package:feelverapp/ui/shop/shop_main.dart';
......
class categoryModel {
List<DATA> dATA;
categoryModel({this.dATA});
categoryModel.fromJson(Map<String, dynamic> json) {
if (json['DATA'] != null) {
dATA = new List<DATA>();
json['DATA'].forEach((v) {
dATA.add(new DATA.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.dATA != null) {
data['DATA'] = this.dATA.map((v) => v.toJson()).toList();
}
return data;
}
}
class DATA {
int id;
int parentId;
String name;
String code;
String displayName;
String cover;
String detail;
Null type;
String status;
int sortOrder;
Null storeId;
Null vendorId;
Null createdAt;
String updatedAt;
String visibility;
DATA(
{this.id,
this.parentId,
this.name,
this.code,
this.displayName,
this.cover,
this.detail,
this.type,
this.status,
this.sortOrder,
this.storeId,
this.vendorId,
this.createdAt,
this.updatedAt,
this.visibility});
DATA.fromJson(Map<String, dynamic> json) {
id = json['id'];
parentId = json['parent_id'];
name = json['name'];
code = json['code'];
displayName = json['display_name'];
cover = json['cover'];
detail = json['detail'];
type = json['type'];
status = json['status'];
sortOrder = json['sort_order'];
storeId = json['store_id'];
vendorId = json['vendor_id'];
createdAt = json['created_at'];
updatedAt = json['updated_at'];
visibility = json['visibility'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['parent_id'] = this.parentId;
data['name'] = this.name;
data['code'] = this.code;
data['display_name'] = this.displayName;
data['cover'] = this.cover;
data['detail'] = this.detail;
data['type'] = this.type;
data['status'] = this.status;
data['sort_order'] = this.sortOrder;
data['store_id'] = this.storeId;
data['vendor_id'] = this.vendorId;
data['created_at'] = this.createdAt;
data['updated_at'] = this.updatedAt;
data['visibility'] = this.visibility;
return data;
}
}
\ No newline at end of file
class HomeModel {
int id;
String parentId;
String name;
String code;
String displayName;
String cover;
String detail;
String type;
String status;
int sortOrder;
String storeId;
String vendorId;
String createdAt;
String updatedAt;
String visibility;
HomeModel(
{this.id,
this.parentId,
this.name,
this.code,
this.displayName,
this.cover,
this.detail,
this.type,
this.status,
this.sortOrder,
this.storeId,
this.vendorId,
this.createdAt,
this.updatedAt,
this.visibility});
HomeModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
parentId = json['parent_id'];
name = json['name'];
code = json['code'];
displayName = json['display_name'];
cover = json['cover'];
detail = json['detail'];
type = json['type'];
status = json['status'];
sortOrder = json['sort_order'];
storeId = json['store_id'];
vendorId = json['vendor_id'];
createdAt = json['created_at'];
updatedAt = json['updated_at'];
visibility = json['visibility'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['parent_id'] = this.parentId;
data['name'] = this.name;
data['code'] = this.code;
data['display_name'] = this.displayName;
data['cover'] = this.cover;
data['detail'] = this.detail;
data['type'] = this.type;
data['status'] = this.status;
data['sort_order'] = this.sortOrder;
data['store_id'] = this.storeId;
data['vendor_id'] = this.vendorId;
data['created_at'] = this.createdAt;
data['updated_at'] = this.updatedAt;
data['visibility'] = this.visibility;
return data;
}
}
\ No newline at end of file
......@@ -2,21 +2,23 @@ import 'dart:convert';
import 'package:feelverapp/model/Login/login_model.dart';
import 'package:feelverapp/model/base/base.dart';
import 'package:feelverapp/model/forgetpassword/forgetpassModel.dart';
import 'package:feelverapp/model/register/register_model.dart';
import 'package:http/http.dart' as http;
import 'package:feelverapp/model/forgetpassword/forgetpassModel.dart';
class Api<T>{
import 'package:feelverapp/model/home/home_model.dart';
import 'package:feelverapp/model/register/register_model.dart';
import 'package:feelverapp/model/category/category_model.dart';
import 'package:http/http.dart' as http;
class Api<T> {
final String _baseApi = "https://backend-uat.feelver.com/api";
final _headerApi = {
"Authorization": "Bearer {{ token }}",
"Authorization":
"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvYmFja2VuZC11YXQuZmVlbHZlci5jb21cL2FwaVwvbG9naW4iLCJpYXQiOjE1OTQ5NzIzMjYsImV4cCI6MTYwMjE3MjMyNiwibmJmIjoxNTk0OTcyMzI2LCJqdGkiOiJsM1BldUJVcTdDNldSbzVGIiwic3ViIjo1LCJwcnYiOiI4N2UwYWYxZWY5ZmQxNTgxMmZkZWM5NzE1M2ExNGUwYjA0NzU0NmFhIn0.fwFqcbzG2T_ZHtIcGF13Ek7nIxxwbnaE9ZXGomo-nzY",
};
Future<Response<T>> forgetPassword(Object body) async {
var _model;
......@@ -41,17 +43,17 @@ Future<Response<T>> forgetPassword(Object body) async {
Future<Response<T>> login(Object body) async {
var _model;
var _fail;
var result;
// (body as Map)['lang'] = allTranslations.currentLanguage;
await _httpConnection(
"${this._baseApi}/login", this._headerApi, body)
await _httpConnection("${this._baseApi}/login", this._headerApi, body)
.then((response) {
print("ผลลัพ เท่ากับบบบ "+"${response.body}");
if (response.statusCode == 200 ) {
print("ผลลัพ เท่ากับบบบ " + "${response.body}");
if (response.statusCode == 200) {
_model = LoginModel.fromJson(json.decode(response.body));
} else {
_fail = FailModel.fromJson(json.decode(response.body));
......@@ -61,18 +63,16 @@ Future<Response<T>> forgetPassword(Object body) async {
return result;
}
Future<Response<T>> register(Object body) async {
Future<Response<T>> register(Object body) async {
var _model;
var _fail;
var result;
// (body as Map)['lang'] = allTranslations.currentLanguage;
await _httpConnection(
"${this._baseApi}/register", this._headerApi, body)
await _httpConnection("${this._baseApi}/register", this._headerApi, body)
.then((response) {
print("ผลลัพ เท่ากับบบบ "+"${response.body}");
if (response.statusCode == 200 ) {
print("ผลลัพ เท่ากับบบบ " + "${response.body}");
if (response.statusCode == 200) {
_model = RegisterModel.fromJson(json.decode(response.body));
} else {
_fail = FailModel.fromJson(json.decode(response.body));
......@@ -82,19 +82,37 @@ Future<Response<T>> register(Object body) async {
return result;
}
Future<Response<T>> category(Object body) async {
var _model;
var _fail;
var result;
await _httpConnection("${this._baseApi}/category", this._headerApi, body)
.then((response) {
print("ผลลัพท์ เท่ากับ " "${response.body}");
if (response.statusCode == 200){
print('testtt');
_model = categoryModel.fromJson(json.decode(response.body));
} else {
_fail = FailModel.fromJson(json.decode(response.body));
}
result = new Response<T>(_model, _fail);
});
return result;
}
///api environment
Future<http.Response> _httpConnection(
String url, Map<String, String> headers, Object body) async {
if (body != null) {
final response = headers != null
? http.post(Uri.encodeFull(url), headers: headers, body: body)
: http.post(Uri.encodeFull(url), body: body);
return response;
} else {
final response = headers != null
? http.get(Uri.encodeFull(url), headers: headers)
: http.get(Uri.encodeFull(url));
......@@ -102,8 +120,6 @@ Future<Response<T>> register(Object body) async {
}
}
dynamic _jsonDecode(String json) {
var resJson = jsonDecode(json);
return resJson;
......@@ -113,6 +129,6 @@ Future<Response<T>> register(Object body) async {
class Response<T> {
T success;
FailModel fail;
Response(this.success, this.fail);
}
import 'package:feelverapp/ui/home/home_presenter.dart';
import 'package:feelverapp/ui/login/login.dart';
import 'package:feelverapp/ui/menu/menu.dart';
import 'package:feelverapp/ui/nearme/near_me_list.dart';
......@@ -16,9 +17,13 @@ class HomePage extends StatefulWidget {
class _HomePageState extends State<HomePage> {
class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
HomePresenter presenter;
@override
void initState() {
presenter = HomePresenter(this);
presenter.Listitem();
......@@ -27,6 +32,7 @@ class _HomePageState extends State<HomePage> {
@override
void dispose() {
super.dispose();
}
......
import 'package:feelverapp/model/category/category_model.dart';
import 'package:feelverapp/model/home/home_model.dart';
import 'package:feelverapp/service/api.dart';
import 'package:feelverapp/service/base_presenter.dart';
import 'package:feelverapp/ui/home/home.dart';
import 'package:flutter/material.dart';
class HomePresenter extends BasePresenter<HomePage>{
Api _api;
final formkey = GlobalKey<FormState>();
HomePresenter(State<HomePage> state) : super(state);
Listitem() async{
_api = Api<categoryModel>();
var res = await _api.category({
"access_type":"portal"
});
if (res.fail == null) {
print('res Success');
}else{
print('res Fail');
}
}
}
\ No newline at end of file
......@@ -7,42 +7,42 @@ packages:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.2"
version: "1.6.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
version: "2.4.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
version: "2.0.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
version: "1.1.3"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
version: "1.14.12"
convert:
dependency: transitive
description:
......@@ -56,7 +56,7 @@ packages:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
version: "2.1.4"
cupertino_icons:
dependency: "direct main"
description:
......@@ -113,7 +113,7 @@ packages:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
version: "2.1.12"
intl:
dependency: transitive
description:
......@@ -204,7 +204,7 @@ packages:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
version: "2.1.3"
rflutter_alert:
dependency: "direct main"
description:
......@@ -258,7 +258,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.5"
version: "1.7.0"
stack_trace:
dependency: transitive
description:
......@@ -293,7 +293,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.11"
version: "0.2.15"
typed_data:
dependency: transitive
description:
......@@ -321,7 +321,7 @@ packages:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.5.0"
version: "3.6.1"
sdks:
dart: ">=2.6.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"
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