update home and search

parent ac07dd74
65bf9efbfad64e1b5e4b50eeaed8247f
\ No newline at end of file
be0f81c896162f43cdffd3c7f9c50177
\ No newline at end of file
......@@ -44,4 +44,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
COCOAPODS: 1.10.0.beta.1
COCOAPODS: 1.9.1
......@@ -33,7 +33,7 @@ class MyApp extends StatelessWidget {
home: MainShop()
home: SplashScreenPage()
//home: EditProfile(),
......
class categoryModel {
List<DATA> dATA;
class CategoryModel {
List<Result> result;
categoryModel({this.dATA});
CategoryModel({this.result});
categoryModel.fromJson(Map<String, dynamic> json) {
if (json['DATA'] != null) {
dATA = new List<DATA>();
json['DATA'].forEach((v) {
dATA.add(new DATA.fromJson(v));
CategoryModel.fromJson(Map<String, dynamic> json) {
if (json['result'] != null) {
result = new List<Result>();
json['result'].forEach((v) {
result.add(new Result.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();
if (this.result != null) {
data['result'] = this.result.map((v) => v.toJson()).toList();
}
return data;
}
}
class DATA {
class Result {
int id;
int parentId;
String name;
......@@ -29,16 +29,16 @@ class DATA {
String displayName;
String cover;
String detail;
dynamic type;
Null type;
String status;
int sortOrder;
dynamic storeId;
dynamic vendorId;
dynamic createdAt;
Null storeId;
Null vendorId;
Null createdAt;
String updatedAt;
String visibility;
DATA(
Result(
{this.id,
this.parentId,
this.name,
......@@ -55,7 +55,7 @@ class DATA {
this.updatedAt,
this.visibility});
DATA.fromJson(Map<String, dynamic> json) {
Result.fromJson(Map<String, dynamic> json) {
id = json['id'];
parentId = json['parent_id'];
name = json['name'];
......
......@@ -220,21 +220,18 @@ class Api<T> {
return result;
}
Future<Response<T>> category(Object body) async {
Future<Response<T>> category(Object body) async {
var _model;
var _fail;
var result;
print("Result test ");
// (body as Map)['lang'] = allTranslations.currentLanguage;
await _httpConnection("${this._baseApi}/category", this._headerApi, body)
.then((response) {
print("ผลลัพท์ เท่ากับ " "${response.body}");
print("ผลลัพ เท่ากับบบบ " + "${response.body}");
if (response.statusCode == 200) {
// Array to Map Json
Map<String, dynamic> myData = arrayToJson(response.body);
_model = categoryModel.fromJson(myData);
print('myModel ' + _model);
_model = CategoryModel.fromJson(json.decode(response.body));
} else {
_fail = FailModel.fromJson(json.decode(response.body));
}
......@@ -243,6 +240,10 @@ class Api<T> {
return result;
}
Future<Response<T>> shoplist(Object body) async {
var _model;
var _fail;
......
......@@ -11,10 +11,9 @@ class BookingDetail extends StatefulWidget {
class _BookingDetailState extends State<BookingDetail> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: _setupView(),
);
return ListView(padding: EdgeInsets.all(0), children: <Widget>[
_setupView(),
]);
}
_setupView() {
......
import 'package:feelverapp/model/category/category_model.dart';
import 'package:feelverapp/service/Loading.dart';
import 'package:feelverapp/service/api.dart';
import 'package:feelverapp/ui/home/home_presenter.dart';
import 'package:feelverapp/ui/login/login.dart';
import 'package:feelverapp/ui/menu/menu.dart';
......@@ -24,7 +26,7 @@ class HomePage extends StatefulWidget {
}
class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
bool search=false;
TabController _tabController;
HomePresenter presenter;
......@@ -53,7 +55,9 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
@override
Widget build(BuildContext context) {
SizeConfig(context);
return Scaffold(
return
Scaffold(
body: _setupView(),
bottomNavigationBar: Container(
color: Color.fromRGBO(69, 85, 79, 1),
......@@ -186,7 +190,8 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
}
_setupView() {
return Column(
return Column(
children: <Widget>[
Stack(
children: <Widget>[
......@@ -264,13 +269,48 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
),
),
),
Positioned(
top: SizeConfig.getPadding(77),
right: SizeConfig.getPadding(20),
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => LoginPage()),
);
},
child: presenter.getmodel == null
? Container()
: Container(
child: ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(SizeConfig.getWidth(56))),
child: Image.network(
presenter.getmodel.result[0].image,
fit: BoxFit.contain,
width: SizeConfig.getWidth(30),
height: SizeConfig.getWidth(30),
),
),
),
),
),
_searchField(),
],
),
Expanded(
),SizedBox(height: 20,),
presenter.CatModel==null? Container(
child: CircularProgressIndicator(
valueColor: new AlwaysStoppedAnimation<Color>(Color.fromRGBO(69, 85, 79, 1),),
),
): search?_getlist():Expanded(
child: Container(
child: presenter.CatModel == null ? Container() : ListView.builder(
itemCount: presenter.CatModel.dATA[0].name.length,
child: ListView.builder(
itemCount: presenter.CatModel.result.length,
itemBuilder: (context, i) {
return list(i);
}),
......@@ -283,12 +323,12 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
list(int index) {
return Container(
padding: EdgeInsets.only(
top: SizeConfig.getPadding(16),
left: SizeConfig.getPadding(16),
right: SizeConfig.getPadding(16),
bottom: SizeConfig.getPadding(10),
),
//color: Colors.orange,
// padding: EdgeInsets.only(
// // top: SizeConfig.getPadding(16),
// // bottom: SizeConfig.getPadding(10),
// ),
child: Column(
children: <Widget>[
_listItem(
......@@ -300,12 +340,12 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
fit: BoxFit.fill,
)
: Image.network(
presenter.CatModel.dATA[index].cover,
height: SizeConfig.getWidth(130),
presenter.CatModel.result[index].cover,
height: SizeConfig.getHeight(130),
width: MediaQuery.of(context).size.width,
fit: BoxFit.cover,
),
presenter.CatModel.dATA[index].name,
presenter.CatModel.result[index].name,
'',
ShopList(),
),
......@@ -317,19 +357,167 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
);
}
Widget _shopItem(String title, String image, String address, String detail) {
return Card(
child: Column(
children: <Widget>[
Container(
height: SizeConfig.getHeight(270),
child: Stack(
children: <Widget>[
presenter.searchhomeModel == null
? Image.network(
'https://image.freepik.com/free-photo/girl-massage-spa-salon_110955-422.jpg',
height: SizeConfig.getWidth(180),
width: MediaQuery.of(context).size.width,
fit: BoxFit.cover,
)
: Image.network(
"https://backend-uat.feelver.com/storage/"+ image,
height: SizeConfig.getWidth(180),
width: MediaQuery.of(context).size.width,
fit: BoxFit.cover,
),
Positioned(
right: SizeConfig.getPadding(16),
top: SizeConfig.getPadding(16),
child: ImageIcon(
AssetImage('assets/images/ic_fav_list.png'),
color: Colors.white,
size: SizeConfig.getFontSize(30),
),
),
Positioned(
left: SizeConfig.getPadding(16),
top: SizeConfig.getPadding(165),
child: Image.asset(
'assets/images/pin_list.png',
width: SizeConfig.getWidth(50),
height: SizeConfig.getWidth(50),
),
),
Positioned(
left: SizeConfig.getPadding(75),
top: SizeConfig.getPadding(190),
child: Text(
title,
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black,
fontSize: SizeConfig.getFontSize(11),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w700),
),
),
Positioned(
left: SizeConfig.getPadding(280),
top: SizeConfig.getPadding(190),
child:Icon(Icons.star,color: Colors.orangeAccent,size: SizeConfig.getFontSize(18),),
),
Positioned(
left: SizeConfig.getPadding(300),
top: SizeConfig.getPadding(190),
child: Text(
"4.9",
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black,
fontSize: SizeConfig.getFontSize(12),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w700),
),
),
],
),
),
Container(
padding: EdgeInsets.only(
bottom:SizeConfig.getPadding(14),
left: SizeConfig.getPadding(24),
right: SizeConfig.getPadding(24)),
alignment: Alignment.topLeft,
child: presenter.searchhomeModel == null
? Text(
"",
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.grey,
fontSize: SizeConfig.getFontSize(12),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w500),
)
: Text(
address,
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.grey,
fontSize: SizeConfig.getFontSize(10),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w500),
),
),
SizedBox(height: 10,)
],
),
);
}
_getlist() {
return Expanded(
child: Container(
padding: EdgeInsets.only(
top: SizeConfig.getPadding(16),
left: SizeConfig.getPadding(16),
right: SizeConfig.getPadding(16),
bottom: SizeConfig.getPadding(10),
),
child: presenter.searchhomeModel == null
? Container()
: ListView.builder(
itemCount: presenter.searchhomeModel.thTH[0].storeCode.length,
itemBuilder: (context, i) {
// new RaisedButton(
// child: new Text(
// 'Load more ...',
// style: new TextStyle(
// color: Colors.black,
// fontWeight: FontWeight.bold,
// ),
// ),
// onPressed: () {
// var nextItems = new List<String>.generate(2, (i) {
// var itemId = i + presenter.shopModel.dATA[i].storeName.length;
// return "Item $itemId";
// });
// setState(() {
// entries.addAll(nextItems);
// });
// });
return _shopItem(
presenter.searchhomeModel.thTH[i].storeName,
presenter.searchhomeModel.thTH[i].storeCover,
presenter.searchhomeModel.thTH[i].address,
presenter.searchhomeModel.thTH[i].detail == null ? "" : presenter.searchhomeModel.thTH[i].detail,);
}),
),
);
}
Widget _listItem(Image img, String title, String view, Widget page) {
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => page,
),
);
presenter.getSearch();
setState(() {
search=true;
});
},
child: Container(
margin: EdgeInsets.all(
SizeConfig.getPadding(24),
margin: EdgeInsets.only(
bottom: 8,
left: SizeConfig.getPadding(15),
right: SizeConfig.getPadding(15),
),
width: MediaQuery.of(context).size.width,
child: Stack(
......@@ -338,6 +526,17 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
width: MediaQuery.of(context).size.width,
child: img,
),
Container(
margin: const EdgeInsets.only(top: 10.0,left: 14),
height: SizeConfig.getHeight(110),
width:SizeConfig.getWidth(320),
decoration: BoxDecoration(
color: Colors.transparent,//remove color to make it transpatent
border: Border.all(
style: BorderStyle.solid,
width: 2,
color: Colors.white)),
),
Container(
alignment: Alignment.center,
padding: EdgeInsets.only(
......@@ -388,10 +587,22 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
const Radius.circular(30.0),
),
),
suffixIcon: IconButton(
onPressed: () {
presenter.searchCtrl.clear();
},
icon: Icon(Icons.clear, color: presenter.searchCtrl==null?Colors.transparent:Colors.black)),
prefixIcon: IconButton(
onPressed: () {
presenter.getSearch();
setState(() {
search=true;
print(search);
});
presenter.getSearch();
},
icon: Icon(Icons.search, color: Colors.grey)),
filled: true,
hintText: 'ค้นหาแบบละเอียด',
......
......@@ -21,7 +21,7 @@ class HomePresenter extends BasePresenter<HomePage> {
GetprofileModel getmodel;
LoginModel logmodel;
categoryModel CatModel;
CategoryModel CatModel;
TextEditingController searchCtrl = TextEditingController();
SearchhomeModel searchhomeModel;
......@@ -29,19 +29,21 @@ class HomePresenter extends BasePresenter<HomePage> {
HomePresenter(State<HomePage> state) : super(state);
Listitem() async {
_api = Api<categoryModel>();
_api = Api<CategoryModel>();
var res = await _api.category({
"access_type": "portal",
"access_type": "mobile",
});
if (res.fail == null){
// LoadingView(state.context).hide();
if (res.success != null){
setState(() {
CatModel = res.success;
print("dddddddddddddddd");
print('${CatModel.dATA[0].name}');
});
} else {
......@@ -50,21 +52,23 @@ class HomePresenter extends BasePresenter<HomePage> {
}
getSearch() async{
LoadingView(state.context).show();
_api = Api<SearchhomeModel>();
var res = await _api.homesearch({
"keyword_shop" : searchCtrl.text,
"lang" : "all",
"access" : "portal",
});
LoadingView(state.context).hide();
print('$searchCtrl');
if (res.fail == null) if (res.success.status) {
if (res.fail == null)
setState(() {
searchhomeModel = res.success;
category_model = res.success;
});
}
else{
}
......
......@@ -117,6 +117,8 @@ class _ShopNearbyPlacesPageState extends State<ShopNearbyPlacesPage> {
),
);
},
child: Card(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
......
......@@ -345,6 +345,24 @@ class _ShopListState extends State<ShopList> with TickerProviderStateMixin {
fontWeight: FontWeight.w700),
),
),
Positioned(
left: SizeConfig.getPadding(280),
top: SizeConfig.getPadding(190),
child:Icon(Icons.star,color: Colors.orangeAccent,size: SizeConfig.getFontSize(18),),
),
Positioned(
left: SizeConfig.getPadding(300),
top: SizeConfig.getPadding(190),
child: Text(
"4.9",
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black,
fontSize: SizeConfig.getFontSize(12),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w700),
),
),
],
),
),
......@@ -390,104 +408,8 @@ class _ShopListState extends State<ShopList> with TickerProviderStateMixin {
fontWeight: FontWeight.w700),
),
),
Row(
children: <Widget>[
SizedBox(
width: SizeConfig.getWidth(20),
),
Image.asset(
'assets/images/clock.png',
width: SizeConfig.getWidth(20),
height: SizeConfig.getWidth(20),
),
SizedBox(
width: SizeConfig.getWidth(10),
),
Text(
'90 นาที',
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black87,
fontSize: SizeConfig.getFontSize(12),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w500),
),
SizedBox(
width: SizeConfig.getWidth(30),
),
Image.asset(
'assets/images/sell.png',
width: SizeConfig.getWidth(20),
height: SizeConfig.getWidth(20),
),
SizedBox(
width: SizeConfig.getWidth(5),
),
Text(
'฿1,599.00 ',
textAlign: TextAlign.left,
style: TextStyle(
color: Color.fromRGBO(238, 175, 183, 1),
fontSize: SizeConfig.getFontSize(12),
decoration: TextDecoration.lineThrough,
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w500),
),
SizedBox(
width: SizeConfig.getWidth(5),
),
Text(
'฿1,599.00 ',
textAlign: TextAlign.left,
style: TextStyle(
color: Color.fromRGBO(253, 41, 86, 1),
fontSize: SizeConfig.getFontSize(22),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w700),
),
],
),
InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ShopListDetail(),
),
);
},
child: Stack(
children: <Widget>[
Container(
child: Image.asset('assets/images/btn_shoplist.png'),
padding: EdgeInsets.only(
left: SizeConfig.getPadding(20),
right: SizeConfig.getPadding(20),
top: SizeConfig.getPadding(20),
bottom: SizeConfig.getPadding(20),
),
),
Container(
alignment: Alignment.center,
child: Text(
'หยิบใส่รถเข็น',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: SizeConfig.getFontSize(14),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w700),
),
padding: EdgeInsets.only(
left: SizeConfig.getPadding(60),
right: SizeConfig.getPadding(20),
top: SizeConfig.getPadding(30),
bottom: SizeConfig.getPadding(20),
),
)
],
),
)
],
),
);
......
import 'package:feelverapp/ui/booking/booking_detail.dart';
import 'package:feelverapp/ui/shop/shop.dart';
import 'package:feelverapp/ui/shop/shop_Nearby_places.dart';
import 'package:feelverapp/ui/shop/shop_reviews.dart';
......@@ -154,7 +155,7 @@ class _MainShopState extends State<MainShop> with SingleTickerProviderStateMixi
//service detail//////////////
child:Shop()
child:BookingDetail()
),
......
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