friend_setting_page.dart 5.9 KB

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