new_user_result_page.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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: SingleChildScrollView(
  60. child: Column(
  61. mainAxisAlignment: MainAxisAlignment.center,
  62. crossAxisAlignment: CrossAxisAlignment.center,
  63. children: [
  64. SizedBox(height: 30.w),
  65. Center(
  66. child: Assets.images.iconNewUserResultTitle.image(
  67. width: 246.w,
  68. height: 41.2.w,
  69. fit: BoxFit.contain,
  70. ),
  71. ),
  72. SizedBox(height: 20.w),
  73. _buildAvatarCard(),
  74. SizedBox(height: 12.w),
  75. _buildZodiacDesc(),
  76. SizedBox(height: 20.w),
  77. buildCharacterList(),
  78. SizedBox(height: 70.w),
  79. buildOpenNowButton(),
  80. ],
  81. ),
  82. ),
  83. ),
  84. ],
  85. ),
  86. ),
  87. ],
  88. );
  89. }
  90. Widget _buildZodiacDesc() {
  91. return Obx(() {
  92. if (controller.keyboardMemeExplain.value.meme == null ||
  93. controller.keyboardMemeExplain.value.explain == null) {
  94. return SizedBox(width: 278.w);
  95. }
  96. return Row(
  97. mainAxisAlignment: MainAxisAlignment.center,
  98. children: [
  99. Stack(
  100. alignment: Alignment.center,
  101. children: [
  102. Container(
  103. alignment: Alignment.center,
  104. padding: EdgeInsets.only(
  105. left: 19.w,
  106. right: 19.w,
  107. top: 7.w,
  108. bottom: 7.w,
  109. ),
  110. decoration: ShapeDecoration(
  111. color: const Color(0x28B70080),
  112. shape: RoundedRectangleBorder(
  113. borderRadius: BorderRadius.circular(16.r),
  114. ),
  115. ),
  116. child: SizedBox(
  117. width: 278.w,
  118. child: Text(
  119. "${controller.keyboardMemeExplain.value.meme ?? ""}\n${controller.keyboardMemeExplain.value.explain ?? ""}",
  120. style: TextStyle(
  121. color: Colors.white.withAlpha(229),
  122. fontSize: 12.sp,
  123. fontWeight: FontWeight.w500,
  124. ),
  125. ),
  126. ),
  127. ),
  128. Positioned(
  129. top: 0.w,
  130. left: 8.w,
  131. child: Assets.images.iconNewUserZodiacLeft.image(
  132. width: 16.w,
  133. height: 16.w,
  134. fit: BoxFit.contain,
  135. ),
  136. ),
  137. Positioned(
  138. right: 8.w,
  139. bottom: 0.w,
  140. child: Assets.images.iconNewUserZodiacRight.image(
  141. width: 16.w,
  142. height: 16.w,
  143. fit: BoxFit.contain,
  144. ),
  145. ),
  146. ],
  147. ),
  148. ],
  149. );
  150. });
  151. }
  152. Widget _buildAvatarCard() {
  153. return Stack(
  154. alignment: Alignment.center,
  155. children: [
  156. Row(
  157. mainAxisAlignment: MainAxisAlignment.center,
  158. children: [
  159. Column(
  160. children: [
  161. SizedBox(height: 20.w),
  162. CircleAvatarWidget(
  163. image: Assets.images.iconKeyboardDefaultAvatar.provider(),
  164. imageUrl: controller.userInfo?.imageUrl,
  165. size: 88.w,
  166. borderColor: Colors.white,
  167. borderWidth: 2.r,
  168. placeholder: (_, __) => const SizedBox.shrink(),
  169. ),
  170. SizedBox(height: 14.w),
  171. Obx(() {
  172. final zodiac = controller.zodiacLabelFromUserInfo;
  173. if (zodiac != null) {
  174. return Row(
  175. children: [
  176. zodiac.image.image(width: 14.w, height: 14.w),
  177. SizedBox(width: 4.w),
  178. Text(
  179. zodiac.name,
  180. style: TextStyle(
  181. color: Colors.white,
  182. fontSize: 14.97.sp,
  183. fontWeight: FontWeight.w700,
  184. ),
  185. ),
  186. ],
  187. );
  188. } else {
  189. return const SizedBox.shrink();
  190. }
  191. }),
  192. ],
  193. ),
  194. Lottie.asset(
  195. Assets.anim.animNewUserData,
  196. repeat: true,
  197. width: 131.w,
  198. fit: BoxFit.contain,
  199. ),
  200. Column(
  201. children: [
  202. SizedBox(height: 20.w),
  203. CircleAvatarWidget(
  204. image: Assets.images.iconKeyboardDefaultAvatar.provider(),
  205. imageUrl: controller.newUserKeyboardInfo.imageUrl,
  206. size: 88.w,
  207. borderColor: Colors.white,
  208. borderWidth: 2.r,
  209. placeholder: (_, __) => const SizedBox.shrink(),
  210. ),
  211. SizedBox(height: 14.w),
  212. Obx(() {
  213. final zodiac = controller.zodiacLabelFromNewUserKeyboardInfo;
  214. if (zodiac != null) {
  215. return Row(
  216. children: [
  217. zodiac.image.image(width: 14.w, height: 14.w),
  218. SizedBox(width: 4.w),
  219. Text(
  220. zodiac.name,
  221. style: TextStyle(
  222. color: Colors.white,
  223. fontSize: 14.97.sp,
  224. fontWeight: FontWeight.w700,
  225. ),
  226. ),
  227. ],
  228. );
  229. } else {
  230. return const SizedBox.shrink();
  231. }
  232. }),
  233. ],
  234. ),
  235. ],
  236. ),
  237. ],
  238. );
  239. }
  240. Widget buildCharacterList() {
  241. return Obx(() {
  242. if (controller.charactersList.isEmpty) {
  243. return const SizedBox.shrink();
  244. }
  245. return Container(
  246. padding: EdgeInsets.only(top: 20.w),
  247. decoration: ShapeDecoration(
  248. color: Colors.white,
  249. shape: RoundedRectangleBorder(
  250. borderRadius: BorderRadius.circular(28.r),
  251. ),
  252. ),
  253. margin: EdgeInsets.only(left: 16.w, right: 16.w),
  254. child: Column(
  255. children: [
  256. Row(
  257. crossAxisAlignment: CrossAxisAlignment.center,
  258. mainAxisAlignment: MainAxisAlignment.center,
  259. children: [
  260. Assets.images.iconNewUserResultLoveLeft.image(
  261. width: 12.w,
  262. height: 12.w,
  263. fit: BoxFit.contain,
  264. ),
  265. Text(
  266. '${StringName.newUserResultIntimacyTitle} ${controller.newUserKeyboardInfo.intimacy ?? "0"}%',
  267. textAlign: TextAlign.center,
  268. style: TextStyle(
  269. color: Colors.black.withAlpha(204),
  270. fontSize: 14.sp,
  271. fontWeight: FontWeight.w700,
  272. ),
  273. ),
  274. Assets.images.iconNewUserResultLoveRight.image(
  275. width: 12.w,
  276. height: 12.w,
  277. fit: BoxFit.contain,
  278. ),
  279. ],
  280. ),
  281. Row(
  282. mainAxisAlignment: MainAxisAlignment.center,
  283. children: [
  284. Text(
  285. StringName.newUserResultIntimacyDesc,
  286. textAlign: TextAlign.center,
  287. style: TextStyle(
  288. color: Colors.black.withAlpha(128),
  289. fontSize: 12.sp,
  290. fontWeight: FontWeight.w400,
  291. ),
  292. ),
  293. ],
  294. ),
  295. SizedBox(height: 26.w),
  296. SizedBox(
  297. height: 100.w,
  298. child: AutoScrollListView(
  299. itemCount: (controller.charactersList.length / 2).ceil(),
  300. scrollDirection: Axis.horizontal,
  301. itemBuilder: (context, columnIndex) {
  302. int rowCount = 2;
  303. int startIndex = columnIndex * rowCount;
  304. final List<CharacterInfo> columnItems =
  305. controller.charactersList
  306. .skip(startIndex)
  307. .take(rowCount)
  308. .toList();
  309. return Column(
  310. children:
  311. columnItems.map((item) {
  312. final emoji = item.emoji ?? "";
  313. final name = item.name ?? "";
  314. return Padding(
  315. padding: EdgeInsets.symmetric(
  316. vertical: 4.w,
  317. horizontal: 4.w,
  318. ),
  319. child: Obx(() {
  320. final isSelected = controller.selectCharactersList
  321. .any(
  322. (selected) => selected.name == item.name,
  323. );
  324. return SizedBox(
  325. height: 36.w,
  326. child: ChoiceChip(
  327. label: Text(
  328. "$emoji$name",
  329. style: TextStyle(
  330. color:
  331. isSelected
  332. ? Colors.white
  333. : Colors.black.withAlpha(204),
  334. fontSize: 13.sp,
  335. fontWeight: FontWeight.w400,
  336. ),
  337. ),
  338. showCheckmark: false,
  339. selected: isSelected,
  340. selectedColor: const Color(0xFFB782FF),
  341. backgroundColor: Color(0xFFF6F5FA),
  342. shape: RoundedRectangleBorder(
  343. borderRadius: BorderRadius.circular(31.r),
  344. ),
  345. side: BorderSide(
  346. width: 0.w,
  347. color: Colors.transparent
  348. ),
  349. onSelected: (selected) {
  350. if (selected != isSelected) {
  351. controller.onSelected(item);
  352. }
  353. },
  354. ),
  355. );
  356. }),
  357. );
  358. }).toList(),
  359. );
  360. },
  361. ),
  362. ),
  363. SizedBox(height: 26.w),
  364. ],
  365. ),
  366. );
  367. });
  368. }
  369. Widget buildOpenNowButton() {
  370. return Column(
  371. children: [
  372. Assets.images.iconNewUserResultOpenDesc.image(
  373. width: 126.w,
  374. height: 18.w,
  375. fit: BoxFit.contain,
  376. ),
  377. SizedBox(height: 18.w),
  378. GestureDetector(
  379. onTap: () {
  380. controller.clickOpenNow();
  381. },
  382. child: Assets.images.iconNewUserOpenNow.image(
  383. width: 256.w,
  384. height: 79.w,
  385. fit: BoxFit.contain,
  386. ),
  387. ),
  388. ],
  389. );
  390. }
  391. }