new_user_result_page.dart 14 KB

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