You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
300 lines
10 KiB
300 lines
10 KiB
3 years ago
|
import 'package:flutter/cupertino.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter_swiper/flutter_swiper.dart';
|
||
|
import 'package:huixiang/generated/l10n.dart';
|
||
|
import 'package:huixiang/retrofit/data/store_info.dart';
|
||
|
import 'package:huixiang/utils/flutter_utils.dart';
|
||
|
import 'package:huixiang/utils/font_weight.dart';
|
||
|
import 'package:huixiang/view_widget/custom_image.dart';
|
||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||
|
import 'package:huixiang/view_widget/round_button.dart';
|
||
|
import 'package:url_launcher/url_launcher.dart';
|
||
|
|
||
|
class StoreInfos extends StatefulWidget {
|
||
|
|
||
|
final StoreInfo storeInfo;
|
||
|
|
||
|
StoreInfos(this.storeInfo);
|
||
|
|
||
|
@override
|
||
|
State<StatefulWidget> createState() {
|
||
|
return _StoreInfos();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
class _StoreInfos extends State<StoreInfos> {
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return AspectRatio(
|
||
|
aspectRatio: 1,
|
||
|
child: Container(
|
||
|
margin: EdgeInsets.fromLTRB(16, 20, 16, 8),
|
||
|
padding: EdgeInsets.fromLTRB(10, 20, 10, 14),
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
borderRadius: BorderRadius.circular(8),
|
||
|
boxShadow: [
|
||
|
BoxShadow(
|
||
|
color: Colors.black.withAlpha(25),
|
||
|
offset: Offset(0, 1),
|
||
|
blurRadius: 12,
|
||
|
spreadRadius: 0,
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
child: Column(
|
||
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
AspectRatio(
|
||
|
aspectRatio: 1.8,
|
||
|
child: buildSwiper(),
|
||
|
),
|
||
|
Expanded(
|
||
|
child: Container(
|
||
|
margin: EdgeInsets.only(
|
||
|
left: 10.w,
|
||
|
right: 10.w,
|
||
|
top: 16.h,
|
||
|
),
|
||
|
child: Column(
|
||
|
mainAxisAlignment:
|
||
|
MainAxisAlignment.spaceBetween,
|
||
|
crossAxisAlignment:
|
||
|
CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
Row(
|
||
|
children: [
|
||
|
Text(
|
||
|
widget.storeInfo != null
|
||
|
? widget.storeInfo.storeName
|
||
|
: "",
|
||
|
style: TextStyle(
|
||
|
fontSize: 16.sp,
|
||
|
color: Colors.black,
|
||
|
fontWeight: MyFontWeight.medium,
|
||
|
),
|
||
|
),
|
||
|
Expanded(
|
||
|
child: Container(
|
||
|
alignment:
|
||
|
Alignment.centerRight,
|
||
|
child: Text(
|
||
|
S.of(context).ren(
|
||
|
widget.storeInfo != null
|
||
|
? widget.storeInfo
|
||
|
.perCapitaConsumption
|
||
|
: "",
|
||
|
),
|
||
|
style: TextStyle(
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.regular,
|
||
|
color: Color(0xFF353535),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
Text(
|
||
|
widget.storeInfo != null
|
||
|
? widget.storeInfo.address
|
||
|
: "",
|
||
|
maxLines: 2,
|
||
|
textAlign: TextAlign.justify,
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF353535),
|
||
|
fontWeight: MyFontWeight.regular,
|
||
|
fontSize: 12.sp,
|
||
|
),
|
||
|
),
|
||
|
Row(
|
||
|
children: itemServer(
|
||
|
widget.storeInfo != null
|
||
|
? widget.storeInfo.businessService
|
||
|
: "",
|
||
|
),
|
||
|
),
|
||
|
Row(
|
||
|
mainAxisAlignment:
|
||
|
MainAxisAlignment.spaceBetween,
|
||
|
crossAxisAlignment:
|
||
|
CrossAxisAlignment.end,
|
||
|
children: [
|
||
|
Expanded(
|
||
|
child: Text(
|
||
|
S.of(context).yingyeshijian(widget.storeInfo ==
|
||
|
null
|
||
|
? ""
|
||
|
: (widget.storeInfo.openStartTime ==
|
||
|
null &&
|
||
|
widget.storeInfo
|
||
|
.openEndTime ==
|
||
|
null)
|
||
|
? S.of(context).quantian
|
||
|
: "${widget.storeInfo.openStartTime.substring(0, widget.storeInfo.openStartTime.lastIndexOf(":"))} "
|
||
|
"- ${widget.storeInfo.openEndTime.substring(0, widget.storeInfo.openEndTime.lastIndexOf(":"))}"),
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF353535),
|
||
|
fontWeight: MyFontWeight.regular,
|
||
|
fontSize: 12.sp,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
SizedBox(
|
||
|
width: 16.w,
|
||
|
),
|
||
|
InkWell(
|
||
|
onTap: () {
|
||
|
if (widget.storeInfo == null ||
|
||
|
widget.storeInfo.latitude ==
|
||
|
null ||
|
||
|
widget.storeInfo.longitude ==
|
||
|
null ||
|
||
|
widget.storeInfo.latitude == "" ||
|
||
|
widget.storeInfo.longitude == "")
|
||
|
return;
|
||
|
Navigator.of(context).pushNamed(
|
||
|
'/router/location_map',
|
||
|
arguments: {
|
||
|
"lat": widget.storeInfo.latitude,
|
||
|
"lng":
|
||
|
widget.storeInfo.longitude,
|
||
|
"storeName":
|
||
|
widget.storeInfo.storeName,
|
||
|
});
|
||
|
},
|
||
|
child: Image.asset(
|
||
|
"assets/image/icon_union_location.png",
|
||
|
width: 24.w,
|
||
|
height: 24.h,
|
||
|
),
|
||
|
),
|
||
|
SizedBox(
|
||
|
width: 16.w,
|
||
|
),
|
||
|
InkWell(
|
||
|
onTap: () {
|
||
|
showCallMobile();
|
||
|
},
|
||
|
child: Image.asset(
|
||
|
"assets/image/icon_union_call.png",
|
||
|
width: 24,
|
||
|
height: 24,
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
flex: 1,
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
Widget buildSwiper() {
|
||
|
return Container(
|
||
|
child: Swiper(
|
||
|
pagination: SwiperPagination(
|
||
|
alignment: Alignment.bottomCenter,
|
||
|
builder: DotSwiperPaginationBuilder(
|
||
|
size: 8.w,
|
||
|
activeSize: 8.w,
|
||
|
space: 5.w,
|
||
|
activeColor: Colors.white,
|
||
|
color: Colors.white.withAlpha(76),
|
||
|
),
|
||
|
),
|
||
|
itemBuilder: (context, position) {
|
||
|
return Container(
|
||
|
margin: EdgeInsets.only(left: 10.w, right: 10.w),
|
||
|
child: MImage(
|
||
|
(widget.storeInfo != null &&
|
||
|
widget.storeInfo.bannerList != null &&
|
||
|
position < widget.storeInfo.bannerList.length)
|
||
|
? widget.storeInfo.bannerList[position].imgUrl
|
||
|
: "",
|
||
|
fit: BoxFit.cover,
|
||
|
radius: BorderRadius.circular(4),
|
||
|
errorSrc: "assets/image/default_2_1.png",
|
||
|
fadeSrc: "assets/image/default_2_1.png",
|
||
|
),
|
||
|
);
|
||
|
},
|
||
|
itemCount: (widget.storeInfo != null && widget.storeInfo.bannerList != null)
|
||
|
? widget.storeInfo.bannerList.length
|
||
|
: 1),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
|
||
|
List<Widget> itemServer(String businessService) {
|
||
|
if (businessService == null || businessService == "") return [];
|
||
|
var list = businessService.split(",");
|
||
|
return list
|
||
|
.map((e) => Container(
|
||
|
margin: EdgeInsets.only(right: 8.w),
|
||
|
child: RoundButton(
|
||
|
height: 14.h * AppUtils.textScale(context),
|
||
|
text: "$e",
|
||
|
backgroup: Color(0xFFFF7A1A),
|
||
|
padding: EdgeInsets.only(
|
||
|
left: 2.w,
|
||
|
right: 2.w,
|
||
|
),
|
||
|
fontSize: 10.sp,
|
||
|
textColor: Colors.white,
|
||
|
),
|
||
|
))
|
||
|
.toList();
|
||
|
}
|
||
|
|
||
|
showCallMobile() {
|
||
|
showCupertinoModalPopup(
|
||
|
context: context,
|
||
|
builder: (context) {
|
||
|
return CupertinoActionSheet(
|
||
|
title: Text(S.of(context).bodadianhua),
|
||
|
actions: [
|
||
|
if (widget.storeInfo != null &&
|
||
|
widget.storeInfo.headMobile != null &&
|
||
|
widget.storeInfo.headMobile != "")
|
||
|
CupertinoActionSheetAction(
|
||
|
child: Text(widget.storeInfo.headMobile),
|
||
|
onPressed: () {
|
||
|
callMobile(widget.storeInfo.headMobile);
|
||
|
Navigator.of(context).pop();
|
||
|
},
|
||
|
isDefaultAction: true,
|
||
|
isDestructiveAction: false,
|
||
|
),
|
||
|
],
|
||
|
cancelButton: CupertinoActionSheetAction(
|
||
|
onPressed: () {
|
||
|
Navigator.of(context).pop();
|
||
|
},
|
||
|
child: Text(S.of(context).quxiao),
|
||
|
isDestructiveAction: true,
|
||
|
),
|
||
|
);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
callMobile(mobile) async {
|
||
|
String url = "tel:$mobile";
|
||
|
if (await canLaunch(url)) {
|
||
|
await launch(url);
|
||
|
} else {
|
||
|
throw 'Could not launch $url';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|