new_user_result_page.dart 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/rendering.dart';
  4. import 'package:flutter/src/widgets/framework.dart';
  5. import 'package:flutter_screenutil/flutter_screenutil.dart';
  6. import 'package:keyboard/base/base_page.dart';
  7. import 'package:get/get.dart';
  8. import 'package:keyboard/data/bean/keyboard_info.dart';
  9. import 'package:keyboard/resource/string.gen.dart';
  10. import 'package:keyboard/utils/age_zodiac_sign_util.dart';
  11. import 'package:lottie/lottie.dart';
  12. import '../../../data/bean/character_info.dart';
  13. import '../../../resource/assets.gen.dart';
  14. import '../../../router/app_pages.dart';
  15. import '../../../widget/auto_scroll_list_view.dart';
  16. import '../../../widget/avatar/avatar_image_widget.dart';
  17. import 'new_user_result_controller.dart';
  18. class NewUserResultPage extends BasePage<NewUserResultController> {
  19. const NewUserResultPage({super.key});
  20. static start({required KeyboardInfo newUserKeyboardInfo}) {
  21. Get.toNamed(
  22. RoutePath.newUserResult,
  23. arguments: {"newUserKeyboardInfo": newUserKeyboardInfo},
  24. );
  25. }
  26. @override
  27. bool immersive() {
  28. return true;
  29. }
  30. @override
  31. bool statusBarDarkFont() {
  32. return false;
  33. }
  34. @override
  35. Widget buildBody(BuildContext context) {
  36. return Stack(
  37. children: [
  38. Assets.images.bgNewUserResult.image(
  39. width: double.infinity,
  40. fit: BoxFit.fill,
  41. ),
  42. SafeArea(
  43. child: Column(
  44. crossAxisAlignment: CrossAxisAlignment.start,
  45. children: [
  46. Padding(
  47. padding: EdgeInsets.only(left: 16.w, top: 12.w),
  48. child: GestureDetector(
  49. onTap: () {
  50. controller.clickBack();
  51. },
  52. child: Assets.images.iconCharacterCustomClose.image(
  53. width: 24.w,
  54. height: 24.w,
  55. ),
  56. ),
  57. ),
  58. Expanded(
  59. child: Column(
  60. mainAxisAlignment: MainAxisAlignment.end,
  61. crossAxisAlignment: CrossAxisAlignment.center,
  62. children: [
  63. // SizedBox(height: 30.w),
  64. Center(
  65. child: Assets.images.iconNewUserResultTitle.image(
  66. width: 246.w,
  67. height: 41.2.w,
  68. fit: BoxFit.contain,
  69. ),
  70. ),
  71. SizedBox(height: 20.w),
  72. _buildAvatarCard(),
  73. SizedBox(height: 12.w),
  74. _buildZodiacDesc(),
  75. SizedBox(height: 20.w),
  76. buildCharacterList(),
  77. SizedBox(height: 30.w),
  78. buildOpenNowButton(),
  79. ],
  80. ),
  81. ),
  82. ],
  83. ),
  84. ),
  85. ],
  86. );
  87. }
  88. Widget _buildZodiacDesc() {
  89. return Obx(() {
  90. if (controller.keyboardMemeExplain.value.meme == null ||
  91. controller.keyboardMemeExplain.value.explain == null) {
  92. return SizedBox(width: 278.w);
  93. }
  94. return Row(
  95. mainAxisAlignment: MainAxisAlignment.center,
  96. children: [
  97. Stack(
  98. alignment: Alignment.center,
  99. children: [
  100. Container(
  101. alignment: Alignment.center,
  102. padding: EdgeInsets.only(
  103. left: 19.w,
  104. right: 19.w,
  105. top: 7.w,
  106. bottom: 7.w,
  107. ),
  108. decoration: ShapeDecoration(
  109. color: const Color(0x28B70080),
  110. shape: RoundedRectangleBorder(
  111. borderRadius: BorderRadius.circular(16.r),
  112. ),
  113. ),
  114. child: SizedBox(
  115. width: 278.w,
  116. child: Text(
  117. "${controller.keyboardMemeExplain.value.meme ?? ""}\n${controller.keyboardMemeExplain.value.explain ?? ""}",
  118. style: TextStyle(
  119. color: Colors.white.withAlpha(229),
  120. fontSize: 12.sp,
  121. fontWeight: FontWeight.w500,
  122. ),
  123. ),
  124. ),
  125. ),
  126. Positioned(
  127. top: 0.w,
  128. left: 8.w,
  129. child: Assets.images.iconNewUserZodiacLeft.image(
  130. width: 16.w,
  131. height: 16.w,
  132. fit: BoxFit.contain,
  133. ),
  134. ),
  135. Positioned(
  136. right: 8.w,
  137. bottom: 0.w,
  138. child: Assets.images.iconNewUserZodiacRight.image(
  139. width: 16.w,
  140. height: 16.w,
  141. fit: BoxFit.contain,
  142. ),
  143. ),
  144. ],
  145. ),
  146. ],
  147. );
  148. });
  149. }
  150. Widget _buildAvatarCard() {
  151. return Stack(
  152. alignment: Alignment.center,
  153. children: [
  154. Row(
  155. mainAxisAlignment: MainAxisAlignment.center,
  156. children: [
  157. Column(
  158. children: [
  159. SizedBox(height: 20.w),
  160. CircleAvatarWidget(
  161. image: Assets.images.iconKeyboardDefaultAvatar.provider(),
  162. imageUrl: controller.userInfo?.imageUrl,
  163. size: 88.w,
  164. borderColor: Colors.white,
  165. borderWidth: 2.r,
  166. placeholder: (_, __) => const SizedBox.shrink(),
  167. ),
  168. SizedBox(height: 14.w),
  169. Obx(() {
  170. final zodiac = controller.zodiacLabelFromUserInfo;
  171. if (zodiac != null) {
  172. return Row(
  173. children: [
  174. zodiac.image.image(width: 14.w, height: 14.w),
  175. SizedBox(width: 4.w),
  176. Text(
  177. zodiac.name,
  178. style: TextStyle(
  179. color: Colors.white,
  180. fontSize: 14.97.sp,
  181. fontWeight: FontWeight.w700,
  182. ),
  183. ),
  184. ],
  185. );
  186. } else {
  187. return const SizedBox.shrink();
  188. }
  189. }),
  190. ],
  191. ),
  192. Lottie.asset(
  193. Assets.anim.animNewUserData,
  194. repeat: true,
  195. width: 131.w,
  196. fit: BoxFit.contain,
  197. ),
  198. Column(
  199. children: [
  200. SizedBox(height: 20.w),
  201. CircleAvatarWidget(
  202. image: Assets.images.iconKeyboardDefaultAvatar.provider(),
  203. imageUrl: controller.newUserKeyboardInfo.imageUrl,
  204. size: 88.w,
  205. borderColor: Colors.white,
  206. borderWidth: 2.r,
  207. placeholder: (_, __) => const SizedBox.shrink(),
  208. ),
  209. SizedBox(height: 14.w),
  210. Obx(() {
  211. final zodiac = controller.zodiacLabelFromNewUserKeyboardInfo;
  212. if (zodiac != null) {
  213. return Row(
  214. children: [
  215. zodiac.image.image(width: 14.w, height: 14.w),
  216. SizedBox(width: 4.w),
  217. Text(
  218. zodiac.name,
  219. style: TextStyle(
  220. color: Colors.white,
  221. fontSize: 14.97.sp,
  222. fontWeight: FontWeight.w700,
  223. ),
  224. ),
  225. ],
  226. );
  227. } else {
  228. return const SizedBox.shrink();
  229. }
  230. }),
  231. ],
  232. ),
  233. ],
  234. ),
  235. ],
  236. );
  237. }
  238. Widget buildCharacterList() {
  239. return Obx(() {
  240. if (controller.charactersList.isEmpty) {
  241. return const SizedBox.shrink();
  242. }
  243. return Container(
  244. padding: EdgeInsets.only(top: 20.w),
  245. decoration: ShapeDecoration(
  246. color: Colors.white,
  247. shape: RoundedRectangleBorder(
  248. borderRadius: BorderRadius.circular(28.r),
  249. ),
  250. ),
  251. margin: EdgeInsets.only(left: 16.w, right: 16.w),
  252. child: Column(
  253. children: [
  254. Row(
  255. crossAxisAlignment: CrossAxisAlignment.center,
  256. mainAxisAlignment: MainAxisAlignment.center,
  257. children: [
  258. Assets.images.iconNewUserResultLoveLeft.image(
  259. width: 12.w,
  260. height: 12.w,
  261. fit: BoxFit.contain,
  262. ),
  263. Text(
  264. '${StringName.newUserResultIntimacyTitle} ${controller.newUserKeyboardInfo.intimacy ?? "0"}%',
  265. textAlign: TextAlign.center,
  266. style: TextStyle(
  267. color: Colors.black.withAlpha(204),
  268. fontSize: 14.sp,
  269. fontWeight: FontWeight.w700,
  270. ),
  271. ),
  272. Assets.images.iconNewUserResultLoveRight.image(
  273. width: 12.w,
  274. height: 12.w,
  275. fit: BoxFit.contain,
  276. ),
  277. ],
  278. ),
  279. Row(
  280. mainAxisAlignment: MainAxisAlignment.center,
  281. children: [
  282. Text(
  283. StringName.newUserResultIntimacyDesc,
  284. textAlign: TextAlign.center,
  285. style: TextStyle(
  286. color: Colors.black.withAlpha(128),
  287. fontSize: 12.sp,
  288. fontWeight: FontWeight.w400,
  289. ),
  290. ),
  291. ],
  292. ),
  293. SizedBox(height: 26.w),
  294. SizedBox(
  295. height: 100.w,
  296. child: Stack(
  297. children: [
  298. // 滚动列表
  299. Positioned.fill(
  300. child: AutoScrollListView(
  301. itemCount: (controller.charactersList.length / 2).ceil(),
  302. scrollDirection: Axis.horizontal,
  303. itemBuilder: (context, columnIndex) {
  304. int rowCount = 2;
  305. int startIndex = columnIndex * rowCount;
  306. final List<CharacterInfo> columnItems =
  307. controller.charactersList
  308. .skip(startIndex)
  309. .take(rowCount)
  310. .toList();
  311. return Column(
  312. children: columnItems.map((item) {
  313. final emoji = item.emoji ?? "";
  314. final name = item.name ?? "";
  315. return Padding(
  316. padding: EdgeInsets.symmetric(
  317. vertical: 4.w,
  318. horizontal: 4.w,
  319. ),
  320. child: Obx(() {
  321. final isSelected = controller.selectCharactersList
  322. .any((selected) => selected.name == item.name);
  323. return SizedBox(
  324. height: 36.w,
  325. child: ChoiceChip(
  326. label: Text(
  327. "$emoji$name",
  328. style: TextStyle(
  329. color: isSelected
  330. ? Colors.white
  331. : Colors.black.withAlpha(204),
  332. fontSize: 13.sp,
  333. fontWeight: FontWeight.w400,
  334. ),
  335. ),
  336. showCheckmark: false,
  337. selected: isSelected,
  338. selectedColor: const Color(0xFFB782FF),
  339. backgroundColor: const Color(0xFFF6F5FA),
  340. shape: RoundedRectangleBorder(
  341. borderRadius: BorderRadius.circular(31.r),
  342. ),
  343. side: BorderSide.none,
  344. onSelected: (selected) {
  345. if (selected != isSelected) {
  346. controller.onSelected(item);
  347. }
  348. },
  349. ),
  350. );
  351. }),
  352. );
  353. }).toList(),
  354. );
  355. },
  356. ),
  357. ),
  358. // 左侧渐变
  359. Positioned(
  360. left: 0,
  361. top: 0,
  362. bottom: 0,
  363. child: Container(
  364. width: 20.w,
  365. height: 94.w,
  366. decoration: BoxDecoration(
  367. gradient: LinearGradient(
  368. begin: Alignment.centerLeft,
  369. end: Alignment.centerRight,
  370. colors: [
  371. Colors.white,
  372. Colors.white.withAlpha(0),
  373. ],
  374. ),
  375. ),
  376. ),
  377. ),
  378. // 右侧渐变
  379. Positioned(
  380. right: 0,
  381. top: 0,
  382. bottom: 0,
  383. child: Container(
  384. width: 20.w,
  385. height: 94.w,
  386. decoration: BoxDecoration(
  387. gradient: LinearGradient(
  388. begin: Alignment.centerRight,
  389. end: Alignment.centerLeft,
  390. colors: [
  391. Colors.white,
  392. Colors.white.withAlpha(0),
  393. ],
  394. ),
  395. ),
  396. ),
  397. ),
  398. ],
  399. ),
  400. ),
  401. SizedBox(height: 26.w),
  402. ],
  403. ),
  404. );
  405. });
  406. }
  407. Widget buildOpenNowButton() {
  408. return Column(
  409. children: [
  410. Assets.images.iconNewUserResultOpenDesc.image(
  411. width: 126.w,
  412. height: 18.w,
  413. fit: BoxFit.contain,
  414. ),
  415. SizedBox(height: 18.w),
  416. GestureDetector(
  417. onTap: () {
  418. controller.clickOpenNow();
  419. },
  420. child: Assets.images.iconNewUserOpenNow.image(
  421. width: 256.w,
  422. height: 79.w,
  423. fit: BoxFit.contain,
  424. ),
  425. ),
  426. ],
  427. );
  428. }
  429. }