| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620 |
- import 'dart:io';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/gestures.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/src/widgets/framework.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:get/get.dart';
- import 'package:get/get_core/src/get_main.dart';
- import 'package:location/base/base_page.dart';
- import 'package:location/data/bean/goods_bean.dart';
- import 'package:location/module/member/activity/member_activity_banner_widget.dart';
- import 'package:location/resource/assets.gen.dart';
- import 'package:location/resource/colors.gen.dart';
- import 'package:location/resource/string.gen.dart';
- import 'package:location/utils/common_expand.dart';
- import 'package:location/utils/project_expand.dart';
- import '../../../resource/fonts.gen.dart';
- import '../../../router/app_pages.dart';
- import '../../../widget/activity_countdown_txt_view.dart';
- import '../../../widget/activity_countdown_view.dart';
- import '../../../widget/shimmer_effect.dart';
- import 'member_activity_controller.dart';
- class MemberActivityPage extends BasePage<MemberActivityController> {
- const MemberActivityPage({super.key});
- static Future<bool> start({bool isOffAll = false}) async {
- if (isOffAll) {
- return await Get.offAllNamed(RoutePath.memberActivity) == true;
- } else {
- return await Get.toNamed(RoutePath.memberActivity) == true;
- }
- }
- @override
- bool immersive() {
- return true;
- }
- @override
- bool statusBarDarkFont() {
- return false;
- }
- @override
- Widget buildBody(BuildContext context) {
- return PopScope(
- canPop: false,
- onPopInvokedWithResult: (bool didPop, dynamic result) {
- if (didPop) {
- return;
- }
- controller.onBack();
- },
- child: Stack(
- children: [
- buildActivityContent(),
- buildToolbar(),
- buildMemberBottomView()
- ],
- ),
- );
- }
- Widget buildToolbar() {
- return SafeArea(
- child: SizedBox(
- width: double.infinity,
- height: 56.w,
- child: Stack(
- children: [
- Positioned(
- left: 10,
- top: 0,
- bottom: 0,
- child: GestureDetector(
- onTap: controller.onBack,
- child: Container(
- padding: EdgeInsets.only(
- left: 10.w, right: 12.w, top: 10.w, bottom: 10.w),
- child: Assets.images.iconMemberActivityClose
- .image(width: 8.w)),
- ),
- ),
- Center(
- child: Text(
- StringName.memberActivityTitle,
- style: TextStyle(
- fontSize: 18.sp,
- color: Colors.white,
- fontWeight: FontWeight.bold),
- ),
- ),
- Positioned(
- right: 10.w,
- top: 0,
- bottom: 0,
- child: Obx(() {
- return Visibility(
- visible: controller.accountRepository.isLogin.value &&
- Platform.isIOS,
- child: GestureDetector(
- onTap: controller.onRecoverClick,
- child: Row(
- children: [
- Assets.images.iconAppleRecoverSubscribe
- .image(width: 14.w, height: 14.w),
- SizedBox(width: 1.w),
- Text(StringName.appleRecoverSubscribeTxt,
- style: TextStyle(
- fontSize: 11.sp,
- color: Colors.white,
- fontWeight: FontWeight.bold))
- ],
- ),
- ),
- );
- }),
- )
- ],
- ),
- ),
- );
- }
- Widget buildActivityContent() {
- return SizedBox(
- width: double.infinity,
- height: double.infinity,
- child: SingleChildScrollView(
- child: Stack(
- children: [
- Assets.images.bgMemberActivity
- .image(width: double.infinity, fit: BoxFit.cover),
- SafeArea(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- SizedBox(height: 83.w),
- Container(
- margin: EdgeInsets.only(left: 16.w),
- child: Assets.images.iconMemberActivityCountdown
- .image(height: 22.w)),
- SizedBox(height: 10.w),
- Container(
- margin: EdgeInsets.only(left: 16.w, bottom: 16.w),
- child: Assets.images.imgMemberActivityFavourableTxt
- .image(height: 20.w),
- ),
- buildGoodsContainer(),
- ],
- ),
- )
- ],
- ),
- ),
- );
- }
- Widget buildGoodsContainer() {
- return Container(
- width: double.infinity,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- stops: const [0.0, 0.16],
- colors: ['#E4E4FF'.color, Colors.white],
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter),
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(20.w), topRight: Radius.circular(20.w)),
- ),
- child: Stack(
- children: [
- Assets.images.bgMemberActivityContainer
- .image(width: double.infinity, fit: BoxFit.fill),
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- SizedBox(height: 14.w),
- buildFunTitleView(),
- buildMemberActivityFunctionIntroduction(),
- SizedBox(height: 8.w),
- buildGoodsListView(),
- buildPrivacyPolicyView(),
- SizedBox(height: 150.w),
- ],
- )
- ],
- ),
- );
- }
- Widget buildFunTitleView() {
- return Container(
- margin: EdgeInsets.only(left: 16.w, bottom: 18.w),
- child: Stack(
- children: [
- Container(
- width: 117.w,
- height: 8.w,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- colors: ['#AA70FE'.color, '#006A2DC4'.color],
- begin: Alignment.centerLeft,
- end: Alignment.centerRight,
- ),
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(10.w),
- bottomLeft: Radius.circular(10.w))),
- margin: EdgeInsets.only(top: 15.5.w),
- ),
- Container(
- margin: EdgeInsets.only(left: 4.w),
- child: Text(
- StringName.memberActivityFunTitle,
- style: TextStyle(
- fontSize: 15.sp,
- color: '#202020'.color,
- fontWeight: FontWeight.bold),
- ),
- ),
- ],
- ),
- );
- }
- Widget buildPrivacyPolicyView() {
- return Padding(
- padding: EdgeInsets.only(left: 15.w),
- child: RichText(
- text: TextSpan(
- style: TextStyle(fontSize: 12.sp, color: ColorName.black40),
- children: [
- TextSpan(text: '购买前请先阅读'),
- TextSpan(
- recognizer: TapGestureRecognizer()
- ..onTap = () {
- controller.onPrivacyPolicyClick();
- },
- text: '隐私政策',
- style: TextStyle(
- color: ColorName.black60,
- decoration: TextDecoration.underline)),
- TextSpan(text: '&'),
- TextSpan(
- recognizer: TapGestureRecognizer()
- ..onTap = () {
- controller.onTermOfServiceClick();
- },
- text: '服务条款',
- style: TextStyle(
- color: ColorName.black60,
- decoration: TextDecoration.underline)),
- if (Platform.isIOS) TextSpan(text: '&'),
- if (Platform.isIOS)
- TextSpan(
- recognizer: TapGestureRecognizer()
- ..onTap = () {
- controller.onRenewalAgreementClick();
- },
- text: '会员协议',
- style: TextStyle(
- color: ColorName.black60,
- decoration: TextDecoration.underline)),
- ])),
- );
- }
- Widget buildCountdownSeparator() {
- return Container(
- margin: EdgeInsets.symmetric(horizontal: 2.w),
- child: IntrinsicHeight(
- child: Column(
- children: [
- Container(
- width: 2.w,
- height: 2.w,
- decoration: BoxDecoration(
- color: '#FF5656'.color,
- shape: BoxShape.circle,
- ),
- ),
- SizedBox(height: 3.w),
- Container(
- width: 2.w,
- height: 2.w,
- decoration: BoxDecoration(
- color: '#FF5656'.color,
- shape: BoxShape.circle,
- ),
- )
- ],
- ),
- ),
- );
- }
- Widget buildMemberBottomView() {
- return Obx(() {
- if (controller.memberStatusInfo != null &&
- controller.memberStatusInfo?.permanent == true) {
- return SizedBox(); // 不显示
- }
- return Align(
- alignment: Alignment.bottomCenter,
- child: Container(
- margin: EdgeInsets.only(bottom: 15.w, left: 12.w, right: 12.w),
- child: Stack(
- children: [
- Container(
- width: 336.w,
- height: 47.w,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(30.w),
- topRight: Radius.circular(30.w),
- ),
- color: '#FFFED8'.color),
- child: Align(
- alignment: Alignment(0.0, -0.75),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- StringName.memberActivityCountdown,
- style: TextStyle(
- fontSize: 11.sp, color: '#FF5656'.color),
- ),
- SizedBox(width: 4.w),
- Obx(() {
- return ActivityCountdownTextView(
- timeItemHeight: 15.w,
- contentPadding: EdgeInsets.zero,
- timeItemWidth: 16.w,
- textStyle: TextStyle(
- fontSize: 10.sp, color: Colors.white),
- duration: controller.activityDuration ??
- Duration(seconds: 0),
- separator: buildCountdownSeparator(),
- timeBgBoxDecoration: BoxDecoration(
- color: '#FF5656'.color,
- borderRadius: BorderRadius.circular(3.w),
- ));
- }),
- SizedBox(width: 4.w),
- Text(
- StringName.memberActivitySpeciallyPreferential,
- style: TextStyle(
- fontSize: 10.sp, color: '#FF5656'.color),
- )
- ],
- ),
- ),
- ),
- GestureDetector(
- onTap: controller.onBuyClick,
- child: Container(
- margin: EdgeInsets.only(top: 24.w),
- height: 50.w,
- width: 336.w,
- child: ShimmerEffect(
- image: Assets.images.imgMemberBtnShadow.provider(),
- shimmerWidthFactor: 0.244047619047619,
- duration: Duration(milliseconds: 3000),
- delay: Duration(milliseconds: 800),
- child: Container(
- height: 50.w,
- width: 336.w,
- alignment: Alignment.center,
- decoration: BoxDecoration(
- image: DecorationImage(
- image: Assets.images.iconMemberSettlementBg
- .provider(),
- fit: BoxFit.fill)),
- child: Text(
- StringName.memberVipUnlock,
- style: TextStyle(
- fontSize: 18.sp,
- color: '#FFF8EF'.color,
- fontWeight: FontWeight.bold),
- ),
- ),
- ),
- ),
- )
- ],
- ),
- ));
- });
- }
- Widget buildMemberActivityFunctionIntroduction() {
- return MemberActivityBannerWidget(
- bannerHeight: 145.w,
- viewportFraction: 0.88,
- itemCount: controller.funImages.length,
- itemBuilder: (context, index) {
- final image = controller.funImages[index];
- return Container(
- margin: EdgeInsets.symmetric(horizontal: 5.w),
- child: Image(
- image: image,
- width: double.infinity,
- height: double.infinity,
- fit: BoxFit.fill),
- );
- });
- }
- Widget buildGoodsListView() {
- return IntrinsicHeight(
- child: Obx(() {
- return Column(
- children: [
- for (int i = 0; i < controller.goodsList.length; i++)
- if (i == 0)
- buildFavourableGoodsView(controller.goodsList[i])
- else
- buildNormalGoodsView(controller.goodsList[i])
- ],
- );
- }),
- );
- }
- Widget buildFavourableGoodsView(GoodsBean goodsInfo) {
- bool isSelected = controller.selectedGoods?.id == goodsInfo.id;
- return GestureDetector(
- onTap: () {
- controller.onGoodsItemClick(goodsInfo);
- },
- child: Container(
- height: 96.w,
- width: double.infinity,
- margin: EdgeInsets.only(left: 12.w, right: 16.w, bottom: 12.w),
- decoration: BoxDecoration(
- image: DecorationImage(
- image: isSelected
- ? Assets.images.iconMemberSpecialProductsSelect.provider()
- : Assets.images.iconMemberSpecialProductsNormal.provider(),
- fit: BoxFit.fill,
- ),
- ),
- child: Stack(
- children: [
- Positioned(
- top: 10.w,
- bottom: 0,
- left: 24.w,
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- RichText(
- text: TextSpan(
- style: TextStyle(
- color: isSelected
- ? '#FF5656'.color
- : "#323133".color,
- fontWeight: FontWeight.bold),
- children: [
- TextSpan(
- text: '¥',
- style: TextStyle(fontSize: 16.sp, height: 1)),
- TextSpan(
- text: goodsInfo.amount.divideBy100(),
- style: TextStyle(
- fontSize: 28.sp,
- height: 1,
- //fontFamily: FontFamily.oppoSans
- ))
- ])),
- Text('¥${goodsInfo.originalAmount.divideBy100()}',
- style: TextStyle(
- decoration: TextDecoration.lineThrough,
- decorationColor: ColorName.black40,
- decorationThickness: 1.0,
- fontSize: 12.sp,
- color: ColorName.black40))
- ],
- ),
- ),
- Positioned(
- top: 10.w,
- bottom: 0,
- left: 105.w,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- goodsInfo.name,
- style: TextStyle(
- fontSize: 17.sp,
- color: "#333333".color,
- fontWeight: FontWeight.bold),
- ),
- SizedBox(
- height: 3.w,
- ),
- Text(
- goodsInfo.description ?? "",
- style: TextStyle(
- fontSize: 11.sp,
- color: "#9191BA".color,
- fontWeight: FontWeight.bold),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- );
- }
- Widget buildNormalGoodsView(GoodsBean goodsInfo) {
- bool isSelected = controller.selectedGoods?.id == goodsInfo.id;
- return GestureDetector(
- onTap: () {
- controller.onGoodsItemClick(goodsInfo);
- },
- child: Container(
- width: double.infinity,
- height: 72.w,
- margin: EdgeInsets.only(left: 16.w, right: 16.w, bottom: 12.w),
- child: Stack(
- children: [
- Container(
- width: double.infinity,
- height: double.infinity,
- decoration: BoxDecoration(
- gradient: isSelected
- ? LinearGradient(
- colors: ['#FFFFFF'.color, '#F3EAFF'.color],
- begin: Alignment.topLeft,
- end: Alignment.bottomRight,
- stops: const [0.4, 1.0])
- : null,
- borderRadius: BorderRadius.circular(12.w),
- border: Border.all(
- color: isSelected ? '#7A13C6'.color : '#DDDDDD'.color,
- width: isSelected ? 2.5.w : 1.w,
- ))),
- Stack(
- children: [
- Positioned(
- top: 4.w,
- bottom: 0,
- left: 20.w,
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- RichText(
- text: TextSpan(
- style: TextStyle(
- fontFamily: FontFamily.oppoSans,
- color: isSelected
- ? '#FF5656'.color
- : "#323133".color,
- fontWeight: FontWeight.bold),
- children: [
- TextSpan(
- text: '¥',
- style: TextStyle(fontSize: 16.sp, height: 1)),
- TextSpan(
- text: goodsInfo.amount.divideBy100(),
- style: TextStyle(
- fontSize: 28.sp,
- height: 1,
- //fontFamily: FontFamily.oppoSans
- ))
- ])),
- Text('¥${goodsInfo.originalAmount.divideBy100()}',
- style: TextStyle(
- decoration: TextDecoration.lineThrough,
- decorationColor: ColorName.black40,
- decorationThickness: 1.0,
- fontSize: 12.sp,
- color: ColorName.black40))
- ],
- ),
- ),
- Positioned(
- top: 0.w,
- bottom: 0,
- left: 101.w,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- goodsInfo.name,
- style: TextStyle(
- fontSize: 17.sp,
- color: "#333333".color,
- fontWeight: FontWeight.bold),
- ),
- SizedBox(
- height: 3.w,
- ),
- Text(
- goodsInfo.description ?? "",
- style: TextStyle(
- fontSize: 11.sp,
- color: "#9191BA".color,
- fontWeight: FontWeight.bold),
- ),
- ],
- ),
- ),
- ],
- ),
- ],
- ),
- ),
- );
- }
- }
|