character_custom_detail_page.dart 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. import 'package:flutter_screenutil/flutter_screenutil.dart';
  2. import 'package:keyboard/base/base_page.dart';
  3. import 'package:flutter/material.dart';
  4. import '../../../resource/assets.gen.dart';
  5. import '../../../resource/string.gen.dart';
  6. import '../../../router/app_pages.dart';
  7. import '../../../utils/styles.dart';
  8. import 'character_custom_detail_controller.dart';
  9. import 'package:get/get.dart';
  10. class CharacterCustomDetailPage
  11. extends BasePage<CharacterCustomDetailController> {
  12. const CharacterCustomDetailPage({super.key});
  13. static void start() {
  14. Get.toNamed(RoutePath.characterCustomDetail, arguments: {});
  15. }
  16. @override
  17. bool immersive() {
  18. return true;
  19. }
  20. @override
  21. Widget buildBody(BuildContext context) {
  22. return Stack(
  23. children: [
  24. Container(
  25. child: Assets.images.bgCharacterCustomDetail.image(
  26. width: double.infinity,
  27. fit: BoxFit.fill,
  28. ),
  29. ),
  30. SafeArea(
  31. child: Container(
  32. color: Colors.transparent,
  33. alignment: Alignment.topCenter,
  34. child: Stack(
  35. children: [
  36. Column(
  37. children: [
  38. _buildTitle(),
  39. SizedBox(height: 42.h),
  40. Expanded(
  41. child: Container(
  42. decoration: ShapeDecoration(
  43. color: Color(0xFFF6F5FA),
  44. shape: RoundedRectangleBorder(
  45. borderRadius: BorderRadius.only(
  46. topLeft: Radius.circular(20.r),
  47. topRight: Radius.circular(20.r),
  48. ),
  49. ),
  50. ),
  51. child: SingleChildScrollView(
  52. child: Column(
  53. children: [
  54. _buildNameCard(),
  55. SizedBox(height: 34.h),
  56. _buildGenderCard(),
  57. SizedBox(height: 10.h),
  58. _buildBirthdayCard(),
  59. SizedBox(height: 10.h),
  60. _hobbiesCard(),
  61. SizedBox(height: 18.h),
  62. _characterCard(),
  63. ],
  64. ),
  65. ),
  66. ),
  67. ),
  68. Container(
  69. color: Color(0xFFF6F5FA),
  70. child: _buildUnlockButton(),
  71. ),
  72. ],
  73. ),
  74. Positioned(left: 16.w, top: 60.h, child: _buildAvatar()),
  75. Positioned(left: 68.w, top: 112.h, child: _buildAvatarSwitch()),
  76. ],
  77. ),
  78. ),
  79. ),
  80. ],
  81. );
  82. }
  83. _buildTitle() {
  84. return Container(
  85. alignment: Alignment.centerLeft,
  86. padding: EdgeInsets.only(top: 12.h, left: 16.w),
  87. child: GestureDetector(
  88. onTap: controller.clickBack,
  89. child: Assets.images.iconMineBackArrow.image(width: 24.w, height: 24.w),
  90. ),
  91. );
  92. }
  93. _buildNameCard() {
  94. return Container(
  95. padding: EdgeInsets.only(left: 104.w, top: 14.h),
  96. child: Row(
  97. crossAxisAlignment: CrossAxisAlignment.end,
  98. children: [
  99. Text(
  100. '自定义人设',
  101. textAlign: TextAlign.center,
  102. style: TextStyle(
  103. color: Colors.black.withAlpha(204),
  104. fontSize: 18.sp,
  105. fontWeight: FontWeight.w500,
  106. ),
  107. ),
  108. Container(
  109. child: Assets.images.iconCharacterCustomDetailEdit.image(
  110. width: 20.r,
  111. height: 20.r,
  112. ),
  113. ),
  114. ],
  115. ),
  116. );
  117. }
  118. _buildAvatar() {
  119. return Container(
  120. width: 72.r,
  121. height: 72.r,
  122. decoration: ShapeDecoration(
  123. shape: OvalBorder(side: BorderSide(width: 2, color: Colors.white)),
  124. ),
  125. );
  126. }
  127. _buildAvatarSwitch() {
  128. return SizedBox(
  129. width: 22.r,
  130. height: 22.r,
  131. child: Assets.images.iconCharacterCustomDetailSwitch.image(
  132. width: 22.r,
  133. height: 22.r,
  134. ),
  135. );
  136. }
  137. // 性别
  138. Widget _buildGenderCard() {
  139. return _buildListItem(
  140. onTap: () {
  141. debugPrint('点击了性别');
  142. },
  143. firstWidget: Text('性别', style: Styles.getTextStyleBlack204W400(14.sp)),
  144. bottomWidget: Row(
  145. children: [
  146. Assets.images.iconCharacterCustomDetailMale.image(
  147. width: 24.w,
  148. height: 24.w,
  149. ),
  150. SizedBox(width: 6.w),
  151. Text('男', style: Styles.getTextStyleBlack204W400(14.sp)),
  152. Spacer(),
  153. Assets.images.iconArrowRight.image(width: 24.w, height: 24.w),
  154. ],
  155. ),
  156. );
  157. }
  158. Widget _buildBirthdayCard() {
  159. return _buildListItem(
  160. onTap: () {
  161. debugPrint('点击了生日');
  162. },
  163. firstWidget: Text('出生日期', style: Styles.getTextStyleBlack204W400(14.sp)),
  164. bottomWidget: Row(
  165. children: [
  166. Text('1998-12-16', style: Styles.getTextStyleBlack204W400(14.sp)),
  167. SizedBox(width: 12.w),
  168. Text('22岁', style: Styles.getTextStyleBlack204W400(14.sp)),
  169. Spacer(),
  170. Assets.images.iconArrowRight.image(width: 24.w, height: 24.w),
  171. ],
  172. ),
  173. );
  174. }
  175. Widget _hobbiesCard() {
  176. return _buildListItem(
  177. onTap: () {
  178. debugPrint('点击了爱好');
  179. },
  180. firstWidget: Text('兴趣爱好', style: Styles.getTextStyleBlack204W400(14.sp)),
  181. bottomWidget: Row(
  182. children: [
  183. Expanded(
  184. child: Wrap(
  185. spacing: 8.w,
  186. runSpacing: 8.h,
  187. children: [
  188. _buildColorTag(
  189. color: Color(0xFFFEECE0),
  190. name: '45sssssssssssssssssss摄影',
  191. ),
  192. _buildColorTag(
  193. color: Color(0xFFE8E4FC),
  194. name: '摄影摄影摄影摄影摄影摄摄影摄影摄影',
  195. ),
  196. _buildColorTag(
  197. color: Color(0xFFE8E4FC),
  198. name: '摄影摄影摄影摄影摄影摄摄影摄影摄影',
  199. ),
  200. ],
  201. ),
  202. ),
  203. SizedBox(width: 8.w),
  204. Assets.images.iconArrowRight.image(width: 24.w, height: 24.w),
  205. ],
  206. ),
  207. );
  208. }
  209. Widget _characterCard() {
  210. return _buildListItem(
  211. onTap: () {
  212. debugPrint('点击了性格');
  213. },
  214. firstWidget: Text('性格', style: Styles.getTextStyleBlack204W400(14.sp)),
  215. bottomWidget: Row(
  216. children: [
  217. Expanded(
  218. child: Wrap(
  219. spacing: 8.w,
  220. runSpacing: 8.h,
  221. children: [
  222. _buildColorTag(color: Color(0xFFFEECE0), name: '45摄影'),
  223. _buildColorTag(color: Color(0xFFE8E4FC), name: '46摄影'),
  224. _buildColorTag(color: Color(0xFFE0EDFD), name: '测试一共有多长才可以'),
  225. ],
  226. ),
  227. ),
  228. SizedBox(width: 8.w),
  229. Assets.images.iconArrowRight.image(width: 24.w, height: 24.w),
  230. ],
  231. ),
  232. );
  233. }
  234. Widget _buildUnlockButton() {
  235. return GestureDetector(
  236. onTap: () {
  237. controller.clickUnlockButton();
  238. },
  239. child: Container(
  240. width: double.infinity,
  241. margin: EdgeInsets.only(left: 16.w, right: 16.w, bottom: 16.h),
  242. height: 48.h,
  243. alignment: Alignment.center,
  244. decoration: ShapeDecoration(
  245. color: const Color(0xFF7D46FC),
  246. shape: RoundedRectangleBorder(
  247. borderRadius: BorderRadius.circular(50.r),
  248. ),
  249. ),
  250. child: Row(
  251. mainAxisAlignment: MainAxisAlignment.center,
  252. children: [
  253. Assets.images.iconCharacterCustomDetailLock.image(
  254. width: 22.w,
  255. height: 22.w,
  256. ),
  257. Text(
  258. StringName.unlockExclusiveCharacter,
  259. textAlign: TextAlign.center,
  260. style: Styles.getTextStyleWhiteW500(16.sp),
  261. ),
  262. ],
  263. ),
  264. ),
  265. );
  266. }
  267. // 列表项
  268. Widget _buildListItem({
  269. required Widget firstWidget,
  270. required Widget bottomWidget,
  271. VoidCallback? onTap,
  272. }) {
  273. return Container(
  274. padding: EdgeInsets.only(
  275. left: 12.w,
  276. right: 12.w,
  277. top: 14.h,
  278. bottom: 14.h,
  279. ),
  280. margin: EdgeInsets.only(left: 16.w, right: 16.w),
  281. width: double.infinity,
  282. decoration: ShapeDecoration(
  283. color: Colors.white,
  284. shape: RoundedRectangleBorder(
  285. borderRadius: BorderRadius.circular(12.r),
  286. ),
  287. ),
  288. child: Column(
  289. crossAxisAlignment: CrossAxisAlignment.start,
  290. mainAxisAlignment: MainAxisAlignment.center,
  291. children: [
  292. firstWidget,
  293. _buildDivider(),
  294. GestureDetector(
  295. behavior: HitTestBehavior.opaque,
  296. onTap: onTap,
  297. child: bottomWidget,
  298. ),
  299. ],
  300. ),
  301. );
  302. }
  303. // 下划线
  304. Widget _buildDivider() {
  305. return Container(
  306. margin: EdgeInsets.only(top: 8.h, bottom: 8.h),
  307. width: 304.w,
  308. decoration: ShapeDecoration(
  309. shape: RoundedRectangleBorder(
  310. side: BorderSide(
  311. width: 1.r,
  312. strokeAlign: BorderSide.strokeAlignCenter,
  313. color: const Color(0xFFF5F4F9),
  314. ),
  315. ),
  316. ),
  317. );
  318. }
  319. Widget _buildColorTag({required Color color, String? name, String? emoji}) {
  320. return Container(
  321. padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 3.h),
  322. decoration: ShapeDecoration(
  323. color: color,
  324. shape: RoundedRectangleBorder(
  325. borderRadius: BorderRadius.circular(23.r),
  326. ),
  327. ),
  328. child: Row(
  329. mainAxisSize: MainAxisSize.min,
  330. mainAxisAlignment: MainAxisAlignment.center,
  331. crossAxisAlignment: CrossAxisAlignment.center,
  332. children: [
  333. if (emoji != null)
  334. Text(emoji, style: Styles.getTextStyleBlack204W400(14.sp)),
  335. if (emoji != null && name != null) SizedBox(width: 4.w),
  336. if (name != null)
  337. Text(name, style: Styles.getTextStyleBlack204W400(14.sp)),
  338. ],
  339. ),
  340. );
  341. }
  342. }