no message

parent 07a87a4b
......@@ -33,7 +33,7 @@ class MyApp extends StatelessWidget {
),
home: Favorite()
home: SplashScreenPage()
......
class AddfavModel {
String message;
AddfavModel({this.message});
AddfavModel.fromJson(Map<String, dynamic> json) {
message = json['message'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['message'] = this.message;
return data;
}
}
......@@ -5,6 +5,7 @@ import 'package:feelverapp/model/Login/login_model.dart';
import 'package:feelverapp/model/base/base.dart';
import 'package:feelverapp/model/editprofile/getprofilemodel.dart';
import 'package:feelverapp/model/favorite/addfav_model.dart';
import 'package:feelverapp/model/favorite/delete_favorite_Model.dart';
import 'package:feelverapp/model/favorite/favorite_Model.dart';
......@@ -311,6 +312,28 @@ class Api<T> {
return result;
}
Future<Response<T>> addfav(Object body) async {
var _model;
var _fail;
var result;
await _httpConnection(
"${this._baseApi}/wish-list/add", this._headerApi, body)
.then((response) {
print("ผลลัพท์ เท่ากับ " "${response.body}");
if (response.statusCode == 200) {
_model = AddfavModel.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 {
......
......@@ -24,6 +24,7 @@ class _ShopListDetailState extends State<ShopListDetail> {
print(widget.id);
presenter = ShoplistdetailPresenter(this);
presenter.Detai(widget.id);
presenter.getid();
// List values = presenter.model.result[0].location.split(","); // split() will split from . and gives new List with separated elements.
//values.forEach(print);
......@@ -142,32 +143,23 @@ class _ShopListDetailState extends State<ShopListDetail> {
focusColor:Color(0xFFDD175F),
splashColor: Color(0xFFDD175F),
onTap: () {
print("add fav");
setState(() {
fav?fav=false:fav=true;
presenter.fav?presenter.fav=false:
presenter.Addfav(widget.id);
});
showDialog(
context: context,
builder: (context) {
Future.delayed(Duration(seconds: 1), () {
Navigator.of(context).pop(true);
});
return AlertDialog(
content:ImageIcon(
AssetImage('assets/images/ic_fav_list.png'),
color:fav?Color(0xFFDD175F): Colors.grey,
size: SizeConfig.getFontSize(30),
) ,
title:Center(child: Text('บันทึกสำเร็จ')),
);
});
},
child:ImageIcon(
AssetImage('assets/images/ic_fav_list.png'),
color:fav?Color(0xFFDD175F): Colors.white,
color:presenter.fav?Color(0xFFDD175F): Colors.white,
size: SizeConfig.getFontSize(30),
),
),),
......@@ -306,7 +298,8 @@ class _ShopListDetailState extends State<ShopListDetail> {
height: SizeConfig.getHeight(20),
),
_detail(),
_servicelist(),
_servicelist(),
],
),
);
......@@ -314,196 +307,197 @@ class _ShopListDetailState extends State<ShopListDetail> {
_servicelist() {
return Column(
children: <Widget>[
Container(
padding: EdgeInsets.only(
top: SizeConfig.getPadding(15),
left: SizeConfig.getPadding(24),
right: SizeConfig.getPadding(24),
bottom: SizeConfig.getPadding(5),
),
alignment: Alignment.topLeft,
child: Text(
'บริการ',
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black87,
fontSize: SizeConfig.getFontSize(16),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w700),
),
),
return Container(
Container(
height: 600,
padding: EdgeInsets.only(
top: SizeConfig.getPadding(0),
left: SizeConfig.getPadding(24),
right: SizeConfig.getPadding(24),
bottom: SizeConfig.getPadding(5),
padding: EdgeInsets.only(left:10,right:10),
child:
Column(
children: <Widget>[
Container(
padding: EdgeInsets.only(
top: SizeConfig.getPadding(15),
left: SizeConfig.getPadding(24),
right: SizeConfig.getPadding(24),
bottom: SizeConfig.getPadding(5),
),
alignment: Alignment.topLeft,
child: Text(
'บริการ',
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black87,
fontSize: SizeConfig.getFontSize(16),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w700),
),
),
alignment: Alignment.topLeft,
child:ListView.builder(
itemCount: presenter.model.result[0].openHour.length,
itemBuilder: (context, i) {
return Column(children: [
SizedBox(height: 30,),
Column(
children:
List.generate( presenter.model.result[0].openHour.length,(i) {
return Column(children: [
SizedBox(height: 30,),
Align(
alignment: Alignment.topLeft,
child:Text(
alignment: Alignment.topLeft,
child:Text(
presenter.model.result[0].storeProduct[i].product.name,
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black87,
fontSize: SizeConfig.getFontSize(16),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w700),
),),
SizedBox(height: 30,),
Row(children: [
presenter.model.result[0].storeProduct[i].product.name,
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black87,
fontSize: SizeConfig.getFontSize(16),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w700),
),),
SizedBox(height: 30,),
Row(children: [
Icon(
Icons.timer,
color: Colors.pinkAccent,
size: 20,
),
Text(
Icon(
Icons.timer,
color: Colors.pinkAccent,
size: 20,
),
Text(
" "+presenter.model.result[0].storeProduct[i].product.duration+" ชม.",
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black87,
fontSize: SizeConfig.getFontSize(12),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w200),
),Spacer(),
presenter.model.result[0].storeProduct[i].product.specialPrice==null?
Text(
" "+presenter.model.result[0].storeProduct[i].product.duration+" ชม.",
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black87,
fontSize: SizeConfig.getFontSize(12),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w200),
),Spacer(),
presenter.model.result[0].storeProduct[i].product.specialPrice==null?
Text(
"฿"+presenter.model.result[0].storeProduct[i].product.price,
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.red,
fontSize: SizeConfig.getFontSize(18),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w700),
):
Container(child:
Row(children: [
Icon(
Icons.local_offer,
color: Colors.pinkAccent,
size: 20,
),
Text(
"฿"+presenter.model.result[0].storeProduct[i].product.price,
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.red,
fontSize: SizeConfig.getFontSize(18),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w700),
):
Container(child:
Row(children: [
Icon(
Icons.local_offer,
color: Colors.pinkAccent,
size: 20,
),
Text(
" ฿"+presenter.model.result[0].storeProduct[i].product.price,
textAlign: TextAlign.left,
style: TextStyle(
decoration: TextDecoration.lineThrough,
color: Colors.pinkAccent,
fontSize: SizeConfig.getFontSize(14),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w700),
),
" ฿"+presenter.model.result[0].storeProduct[i].product.price,
textAlign: TextAlign.left,
style: TextStyle(
decoration: TextDecoration.lineThrough,
color: Colors.pinkAccent,
fontSize: SizeConfig.getFontSize(14),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w700),
),
Text(
" ฿"+presenter.model.result[0].storeProduct[i].product.specialPrice,
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.red,
fontSize: SizeConfig.getFontSize(18),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w700),
)
],)
)
" ฿"+presenter.model.result[0].storeProduct[i].product.specialPrice,
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.red,
fontSize: SizeConfig.getFontSize(18),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w700),
)
],)
)
]),
]),
SizedBox(height: 20,),
Padding(
padding: EdgeInsets.fromLTRB(0.0, 5.0, 0.0, 0.0),
child: Material( //Wrap with Material
shape: RoundedRectangleBorder(borderRadius:BorderRadius.circular(30.0) ),
elevation: 0.0,
color: Color.fromRGBO(106, 179, 170, 1),
clipBehavior: Clip.antiAlias, // Add This
child: MaterialButton(
Padding(
padding: EdgeInsets.fromLTRB(0.0, 5.0, 0.0, 0.0),
child: Material( //Wrap with Material
shape: RoundedRectangleBorder(borderRadius:BorderRadius.circular(30.0) ),
elevation: 0.0,
color: Color.fromRGBO(106, 179, 170, 1),
clipBehavior: Clip.antiAlias, // Add This
child: MaterialButton(
minWidth:MediaQuery.of(context).size.width - 50,
minWidth:MediaQuery.of(context).size.width - 50,
height: 55,
color: Color(0xff3694A3),
child:
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
color: Color(0xff3694A3),
child:
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.shopping_cart,
color: Colors.white,
size: 25,
),
Icons.shopping_cart,
color: Colors.white,
size: 25,
),
new Text(' หยิบใส่รถเข็น',
style: new TextStyle(fontSize: 16.0, color: Colors.white)),
],),
style: new TextStyle(fontSize: 16.0, color: Colors.white)),
],),
onPressed: () {
print(" Go to cart");
},
onPressed: () {
print(" Go to cart");
},
),
),
),
),
SizedBox(height: 30,),
SizedBox(height: 30,),
Container(
padding: EdgeInsets.only(
left: SizeConfig.getPadding(20),
right: SizeConfig.getPadding(20),
top: SizeConfig.getPadding(40),
bottom: SizeConfig.getPadding(20),
),
height: SizeConfig.getHeight(1),
width: MediaQuery.of(context).size.width - 40,
color: Colors.grey,
)
Container(
padding: EdgeInsets.only(
left: SizeConfig.getPadding(20),
right: SizeConfig.getPadding(20),
top: SizeConfig.getPadding(40),
bottom: SizeConfig.getPadding(20),
),
height: SizeConfig.getHeight(1),
width: MediaQuery.of(context).size.width - 40,
color: Colors.grey,
)
],);
},
),
),
],);
},
),
),
Container(
padding: EdgeInsets.only(
left: SizeConfig.getPadding(20),
right: SizeConfig.getPadding(20),
top: SizeConfig.getPadding(40),
bottom: SizeConfig.getPadding(20),
Container(
padding: EdgeInsets.only(
left: SizeConfig.getPadding(20),
right: SizeConfig.getPadding(20),
top: SizeConfig.getPadding(40),
bottom: SizeConfig.getPadding(20),
),
height: SizeConfig.getHeight(1),
width: MediaQuery.of(context).size.width - 40,
color: Colors.grey,
),
height: SizeConfig.getHeight(1),
width: MediaQuery.of(context).size.width - 40,
color: Colors.grey,
),
],
],
),
);
}
......
import 'package:feelverapp/model/favorite/addfav_model.dart';
import 'package:feelverapp/model/shoplistdetail/shoplistdetail_Model.dart';
import 'package:feelverapp/service/Loading.dart';
import 'package:feelverapp/service/api.dart';
import 'package:feelverapp/service/base_presenter.dart';
import 'package:feelverapp/ui/shop/shop_list_detail.dart';
import 'package:feelverapp/util/SizeConfig.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_launcher/url_launcher.dart';
......@@ -11,7 +14,13 @@ class ShoplistdetailPresenter extends BasePresenter<ShopListDetail>{
Api _api;
final formkey = GlobalKey<FormState>();
shoplistdetailModel model;
AddfavModel addmodel;
bool fav=false;
ShoplistdetailPresenter(State<ShopListDetail> state) : super(state);
String uid;
Detai(String id) async{
......@@ -33,6 +42,54 @@ class ShoplistdetailPresenter extends BasePresenter<ShopListDetail>{
print('res Fail');
}
}
getid() async {
SharedPreferences pref = await SharedPreferences.getInstance();
setState(() {
uid = pref.getString('Id');
});
return uid;
}
Addfav(String id) async{
LoadingView(state.context).show();
_api = Api<AddfavModel>();
var res = await _api.addfav({
"customer_id": uid,
"store_id":id,
"vendor_id":id,
"product_id":id,
});
LoadingView(state.context).hide();
if (res.fail == null) {
setState(() {
addmodel = res.success;
print("complete");
fav=true;
});
showDialog(
context: state.context,
builder: (context) {
Future.delayed(Duration(seconds: 1), () {
Navigator.of(context).pop(true);
});
return AlertDialog(
content:ImageIcon(
AssetImage('assets/images/ic_fav_list.png'),
color:fav?Color(0xFFDD175F): Colors.grey,
size: SizeConfig.getFontSize(30),
) ,
title:Center(child: Text('บันทึกสำเร็จ')),
);
});
} else {
print('res Fail');
}
}
gotoDirection(String lat,String lng){
print("debug");
......
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.1"
version: "2.4.2"
boolean_selector:
dependency: transitive
description:
......@@ -43,34 +29,34 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
charcode:
characters:
dependency: transitive
description:
name: charcode
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
collection:
version: "1.0.0"
charcode:
dependency: transitive
description:
name: collection
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.12"
convert:
version: "1.1.3"
clock:
dependency: transitive
description:
name: convert
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
version: "1.0.1"
collection:
dependency: transitive
description:
name: crypto
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
version: "1.14.13"
csslib:
dependency: transitive
description:
......@@ -92,6 +78,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.8"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
file:
dependency: transitive
description:
......@@ -156,13 +149,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.4"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.12"
image_cropper:
dependency: "direct main"
description:
......@@ -211,7 +197,7 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.6"
version: "0.12.8"
meta:
dependency: transitive
description:
......@@ -225,7 +211,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
version: "1.7.0"
path_provider_linux:
dependency: transitive
description:
......@@ -247,13 +233,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.0"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
platform:
dependency: transitive
description:
......@@ -289,13 +268,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.4"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
rflutter_alert:
dependency: "direct main"
description:
......@@ -356,7 +328,7 @@ packages:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.3"
version: "1.9.5"
stream_channel:
dependency: transitive
description:
......@@ -384,14 +356,14 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.15"
version: "0.2.17"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.2.0"
url_launcher:
dependency: "direct main"
description:
......@@ -441,13 +413,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.1"
sdks:
dart: ">=2.6.0 <3.0.0"
dart: ">=2.9.0-14.0.dev <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