location_controller.dart 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import 'package:abroad_location/base/base_controller.dart';
  2. import 'package:get/get.dart';
  3. import 'package:injectable/injectable.dart';
  4. import 'package:sliding_sheet2/sliding_sheet2.dart';
  5. import '../../data/bean/user_info.dart';
  6. @injectable
  7. class LocationController extends BaseController {
  8. SheetController sheetController = SheetController();
  9. final RxDouble _sheetProgress = 0.0.obs;
  10. double get sheetProgress => _sheetProgress.value;
  11. final Rxn<UserInfo> _selectUserInfo = Rxn();
  12. UserInfo? get selectUserInfo => _selectUserInfo.value;
  13. final RxList<UserInfo> locationFriendList = RxList();
  14. final RxBool _isFindContact = false.obs;
  15. bool get isFindContact => _isFindContact.value;
  16. final findContactAnimatedDuration = const Duration(milliseconds: 250);
  17. @override
  18. void onReady() {
  19. super.onReady();
  20. //*******测试*******
  21. for (int i = 0; i < 20; i++) {
  22. locationFriendList.add(UserInfo(
  23. id: 'id$i',
  24. phoneNumber: 'phoneNumber$i',
  25. remark: 'remark$i',
  26. timestamp: 1234567890,
  27. blockedHim: false,
  28. blockedMe: false,
  29. virtual: false,
  30. isMine: false,
  31. ));
  32. }
  33. _selectUserInfo.value = locationFriendList[0];
  34. //**********
  35. }
  36. setSheetProgress(double progress) {
  37. _sheetProgress.value = progress;
  38. }
  39. onSelectItemClick(UserInfo userInfo) async {
  40. _selectUserInfo.value = userInfo;
  41. await sheetController.scrollTo(0, duration: Duration(milliseconds: 1));
  42. sheetController.snapToExtent(0, duration: Duration(milliseconds: 350));
  43. }
  44. void onFindContactClick() {
  45. _isFindContact.value = !isFindContact;
  46. }
  47. }