discount_view.dart 14 KB

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