friend_setting_page.dart 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. import 'dart:io';
  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 '../../../resource/colors.gen.dart';
  14. import '../../../resource/string.gen.dart';
  15. import '../../../widget/common_view.dart';
  16. import '../../../widget/gradient_switch.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(
  77. Platform.isAndroid
  78. ? StringName.friendDelete
  79. : StringName.blockedFriend,
  80. style: TextStyle(
  81. fontSize: 15.sp,
  82. color: '#E1261A'.color,
  83. fontWeight: FontWeight.bold)))),
  84. )
  85. ],
  86. ),
  87. ))
  88. ],
  89. );
  90. }
  91. Widget buildHeadView() {
  92. return Container(
  93. width: double.infinity,
  94. padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 14.w),
  95. child: Stack(
  96. children: [
  97. GestureDetector(
  98. onTap: controller.back, child: CommonView.getBackBtnView()),
  99. Positioned(
  100. left: 0,
  101. right: 0,
  102. top: 0,
  103. bottom: 0,
  104. child: Center(
  105. child: Text(StringName.friendInfoEdit,
  106. style: TextStyle(
  107. height: 1,
  108. fontSize: 16.sp,
  109. color: ColorName.black90,
  110. fontWeight: FontWeight.bold)),
  111. ),
  112. )
  113. ],
  114. ),
  115. );
  116. }
  117. BoxDecoration _getSettingCardDecoration() {
  118. return BoxDecoration(
  119. color: ColorName.white, borderRadius: BorderRadius.circular(8.w));
  120. }
  121. Widget _buildInfoEditType(
  122. String title, String content, ImageProvider imageProvider,
  123. {VoidCallback? onTap}) {
  124. return GestureDetector(
  125. behavior: HitTestBehavior.translucent,
  126. onTap: onTap,
  127. child: SizedBox(
  128. height: 50.w,
  129. child: Row(
  130. crossAxisAlignment: CrossAxisAlignment.center,
  131. children: [
  132. Text(
  133. title,
  134. style: TextStyle(
  135. fontSize: 15.sp,
  136. color: '#202020'.color,
  137. fontWeight: FontWeight.bold),
  138. ),
  139. Spacer(),
  140. Text(content,
  141. style: TextStyle(fontSize: 14.sp, color: '#666666'.color)),
  142. SizedBox(width: 5.w),
  143. Image(image: imageProvider, width: 20.w, height: 20.w)
  144. ],
  145. ),
  146. ),
  147. );
  148. }
  149. Widget buildInfoSwitchType(String title, bool isSwitchOn,
  150. {required Future<bool> Function(bool value) future}) {
  151. return Container(
  152. height: 54.w,
  153. padding: EdgeInsets.symmetric(horizontal: 12.w),
  154. decoration: _getSettingCardDecoration(),
  155. child: Row(children: [
  156. Text(
  157. title,
  158. style: TextStyle(
  159. fontSize: 15.sp,
  160. color: '#202020'.color,
  161. fontWeight: FontWeight.bold),
  162. ),
  163. Spacer(),
  164. GradientSwitch(
  165. unselectedGradient:
  166. LinearGradient(colors: ['#EBEBEB'.color, '#EBEBEB'.color]),
  167. selectedGradient: LinearGradient(
  168. colors: [ColorName.colorPrimary, ColorName.colorPrimary]),
  169. indicatorSize: 20.w,
  170. width: 46.w,
  171. height: 25.w,
  172. value: isSwitchOn,
  173. onChanged: future)
  174. ]),
  175. );
  176. }
  177. }