|
@@ -11,6 +11,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:router/ext/auto_router_extensions.dart';
|
|
import 'package:router/ext/auto_router_extensions.dart';
|
|
import 'package:shared/utils/color_utils.dart';
|
|
import 'package:shared/utils/color_utils.dart';
|
|
import 'package:shared/utils/log_utils.dart';
|
|
import 'package:shared/utils/log_utils.dart';
|
|
|
|
+import 'package:widgets/ext/ex_widget.dart';
|
|
import 'package:widgets/load_state_layout.dart';
|
|
import 'package:widgets/load_state_layout.dart';
|
|
import 'package:widgets/my_appbar.dart';
|
|
import 'package:widgets/my_appbar.dart';
|
|
import 'package:widgets/my_like_button.dart';
|
|
import 'package:widgets/my_like_button.dart';
|
|
@@ -44,7 +45,9 @@ class GaragesaleDetailPage extends HookConsumerWidget {
|
|
GarageSaleRentDetailEntity detailInfo = state.datas?? GarageSaleRentDetailEntity();
|
|
GarageSaleRentDetailEntity detailInfo = state.datas?? GarageSaleRentDetailEntity();
|
|
String title = detailInfo.title?? '';
|
|
String title = detailInfo.title?? '';
|
|
int price = detailInfo.price?? 0;
|
|
int price = detailInfo.price?? 0;
|
|
- String contactType = '';
|
|
|
|
|
|
+
|
|
|
|
+ String contactType = detailInfo.contact??'';
|
|
|
|
+
|
|
String description = '';
|
|
String description = '';
|
|
|
|
|
|
|
|
|
|
@@ -70,15 +73,13 @@ class GaragesaleDetailPage extends HookConsumerWidget {
|
|
child: EasyRefresh(
|
|
child: EasyRefresh(
|
|
controller: vm.refreshController,
|
|
controller: vm.refreshController,
|
|
// 上拉加载
|
|
// 上拉加载
|
|
- onLoad: () async{
|
|
|
|
- Log.d("----onLoad");
|
|
|
|
- // vm.loadMore();
|
|
|
|
- },
|
|
|
|
|
|
+ onLoad: null,
|
|
// 下拉刷新
|
|
// 下拉刷新
|
|
onRefresh: () async{
|
|
onRefresh: () async{
|
|
Log.d("----onRefresh");
|
|
Log.d("----onRefresh");
|
|
vm.onRefresh();
|
|
vm.onRefresh();
|
|
},
|
|
},
|
|
|
|
+ // header: MaterialHeader(),
|
|
child: Stack(
|
|
child: Stack(
|
|
children:[
|
|
children:[
|
|
LoadStateLayout(
|
|
LoadStateLayout(
|
|
@@ -106,11 +107,14 @@ class GaragesaleDetailPage extends HookConsumerWidget {
|
|
),
|
|
),
|
|
Visibility(
|
|
Visibility(
|
|
visible: state.loadingState == LoadState.State_Success,
|
|
visible: state.loadingState == LoadState.State_Success,
|
|
- child: _buildWhatsApp(context, ref,
|
|
|
|
- title:title,
|
|
|
|
- price:price,
|
|
|
|
- contactType:contactType,
|
|
|
|
- description:description,
|
|
|
|
|
|
+ child: Visibility(
|
|
|
|
+ visible: vm.isContactWhatsApp(contactType),
|
|
|
|
+ child: _buildWhatsApp(context, ref,
|
|
|
|
+ title:title,
|
|
|
|
+ price:price,
|
|
|
|
+ contactType:contactType,
|
|
|
|
+ description:description,
|
|
|
|
+ ),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
]
|
|
]
|
|
@@ -140,8 +144,8 @@ class GaragesaleDetailPage extends HookConsumerWidget {
|
|
bottom: 42,
|
|
bottom: 42,
|
|
child: InkWell(
|
|
child: InkWell(
|
|
onTap: () {
|
|
onTap: () {
|
|
- // 跳转 WhatsApp
|
|
|
|
- vm.gotoWhatsApp();
|
|
|
|
|
|
+ // 点击了whatsapp
|
|
|
|
+ vm.handlerClickWhatsapp(context, contactType, title, price);
|
|
},
|
|
},
|
|
child: const MyAssetImage(Assets.communityWhatsAPP, width: 57,height: 57,),
|
|
child: const MyAssetImage(Assets.communityWhatsAPP, width: 57,height: 57,),
|
|
),
|
|
),
|
|
@@ -149,11 +153,13 @@ class GaragesaleDetailPage extends HookConsumerWidget {
|
|
}
|
|
}
|
|
|
|
|
|
Widget _buildContentBox(BuildContext context, WidgetRef ref, GarageSaleRentDetailEntity detailInfo) {
|
|
Widget _buildContentBox(BuildContext context, WidgetRef ref, GarageSaleRentDetailEntity detailInfo) {
|
|
- String goods_img = detailInfo.resources?[0]??'';
|
|
|
|
|
|
+ List<String> resources = detailInfo.resources??[];
|
|
|
|
+ String goods_img = resources[0]??'';
|
|
String title = detailInfo.title??'';
|
|
String title = detailInfo.title??'';
|
|
int price = detailInfo.price??0;
|
|
int price = detailInfo.price??0;
|
|
String contactType = '';
|
|
String contactType = '';
|
|
String description = detailInfo.description??'';
|
|
String description = detailInfo.description??'';
|
|
|
|
+ CarouselSliderController buttonCarouselController = CarouselSliderController();
|
|
return Column(
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
children: [
|
|
@@ -161,8 +167,17 @@ class GaragesaleDetailPage extends HookConsumerWidget {
|
|
SizedBox(
|
|
SizedBox(
|
|
width: double.infinity,
|
|
width: double.infinity,
|
|
height: 173.5,
|
|
height: 173.5,
|
|
- child: MyLoadImage(
|
|
|
|
- goods_img,
|
|
|
|
|
|
+ child: CarouselSlider(
|
|
|
|
+ // items: [MyLoadImage(goods_img)] ,
|
|
|
|
+ items: resources.map((resource) => MyLoadImage(resource)).toList(),
|
|
|
|
+ carouselController: buttonCarouselController,
|
|
|
|
+ options: CarouselOptions(
|
|
|
|
+ autoPlay: true,
|
|
|
|
+ enlargeCenterPage: true,
|
|
|
|
+ viewportFraction: 0.9,
|
|
|
|
+ aspectRatio: 2.0,
|
|
|
|
+ initialPage: 0,
|
|
|
|
+ ),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Column(
|
|
Column(
|
|
@@ -202,17 +217,20 @@ class GaragesaleDetailPage extends HookConsumerWidget {
|
|
required GarageSaleRentDetailEntity detailInfo,
|
|
required GarageSaleRentDetailEntity detailInfo,
|
|
}
|
|
}
|
|
) {
|
|
) {
|
|
- final state = ref.watch(garagesaleDetailVmProvider);
|
|
|
|
-
|
|
|
|
|
|
+ final vm = ref.read(garagesaleDetailVmProvider.notifier);
|
|
|
|
|
|
GarageSaleRentDetailAccount account = detailInfo.account?? GarageSaleRentDetailAccount();
|
|
GarageSaleRentDetailAccount account = detailInfo.account?? GarageSaleRentDetailAccount();
|
|
|
|
|
|
String publisher = account.name??'-';
|
|
String publisher = account.name??'-';
|
|
- String contactType = '';
|
|
|
|
String publisherAvatar = account.avatar??'-';
|
|
String publisherAvatar = account.avatar??'-';
|
|
|
|
+
|
|
|
|
+ String contactType = detailInfo.contact??'';
|
|
String publisherTime = detailInfo.createdAt??'-';
|
|
String publisherTime = detailInfo.createdAt??'-';
|
|
int likes_count = detailInfo!.likesCount??0;
|
|
int likes_count = detailInfo!.likesCount??0;
|
|
|
|
|
|
|
|
+ final _likes_count = useState(likes_count);
|
|
|
|
+ final _isLiked = useState<bool>(false);
|
|
|
|
+
|
|
return Container(
|
|
return Container(
|
|
height: 50,
|
|
height: 50,
|
|
color: ColorUtils.string2Color('#4161D0'),
|
|
color: ColorUtils.string2Color('#4161D0'),
|
|
@@ -255,18 +273,32 @@ class GaragesaleDetailPage extends HookConsumerWidget {
|
|
children: [
|
|
children: [
|
|
MyLikeButton(
|
|
MyLikeButton(
|
|
key: likeButtonKey,
|
|
key: likeButtonKey,
|
|
- isLiked: false,
|
|
|
|
|
|
+ isLiked: _isLiked.value,
|
|
isCustomIcon: true,
|
|
isCustomIcon: true,
|
|
customIconUnActiveAssets: Assets.communityCollection,
|
|
customIconUnActiveAssets: Assets.communityCollection,
|
|
customIconActiveAssets: Assets.communityLikeActive,
|
|
customIconActiveAssets: Assets.communityLikeActive,
|
|
// customIconWidth: 18,
|
|
// customIconWidth: 18,
|
|
// customIconHeight: 18,
|
|
// customIconHeight: 18,
|
|
- onLike: () {
|
|
|
|
|
|
+ onLike: () async {
|
|
Log.d('点击了like button');
|
|
Log.d('点击了like button');
|
|
|
|
+ int id = detailInfo!.id as int;
|
|
|
|
+ final isSuccess = await vm.handlerClickCollection(context, id, true);
|
|
|
|
+ if(isSuccess!=null && isSuccess){
|
|
|
|
+ // 成功
|
|
|
|
+ if(_isLiked.value){
|
|
|
|
+ Log.d("取消点赞");
|
|
|
|
+ _likes_count.value--;
|
|
|
|
+ _isLiked.value = false;
|
|
|
|
+ }else {
|
|
|
|
+ Log.d("点赞");
|
|
|
|
+ _likes_count.value++;
|
|
|
|
+ _isLiked.value = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
},
|
|
},
|
|
),
|
|
),
|
|
MyTextView(
|
|
MyTextView(
|
|
- "$likes_count",
|
|
|
|
|
|
+ "${_likes_count.value}",
|
|
fontSize: 18,
|
|
fontSize: 18,
|
|
textColor: Colors.white,
|
|
textColor: Colors.white,
|
|
isFontRegular: true,
|
|
isFontRegular: true,
|
|
@@ -282,12 +314,18 @@ class GaragesaleDetailPage extends HookConsumerWidget {
|
|
),
|
|
),
|
|
// const MyAssetImage(Assets.communityCollection, width: 18,height: 18,),
|
|
// const MyAssetImage(Assets.communityCollection, width: 18,height: 18,),
|
|
Visibility(
|
|
Visibility(
|
|
- visible: contactType == 'Mobile Phone',
|
|
|
|
- child: const Row(
|
|
|
|
|
|
+ visible: vm.isContactMobile(contactType),
|
|
|
|
+ child: Row(
|
|
children: [
|
|
children: [
|
|
- SizedBox(width: 4,),
|
|
|
|
- MyAssetImage(Assets.communityPhone, width: 21.5,height: 18,),
|
|
|
|
- SizedBox(width: 15,),
|
|
|
|
|
|
+ const SizedBox(width: 4,),
|
|
|
|
+ const MyAssetImage(
|
|
|
|
+ Assets.communityPhone,
|
|
|
|
+ width: 21.5,
|
|
|
|
+ height: 18,
|
|
|
|
+ ).onTap((){
|
|
|
|
+ vm.handlerClickMobile(context, contactType);
|
|
|
|
+ }),
|
|
|
|
+ const SizedBox(width: 15,),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|