friend_setting_page.dart 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. import 'package:animated_toggle_switch/animated_toggle_switch.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter/src/widgets/framework.dart';
  5. import 'package:flutter_screenutil/flutter_screenutil.dart';
  6. import 'package:get/get.dart';
  7. import 'package:get/get_core/src/get_main.dart';
  8. import 'package:location/base/base_page.dart';
  9. import 'package:location/data/bean/user_info.dart';
  10. import 'package:location/resource/assets.gen.dart';
  11. import 'package:location/router/app_pages.dart';
  12. import 'package:location/utils/common_expand.dart';
  13. import 'package:location/widget/load_switch.dart';
  14. import '../../../resource/colors.gen.dart';
  15. import '../../../resource/string.gen.dart';
  16. import '../../../widget/common_view.dart';
  17. import 'friend_setting_controller.dart';
  18. class FriendSettingPage extends BasePage<FriendSettingController> {
  19. const FriendSettingPage({super.key});
  20. static void start(UserInfo userInfo) {
  21. Get.toNamed(RoutePath.friendSetting, arguments: userInfo);
  22. }
  23. @override
  24. Color backgroundColor() {
  25. return '#F7F7F7'.color;
  26. }
  27. @override
  28. Widget buildBody(BuildContext context) {
  29. return Column(
  30. children: [
  31. buildHeadView(),
  32. Expanded(
  33. child: Padding(
  34. padding: EdgeInsets.symmetric(horizontal: 12.w),
  35. child: Column(
  36. children: [
  37. SizedBox(height: 15.w),
  38. Container(
  39. padding: EdgeInsets.symmetric(horizontal: 12.w),
  40. width: double.infinity,
  41. decoration: _getSettingCardDecoration(),
  42. child: Column(
  43. children: [
  44. Obx(() {
  45. return _buildInfoEditType(
  46. StringName.friendEditRemarkTitle,
  47. controller.userInfo?.remark ?? '',
  48. Assets.images.iconFriendEditArrow.provider(),
  49. onTap: controller.editRemarkClick);
  50. }),
  51. Container(
  52. width: double.infinity,
  53. height: 1.w,
  54. color: '#F8F8F8'.color),
  55. _buildInfoEditType(
  56. StringName.friendEditPhoneTitle,
  57. controller.userInfo?.phoneNumber ?? '',
  58. Assets.images.iconFriendSettingCopy.provider(),
  59. onTap: controller.copyPhoneClick),
  60. ],
  61. ),
  62. ),
  63. SizedBox(height: 10.w),
  64. Obx(() {
  65. return buildInfoSwitchType(StringName.friendEditBlockTitle,
  66. controller.userInfo?.blockedHim ?? false,
  67. future: (value) => controller.blockHimFuture(value));
  68. }),
  69. SizedBox(height: 16.w),
  70. GestureDetector(
  71. onTap: controller.deleteFriendClick,
  72. child: Container(
  73. height: 54.w,
  74. decoration: _getSettingCardDecoration(),
  75. child: Center(
  76. child: Text(StringName.friendDelete,
  77. style: TextStyle(
  78. fontSize: 15.sp,
  79. color: '#E1261A'.color,
  80. fontWeight: FontWeight.bold)))),
  81. )
  82. ],
  83. ),
  84. ))
  85. ],
  86. );
  87. }
  88. Widget buildHeadView() {
  89. return Container(
  90. width: double.infinity,
  91. padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 14.w),
  92. child: Stack(
  93. children: [
  94. GestureDetector(
  95. onTap: controller.back, child: CommonView.getBackBtnView()),
  96. Positioned(
  97. left: 0,
  98. right: 0,
  99. top: 0,
  100. bottom: 0,
  101. child: Center(
  102. child: Text(StringName.friendInfoEdit,
  103. style: TextStyle(
  104. height: 1,
  105. fontSize: 16.sp,
  106. color: ColorName.black90,
  107. fontWeight: FontWeight.bold)),
  108. ),
  109. )
  110. ],
  111. ),
  112. );
  113. }
  114. BoxDecoration _getSettingCardDecoration() {
  115. return BoxDecoration(
  116. color: ColorName.white, borderRadius: BorderRadius.circular(8.w));
  117. }
  118. Widget _buildInfoEditType(
  119. String title, String content, ImageProvider imageProvider,
  120. {VoidCallback? onTap}) {
  121. return GestureDetector(
  122. behavior: HitTestBehavior.translucent,
  123. onTap: onTap,
  124. child: SizedBox(
  125. height: 50.w,
  126. child: Row(
  127. crossAxisAlignment: CrossAxisAlignment.center,
  128. children: [
  129. Text(
  130. title,
  131. style: TextStyle(
  132. fontSize: 15.sp,
  133. color: '#202020'.color,
  134. fontWeight: FontWeight.bold),
  135. ),
  136. Spacer(),
  137. Text(content,
  138. style: TextStyle(fontSize: 14.sp, color: '#666666'.color)),
  139. SizedBox(width: 5.w),
  140. Image(image: imageProvider, width: 20.w, height: 20.w)
  141. ],
  142. ),
  143. ),
  144. );
  145. }
  146. Widget buildInfoSwitchType(String title, bool isSwitchOn,
  147. {required LoadFutureCallback future}) {
  148. return Container(
  149. height: 54.w,
  150. padding: EdgeInsets.symmetric(horizontal: 12.w),
  151. decoration: _getSettingCardDecoration(),
  152. child: Row(children: [
  153. Text(
  154. title,
  155. style: TextStyle(
  156. fontSize: 15.sp,
  157. color: '#202020'.color,
  158. fontWeight: FontWeight.bold),
  159. ),
  160. Spacer(),
  161. LoadSwitch(
  162. value: isSwitchOn,
  163. future: future,
  164. height: 24.w,
  165. borderWidth: 4.w,
  166. loadingColor: ColorName.colorPrimary,
  167. selectedColor: ColorName.colorPrimary,
  168. unselectedColor: '#EBEBEB'.color)
  169. ]),
  170. );
  171. }
  172. }