| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710 |
- import 'package:flutter/src/widgets/framework.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:keyboard/base/base_page.dart';
- import 'package:keyboard/module/store/new_discount/new_discount_controller.dart';
- import 'package:flutter/material.dart';
- import 'package:carousel_slider/carousel_slider.dart';
- import 'package:get/get.dart';
- import '../../../data/bean/character_info.dart';
- import '../../../data/consts/payment_type.dart';
- import '../../../data/consts/web_url.dart';
- import '../../../resource/assets.gen.dart';
- import '../../../resource/colors.gen.dart';
- import '../../../resource/string.gen.dart';
- import '../../../router/app_pages.dart';
- import '../../../utils/styles.dart';
- import '../../../widget/auto_scroll_list_view.dart';
- import '../../../widget/click_text_span.dart';
- class NewDiscountPage extends BasePage<NewDiscountController> {
- const NewDiscountPage({super.key});
- /// 跳转
- static void start() {
- Get.toNamed(RoutePath.newDiscount);
- }
- @override
- bool immersive() {
- return true;
- }
- @override
- backgroundColor() => Colors.white;
- @override
- Widget buildBody(BuildContext context) {
- return Stack(
- children: [
- Positioned(top: 0.w, child: _buildBanner()),
- Positioned(
- top: 408.w,
- child: Container(
- decoration: BoxDecoration(
- color: ColorName.white,
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(24.r),
- topRight: Radius.circular(24.r),
- ),
- ),
- width: 360.w,
- height: 392.w,
- child: SingleChildScrollView(
- child: Column(
- children: [
- SizedBox(height: 16.w),
- _buildGoodsCard(),
- SizedBox(height: 12.w),
- _buildPayWayCard(),
- SizedBox(height: 8.w),
- _buildSelectedDesc(),
- SizedBox(height: 30.w),
- _buildMemberCard(),
- SizedBox(height: 200.w),
- ],
- ),
- ),
- ),
- ),
- Positioned(top: 0, left: 0, right: 0, child: _buildTitle()),
- Positioned(bottom: 0, left: 0, right: 0, child: _buildBuyButtonCard()),
- ],
- );
- }
- _buildTitle() {
- return SafeArea(
- child: Container(
- alignment: Alignment.centerLeft,
- padding: EdgeInsets.only(top: 16.h, left: 16.w, right: 16.w),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- GestureDetector(
- onTap: controller.clickBack,
- child: Assets.images.iconStoreBack.image(
- width: 32.w,
- height: 32.w,
- ),
- ),
- ],
- ),
- ),
- );
- }
- Widget _buildBanner() {
- return SizedBox(
- width: 360.w,
- child: Stack(
- children: [
- CarouselSlider(
- carouselController: controller.carouselSliderController,
- options: CarouselOptions(
- height: 438.w,
- viewportFraction: 1,
- initialPage: 0,
- enableInfiniteScroll: true,
- reverse: false,
- autoPlay: true,
- autoPlayInterval: const Duration(seconds: 3),
- autoPlayAnimationDuration: const Duration(milliseconds: 500),
- autoPlayCurve: Curves.fastOutSlowIn,
- scrollDirection: Axis.horizontal,
- onPageChanged: (index, reason) {
- controller.onBannerChanged(index, reason);
- },
- ),
- items:
- controller.bannerList.map((item) {
- return item.image(width: 360.w, fit: BoxFit.contain);
- }).toList(),
- ),
- Positioned(
- bottom: 149.16.w,
- left: 31.w,
- child: Assets.images.iconNewDiscountCharacterTitle.image(
- width: 296.w,
- height: 39.w,
- ),
- ),
- Positioned(
- bottom: 211.13.w,
- left: 42.w,
- right: 0,
- child: _buildIndicator(),
- ),
- Positioned(
- bottom: 0,
- left: 0,
- right: 0,
- child: _buildAutoCharacterList(),
- ),
- ],
- ),
- );
- }
- /// 指示器
- _buildIndicator() {
- return Row(
- children:
- controller.bannerList.asMap().entries.map((entry) {
- return Obx(() {
- final isSelectedBanner =
- controller.currentBannerIndex == entry.key;
- return Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- GestureDetector(
- onTap:
- () => controller.carouselSliderController.animateToPage(
- entry.key,
- ),
- child: AnimatedContainer(
- duration: const Duration(milliseconds: 300),
- margin: EdgeInsets.only(right: 5.w),
- height: 5.w,
- width: isSelectedBanner ? 10.w : 5.w,
- decoration: BoxDecoration(
- color:
- isSelectedBanner
- ? const Color(0xff483459)
- : const Color(0xffAFB4BF),
- borderRadius: BorderRadius.circular(5.r),
- ),
- ),
- ),
- ],
- );
- });
- }).toList(),
- );
- }
- Widget _buildAutoCharacterList() {
- return Obx(() {
- if (controller.charactersList.isEmpty) {
- return Container();
- }
- return SizedBox(
- height: 130.w,
- child: AutoScrollListView(
- itemCount: (controller.charactersList.length / 2).ceil(),
- scrollDirection: Axis.horizontal,
- itemBuilder: (context, columnIndex) {
- int rowCount = 2;
- int startIndex = columnIndex * rowCount;
- final List<CharacterInfo> columnItems =
- controller.charactersList
- .skip(startIndex)
- .take(rowCount)
- .toList();
- return Column(
- children:
- columnItems.map((item) {
- final emoji = item.emoji ?? "";
- final name = item.name ?? "";
- return Padding(
- padding: EdgeInsets.symmetric(
- vertical: 4.w,
- horizontal: 4.w,
- ),
- child: Container(
- padding: EdgeInsets.symmetric(
- horizontal: 12.w,
- vertical: 6.w,
- ),
- decoration: ShapeDecoration(
- color: Colors.white,
- shape: RoundedRectangleBorder(
- side: BorderSide(
- width: 1.w,
- color: const Color(0xFFF4F1FF),
- ),
- borderRadius: BorderRadius.circular(31.r),
- ),
- ),
- child: Text(
- "$emoji$name",
- style: TextStyle(
- color: Colors.black.withAlpha(204),
- fontSize: 13.sp,
- fontWeight: FontWeight.w400,
- ),
- ),
- ),
- );
- }).toList(),
- );
- },
- ),
- );
- });
- }
- Widget _buildBuyButtonCard() {
- return Container(
- width: 360.w,
- padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 11.h),
- decoration: ShapeDecoration(
- color: Colors.white,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(24.r),
- topRight: Radius.circular(24.r),
- ),
- ),
- shadows: [
- BoxShadow(
- color: Color(0x99FFE498),
- blurRadius: 20,
- offset: Offset(0, 0),
- spreadRadius: 0,
- ),
- ],
- ),
- child: Column(
- children: [
- GestureDetector(
- onTap: controller.clickPayNow,
- child: Container(
- width: 328.w,
- height: 56.w,
- decoration: ShapeDecoration(
- shape: RoundedRectangleBorder(
- side: BorderSide(width: 2.w, color: const Color(0xFFFFF6C9)),
- borderRadius: BorderRadius.circular(30.55),
- ),
- ),
- child: Container(
- width: 328,
- height: 54,
- decoration: ShapeDecoration(
- gradient: LinearGradient(
- begin: Alignment(0.60, -0.39),
- end: Alignment(0.60, 0.95),
- colors: [
- const Color(0xFFF95FAC),
- const Color(0xFFFD4D99),
- const Color(0xFFFF3E75),
- const Color(0xFFFF0F53),
- ],
- ),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(30.55),
- ),
- ),
- child: Center(
- child: Text(
- StringName.newDiscountUnlockNow,
- style: Styles.getTextStyleWhiteW500(17.sp),
- ),
- ),
- ),
- ),
- ),
- SizedBox(height: 11.h),
- _buildPrivacyTextSpan(),
- ],
- ),
- );
- }
- Widget _buildGoodsCard() {
- return Container(
- margin: EdgeInsets.symmetric(horizontal: 16.w),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- Obx(() {
- final goodsList = controller.filteredGoodsList;
- return Column(
- children: List.generate(goodsList.length, (index) {
- final item = goodsList[index];
- final isSelected =
- controller.selectedGoodsInfoItem?.id == item.id;
- return Column(
- children: [
- GestureDetector(
- onTap: () => controller.onGoodsItemClick(item),
- child: _buildGoodsItem(item, isSelected),
- ),
- if (index != goodsList.length - 1) SizedBox(height: 10.w),
- ],
- );
- }),
- );
- }),
- ],
- ),
- );
- }
- Widget _buildPayWayCard() {
- return GestureDetector(
- onTap: () => controller.clickPayWaySwitch(),
- child: Container(
- margin: EdgeInsets.symmetric(horizontal: 16.w),
- height: 36.h,
- padding: EdgeInsets.symmetric(horizontal: 10.w),
- decoration: ShapeDecoration(
- shape: RoundedRectangleBorder(
- side: BorderSide(width: 1, color: const Color(0xFFECEBE0)),
- borderRadius: BorderRadius.circular(10.r),
- ),
- ),
- child: Row(
- children: [
- Text(
- StringName.storePayWay,
- style: Styles.getTextStyleBlack204W400(14.sp),
- ),
- const Spacer(),
- Obx(() {
- if (controller.selectedPayWay == null) {
- return SizedBox.shrink();
- }
- return Row(
- children: [
- Image.asset(
- getPaymentIconPath(
- payMethod: controller.selectedPayWay!.payMethod,
- payPlatform: controller.selectedPayWay!.payPlatform,
- ),
- width: 20.w,
- height: 20.w,
- ),
- SizedBox(width: 4.w),
- Text(
- controller.selectedPayWay?.title ?? '',
- style: Styles.getTextStyleBlack204W400(14.sp),
- ),
- SizedBox(width: 6.w),
- Assets.images.iconStoreSwitchPay.image(
- width: 20.w,
- height: 20.w,
- fit: BoxFit.fill,
- ),
- ],
- );
- }),
- ],
- ),
- ),
- );
- }
- Widget _buildGoodsItem(item, bool isSelected) {
- return Container(
- height: 70.w,
- width: 328.w,
- padding: EdgeInsets.symmetric(horizontal: 16.w),
- decoration:
- isSelected
- ? BoxDecoration(
- borderRadius: BorderRadius.circular(16.w),
- image: DecorationImage(
- image: Assets.images.bgNewDiscountItemSelect.provider(),
- fit: BoxFit.fill,
- ),
- )
- : BoxDecoration(
- borderRadius: BorderRadius.circular(16.w),
- image: DecorationImage(
- image: Assets.images.bgNewDiscountItemUnselect.provider(),
- fit: BoxFit.fill,
- ),
- ),
- child: Row(
- children: [
- Text(
- "¥",
- style: TextStyle(
- color:
- isSelected
- ? const Color(0xFFFF684E)
- : Colors.black.withAlpha(204),
- fontSize: 16.sp,
- fontWeight: FontWeight.w700,
- ),
- ),
- Text(
- '${item.amountText}',
- textAlign: TextAlign.center,
- style: TextStyle(
- color:
- isSelected
- ? const Color(0xFFFF684E)
- : Colors.black.withAlpha(204),
- fontSize: 29.sp,
- fontWeight: FontWeight.w700,
- ),
- ),
- SizedBox(width: 9.w),
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Row(
- children: [
- Text(
- item.name,
- style: TextStyle(
- color: Colors.black.withAlpha(204),
- fontSize: 14.sp,
- fontWeight: FontWeight.w500,
- ),
- ),
- SizedBox(width: 4.5.w),
- if (item.mostDesc?.isNotEmpty == true)
- Container(
- padding: EdgeInsets.symmetric(
- horizontal: 4.w,
- vertical: 2.w,
- ),
- margin: EdgeInsets.only(bottom: 4.w),
- decoration: ShapeDecoration(
- gradient: LinearGradient(
- begin: Alignment(0.00, 0.50),
- end: Alignment(1.00, 0.50),
- colors: [
- const Color(0xFFFF684E),
- const Color(0xFFFF4F9A),
- ],
- ),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(10.50),
- topRight: Radius.circular(10.50),
- bottomRight: Radius.circular(10.50),
- ),
- ),
- ),
- child: Text(
- item.mostDesc!,
- style: TextStyle(
- color: Colors.white,
- fontSize: 12.sp,
- fontWeight: FontWeight.w500,
- ),
- ),
- ),
- ],
- ),
- Text(
- item.priceDesc,
- style: TextStyle(
- color: Colors.black.withAlpha(153),
- fontSize: 12.sp,
- fontWeight: FontWeight.w400,
- ),
- ),
- ],
- ),
- Spacer(),
- isSelected
- ? Assets.images.iconCustomCharacterAddDialogSelect.image(
- width: 20.w,
- height: 20.w,
- fit: BoxFit.contain,
- )
- : Container(
- width: 20.w,
- height: 20.w,
- decoration: ShapeDecoration(
- color: Colors.white,
- shape: OvalBorder(
- side: BorderSide(
- width: 2.w,
- color: const Color(0xFFE6E6E6),
- ),
- ),
- ),
- ),
- ],
- ),
- );
- }
- _buildSelectedDesc() {
- return Obx(() {
- return Container(
- margin: EdgeInsets.symmetric(horizontal: 16.w),
- child: Row(
- children: [
- Text(
- controller.selectedGoodsInfoItem?.selectDesc ?? "",
- style: TextStyle(
- color: Colors.black.withAlpha(102),
- fontSize: 12.sp,
- fontWeight: FontWeight.w400,
- ),
- ),
- ],
- ),
- );
- });
- }
- Widget _buildMemberCard() {
- return Container(
- margin: EdgeInsets.symmetric(horizontal: 16.w),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Assets.images.iconNewDiscountMembershipCardTitle.image(
- width: 79.w,
- height: 24.w,
- ),
- SizedBox(height: 6.w),
- Text(
- StringName.newDiscountMemberCardDesc,
- style: TextStyle(
- color: Colors.black.withValues(alpha: 87),
- fontSize: 11.sp,
- fontWeight: FontWeight.w400,
- ),
- ),
- SizedBox(height: 8.w),
- _buildMemberCardItem(),
- ],
- ),
- );
- }
- // 卡片权益
- _buildMemberCardItem() {
- return SizedBox(
- height: 80.w,
- child: AutoScrollListView(
- scrollDirection: Axis.horizontal,
- itemBuilder: (context, index) {
- final item = controller.memberCardList[index];
- return Container(
- margin: EdgeInsets.only(right: 8.w),
- width: 140.w,
- height: 65.w,
- decoration: ShapeDecoration(
- gradient: item.gradient,
- shape: RoundedRectangleBorder(
- side: BorderSide(width: 1.w, color: Colors.black.withAlpha(8)),
- borderRadius: BorderRadius.circular(20.r),
- ),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- item.imageUrl.image(width: 28.w, height: 27.62.w),
- SizedBox(width: 8.w),
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- item.title,
- style: TextStyle(
- color: Colors.black.withAlpha(204),
- fontSize: 12.sp,
- fontWeight: FontWeight.w700,
- ),
- ),
- SizedBox(height: 6.w),
- Text(
- item.desc,
- style: TextStyle(
- color: Colors.black.withAlpha(128),
- fontSize: 10.sp,
- fontWeight: FontWeight.w400,
- ),
- ),
- ],
- ),
- ],
- ),
- );
- },
- itemCount: controller.memberCardList.length,
- ),
- );
- }
- Widget _buildPrivacyTextSpan() {
- return Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Obx(() {
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () {
- controller.isAgree.value = !controller.isAgree.value;
- },
- child:
- controller.isAgree.value
- ? Assets.images.iconStoreAgreePrivacy.image(
- width: 16.w,
- height: 16.w,
- )
- : SizedBox(
- child: Container(
- padding: EdgeInsets.all(1.w),
- width: 16.w,
- height: 16.w,
- child: Container(
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- border: Border.all(
- color: Colors.black.withAlpha(153),
- width: 1.w,
- ),
- ),
- ),
- ),
- ),
- );
- }),
- Text.rich(
- TextSpan(
- children: [
- TextSpan(
- text: StringName.textSpanIHaveReadAndAgree,
- style: TextStyle(
- color: Colors.black.withAlpha(153),
- fontSize: 10.sp,
- fontWeight: FontWeight.w400,
- ),
- ),
- ClickTextSpan(
- text: StringName.textSpanPrivacyPolicy,
- url: WebUrl.privacyPolicy,
- ),
- TextSpan(
- text: StringName.textSpanAnd,
- style: TextStyle(
- color: Colors.black.withAlpha(153),
- fontSize: 10.sp,
- fontWeight: FontWeight.w400,
- ),
- ),
- ClickTextSpan(
- text: StringName.textSpanServiceTerms,
- url: WebUrl.serviceAgreement,
- ),
- ],
- ),
- ),
- ],
- );
- }
- }
|