|
@@ -23,6 +23,7 @@ import 'package:location/module/urgent_contact/urgent_contact_page.dart';
|
|
|
import 'package:location/resource/string.gen.dart';
|
|
import 'package:location/resource/string.gen.dart';
|
|
|
import 'package:location/sdk/map/map_helper.dart';
|
|
import 'package:location/sdk/map/map_helper.dart';
|
|
|
import 'package:location/utils/base_expand.dart';
|
|
import 'package:location/utils/base_expand.dart';
|
|
|
|
|
+import 'package:location/utils/mmkv_util.dart';
|
|
|
import 'package:location/utils/toast_util.dart';
|
|
import 'package:location/utils/toast_util.dart';
|
|
|
import '../../data/repositories/config_repository.dart';
|
|
import '../../data/repositories/config_repository.dart';
|
|
|
import '../../data/repositories/urgent_contact_repository.dart';
|
|
import '../../data/repositories/urgent_contact_repository.dart';
|
|
@@ -69,6 +70,9 @@ class MainController extends BaseController {
|
|
|
|
|
|
|
|
DateTime? _lastPressedAt;
|
|
DateTime? _lastPressedAt;
|
|
|
|
|
|
|
|
|
|
+ String? lastCheckFriendId;
|
|
|
|
|
+ bool isExecuteAutoSelect = false;
|
|
|
|
|
+
|
|
|
MainController(
|
|
MainController(
|
|
|
this.friendsRepository,
|
|
this.friendsRepository,
|
|
|
this.accountRepository,
|
|
this.accountRepository,
|
|
@@ -81,6 +85,7 @@ class MainController extends BaseController {
|
|
|
void onReady() {
|
|
void onReady() {
|
|
|
super.onReady();
|
|
super.onReady();
|
|
|
integrateList.add(mineUserInfo);
|
|
integrateList.add(mineUserInfo);
|
|
|
|
|
+ initLastCheckFriendId();
|
|
|
|
|
|
|
|
AddFriendDialog.show(
|
|
AddFriendDialog.show(
|
|
|
onAddClick: () async {
|
|
onAddClick: () async {
|
|
@@ -106,6 +111,7 @@ class MainController extends BaseController {
|
|
|
.firstWhereOrNull((element) => element.id == selectedFriend?.id);
|
|
.firstWhereOrNull((element) => element.id == selectedFriend?.id);
|
|
|
_selectedFriend.value = userInfo;
|
|
_selectedFriend.value = userInfo;
|
|
|
}
|
|
}
|
|
|
|
|
+ _autoSelectFriend();
|
|
|
});
|
|
});
|
|
|
mineLocationSubscription =
|
|
mineLocationSubscription =
|
|
|
accountRepository.mineUserInfo.value.lastLocation.listen((location) {
|
|
accountRepository.mineUserInfo.value.lastLocation.listen((location) {
|
|
@@ -135,7 +141,12 @@ class MainController extends BaseController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- void onSelectClick(UserInfo userInfo) {
|
|
|
|
|
|
|
+ void onSelectUserClick(UserInfo userInfo) {
|
|
|
|
|
+ KVUtil.putString(Constants.keyLastSelectFriendId, userInfo.id);
|
|
|
|
|
+ _setSelectUserInfo(userInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void _setSelectUserInfo(UserInfo userInfo) {
|
|
|
UserInfo? oldInfo = _selectedFriend.value;
|
|
UserInfo? oldInfo = _selectedFriend.value;
|
|
|
_selectedFriend.value = userInfo;
|
|
_selectedFriend.value = userInfo;
|
|
|
//修改地图选中
|
|
//修改地图选中
|
|
@@ -175,16 +186,12 @@ class MainController extends BaseController {
|
|
|
|
|
|
|
|
void onMarkerTap(Marker marker) {
|
|
void onMarkerTap(Marker marker) {
|
|
|
String id = marker.id;
|
|
String id = marker.id;
|
|
|
- if (id == Constants.mineLocationId) {
|
|
|
|
|
- onSelectClick(mineUserInfo);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
UserInfo? userInfo =
|
|
UserInfo? userInfo =
|
|
|
integrateList.firstWhereOrNull((element) => element.id == id);
|
|
integrateList.firstWhereOrNull((element) => element.id == id);
|
|
|
if (userInfo == null) {
|
|
if (userInfo == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- onSelectClick(userInfo);
|
|
|
|
|
|
|
+ onSelectUserClick(userInfo);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void onCurrentLocationClick() async {
|
|
void onCurrentLocationClick() async {
|
|
@@ -333,4 +340,22 @@ class MainController extends BaseController {
|
|
|
SystemNavigator.pop();
|
|
SystemNavigator.pop();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ void initLastCheckFriendId() {
|
|
|
|
|
+ lastCheckFriendId = KVUtil.getString(Constants.keyLastSelectFriendId, null);
|
|
|
|
|
+ _autoSelectFriend();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void _autoSelectFriend() {
|
|
|
|
|
+ if (lastCheckFriendId == null || isExecuteAutoSelect) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (var value in integrateList) {
|
|
|
|
|
+ if (value.id == lastCheckFriendId) {
|
|
|
|
|
+ isExecuteAutoSelect = true;
|
|
|
|
|
+ _setSelectUserInfo(value);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|