discount_view.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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. );
  190. }
  191. }
  192. class _PurchaseSection extends StatelessWidget {
  193. final bool isShowFree;
  194. final DiscountController controller;
  195. const _PurchaseSection({
  196. Key? key,
  197. required this.isShowFree,
  198. required this.controller,
  199. }) : super(key: key);
  200. @override
  201. Widget build(BuildContext context) {
  202. return Column(
  203. children: [
  204. Text(
  205. isShowFree
  206. ? controller.currentSelectedStoreItem.value?.freeTrialName ?? ""
  207. : controller.currentSelectedStoreItem.value?.name ?? "",
  208. style: TextStyle(
  209. color: Colors.white,
  210. fontSize: 16.sp,
  211. fontWeight: FontWeight.w500,
  212. ),
  213. ),
  214. Text(
  215. isShowFree
  216. ? controller.currentSelectedStoreItem.value?.freeTrialPriceDesc ?? ""
  217. : controller.currentSelectedStoreItem.value?.priceDesc ?? "",
  218. style: TextStyle(
  219. color: Colors.white,
  220. fontSize: 13.sp,
  221. ),
  222. ),
  223. SizedBox(height: 14.h),
  224. GestureDetector(
  225. onTap: () {
  226. controller.onBuyClick();
  227. },
  228. child: Container(
  229. width: 312.w,
  230. height: 48.h,
  231. decoration: BoxDecoration(
  232. color: "#0279FB".color,
  233. borderRadius: BorderRadius.all(
  234. Radius.circular(24.r),
  235. ),
  236. ),
  237. child: Center(
  238. child: Text(
  239. isShowFree ? "START FREE TRIAL" : "START NOW",
  240. style: TextStyle(
  241. color: Colors.white,
  242. fontWeight: FontWeight.w700,
  243. fontSize: 16.sp,
  244. ),
  245. ),
  246. ),
  247. ),
  248. ),
  249. SizedBox(height: 5.h),
  250. Text(
  251. isShowFree ? "No payment now!" : "Cancel anytime",
  252. style: TextStyle(
  253. color: isShowFree ? "#57C87A".color : Colors.white,
  254. fontSize: 12.sp,
  255. fontWeight: FontWeight.w500,
  256. ),
  257. ),
  258. ],
  259. );
  260. }
  261. }
  262. class _MorePlansSection extends StatelessWidget {
  263. const _MorePlansSection({Key? key}) : super(key: key);
  264. @override
  265. Widget build(BuildContext context) {
  266. return Container(
  267. width: double.infinity,
  268. child: Row(
  269. mainAxisAlignment: MainAxisAlignment.center,
  270. children: [
  271. Assets.images.iconStoreMoreArrow.image(width: 8.w, height: 8.w),
  272. SizedBox(width: 5.w),
  273. Text("More Plans", style: TextStyle(color: 'ffffff'.color.withOpacity(0.7), fontSize: 12.sp, fontWeight: FontWeight.w400)),
  274. SizedBox(width: 5.w),
  275. Assets.images.iconStoreMoreArrow.image(width: 8.w, height: 8.w),
  276. ],
  277. ),
  278. );
  279. }
  280. }
  281. class _DiscountFreeTrialSpecialRow extends StatelessWidget {
  282. final String title;
  283. final String desc;
  284. final bool isSelected;
  285. final Function(String) onSelect;
  286. const _DiscountFreeTrialSpecialRow({Key? key, required this.title, required this.desc, required this.isSelected, required this.onSelect}) : super(key: key);
  287. @override
  288. Widget build(BuildContext context) {
  289. return Container(
  290. margin: EdgeInsets.symmetric(horizontal: 15.w),
  291. child: GestureDetector(
  292. onTap: () {
  293. onSelect(title);
  294. },
  295. child: Stack(
  296. alignment: Alignment.bottomRight,
  297. clipBehavior: Clip.none,
  298. children: [
  299. Positioned(
  300. bottom: -18.h,
  301. child: Container(
  302. alignment: Alignment.bottomCenter,
  303. height: 43.h,
  304. decoration: BoxDecoration(
  305. color: '#1B2231'.color,
  306. borderRadius: BorderRadius.circular(12.r),
  307. ),
  308. child: Padding(
  309. padding: EdgeInsets.only(top: 14.h, left: 7.w, right: 9.w, bottom: 2.h),
  310. child: Text(desc, style: TextStyle(color: '#ffffff'.color.withOpacity(0.7), fontSize: 12, fontWeight: FontWeight.w400)),
  311. )
  312. ),
  313. ),
  314. Container(
  315. padding: EdgeInsets.all(2),
  316. decoration: BoxDecoration(
  317. gradient: LinearGradient(
  318. begin: Alignment.topLeft,
  319. end: Alignment.bottomRight,
  320. colors: isSelected ? [
  321. '#D2A3FF'.color,
  322. '#419CFF'.color,
  323. '#01D0FF'.color,
  324. ] : [
  325. '#33FFFFFF'.color,
  326. '#33FFFFFF'.color,
  327. '#33FFFFFF'.color,
  328. ]
  329. ),
  330. borderRadius: BorderRadius.circular(20.r),
  331. ),
  332. child: Container(
  333. height: 74.w,
  334. decoration: BoxDecoration(
  335. color: isSelected ? '#111f4b'.color : '000000'.color,
  336. borderRadius: BorderRadius.circular(18.r),
  337. ),
  338. child: Stack(
  339. clipBehavior: Clip.none,
  340. children: [
  341. Padding(
  342. padding: EdgeInsets.symmetric(horizontal: 15),
  343. child: SizedBox(
  344. width: double.infinity,
  345. height: double.infinity,
  346. child: Column(
  347. mainAxisAlignment: MainAxisAlignment.center,
  348. crossAxisAlignment: CrossAxisAlignment.start,
  349. children: [
  350. Text(
  351. title,
  352. style: TextStyle(
  353. color: isSelected ? '#FFe168'.color : '#ffffff'.color,
  354. fontSize: 22.sp,
  355. fontWeight: FontWeight.w900,
  356. ),
  357. ),
  358. ],
  359. ),
  360. ),
  361. ),
  362. // 右上角FREE标签
  363. if (isSelected)
  364. Positioned(
  365. top: -14,
  366. right: 10,
  367. child:Stack(
  368. clipBehavior: Clip.none,
  369. alignment: Alignment.centerLeft,
  370. children: [
  371. Container(
  372. padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 4.h),
  373. decoration: BoxDecoration(
  374. gradient: LinearGradient(
  375. begin: Alignment.centerLeft,
  376. end: Alignment.centerRight,
  377. colors: [
  378. '#53CDFE'.color,
  379. '#0279FB'.color,
  380. ],
  381. ),
  382. borderRadius: BorderRadius.all(Radius.circular(20.w))
  383. ),
  384. child: Text(
  385. 'No payment now!',
  386. style: TextStyle(
  387. color: Colors.white,
  388. fontSize: 12.sp,
  389. ),
  390. ),
  391. ),
  392. Positioned(
  393. left: -22,
  394. child: Assets.images.iconStoreFree.image(width: 30.w, height: 30.w)
  395. )
  396. ],
  397. )
  398. ),
  399. ],
  400. ),
  401. ),
  402. )
  403. ],
  404. ),
  405. ),
  406. );
  407. }
  408. }