Commit ff1456fd by Mobile : Jetrin Phuekkaew (N'new)

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

# Conflicts:
#	lib/main.dart
parents 4b7adf32 620031b6
...@@ -4,6 +4,7 @@ import 'package:feelverapp/ui/booking/booking_detail.dart'; ...@@ -4,6 +4,7 @@ import 'package:feelverapp/ui/booking/booking_detail.dart';
import 'package:feelverapp/ui/home/home.dart'; import 'package:feelverapp/ui/home/home.dart';
import 'package:feelverapp/ui/login/login.dart'; import 'package:feelverapp/ui/login/login.dart';
import 'package:feelverapp/ui/my_reviews/my_reviews_page.dart'; import 'package:feelverapp/ui/my_reviews/my_reviews_page.dart';
import 'package:feelverapp/ui/shop/shop_list.dart';
import 'package:feelverapp/ui/shop/shop_main.dart'; import 'package:feelverapp/ui/shop/shop_main.dart';
import 'package:feelverapp/ui/splashscreen/splash_screen_page.dart'; import 'package:feelverapp/ui/splashscreen/splash_screen_page.dart';
...@@ -25,7 +26,8 @@ class MyApp extends StatelessWidget { ...@@ -25,7 +26,8 @@ class MyApp extends StatelessWidget {
), ),
// home: SplashScreenPage(), // home: SplashScreenPage(),
home: EditProfile(),
home: ShopList(),
); );
} }
......
class shoplistModel {
List<DATA> dATA;
shoplistModel({this.dATA});
shoplistModel.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;
String storeCode;
String storeName;
String storeCover;
String displayCover;
String isActive;
int storeOrder;
int customerGroupId;
int vendorId;
dynamic createdAt;
dynamic updatedAt;
String location;
String email;
String phone;
String mobile;
String address;
String city;
String country;
String zipCode;
String website;
String allowRoute;
dynamic excerpt;
dynamic detail;
dynamic storeLogo;
dynamic isFacilities;
String distanceWithLocation;
int star;
dynamic ratings;
DATA(
{this.id,
this.storeCode,
this.storeName,
this.storeCover,
this.displayCover,
this.isActive,
this.storeOrder,
this.customerGroupId,
this.vendorId,
this.createdAt,
this.updatedAt,
this.location,
this.email,
this.phone,
this.mobile,
this.address,
this.city,
this.country,
this.zipCode,
this.website,
this.allowRoute,
this.excerpt,
this.detail,
this.storeLogo,
this.isFacilities,
this.distanceWithLocation,
this.star,
this.ratings});
DATA.fromJson(Map<String, dynamic> json) {
id = json['id'];
storeCode = json['store_code'];
storeName = json['store_name'];
storeCover = json['store_cover'];
displayCover = json['display_cover'];
isActive = json['is_active'];
storeOrder = json['store_order'];
customerGroupId = json['customer_group_id'];
vendorId = json['vendor_id'];
createdAt = json['created_at'];
updatedAt = json['updated_at'];
location = json['location'];
email = json['email'];
phone = json['phone'];
mobile = json['mobile'];
address = json['address'];
city = json['city'];
country = json['country'];
zipCode = json['zip_code'];
website = json['website'];
allowRoute = json['allow_route'];
excerpt = json['excerpt'];
detail = json['detail'];
storeLogo = json['store_logo'];
isFacilities = json['is_facilities'];
distanceWithLocation = json['distance_with_location'];
star = json['star'];
ratings = json['ratings'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['store_code'] = this.storeCode;
data['store_name'] = this.storeName;
data['store_cover'] = this.storeCover;
data['display_cover'] = this.displayCover;
data['is_active'] = this.isActive;
data['store_order'] = this.storeOrder;
data['customer_group_id'] = this.customerGroupId;
data['vendor_id'] = this.vendorId;
data['created_at'] = this.createdAt;
data['updated_at'] = this.updatedAt;
data['location'] = this.location;
data['email'] = this.email;
data['phone'] = this.phone;
data['mobile'] = this.mobile;
data['address'] = this.address;
data['city'] = this.city;
data['country'] = this.country;
data['zip_code'] = this.zipCode;
data['website'] = this.website;
data['allow_route'] = this.allowRoute;
data['excerpt'] = this.excerpt;
data['detail'] = this.detail;
data['store_logo'] = this.storeLogo;
data['is_facilities'] = this.isFacilities;
data['distance_with_location'] = this.distanceWithLocation;
data['star'] = this.star;
data['ratings'] = this.ratings;
return data;
}
}
\ No newline at end of file
...@@ -11,6 +11,7 @@ import 'package:feelverapp/model/home/home_model.dart'; ...@@ -11,6 +11,7 @@ import 'package:feelverapp/model/home/home_model.dart';
import 'package:feelverapp/model/register/register_model.dart'; import 'package:feelverapp/model/register/register_model.dart';
import 'package:feelverapp/model/category/category_model.dart'; import 'package:feelverapp/model/category/category_model.dart';
import 'package:feelverapp/model/shoplist/shoplist_Model.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
class Api<T> { class Api<T> {
...@@ -122,6 +123,28 @@ class Api<T> { ...@@ -122,6 +123,28 @@ class Api<T> {
} }
Future<Response<T>> shoplist(Object body) async{
var _model;
var _fail;
var result;
await _httpConnection("${this._baseApi}/store", this._headerApi, body).then((response){
print("ผลลัพท์ เท่ากับ " "${response.body}");
if(response.statusCode == 200){
// Array to Map Json
Map<String, dynamic> myData = arrayToJson(response.body);
print(myData);
_model = shoplistModel.fromJson(myData);
}else{
_fail = FailModel.fromJson(json.decode(response.body));
}
result = new Response<T>(_model, _fail);
});
return result;
}
///api environment ///api environment
Future<http.Response> _httpConnection( Future<http.Response> _httpConnection(
String url, Map<String, String> headers, Object body) async { String url, Map<String, String> headers, Object body) async {
......
...@@ -13,7 +13,9 @@ class HomePresenter extends BasePresenter<HomePage> { ...@@ -13,7 +13,9 @@ class HomePresenter extends BasePresenter<HomePage> {
Listitem() async { Listitem() async {
_api = Api<categoryModel>(); _api = Api<categoryModel>();
var res = await _api.category({"access_type": "portal"}); var res = await _api.category({
"access_type": "portal",
});
if (res.fail == null) { if (res.fail == null) {
print('res Success'); print('res Success');
} else { } else {
......
import 'package:feelverapp/ui/home/home.dart'; import 'package:feelverapp/ui/home/home.dart';
import 'package:feelverapp/ui/menu/menu.dart'; import 'package:feelverapp/ui/menu/menu.dart';
import 'package:feelverapp/ui/shop/shop_list_detail.dart'; import 'package:feelverapp/ui/shop/shop_list_detail.dart';
import 'package:feelverapp/ui/shop/shoplist_presenter.dart';
import 'package:feelverapp/util/SizeConfig.dart'; import 'package:feelverapp/util/SizeConfig.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ShopList extends StatefulWidget { class ShopList extends StatefulWidget {
@override @override
_ShopListState createState() => _ShopListState(); _ShopListState createState() => _ShopListState();
} }
class _ShopListState extends State<ShopList> { class _ShopListState extends State<ShopList> with TickerProviderStateMixin {
var entries = new List<String>.generate(2, (i) => "Item $i");
ShoplistPresenter presenter;
@override
void initState() {
presenter = ShoplistPresenter(this);
presenter.Listitem();
}
@override
void dispose() {
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
SizeConfig(context); SizeConfig(context);
...@@ -249,11 +265,30 @@ class _ShopListState extends State<ShopList> { ...@@ -249,11 +265,30 @@ class _ShopListState extends State<ShopList> {
bottom: SizeConfig.getPadding(10), bottom: SizeConfig.getPadding(10),
), ),
child: ListView.builder( child: ListView.builder(
itemCount: entries.length, itemCount: entries.length + 1,
itemBuilder: (context, i) { itemBuilder: (context, i) {
return _shopItem(entries[i]); final widgetItem = (i == entries.length);
}, new RaisedButton(
child: new Text(
'Load more ...',
style: new TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
), ),
onPressed: () {
var nextItems = new List<String>.generate(2, (i) {
var itemId = i + entries.length;
return "Item $itemId";
});
setState(() {
entries.addAll(nextItems);
});
});
return _shopItem(entries[i]);
}),
), ),
); );
} }
......
import 'package:feelverapp/model/shoplist/shoplist_Model.dart';
import 'package:feelverapp/service/api.dart';
import 'package:feelverapp/service/base_presenter.dart';
import 'package:feelverapp/ui/shop/shop_list.dart';
import 'package:flutter/material.dart';
class ShoplistPresenter extends BasePresenter<ShopList>{
Api _api;
final formkey = GlobalKey<FormState>();
ShoplistPresenter(State<ShopList> state) : super(state);
Listitem() async {
_api = Api<shoplistModel>();
var res = await _api.shoplist({
"sort": "asc",
"lang": "en_US",
"limit": "8",
});
if (res.fail == null) {
print('res Success');
} else {
print('res Fail');
}
}
}
\ No newline at end of file
...@@ -128,6 +128,13 @@ packages: ...@@ -128,6 +128,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.1" version: "3.0.1"
loadmore:
dependency: "direct main"
description:
name: loadmore
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
......
...@@ -28,6 +28,7 @@ dependencies: ...@@ -28,6 +28,7 @@ dependencies:
json_annotation: ^3.0.1 json_annotation: ^3.0.1
rflutter_alert: ^1.0.3 rflutter_alert: ^1.0.3
shared_preferences: ^0.5.6+1 shared_preferences: ^0.5.6+1
loadmore: ^1.0.4
dev_dependencies: dev_dependencies:
......
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