discount_view.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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: SingleChildScrollView(
  31. child: Column(
  32. crossAxisAlignment: CrossAxisAlignment.center,
  33. children: [
  34. _AppBar(),
  35. _DiscountHeader(),
  36. SizedBox(height: 26.h),
  37. // 创建一个1分钟的倒计时
  38. CountdownTimer(duration: const Duration(minutes: 1)),
  39. SizedBox(height: 40.h),
  40. _DiscountFreeTrialSpecialRow(
  41. title: '3-DAY FREE TRIAL',
  42. desc: 'Then \$6.99/week only \$0.54/day',
  43. isSelected: isFreeItem,
  44. onSelect: (title) {
  45. if (isFreeItem) {
  46. controller.currentSelectedStoreItem.value = null;
  47. } else {
  48. controller.currentSelectedStoreItem.value = controller.storeItems.firstWhere((element) => element.freeTrialName != "");
  49. }
  50. },
  51. ),
  52. SizedBox(height: 40.h),
  53. _FeaturesPreview(),
  54. SizedBox(height: 40.h),
  55. _MorePlansSection(),
  56. SizedBox(height: 40.h),
  57. // 撑高
  58. SizedBox(height: 100.h),
  59. ],
  60. ),
  61. ),
  62. ),
  63. SafeArea(
  64. top: false,
  65. child: Column(
  66. mainAxisSize: MainAxisSize.min,
  67. children: [
  68. Spacer(),
  69. Container(
  70. decoration: BoxDecoration(
  71. gradient: LinearGradient(
  72. begin: Alignment.topCenter,
  73. end: Alignment.bottomCenter,
  74. colors: [
  75. "#05050D".color.withOpacity(0),
  76. "#05050D".color,
  77. ],
  78. ),
  79. ),
  80. height: 20.h,
  81. ),
  82. _PurchaseSection(
  83. isShowFree: isShowFree,
  84. controller: controller,
  85. ),
  86. ],
  87. ),
  88. ),
  89. ],
  90. ),
  91. );
  92. });
  93. }
  94. }
  95. class _AppBar extends StatelessWidget {
  96. const _AppBar({Key? key}) : super(key: key);
  97. @override
  98. Widget build(BuildContext context) {
  99. return Row(
  100. children: [
  101. Container(
  102. margin: EdgeInsets.only(left: 16.w, top: 14.h),
  103. child: GestureDetector(
  104. onTap: () {
  105. Get.back();
  106. },
  107. child: Assets.images.iconStoreClose
  108. .image(width: 28.w, height: 28.w),
  109. ),
  110. ),
  111. ],
  112. );
  113. }
  114. }
  115. class _DiscountHeader extends StatelessWidget {
  116. const _DiscountHeader({Key? key}) : super(key: key);
  117. @override
  118. Widget build(BuildContext context) {
  119. return Column(
  120. children: [
  121. Assets.images.iconDiscountTitle
  122. .image(width: 259.w, height: 55.h),
  123. SizedBox(height: 20.h),
  124. Assets.images.iconDiscountPercent
  125. .image(width: 195.w, height: 86.h),
  126. SizedBox(height: 13.h),
  127. Container(
  128. width: 197.w,
  129. height: 32.h,
  130. padding: EdgeInsets.all(1.w),
  131. decoration: BoxDecoration(
  132. gradient: LinearGradient(
  133. begin: Alignment.topCenter,
  134. end: Alignment.bottomCenter,
  135. colors: [
  136. '#CF9EFD'.color,
  137. '#4DCFFF'.color.withOpacity(0.5),
  138. ],
  139. ),
  140. borderRadius: BorderRadius.all(Radius.circular(18.r)),
  141. ),
  142. child: Container(
  143. decoration: BoxDecoration(
  144. color: "#05050D".color,
  145. borderRadius: BorderRadius.all(Radius.circular(18.r)),
  146. ),
  147. child: Center(
  148. child: Text(
  149. "Get CleanPro Premium",
  150. style: TextStyle(
  151. color: Colors.white,
  152. fontSize: 15.sp,
  153. fontWeight: FontWeight.w700,
  154. ),
  155. ),
  156. ),
  157. ),
  158. ),
  159. ],
  160. );
  161. }
  162. }
  163. class _FeaturesPreview extends StatelessWidget {
  164. const _FeaturesPreview({Key? key}) : super(key: key);
  165. @override
  166. Widget build(BuildContext context) {
  167. return InfinitePreviewPageView(
  168. height: 98.h,
  169. autoPlay: true,
  170. autoPlayDuration: const Duration(seconds: 5),
  171. items: [
  172. PreviewItem(
  173. title: 'One-click Remove Similar Photos',
  174. icon: Assets.images.iconStoreSimilar.image(),
  175. ),
  176. PreviewItem(
  177. title: 'Detect Blurry and Junk Photos',
  178. icon: Assets.images.iconStoreAi.image(),
  179. ),
  180. PreviewItem(
  181. title: 'Merge Duplicate Contacts',
  182. icon: Assets.images.iconStoreContacts.image(),
  183. ),
  184. PreviewItem(
  185. title: 'Premium Unlimited',
  186. icon: Assets.images.iconStorePremium.image(),
  187. ),
  188. ],
  189. showIndicator: true,
  190. );
  191. }
  192. }
  193. class _PurchaseSection extends StatelessWidget {
  194. final bool isShowFree;
  195. final DiscountController controller;
  196. const _PurchaseSection({
  197. Key? key,
  198. required this.isShowFree,
  199. required this.controller,
  200. }) : super(key: key);
  201. @override
  202. Widget build(BuildContext context) {
  203. return Column(
  204. children: [
  205. Text(
  206. isShowFree
  207. ? controller.currentSelectedStoreItem.value?.freeTrialName ?? ""
  208. : controller.currentSelectedStoreItem.value?.name ?? "",
  209. style: TextStyle(
  210. color: Colors.white,
  211. fontSize: 16.sp,
  212. fontWeight: FontWeight.w500,
  213. ),
  214. ),
  215. Text(
  216. isShowFree
  217. ? controller.currentSelectedStoreItem.value?.freeTrialPriceDesc ?? ""
  218. : controller.currentSelectedStoreItem.value?.priceDesc ?? "",
  219. style: TextStyle(
  220. color: Colors.white,
  221. fontSize: 13.sp,
  222. ),
  223. ),
  224. SizedBox(height: 14.h),
  225. GestureDetector(
  226. onTap: () {
  227. controller.onBuyClick();
  228. },
  229. child: Container(
  230. width: 312.w,
  231. height: 48.h,
  232. decoration: BoxDecoration(
  233. color: "#0279FB".color,
  234. borderRadius: BorderRadius.all(
  235. Radius.circular(24.r),
  236. ),
  237. ),
  238. child: Center(
  239. child: Text(
  240. isShowFree ? "START FREE TRIAL" : "START NOW",
  241. style: TextStyle(
  242. color: Colors.white,
  243. fontWeight: FontWeight.w700,
  244. fontSize: 16.sp,
  245. ),
  246. ),
  247. ),
  248. ),
  249. ),
  250. SizedBox(height: 5.h),
  251. Text(
  252. isShowFree ? "No payment now!" : "Cancel anytime",
  253. style: TextStyle(
  254. color: isShowFree ? "#57C87A".color : Colors.white,
  255. fontSize: 12.sp,
  256. fontWeight: FontWeight.w500,
  257. ),
  258. ),
  259. ],
  260. );
  261. }
  262. }
  263. class _MorePlansSection extends StatelessWidget {
  264. const _MorePlansSection({Key? key}) : super(key: key);
  265. @override
  266. Widget build(BuildContext context) {
  267. return Container(
  268. width: double.infinity,
  269. child: Row(
  270. mainAxisAlignment: MainAxisAlignment.center,
  271. children: [
  272. Assets.images.iconStoreMoreArrow.image(width: 8.w, height: 8.w),
  273. SizedBox(width: 5.w),
  274. Text("More Plans", style: TextStyle(color: 'ffffff'.color.withOpacity(0.7), fontSize: 12.sp, fontWeight: FontWeight.w400)),
  275. SizedBox(width: 5.w),
  276. Assets.images.iconStoreMoreArrow.image(width: 8.w, height: 8.w),
  277. ],
  278. ),
  279. );
  280. }
  281. }
  282. class _DiscountFreeTrialSpecialRow extends StatelessWidget {
  283. final String title;
  284. final String desc;
  285. final bool isSelected;
  286. final Function(String) onSelect;
  287. const _DiscountFreeTrialSpecialRow({Key? key, required this.title, required this.desc, required this.isSelected, required this.onSelect}) : super(key: key);
  288. @override
  289. Widget build(BuildContext context) {
  290. return Container(
  291. margin: EdgeInsets.symmetric(horizontal: 15.w),
  292. child: GestureDetector(
  293. onTap: () {
  294. onSelect(title);
  295. },
  296. child: Stack(
  297. alignment: Alignment.bottomRight,
  298. clipBehavior: Clip.none,
  299. children: [
  300. Positioned(
  301. bottom: -18.h,
  302. child: Container(
  303. alignment: Alignment.bottomCenter,
  304. height: 43.h,
  305. decoration: BoxDecoration(
  306. color: '#1B2231'.color,
  307. borderRadius: BorderRadius.circular(12.r),
  308. ),
  309. child: Padding(
  310. padding: EdgeInsets.only(top: 14.h, left: 7.w, right: 9.w, bottom: 2.h),
  311. child: Text(desc, style: TextStyle(color: '#ffffff'.color.withOpacity(0.7), fontSize: 12, fontWeight: FontWeight.w400)),
  312. )
  313. ),
  314. ),
  315. Container(
  316. padding: EdgeInsets.all(2),
  317. decoration: BoxDecoration(
  318. gradient: LinearGradient(
  319. begin: Alignment.topLeft,
  320. end: Alignment.bottomRight,
  321. colors: isSelected ? [
  322. '#D2A3FF'.color,
  323. '#419CFF'.color,
  324. '#01D0FF'.color,
  325. ] : [
  326. '#33FFFFFF'.color,
  327. '#33FFFFFF'.color,
  328. '#33FFFFFF'.color,
  329. ]
  330. ),
  331. borderRadius: BorderRadius.circular(20.r),
  332. ),
  333. child: Container(
  334. height: 74.w,
  335. decoration: BoxDecoration(
  336. color: isSelected ? '#111f4b'.color : '000000'.color,
  337. borderRadius: BorderRadius.circular(18.r),
  338. ),
  339. child: Stack(
  340. clipBehavior: Clip.none,
  341. children: [
  342. Padding(
  343. padding: EdgeInsets.symmetric(horizontal: 15),
  344. child: SizedBox(
  345. width: double.infinity,
  346. height: double.infinity,
  347. child: Column(
  348. mainAxisAlignment: MainAxisAlignment.center,
  349. crossAxisAlignment: CrossAxisAlignment.start,
  350. children: [
  351. Text(
  352. title,
  353. style: TextStyle(
  354. color: isSelected ? '#FFe168'.color : '#ffffff'.color,
  355. fontSize: 22.sp,
  356. fontWeight: FontWeight.w900,
  357. ),
  358. ),
  359. ],
  360. ),
  361. ),
  362. ),
  363. // 右上角FREE标签
  364. if (isSelected)
  365. Positioned(
  366. top: -14,
  367. right: 10,
  368. child:Stack(
  369. clipBehavior: Clip.none,
  370. alignment: Alignment.centerLeft,
  371. children: [
  372. Container(
  373. padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 4.h),
  374. decoration: BoxDecoration(
  375. gradient: LinearGradient(
  376. begin: Alignment.centerLeft,
  377. end: Alignment.centerRight,
  378. colors: [
  379. '#53CDFE'.color,
  380. '#0279FB'.color,
  381. ],
  382. ),
  383. borderRadius: BorderRadius.all(Radius.circular(20.w))
  384. ),
  385. child: Text(
  386. 'No payment now!',
  387. style: TextStyle(
  388. color: Colors.white,
  389. fontSize: 12.sp,
  390. ),
  391. ),
  392. ),
  393. Positioned(
  394. left: -22,
  395. child: Assets.images.iconStoreFree.image(width: 30.w, height: 30.w)
  396. )
  397. ],
  398. )
  399. ),
  400. ],
  401. ),
  402. ),
  403. )
  404. ],
  405. ),
  406. ),
  407. );
  408. }
  409. }