discount_view.dart 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. import 'dart:async';
  2. import 'package:clean/base/base_page.dart';
  3. import 'package:clean/module/store/discount/discount_controller.dart';
  4. import 'package:clean/utils/expand.dart';
  5. import 'package:flutter/Material.dart';
  6. import 'package:flutter_screenutil/flutter_screenutil.dart';
  7. import 'package:get/get.dart';
  8. import '../../../resource/assets.gen.dart';
  9. import 'count_down_timer.dart';
  10. import 'func_page_view.dart';
  11. class DiscountPage extends BasePage<DiscountController> {
  12. const DiscountPage({super.key});
  13. @override
  14. bool immersive() {
  15. return true;
  16. }
  17. @override
  18. bool statusBarDarkFont() => false;
  19. @override
  20. Widget buildBody(BuildContext context) {
  21. return Obx(() {
  22. bool isFreeItem =
  23. (controller.currentSelectedStoreItem.value?.freeTrialName != null);
  24. bool isShowFree = isFreeItem && controller.isFree.value;
  25. return Scaffold(
  26. backgroundColor: "#05050D".color,
  27. body: Stack(
  28. children: [
  29. SafeArea(
  30. child: Column(
  31. crossAxisAlignment: CrossAxisAlignment.center,
  32. children: [
  33. _AppBar(),
  34. _DiscountHeader(),
  35. SizedBox(height: 26.h),
  36. // 创建一个1分钟的倒计时
  37. CountdownTimer(duration: const Duration(minutes: 1)),
  38. SizedBox(height: 40.h),
  39. _FeaturesPreview(),
  40. Spacer(),
  41. _PurchaseSection(
  42. isShowFree: isShowFree,
  43. controller: controller,
  44. ),
  45. ],
  46. ),
  47. ),
  48. ],
  49. ),
  50. );
  51. });
  52. }
  53. }
  54. class _AppBar extends StatelessWidget {
  55. const _AppBar({Key? key}) : super(key: key);
  56. @override
  57. Widget build(BuildContext context) {
  58. return Row(
  59. children: [
  60. Container(
  61. margin: EdgeInsets.only(left: 16.w, top: 14.h),
  62. child: GestureDetector(
  63. onTap: () {
  64. Get.back();
  65. },
  66. child: Assets.images.iconStoreClose
  67. .image(width: 28.w, height: 28.w),
  68. ),
  69. ),
  70. ],
  71. );
  72. }
  73. }
  74. class _DiscountHeader extends StatelessWidget {
  75. const _DiscountHeader({Key? key}) : super(key: key);
  76. @override
  77. Widget build(BuildContext context) {
  78. return Column(
  79. children: [
  80. Assets.images.iconDiscountTitle
  81. .image(width: 259.w, height: 55.h),
  82. SizedBox(height: 20.h),
  83. Assets.images.iconDiscountPercent
  84. .image(width: 195.w, height: 86.h),
  85. SizedBox(height: 13.h),
  86. Container(
  87. width: 197.w,
  88. height: 32.h,
  89. padding: EdgeInsets.all(1.w),
  90. decoration: BoxDecoration(
  91. gradient: LinearGradient(
  92. begin: Alignment.topCenter,
  93. end: Alignment.bottomCenter,
  94. colors: [
  95. '#CF9EFD'.color,
  96. '#4DCFFF'.color.withOpacity(0.5),
  97. ],
  98. ),
  99. borderRadius: BorderRadius.all(Radius.circular(18.r)),
  100. ),
  101. child: Container(
  102. decoration: BoxDecoration(
  103. color: "#05050D".color,
  104. borderRadius: BorderRadius.all(Radius.circular(18.r)),
  105. ),
  106. child: Center(
  107. child: Text(
  108. "Get CleanPro Premium",
  109. style: TextStyle(
  110. color: Colors.white,
  111. fontSize: 15.sp,
  112. fontWeight: FontWeight.w700,
  113. ),
  114. ),
  115. ),
  116. ),
  117. ),
  118. ],
  119. );
  120. }
  121. }
  122. class _FeaturesPreview extends StatelessWidget {
  123. const _FeaturesPreview({Key? key}) : super(key: key);
  124. @override
  125. Widget build(BuildContext context) {
  126. return InfinitePreviewPageView(
  127. height: 98.h,
  128. autoPlay: true,
  129. autoPlayDuration: const Duration(seconds: 5),
  130. items: [
  131. PreviewItem(
  132. title: 'One-click Remove Similar Photos',
  133. icon: Assets.images.iconStoreSimilar.image(),
  134. ),
  135. PreviewItem(
  136. title: 'Detect Blurry and Junk Photos',
  137. icon: Assets.images.iconStoreAi.image(),
  138. ),
  139. PreviewItem(
  140. title: 'Merge Duplicate Contacts',
  141. icon: Assets.images.iconStoreContacts.image(),
  142. ),
  143. PreviewItem(
  144. title: 'Premium Unlimited',
  145. icon: Assets.images.iconStorePremium.image(),
  146. ),
  147. ],
  148. );
  149. }
  150. }
  151. class _PurchaseSection extends StatelessWidget {
  152. final bool isShowFree;
  153. final DiscountController controller;
  154. const _PurchaseSection({
  155. Key? key,
  156. required this.isShowFree,
  157. required this.controller,
  158. }) : super(key: key);
  159. @override
  160. Widget build(BuildContext context) {
  161. return Column(
  162. children: [
  163. Text(
  164. isShowFree
  165. ? controller.currentSelectedStoreItem.value?.freeTrialName ?? ""
  166. : controller.currentSelectedStoreItem.value?.name ?? "",
  167. style: TextStyle(
  168. color: Colors.white,
  169. fontSize: 16.sp,
  170. fontWeight: FontWeight.w500,
  171. ),
  172. ),
  173. Text(
  174. isShowFree
  175. ? controller.currentSelectedStoreItem.value?.freeTrialPriceDesc ?? ""
  176. : controller.currentSelectedStoreItem.value?.priceDesc ?? "",
  177. style: TextStyle(
  178. color: Colors.white,
  179. fontSize: 13.sp,
  180. ),
  181. ),
  182. SizedBox(height: 14.h),
  183. GestureDetector(
  184. onTap: () {
  185. controller.onBuyClick();
  186. },
  187. child: Container(
  188. width: 312.w,
  189. height: 48.h,
  190. decoration: BoxDecoration(
  191. color: "#0279FB".color,
  192. borderRadius: BorderRadius.all(
  193. Radius.circular(24.r),
  194. ),
  195. ),
  196. child: Center(
  197. child: Text(
  198. isShowFree ? "START FREE TRIAL" : "START NOW",
  199. style: TextStyle(
  200. color: Colors.white,
  201. fontWeight: FontWeight.w700,
  202. fontSize: 16.sp,
  203. ),
  204. ),
  205. ),
  206. ),
  207. ),
  208. SizedBox(height: 5.h),
  209. Text(
  210. isShowFree ? "No payment now!" : "Cancel anytime",
  211. style: TextStyle(
  212. color: isShowFree ? "#57C87A".color : Colors.white,
  213. fontSize: 12.sp,
  214. fontWeight: FontWeight.w500,
  215. ),
  216. ),
  217. ],
  218. );
  219. }
  220. }