intimacy_scale_page.dart 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. import 'package:flutter_screenutil/flutter_screenutil.dart';
  2. import 'package:keyboard/base/base_page.dart';
  3. import 'package:keyboard/module/intimacy_scale/intimacy_scale_controller.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:get/get.dart';
  6. import '../../resource/assets.gen.dart';
  7. import '../../resource/string.gen.dart';
  8. import '../../router/app_pages.dart';
  9. import '../../utils/intimacy_util.dart';
  10. import '../../utils/styles.dart';
  11. import '../../widget/flutter_ruler_picker.dart';
  12. import '../../widget/heart_fill_view.dart';
  13. class IntimacyScalePage extends BasePage<IntimacyScaleController> {
  14. const IntimacyScalePage({super.key});
  15. static void start() {
  16. Get.toNamed(RoutePath.intimacyScale);
  17. }
  18. @override
  19. bool immersive() {
  20. return true;
  21. }
  22. @override
  23. Color backgroundColor() {
  24. return Color(0xFFF6F5FA);
  25. }
  26. @override
  27. Widget buildBody(BuildContext context) {
  28. return Stack(
  29. children: [
  30. SafeArea(
  31. child: Column(
  32. crossAxisAlignment: CrossAxisAlignment.center,
  33. children: [
  34. _buildTitle(),
  35. SizedBox(height: 128.w),
  36. SizedBox(
  37. width: 250.w,
  38. child: Stack(
  39. alignment: Alignment.center,
  40. children: [
  41. Obx(() {
  42. return HeartFillAnimation(
  43. fillProgress:
  44. controller.currentCustomIntimacy.value > 0
  45. ? controller.currentCustomIntimacy.value / 100
  46. : 0,
  47. width: 210.w,
  48. );
  49. }),
  50. Positioned(
  51. left: 0,
  52. right: 0,
  53. child: Obx(() {
  54. return Text.rich(
  55. TextSpan(
  56. children: [
  57. TextSpan(
  58. text: controller.currentCustomIntimacy.value.toString(),
  59. style: TextStyle(
  60. color: Colors.white,
  61. fontSize: 70.sp,
  62. wordSpacing: 0,
  63. height: 0,
  64. fontWeight: FontWeight.w700,
  65. shadows: [
  66. Shadow(
  67. offset: Offset(0, 3),
  68. blurRadius: 9,
  69. color: const Color(
  70. 0xFFFF6BD3,
  71. ).withOpacity(0.63),
  72. ),
  73. ],
  74. ),
  75. ),
  76. TextSpan(
  77. text: "%",
  78. style: TextStyle(
  79. wordSpacing: 0,
  80. color: Colors.white,
  81. fontSize: 35.15.sp,
  82. fontWeight: FontWeight.w700,
  83. shadows: [
  84. Shadow(
  85. offset: Offset(0, 3),
  86. blurRadius: 9,
  87. color: const Color(
  88. 0xFFFF6BD3,
  89. ).withOpacity(0.63),
  90. ),
  91. ],
  92. ),
  93. ),
  94. ],
  95. ),
  96. textAlign: TextAlign.center,
  97. );
  98. }),
  99. ),
  100. ],
  101. ),
  102. ),
  103. SizedBox(height: 50.w),
  104. buildIntimacyLevelName(),
  105. SizedBox(height: 20.w),
  106. buildRulerPicker(context),
  107. ],
  108. ),
  109. ),
  110. Positioned(
  111. bottom: 20.h,
  112. left: 16.w,
  113. right: 16.w,
  114. child: InkWell(
  115. onTap: () {
  116. controller.clickSaveButton();
  117. },
  118. child: Center(
  119. child: Container(
  120. width: 150.w,
  121. height: 48.h,
  122. alignment: Alignment.center,
  123. decoration: Styles.getActivateButtonDecoration(31.r),
  124. child: Text(
  125. StringName.save,
  126. style: Styles.getTextStyleWhiteW500(16.sp),
  127. ),
  128. ),
  129. ),
  130. ),
  131. ),
  132. // 背景图片
  133. IgnorePointer(child: Assets.images.bgMine.image(width: 360.w)),
  134. ],
  135. );
  136. }
  137. Row buildRulerPicker(BuildContext context) {
  138. return Row(
  139. children: [
  140. SizedBox(
  141. child: Obx(() {
  142. return RulerPicker(
  143. rulerBackgroundColor: Colors.transparent,
  144. controller: controller.rulerPickerController.value,
  145. onBuildRulerScaleText: (index, value) {
  146. return "";
  147. },
  148. ranges: controller.ranges,
  149. onValueChanged: (value) {
  150. controller.onChangeIntimacy(value);
  151. },
  152. width: 360.w,
  153. height: 96.w,
  154. rulerMarginTop: 25.w,
  155. marker: Column(
  156. children: [
  157. Assets.images.iconIntimacyScaleMark.image(
  158. width: 25.w,
  159. height: 25.w,
  160. ),
  161. Container(
  162. width: 8.w,
  163. height: 48.w,
  164. decoration: BoxDecoration(
  165. borderRadius: BorderRadius.circular(40.w),
  166. color: Color(0xff7d46fc),
  167. ),
  168. ),
  169. ],
  170. ),
  171. );
  172. }),
  173. ),
  174. ],
  175. );
  176. }
  177. _buildTitle() {
  178. return Container(
  179. alignment: Alignment.centerLeft,
  180. padding: EdgeInsets.only(top: 12.h, left: 16.w, right: 16.w),
  181. child: Row(
  182. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  183. children: [
  184. GestureDetector(
  185. onTap: () => controller.clickBack(),
  186. child: Assets.images.iconMineBackArrow.image(
  187. width: 24.w,
  188. height: 24.w,
  189. ),
  190. ),
  191. Text(
  192. StringName.intimacyIndex,
  193. style: Styles.getTextStyleBlack204W500(17.sp),
  194. ),
  195. SizedBox(width: 24.w, height: 24.w),
  196. ],
  197. ),
  198. );
  199. }
  200. // 亲密阶段名称
  201. Widget buildIntimacyLevelName() {
  202. return Obx(() {
  203. return Container(
  204. padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 4.h),
  205. decoration: ShapeDecoration(
  206. color: Colors.white,
  207. shape: RoundedRectangleBorder(
  208. borderRadius: BorderRadius.circular(17.r),
  209. ),
  210. ),
  211. child: Row(
  212. mainAxisSize: MainAxisSize.min,
  213. mainAxisAlignment: MainAxisAlignment.center,
  214. children: [
  215. Assets.images.iconKeyboardLoveLogo.image(width: 18.w, height: 18.w),
  216. Text(
  217. IntimacyUtil.getIntimacyName(controller.currentCustomIntimacy.value),
  218. style: Styles.getTextStyleBlack153W400(14.sp),
  219. ),
  220. ],
  221. ),
  222. );
  223. });
  224. }
  225. }