view.dart 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. import 'package:electronic_assistant/base/base_page.dart';
  2. import 'package:electronic_assistant/resource/assets.gen.dart';
  3. import 'package:electronic_assistant/resource/colors.gen.dart';
  4. import 'package:electronic_assistant/utils/expand.dart';
  5. import 'package:electronic_assistant/widget/login_code_btn.dart';
  6. import 'package:flutter/material.dart';
  7. import 'package:flutter/services.dart';
  8. import 'package:flutter_screenutil/flutter_screenutil.dart';
  9. import 'package:get/get.dart';
  10. import 'controller.dart';
  11. class StorePage extends BasePage<StoreController> {
  12. const StorePage({super.key});
  13. @override
  14. bool immersive() {
  15. return true;
  16. }
  17. @override
  18. Widget buildBody(BuildContext context) {
  19. return Stack(
  20. children: [
  21. SingleChildScrollView(
  22. scrollDirection: Axis.vertical,
  23. child: Stack(
  24. alignment: AlignmentDirectional.topStart,
  25. children: [
  26. _buildBackgroundGradient(),
  27. _buildTopBG(),
  28. Positioned(
  29. left: 12.w,
  30. top: 280,
  31. width: ScreenUtil().screenWidth - 24.w,
  32. child: Column(
  33. crossAxisAlignment: CrossAxisAlignment.start,
  34. children: [
  35. SizedBox(
  36. height: 20.h,
  37. child: Assets.images.iconStoreDescripe.image(),
  38. ),
  39. SizedBox(
  40. height: 16.h,
  41. ),
  42. _buildGoods(),
  43. SizedBox(
  44. height: 16.h,
  45. ),
  46. Text(
  47. "·该套餐约可倾听45小时",
  48. style: TextStyle(
  49. fontSize: 10.sp,
  50. color: "#AFAFAF".toColor(),
  51. ),
  52. ),
  53. SizedBox(
  54. height: 16.h,
  55. ),
  56. _buildPayMethod(),
  57. SizedBox(
  58. height: 39.h,
  59. ),
  60. _buildService(),
  61. ],
  62. ),
  63. ),
  64. ],
  65. ),
  66. ),
  67. _buildTopBar(),
  68. Positioned(
  69. bottom: 0,
  70. left: 0,
  71. right: 0,
  72. child: _buildBottombar(),
  73. ),
  74. ],
  75. );
  76. }
  77. // 背景颜色
  78. Widget _buildBackgroundGradient() {
  79. return Container(
  80. width: 1.sw,
  81. height: 1.sh,
  82. decoration: BoxDecoration(
  83. gradient: LinearGradient(
  84. colors: ['#071935'.toColor(), '#283B58'.toColor()],
  85. begin: Alignment.topCenter,
  86. end: Alignment.bottomCenter,
  87. stops: const [0.4, 1.0],
  88. ),
  89. ),
  90. );
  91. }
  92. // 顶部背景图片
  93. Widget _buildTopBG() {
  94. return Assets.images.bgStoreTop.image();
  95. }
  96. Widget _buildTopBar() {
  97. return Container(
  98. height: 44.h,
  99. margin: EdgeInsets.only(
  100. left: 0,
  101. right: 0,
  102. top: ScreenUtil().statusBarHeight,
  103. ),
  104. padding: EdgeInsets.symmetric(horizontal: 12.w),
  105. child: Row(
  106. children: [
  107. IconButton(
  108. onPressed: () {},
  109. icon: ImageIcon(
  110. Assets.images.iconArrowBackWhite.provider(),
  111. color: Colors.white,
  112. ),
  113. ),
  114. const Spacer(),
  115. Container(
  116. padding:
  117. EdgeInsets.only(left: 6.w, top: 6.h, bottom: 6.h, right: 12.w),
  118. decoration: BoxDecoration(
  119. color: "#01051C".toColor(),
  120. border: Border.all(
  121. color: "#7688B1".toColor(),
  122. width: 1,
  123. ),
  124. borderRadius: BorderRadius.circular(16.h),
  125. ),
  126. child: Row(
  127. children: [
  128. SizedBox(
  129. width: 20,
  130. child: Assets.images.iconStoreLogo.image(),
  131. ),
  132. SizedBox(
  133. width: 3.w,
  134. ),
  135. const Text(
  136. "电量 ",
  137. style: TextStyle(
  138. fontSize: 12,
  139. color: Colors.white,
  140. ),
  141. ),
  142. Text(
  143. "600",
  144. style: TextStyle(
  145. fontSize: 12,
  146. color: Colors.white,
  147. ),
  148. ),
  149. ],
  150. ),
  151. ),
  152. ],
  153. ),
  154. );
  155. }
  156. Widget _buildGoods() {
  157. return SizedBox(
  158. height: 154,
  159. child: ListView.builder(
  160. scrollDirection: Axis.horizontal,
  161. padding: const EdgeInsets.only(top: 0),
  162. itemBuilder: (context, index) {
  163. return _buildGoodItem();
  164. },
  165. itemCount: 4,
  166. ),
  167. );
  168. }
  169. Widget _buildGoodItem() {
  170. return Container(
  171. height: 154,
  172. width: 132,
  173. margin: const EdgeInsets.only(right: 10),
  174. child: Stack(
  175. clipBehavior: Clip.none,
  176. children: [
  177. Positioned(
  178. left: 0,
  179. top: 10,
  180. width: 132,
  181. height: 144,
  182. child: Container(
  183. padding: const EdgeInsets.all(2),
  184. decoration: BoxDecoration(
  185. borderRadius: BorderRadius.circular(12),
  186. gradient: LinearGradient(
  187. colors: ['#9075FF'.toColor(), '#4366FF'.toColor()],
  188. begin: Alignment.centerLeft,
  189. end: Alignment.centerRight,
  190. stops: const [0.0, 1.0],
  191. ),
  192. ),
  193. child: Container(
  194. width: 128,
  195. decoration: BoxDecoration(
  196. gradient: LinearGradient(
  197. colors: ['#FFF3F6'.toColor(), '#DADBFF'.toColor()],
  198. begin: Alignment.topCenter,
  199. end: Alignment.bottomCenter,
  200. stops: const [0.0, 1.0],
  201. ),
  202. borderRadius: BorderRadius.circular(12),
  203. ),
  204. child: Column(
  205. mainAxisAlignment: MainAxisAlignment.start,
  206. children: [
  207. SizedBox(
  208. height: 12,
  209. ),
  210. Text(
  211. "大电池",
  212. style: TextStyle(
  213. fontSize: 13,
  214. fontWeight: FontWeight.w700,
  215. color: "#6177F2".toColor(),
  216. ),
  217. ),
  218. Row(
  219. crossAxisAlignment: CrossAxisAlignment.end,
  220. mainAxisAlignment: MainAxisAlignment.center,
  221. mainAxisSize: MainAxisSize.min,
  222. children: [
  223. Container(
  224. margin: EdgeInsets.only(bottom: 9),
  225. child: Text(
  226. "¥",
  227. style: TextStyle(
  228. fontSize: 16,
  229. color: "#6177F2".toColor(),
  230. ),
  231. ),
  232. ),
  233. Text(
  234. "198",
  235. textAlign: TextAlign.center,
  236. style: TextStyle(
  237. fontSize: 39,
  238. fontWeight: FontWeight.bold,
  239. color: "#6177F2".toColor(),
  240. ),
  241. ),
  242. ],
  243. ),
  244. Text(
  245. "¥258",
  246. style: TextStyle(
  247. color: "#AFAFAF".toColor(),
  248. decoration: TextDecoration.lineThrough,
  249. decorationColor: "#AFAFAF".toColor(),
  250. fontSize: 14.0,
  251. ),
  252. ),
  253. Container(
  254. padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
  255. decoration: BoxDecoration(
  256. gradient: LinearGradient(
  257. colors: ['#9075FF'.toColor(), '#4366FF'.toColor()],
  258. begin: Alignment.topCenter,
  259. end: Alignment.bottomCenter,
  260. stops: const [0.0, 1.0],
  261. ),
  262. borderRadius: BorderRadius.circular(12),
  263. ),
  264. child: Row(
  265. mainAxisSize: MainAxisSize.min,
  266. children: [
  267. SizedBox(
  268. width: 16,
  269. child: Assets.images.iconStoreGoodFlash.image(),
  270. ),
  271. Text(
  272. "550电量",
  273. style: TextStyle(
  274. fontSize: 13,
  275. color: Colors.white,
  276. ),
  277. )
  278. ],
  279. ),
  280. )
  281. ],
  282. ),
  283. ),
  284. ),
  285. ),
  286. Stack(
  287. children: [
  288. Container(
  289. height: 29,
  290. child: Assets.images.iconStoreGoodTag.image(),
  291. ),
  292. Positioned(
  293. left: 8,
  294. top: 2,
  295. child: Text(
  296. "最多人买",
  297. style: TextStyle(
  298. fontSize: 12,
  299. fontWeight: FontWeight.w500,
  300. color: "#703D27".toColor(),
  301. ),
  302. ),
  303. ),
  304. ],
  305. ),
  306. ],
  307. ),
  308. );
  309. }
  310. Widget _buildTopPayMethod(Image icon, String title) {
  311. return Row(
  312. children: [
  313. SizedBox(
  314. width: 20.w,
  315. child: icon,
  316. ),
  317. const SizedBox(
  318. width: 6,
  319. ),
  320. Text(
  321. title,
  322. style: TextStyle(color: Colors.white, fontSize: 14.sp),
  323. ),
  324. ],
  325. );
  326. }
  327. Widget _buildPayMethod() {
  328. return Column(
  329. children: [
  330. Row(
  331. children: [
  332. Text(
  333. "支付方式",
  334. style: TextStyle(
  335. fontSize: 14.sp,
  336. color: Colors.white,
  337. fontWeight: FontWeight.w500,
  338. ),
  339. ),
  340. const Spacer(),
  341. Obx(() {
  342. return GestureDetector(
  343. onTap: () {
  344. controller.isExpanded.value = !controller.isExpanded.value;
  345. },
  346. child: Row(
  347. children: [
  348. Visibility(
  349. visible: !controller.isExpanded.value,
  350. child: _buildTopPayMethod(
  351. Assets.images.iconStoreAlipay.image(),
  352. "支付宝",
  353. ),
  354. ),
  355. Visibility(
  356. visible: controller.isExpanded.value,
  357. child: Text(
  358. "收起",
  359. style: TextStyle(
  360. fontSize: 14.sp,
  361. color: Colors.white,
  362. ),
  363. ),
  364. ),
  365. Container(
  366. width: 16.w,
  367. child: controller.isExpanded.value
  368. ? Assets.images.iconArrowUpWhite.image()
  369. : Assets.images.iconArrowDownWhite.image(),
  370. ),
  371. ],
  372. ),
  373. );
  374. }),
  375. ],
  376. ),
  377. Obx(() {
  378. return Visibility(
  379. visible: controller.isExpanded.value,
  380. child: SizedBox(
  381. height: 2 * 32,
  382. child: ListView.builder(
  383. padding: const EdgeInsets.only(top: 0),
  384. physics: const NeverScrollableScrollPhysics(),
  385. itemBuilder: (context, index) {
  386. return _buildPayItem(
  387. Assets.images.iconStoreAlipay.image().obs.value,
  388. "支付宝",
  389. true);
  390. },
  391. itemCount: 2,
  392. ),
  393. ),
  394. );
  395. }),
  396. ],
  397. );
  398. }
  399. Widget _buildPayItem(Image icon, String title, bool isSelect) {
  400. return Container(
  401. height: 20.h,
  402. margin: const EdgeInsets.only(top: 12),
  403. child: Row(
  404. children: [
  405. SizedBox(
  406. width: 20.w,
  407. child: icon,
  408. ),
  409. const SizedBox(
  410. width: 6,
  411. ),
  412. Text(
  413. title,
  414. style: TextStyle(color: Colors.white, fontSize: 14.sp),
  415. ),
  416. const Spacer(),
  417. GestureDetector(
  418. onTap: () {
  419. // controller.isAgree.value = !controller.isAgree.value;
  420. },
  421. child: SizedBox(
  422. width: 20.w,
  423. height: 20.w,
  424. child: isSelect
  425. ? Assets.images.iconSelectTrue.image()
  426. : Assets.images.iconSelectFalse.image(),
  427. ),
  428. ),
  429. ],
  430. ),
  431. );
  432. }
  433. Widget _buildService() {
  434. return Column(
  435. children: [
  436. Row(
  437. children: [
  438. Container(
  439. width: 4.w,
  440. height: 16.h,
  441. decoration: BoxDecoration(
  442. color: Colors.white,
  443. borderRadius: BorderRadius.circular(2),
  444. gradient: LinearGradient(
  445. colors: ['#357AFF'.toColor(), '#E389FF'.toColor()],
  446. begin: Alignment.topCenter,
  447. end: Alignment.bottomCenter,
  448. stops: const [0.0, 1.0],
  449. ),
  450. ),
  451. ),
  452. SizedBox(
  453. width: 6.w,
  454. ),
  455. Text(
  456. "多种专属服务·高效辅助办公",
  457. style: TextStyle(
  458. fontSize: 15.sp,
  459. color: Colors.white,
  460. fontWeight: FontWeight.w500,
  461. ),
  462. ),
  463. ],
  464. ),
  465. Container(
  466. padding: EdgeInsets.only(
  467. left: 9,
  468. right: 9,
  469. top: 16,
  470. ),
  471. child: Row(
  472. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  473. children: [
  474. _buildServiceItem(
  475. Assets.images.iconStoreServiceSum.image(),
  476. "智能谈话总结",
  477. ),
  478. _buildServiceItem(
  479. Assets.images.iconStoreServiceRemain.image(),
  480. "待办任务处理",
  481. ),
  482. _buildServiceItem(
  483. Assets.images.iconStoreServiceAdvice.image(),
  484. "专业工作建议",
  485. ),
  486. _buildServiceItem(
  487. Assets.images.iconStoreServiceDeal.image(),
  488. "处理交代事宜",
  489. ),
  490. ],
  491. ),
  492. ),
  493. SizedBox(
  494. height: 26.h,
  495. ),
  496. Container(
  497. width: double.infinity,
  498. padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
  499. decoration: BoxDecoration(
  500. color: "#40567D".toColor().withOpacity(0.2),
  501. borderRadius: BorderRadius.circular(8),
  502. ),
  503. child: Column(
  504. crossAxisAlignment: CrossAxisAlignment.start,
  505. children: [
  506. Text(
  507. "扣电规则",
  508. style: TextStyle(
  509. fontSize: 12,
  510. fontWeight: FontWeight.w500,
  511. color: Colors.white.withOpacity(0.6),
  512. ),
  513. ),
  514. SizedBox(
  515. height: 6.h,
  516. ),
  517. Text(
  518. "1、小听每听5分钟扣1电量,不满5分钟按5分钟算。",
  519. style: TextStyle(
  520. fontSize: 12,
  521. color: Colors.white.withOpacity(0.6),
  522. ),
  523. ),
  524. Text(
  525. "2、大文件、超大文件生成新的总结,每次扣1电量。",
  526. style: TextStyle(
  527. fontSize: 12,
  528. fontWeight: FontWeight.w500,
  529. color: Colors.white.withOpacity(0.6),
  530. ),
  531. ),
  532. Text(
  533. "3、用大文件和小听对话,每次对话扣1电量。",
  534. style: TextStyle(
  535. fontSize: 12,
  536. fontWeight: FontWeight.w500,
  537. color: Colors.white.withOpacity(0.6),
  538. ),
  539. ),
  540. ],
  541. ),
  542. ),
  543. ],
  544. );
  545. }
  546. Widget _buildServiceItem(Image icon, String title) {
  547. return Column(
  548. children: [
  549. SizedBox(
  550. width: 32.w,
  551. child: icon,
  552. ),
  553. SizedBox(
  554. height: 2.h,
  555. ),
  556. Text(
  557. title,
  558. style: TextStyle(
  559. color: ColorName.white.withOpacity(0.8),
  560. fontSize: 11.sp,
  561. ),
  562. ),
  563. ],
  564. );
  565. }
  566. Widget _buildBottombar() {
  567. return Container(
  568. padding: EdgeInsets.only(
  569. left: 16.w,
  570. right: 16.w,
  571. top: 12.h,
  572. bottom: ScreenUtil().bottomBarHeight + 12.h),
  573. alignment: Alignment.topCenter,
  574. decoration: BoxDecoration(
  575. color: "#283B58".toColor(),
  576. boxShadow: const [
  577. BoxShadow(
  578. color: Color.fromARGB(1, 42, 48, 59), // 阴影颜色
  579. spreadRadius: 0, // 阴影扩散半径
  580. blurRadius: 20, // 阴影模糊半径
  581. offset: Offset(0, 0), // 阴影偏移量
  582. ),
  583. ],
  584. borderRadius: BorderRadius.only(
  585. topLeft: Radius.circular(12.w),
  586. topRight: Radius.circular(12.w),
  587. ),
  588. ),
  589. child: GestureDetector(
  590. onTap: () {
  591. // print(ScreenUtil().bottomBarHeight);
  592. },
  593. child: Container(
  594. height: 48.h,
  595. alignment: Alignment.center,
  596. decoration: BoxDecoration(
  597. gradient: LinearGradient(
  598. colors: ['#9075FF'.toColor(), '#4366FF'.toColor()],
  599. begin: Alignment.centerRight,
  600. end: Alignment.centerRight,
  601. stops: const [0.0, 1.0],
  602. ),
  603. borderRadius: BorderRadius.circular(8.h),
  604. ),
  605. child: Row(
  606. mainAxisAlignment: MainAxisAlignment.center,
  607. children: [
  608. Text(
  609. "立即购买",
  610. style: TextStyle(
  611. color: Colors.white,
  612. fontSize: 16.sp,
  613. fontWeight: FontWeight.w500,
  614. ),
  615. ),
  616. SizedBox(
  617. width: 4.w,
  618. ),
  619. Text(
  620. "¥198",
  621. style: TextStyle(
  622. color: Colors.white,
  623. fontSize: 18.sp,
  624. fontWeight: FontWeight.w500,
  625. ),
  626. ),
  627. ],
  628. ),
  629. ),
  630. ),
  631. );
  632. }
  633. }