intro get_it_mix and implemente deleting friend
parent
9a5ecc9643
commit
16a7a83e42
|
@ -4,7 +4,7 @@ class FriendSetting {
|
||||||
String friendRemark = '';
|
String friendRemark = '';
|
||||||
String friendGroup = '';
|
String friendGroup = '';
|
||||||
|
|
||||||
FriendSetting.fromJson(Map<String, dynamic> json) {
|
FriendSetting.fromJson(Map json) {
|
||||||
friendRemark = json['friendRemark'] ?? '';
|
friendRemark = json['friendRemark'] ?? '';
|
||||||
friendGroup = json['friendGroup'] ?? '我的好友';
|
friendGroup = json['friendGroup'] ?? '我的好友';
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,10 @@ class Contact extends ChangeNotifier {
|
||||||
// groupChats[key] = GroupChatSetting.fromJson(value);
|
// groupChats[key] = GroupChatSetting.fromJson(value);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
for (String i in json['friendGroups']) {
|
// for (String i in json['friendGroups']) {
|
||||||
friendGroups.add(i);
|
// friendGroups.add(i);
|
||||||
}
|
// }
|
||||||
|
friendGroups = List.from(json['friendGroups']);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, FriendSetting> filterGroupFriends(String groupName) {
|
Map<String, FriendSetting> filterGroupFriends(String groupName) {
|
||||||
|
@ -51,6 +52,11 @@ class Contact extends ChangeNotifier {
|
||||||
return groupFriends;
|
return groupFriends;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addFriend(String friendId, Map friendSetting) {
|
||||||
|
friends[friendId] = FriendSetting.fromJson(friendSetting);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
void changeFriendRemark(String friendId, String remark) {
|
void changeFriendRemark(String friendId, String remark) {
|
||||||
friends[friendId]!.friendRemark = remark;
|
friends[friendId]!.friendRemark = remark;
|
||||||
}
|
}
|
||||||
|
@ -59,23 +65,9 @@ class Contact extends ChangeNotifier {
|
||||||
friends[friendId]!.friendGroup = group;
|
friends[friendId]!.friendGroup = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
void manageGroup(
|
void removeFriend(String friendId) {
|
||||||
List<String> newGroups,
|
friends.remove(friendId);
|
||||||
List<List<String>> groupNameChangePair,
|
notifyListeners();
|
||||||
String newDefaultGroup,
|
|
||||||
) {
|
|
||||||
defaultGroup = newDefaultGroup;
|
|
||||||
friendGroups = newGroups;
|
|
||||||
for (var pair in groupNameChangePair) {
|
|
||||||
if (pair[1].isEmpty) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
friends.forEach((key, value) {
|
|
||||||
if (value.friendGroup == pair[0]) {
|
|
||||||
friends[key]!.friendGroup = pair[1];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,4 +105,23 @@ class ContactAccountProfile extends ChangeNotifier {
|
||||||
friends[key] = FriendAccountProfile.fromJson(value);
|
friends[key] = FriendAccountProfile.fromJson(value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(bool, String) getIdBy(String condition, String filterValue) {
|
||||||
|
String friendId = '';
|
||||||
|
switch (condition) {
|
||||||
|
case 'username':
|
||||||
|
for (var key in friends.keys) {
|
||||||
|
if (friends[key]!.username == filterValue) {
|
||||||
|
friendId = key;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return friendId.isNotEmpty ? (true, friendId) : (false, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeFriend(String friendId) {
|
||||||
|
friends.remove(friendId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ Future<Map<String, dynamic>> manageGroups(
|
||||||
String userId,
|
String userId,
|
||||||
List<String> groups,
|
List<String> groups,
|
||||||
List<List<String>> groupNameChangePair,
|
List<List<String>> groupNameChangePair,
|
||||||
|
List<String> deletedOriginGroups,
|
||||||
String defaultGroup,
|
String defaultGroup,
|
||||||
) async {
|
) async {
|
||||||
Response response = await request.post(
|
Response response = await request.post(
|
||||||
|
@ -70,9 +71,25 @@ Future<Map<String, dynamic>> manageGroups(
|
||||||
'user_id': userId,
|
'user_id': userId,
|
||||||
'groups': groups,
|
'groups': groups,
|
||||||
'group_name_change_pair': groupNameChangePair,
|
'group_name_change_pair': groupNameChangePair,
|
||||||
|
'deleted_origin_groups': deletedOriginGroups,
|
||||||
'default_group': defaultGroup,
|
'default_group': defaultGroup,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> deleteFriend(
|
||||||
|
String userId,
|
||||||
|
String friendId,
|
||||||
|
) async {
|
||||||
|
Response response = await request.post(
|
||||||
|
'/contact/delete/friend',
|
||||||
|
data: {
|
||||||
|
'user_id': userId,
|
||||||
|
'friend_id': friendId,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import 'package:together_mobile/screens/message/message_screen.dart';
|
||||||
final chatRouter = GoRoute(
|
final chatRouter = GoRoute(
|
||||||
path: '/chat',
|
path: '/chat',
|
||||||
name: 'Chat',
|
name: 'Chat',
|
||||||
builder: (context, state) => const ChatScreen(),
|
builder: (context, state) => ChatScreen(),
|
||||||
routes: [
|
routes: [
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: 'message',
|
path: 'message',
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:together_mobile/models/contact_model.dart';
|
||||||
|
import 'package:together_mobile/models/init_get_it.dart';
|
||||||
import 'package:together_mobile/screens/contact/contact_apply_screen/applicant_profile_screen/applicant_profile_screen.dart';
|
import 'package:together_mobile/screens/contact/contact_apply_screen/applicant_profile_screen/applicant_profile_screen.dart';
|
||||||
import 'package:together_mobile/screens/friend_profile/friend_setting_screen/friend_setting_screen.dart';
|
import 'package:together_mobile/screens/friend_profile/friend_setting_screen/friend_setting_screen.dart';
|
||||||
|
|
||||||
import 'router_key.dart';
|
import 'router_key.dart';
|
||||||
import 'package:together_mobile/screens/contact/contact_apply_screen/apply_list_screen.dart';
|
import 'package:together_mobile/screens/contact/contact_apply_screen/apply_list_screen.dart';
|
||||||
import 'package:together_mobile/screens/contact/contact_screen.dart';
|
import 'package:together_mobile/screens/contact/contact_screen.dart';
|
||||||
import 'package:together_mobile/screens/contact/friend_group_screen/friend_group_screen.dart';
|
import 'package:together_mobile/screens/contact/manage_group_screen/manage_group_screen.dart';
|
||||||
import 'package:together_mobile/screens/contact_add/contact_add_friend_screen/add_friend_screen.dart';
|
import 'package:together_mobile/screens/contact_add/contact_add_friend_screen/add_friend_screen.dart';
|
||||||
import 'package:together_mobile/screens/contact_add/search_new_screen.dart';
|
import 'package:together_mobile/screens/contact_add/search_new_screen.dart';
|
||||||
import 'package:together_mobile/screens/friend_profile/friend_profile_screen.dart';
|
import 'package:together_mobile/screens/friend_profile/friend_profile_screen.dart';
|
||||||
|
@ -16,7 +18,14 @@ import 'package:together_mobile/screens/group_chat_profile/group_chat_profile_sc
|
||||||
final contactRouter = GoRoute(
|
final contactRouter = GoRoute(
|
||||||
path: '/contact',
|
path: '/contact',
|
||||||
name: 'Contact',
|
name: 'Contact',
|
||||||
builder: (context, state) => const ContactScreen(),
|
builder: (context, state) {
|
||||||
|
if (state.queryParameters.isNotEmpty) {
|
||||||
|
var deletedFriendId = state.queryParameters['deletedFriendId'];
|
||||||
|
getIt.get<Contact>().removeFriend(deletedFriendId!);
|
||||||
|
getIt.get<ContactAccountProfile>().removeFriend(deletedFriendId);
|
||||||
|
}
|
||||||
|
return ContactScreen();
|
||||||
|
},
|
||||||
routes: [
|
routes: [
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: 'add',
|
path: 'add',
|
||||||
|
@ -92,7 +101,9 @@ final contactRouter = GoRoute(
|
||||||
path: 'friend_setting',
|
path: 'friend_setting',
|
||||||
name: 'FriendSetting',
|
name: 'FriendSetting',
|
||||||
parentNavigatorKey: rootNavigatorKey,
|
parentNavigatorKey: rootNavigatorKey,
|
||||||
builder: (context, state) => FriendSettingScreen(friendId: state.queryParameters['friendId']!,),
|
builder: (context, state) => FriendSettingScreen(
|
||||||
|
friendId: state.queryParameters['friendId']!,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:together_mobile/models/contact_model.dart';
|
|
||||||
|
|
||||||
import 'components/chat_tile.dart';
|
import 'components/chat_tile.dart';
|
||||||
|
import 'package:together_mobile/models/contact_model.dart';
|
||||||
import 'package:together_mobile/models/apply_list_model.dart';
|
import 'package:together_mobile/models/apply_list_model.dart';
|
||||||
import 'package:together_mobile/request/apply.dart';
|
import 'package:together_mobile/request/apply.dart';
|
||||||
import 'package:together_mobile/request/server.dart';
|
import 'package:together_mobile/request/server.dart';
|
||||||
|
|
|
@ -18,29 +18,30 @@ class FriendGroup extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FriendGroupState extends State<FriendGroup> {
|
class _FriendGroupState extends State<FriendGroup> {
|
||||||
late Map<String, FriendSetting> _groupFriends;
|
|
||||||
late List<FriendTile> _friendTiles;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_groupFriends = getIt.get<Contact>().filterGroupFriends(widget.groupName);
|
|
||||||
_friendTiles = List.generate(
|
|
||||||
_groupFriends.length,
|
|
||||||
(index) => FriendTile(
|
|
||||||
key: ValueKey(
|
|
||||||
getIt.get<Contact>().friends.keys.toList()[index],
|
|
||||||
),
|
|
||||||
friendId: _groupFriends.keys.toList()[index]),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ExpansionTile(
|
return ExpansionTile(
|
||||||
title: Text(widget.groupName),
|
title: Text(widget.groupName),
|
||||||
trailing: Text(_friendTiles.length.toString()),
|
trailing: Text(
|
||||||
children: _friendTiles,
|
getIt
|
||||||
|
.get<Contact>()
|
||||||
|
.filterGroupFriends(widget.groupName)
|
||||||
|
.length
|
||||||
|
.toString(),
|
||||||
|
),
|
||||||
|
children: List.generate(
|
||||||
|
getIt.get<Contact>().filterGroupFriends(widget.groupName).length,
|
||||||
|
(index) => FriendTile(
|
||||||
|
key: ValueKey(
|
||||||
|
getIt.get<Contact>().friends.keys.toList()[index],
|
||||||
|
),
|
||||||
|
friendId: getIt
|
||||||
|
.get<Contact>()
|
||||||
|
.filterGroupFriends(widget.groupName)
|
||||||
|
.keys
|
||||||
|
.toList()[index],
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -6,8 +5,6 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:together_mobile/common/constants.dart';
|
import 'package:together_mobile/common/constants.dart';
|
||||||
import 'package:together_mobile/request/server.dart';
|
import 'package:together_mobile/request/server.dart';
|
||||||
import 'package:together_mobile/screens/friend_profile/components/friend_profile_card.dart';
|
import 'package:together_mobile/screens/friend_profile/components/friend_profile_card.dart';
|
||||||
import 'package:together_mobile/models/init_get_it.dart';
|
|
||||||
import 'package:together_mobile/models/user_model.dart';
|
|
||||||
|
|
||||||
class ApplicantProfileScreen extends StatelessWidget {
|
class ApplicantProfileScreen extends StatelessWidget {
|
||||||
const ApplicantProfileScreen({
|
const ApplicantProfileScreen({
|
||||||
|
|
|
@ -7,13 +7,12 @@ import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
import 'package:together_mobile/common/constants.dart';
|
import 'package:together_mobile/common/constants.dart';
|
||||||
import 'package:together_mobile/models/apply_list_model.dart';
|
import 'package:together_mobile/models/apply_list_model.dart';
|
||||||
|
import 'package:together_mobile/models/contact_model.dart';
|
||||||
import 'package:together_mobile/models/init_get_it.dart';
|
import 'package:together_mobile/models/init_get_it.dart';
|
||||||
import 'package:together_mobile/models/user_model.dart';
|
import 'package:together_mobile/models/user_model.dart';
|
||||||
import 'package:together_mobile/request/apply.dart';
|
import 'package:together_mobile/request/apply.dart';
|
||||||
import 'package:together_mobile/request/server.dart';
|
import 'package:together_mobile/request/server.dart';
|
||||||
|
|
||||||
const List<String> friendGroup = ['我的好友', '同学', '同事', '朋友', '家人'];
|
|
||||||
|
|
||||||
class ApplyBottomSheet extends StatefulWidget {
|
class ApplyBottomSheet extends StatefulWidget {
|
||||||
const ApplyBottomSheet({
|
const ApplyBottomSheet({
|
||||||
super.key,
|
super.key,
|
||||||
|
@ -33,7 +32,7 @@ class ApplyBottomSheet extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ApplyBottomSheetState extends State<ApplyBottomSheet> {
|
class _ApplyBottomSheetState extends State<ApplyBottomSheet> {
|
||||||
String _curValue = friendGroup.first;
|
String _curValue = getIt.get<Contact>().friendGroups.first;
|
||||||
final _remarkController = TextEditingController();
|
final _remarkController = TextEditingController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -163,7 +162,10 @@ class _ApplyBottomSheetState extends State<ApplyBottomSheet> {
|
||||||
_curValue = value!;
|
_curValue = value!;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
items: friendGroup.map<DropdownMenuItem<String>>((String value) {
|
items: getIt
|
||||||
|
.get<Contact>()
|
||||||
|
.friendGroups
|
||||||
|
.map<DropdownMenuItem<String>>((String value) {
|
||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
value: value,
|
value: value,
|
||||||
child: Text(value),
|
child: Text(value),
|
||||||
|
@ -212,12 +214,24 @@ class _ApplyBottomSheetState extends State<ApplyBottomSheet> {
|
||||||
|
|
||||||
if (res['code'] == 10600) {
|
if (res['code'] == 10600) {
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
CherryToast.success(title: const Text('添加好友成功')).show(context);
|
CherryToast.success(
|
||||||
|
title: const Text(
|
||||||
|
'添加好友成功',
|
||||||
|
style: TextStyle(
|
||||||
|
color: kContentColorLight,
|
||||||
|
),
|
||||||
|
)).show(context);
|
||||||
getIt.get<ApplyList>().removeAt(widget.index);
|
getIt.get<ApplyList>().removeAt(widget.index);
|
||||||
widget.refreshCallback();
|
widget.refreshCallback();
|
||||||
|
getIt.get<Contact>().addFriend(widget.apply.applicant!, recipientSetting);
|
||||||
} else {
|
} else {
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
CherryToast.error(title: const Text('添加失败,稍后重试')).show(context);
|
CherryToast.error(
|
||||||
|
title: const Text(
|
||||||
|
'添加失败,稍后重试',
|
||||||
|
style: TextStyle(color: kContentColorLight),
|
||||||
|
),
|
||||||
|
).show(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:badges/badges.dart' as badges;
|
import 'package:badges/badges.dart' as badges;
|
||||||
import 'package:visibility_detector/visibility_detector.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:get_it_mixin/get_it_mixin.dart';
|
||||||
|
|
||||||
import 'package:together_mobile/common/constants.dart';
|
import 'package:together_mobile/common/constants.dart';
|
||||||
import 'package:together_mobile/models/apply_list_model.dart';
|
import 'package:together_mobile/models/apply_list_model.dart';
|
||||||
import 'package:together_mobile/models/contact_model.dart';
|
import 'package:together_mobile/models/contact_model.dart';
|
||||||
import 'package:together_mobile/models/init_get_it.dart';
|
|
||||||
import 'package:together_mobile/models/user_model.dart';
|
import 'package:together_mobile/models/user_model.dart';
|
||||||
import 'package:together_mobile/request/server.dart';
|
import 'package:together_mobile/request/server.dart';
|
||||||
import 'package:together_mobile/screens/contact/components/friend_group.dart';
|
import 'package:together_mobile/screens/contact/components/friend_group.dart';
|
||||||
import 'package:together_mobile/screens/contact/components/friend_tile.dart';
|
import 'package:together_mobile/screens/contact/components/friend_tile.dart';
|
||||||
import 'package:together_mobile/screens/contact/components/group_chat_tile.dart';
|
import 'package:together_mobile/screens/contact/components/group_chat_tile.dart';
|
||||||
|
|
||||||
class ContactScreen extends StatefulWidget {
|
class ContactScreen extends StatefulWidget with GetItStatefulWidgetMixin {
|
||||||
const ContactScreen({super.key});
|
ContactScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ContactScreen> createState() => _ContactScreenState();
|
State<ContactScreen> createState() => _ContactScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ContactScreenState extends State<ContactScreen> {
|
class _ContactScreenState extends State<ContactScreen> with GetItStateMixin {
|
||||||
final Map<String, bool> _shows = {
|
final Map<String, bool> _shows = {
|
||||||
'friendGroups': true,
|
'friendGroups': true,
|
||||||
'allFriends': false,
|
'allFriends': false,
|
||||||
|
@ -30,6 +30,13 @@ class _ContactScreenState extends State<ContactScreen> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
Map<String, FriendSetting> friends = watchOnly(
|
||||||
|
(Contact contact) => contact.friends,
|
||||||
|
);
|
||||||
|
List<String> friendGroups = watchOnly(
|
||||||
|
(Contact contact) => contact.friendGroups,
|
||||||
|
);
|
||||||
|
|
||||||
// Create a localkey, use to generate the custom scroll view,
|
// Create a localkey, use to generate the custom scroll view,
|
||||||
// or there will be a error: "Duplicate GlobalKey detected in widget tree."
|
// or there will be a error: "Duplicate GlobalKey detected in widget tree."
|
||||||
// But when I wrap custom scroll view into the RefrashIndicator, the key isn't needed any more
|
// But when I wrap custom scroll view into the RefrashIndicator, the key isn't needed any more
|
||||||
|
@ -39,13 +46,13 @@ class _ContactScreenState extends State<ContactScreen> {
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
leading: Container(
|
leading: Container(
|
||||||
margin: const EdgeInsets.only(left: 8),
|
margin: const EdgeInsets.only(left: 8),
|
||||||
child: getIt.get<UserProfile>().avatar.isEmpty
|
child: get<UserProfile>().avatar.isEmpty
|
||||||
? const CircleAvatar(
|
? const CircleAvatar(
|
||||||
backgroundImage: AssetImage('assets/images/user_2.png'),
|
backgroundImage: AssetImage('assets/images/user_2.png'),
|
||||||
)
|
)
|
||||||
: CircleAvatar(
|
: CircleAvatar(
|
||||||
backgroundImage: CachedNetworkImageProvider(
|
backgroundImage: CachedNetworkImageProvider(
|
||||||
'$avatarsUrl/${getIt.get<UserProfile>().avatar}',
|
'$avatarsUrl/${get<UserProfile>().avatar}',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -79,7 +86,7 @@ class _ContactScreenState extends State<ContactScreen> {
|
||||||
[
|
[
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
// await getApplicantInfo(getIt.get<ApplyList>().applicantIds);
|
// await getApplicantInfo(get<ApplyList>().applicantIds);
|
||||||
context.push('/contact/apply_list');
|
context.push('/contact/apply_list');
|
||||||
},
|
},
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
|
@ -89,13 +96,13 @@ class _ContactScreenState extends State<ContactScreen> {
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
badges.Badge(
|
badges.Badge(
|
||||||
showBadge: getIt.get<ApplyList>().count > 0,
|
showBadge: get<ApplyList>().count > 0,
|
||||||
badgeStyle: const badges.BadgeStyle(
|
badgeStyle: const badges.BadgeStyle(
|
||||||
badgeColor: kErrorColor,
|
badgeColor: kErrorColor,
|
||||||
elevation: 12,
|
elevation: 12,
|
||||||
),
|
),
|
||||||
badgeContent: Text(
|
badgeContent: Text(
|
||||||
getIt.get<ApplyList>().count.toString(),
|
get<ApplyList>().count.toString(),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
color:
|
color:
|
||||||
|
@ -158,26 +165,25 @@ class _ContactScreenState extends State<ContactScreen> {
|
||||||
(BuildContext context, int index) {
|
(BuildContext context, int index) {
|
||||||
if (_shows['friendGroups']!) {
|
if (_shows['friendGroups']!) {
|
||||||
return FriendGroup(
|
return FriendGroup(
|
||||||
key: ValueKey(getIt.get<Contact>().friendGroups[index]),
|
key: ValueKey(friendGroups[index]),
|
||||||
groupName: getIt.get<Contact>().friendGroups[index],
|
groupName: friendGroups[index],
|
||||||
);
|
);
|
||||||
} else if (_shows['allFriends']!) {
|
} else if (_shows['allFriends']!) {
|
||||||
return FriendTile(
|
return FriendTile(
|
||||||
key: ValueKey(
|
key: ValueKey(
|
||||||
getIt.get<Contact>().friends.keys.toList()[index],
|
friends.keys.toList()[index],
|
||||||
),
|
),
|
||||||
friendId:
|
friendId: friends.keys.toList()[index],
|
||||||
getIt.get<Contact>().friends.keys.toList()[index],
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return GroupChatTile();
|
return GroupChatTile();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
childCount: _shows['friendGroups']!
|
childCount: _shows['friendGroups']!
|
||||||
? getIt.get<Contact>().friendGroups.length
|
? get<Contact>().friendGroups.length
|
||||||
: _shows['allFriends']!
|
: _shows['allFriends']!
|
||||||
? getIt.get<Contact>().friends.length
|
? get<Contact>().friends.length
|
||||||
: getIt.get<Contact>().groupChats.length,
|
: get<Contact>().groupChats.length,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -4,6 +4,8 @@ import 'package:go_router/go_router.dart';
|
||||||
import 'package:cherry_toast/cherry_toast.dart';
|
import 'package:cherry_toast/cherry_toast.dart';
|
||||||
|
|
||||||
import 'package:together_mobile/common/constants.dart';
|
import 'package:together_mobile/common/constants.dart';
|
||||||
|
import 'package:together_mobile/models/contact_model.dart';
|
||||||
|
import 'package:together_mobile/models/init_get_it.dart';
|
||||||
|
|
||||||
class EditGroupBottomSheet extends StatefulWidget {
|
class EditGroupBottomSheet extends StatefulWidget {
|
||||||
const EditGroupBottomSheet({
|
const EditGroupBottomSheet({
|
||||||
|
@ -130,18 +132,48 @@ class _EditGroupBottomSheetState extends State<EditGroupBottomSheet> {
|
||||||
thickness: 1,
|
thickness: 1,
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
if (widget.tempGroups[widget.index] == widget.tempDefaultGroup) {
|
String deletedGroup = widget.tempGroups[widget.index];
|
||||||
|
if (deletedGroup == widget.tempDefaultGroup) {
|
||||||
CherryToast.warning(
|
CherryToast.warning(
|
||||||
title: const Text('不可删除默认分组'),
|
title: const Text(
|
||||||
|
'不可删除默认分组',
|
||||||
|
style: TextStyle(
|
||||||
|
color: kContentColorLight,
|
||||||
|
),
|
||||||
|
),
|
||||||
).show(context);
|
).show(context);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int? choose = await showDialog<int>(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('删除分组'),
|
||||||
|
content: const Text('该分组内的好友将被移到默认分组'),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => context.pop<int>(0),
|
||||||
|
child: const Text('取消'),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => context.pop<int>(1),
|
||||||
|
child: const Text('确定'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (choose == 1) {
|
||||||
// close the bottomsheet
|
// close the bottomsheet
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
context.pop();
|
context.pop();
|
||||||
widget.deleteCallback(widget.index);
|
widget.deleteCallback(widget.index);
|
||||||
widget.refreshCallback();
|
widget.refreshCallback();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
fixedSize: const Size(240, 40),
|
fixedSize: const Size(240, 40),
|
|
@ -5,7 +5,7 @@ import 'package:flutter_slidable/flutter_slidable.dart';
|
||||||
|
|
||||||
import 'package:reorderables/reorderables.dart';
|
import 'package:reorderables/reorderables.dart';
|
||||||
import 'package:together_mobile/common/constants.dart';
|
import 'package:together_mobile/common/constants.dart';
|
||||||
import 'package:together_mobile/screens/contact/friend_group_screen/components/group_bottom_sheet.dart';
|
import 'package:together_mobile/screens/contact/manage_group_screen/components/group_bottom_sheet.dart';
|
||||||
|
|
||||||
class ReorderableFriendGroupList extends StatefulWidget {
|
class ReorderableFriendGroupList extends StatefulWidget {
|
||||||
const ReorderableFriendGroupList({
|
const ReorderableFriendGroupList({
|
||||||
|
@ -62,7 +62,9 @@ class _ReorderableFriendGroupListState
|
||||||
onPressed: (BuildContext context) {
|
onPressed: (BuildContext context) {
|
||||||
if (widget.tempGroups[index] == widget.tempDefaultGroup) {
|
if (widget.tempGroups[index] == widget.tempDefaultGroup) {
|
||||||
CherryToast.warning(
|
CherryToast.warning(
|
||||||
title: const Text('不可删除默认分组'),
|
title: const Text(
|
||||||
|
'不可删除默认分组',
|
||||||
|
),
|
||||||
).show(context);
|
).show(context);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@ import 'package:together_mobile/models/init_get_it.dart';
|
||||||
import 'package:together_mobile/models/user_model.dart';
|
import 'package:together_mobile/models/user_model.dart';
|
||||||
import 'package:together_mobile/request/contact.dart';
|
import 'package:together_mobile/request/contact.dart';
|
||||||
|
|
||||||
import 'package:together_mobile/screens/contact/friend_group_screen/components/reorderable_friend_group_list.dart';
|
import 'package:together_mobile/screens/contact/manage_group_screen/components/reorderable_friend_group_list.dart';
|
||||||
|
|
||||||
class FriendGroupScreen extends StatefulWidget {
|
class FriendGroupScreen extends StatefulWidget {
|
||||||
const FriendGroupScreen({super.key});
|
const FriendGroupScreen({super.key});
|
||||||
|
@ -22,6 +22,7 @@ class _FriendGroupScreenState extends State<FriendGroupScreen> {
|
||||||
bool _isChanged = false;
|
bool _isChanged = false;
|
||||||
final List<String> _tempGroups = [];
|
final List<String> _tempGroups = [];
|
||||||
final List<List<String>> _groupNameChangePair = [];
|
final List<List<String>> _groupNameChangePair = [];
|
||||||
|
final List<String> _deletedOriginGroups = [];
|
||||||
String _tempDefaultGroup = getIt.get<Contact>().defaultGroup;
|
String _tempDefaultGroup = getIt.get<Contact>().defaultGroup;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -59,7 +60,7 @@ class _FriendGroupScreenState extends State<FriendGroupScreen> {
|
||||||
? kUnActivatedColor
|
? kUnActivatedColor
|
||||||
: Theme.of(context).brightness == Brightness.light
|
: Theme.of(context).brightness == Brightness.light
|
||||||
? kContentColorDark
|
? kContentColorDark
|
||||||
: kContentColorLight,
|
: kPrimaryColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -85,6 +86,12 @@ class _FriendGroupScreenState extends State<FriendGroupScreen> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _delete(int index) {
|
void _delete(int index) {
|
||||||
|
if (getIt.get<Contact>().friendGroups.contains(_tempGroups[index])) {
|
||||||
|
setState(() {
|
||||||
|
_deletedOriginGroups.add(_tempGroups[index]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_tempGroups.removeAt(index);
|
_tempGroups.removeAt(index);
|
||||||
_isChanged = !listEquals(_tempGroups, getIt.get<Contact>().friendGroups);
|
_isChanged = !listEquals(_tempGroups, getIt.get<Contact>().friendGroups);
|
||||||
|
@ -118,25 +125,32 @@ class _FriendGroupScreenState extends State<FriendGroupScreen> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _save() async {
|
Future<void> _save() async {
|
||||||
|
int sub =
|
||||||
|
getIt.get<Contact>().friendGroups.length - _deletedOriginGroups.length;
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_deletedOriginGroups.addAll(List.filled(sub - 1, ''));
|
||||||
|
});
|
||||||
|
|
||||||
Map<String, dynamic> res = await manageGroups(
|
Map<String, dynamic> res = await manageGroups(
|
||||||
getIt.get<UserAccount>().id,
|
getIt.get<UserAccount>().id,
|
||||||
_tempGroups,
|
_tempGroups,
|
||||||
_groupNameChangePair,
|
_groupNameChangePair,
|
||||||
|
_deletedOriginGroups,
|
||||||
_tempDefaultGroup,
|
_tempDefaultGroup,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (res['code'] == 10700) {
|
if (res['code'] == 10700) {
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
CherryToast.success(
|
CherryToast.success(
|
||||||
title: const Text('保存更改成功'),
|
title: const Text(
|
||||||
|
'保存更改成功',
|
||||||
|
style: TextStyle(color: kContentColorLight),
|
||||||
|
),
|
||||||
).show(context);
|
).show(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
getIt.get<Contact>().manageGroup(
|
getIt.get<Contact>().init(res['data']);
|
||||||
_tempGroups,
|
|
||||||
_groupNameChangePair,
|
|
||||||
_tempDefaultGroup,
|
|
||||||
);
|
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_isChanged = false;
|
_isChanged = false;
|
|
@ -1,15 +1,16 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:cherry_toast/cherry_toast.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:cherry_toast/cherry_toast.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
import 'package:together_mobile/common/constants.dart';
|
import 'package:together_mobile/common/constants.dart';
|
||||||
|
import 'package:together_mobile/models/contact_model.dart';
|
||||||
import 'package:together_mobile/models/init_get_it.dart';
|
import 'package:together_mobile/models/init_get_it.dart';
|
||||||
import 'package:together_mobile/models/user_model.dart';
|
import 'package:together_mobile/models/user_model.dart';
|
||||||
import 'package:together_mobile/request/apply.dart';
|
import 'package:together_mobile/request/apply.dart';
|
||||||
|
import 'package:together_mobile/request/server.dart';
|
||||||
const List<String> friendGroup = ['我的好友', '同学', '同事', '朋友', '家人'];
|
|
||||||
|
|
||||||
class AddBottomSheet extends StatefulWidget {
|
class AddBottomSheet extends StatefulWidget {
|
||||||
const AddBottomSheet({super.key, required this.friendId});
|
const AddBottomSheet({super.key, required this.friendId});
|
||||||
|
@ -23,7 +24,7 @@ class AddBottomSheet extends StatefulWidget {
|
||||||
class _AddBottomSheetState extends State<AddBottomSheet> {
|
class _AddBottomSheetState extends State<AddBottomSheet> {
|
||||||
final TextEditingController _helloController = TextEditingController();
|
final TextEditingController _helloController = TextEditingController();
|
||||||
final TextEditingController _remarkController = TextEditingController();
|
final TextEditingController _remarkController = TextEditingController();
|
||||||
String _selectedGroup = friendGroup.first;
|
String _selectedGroup = getIt.get<Contact>().friendGroups.first;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
@ -62,8 +63,8 @@ class _AddBottomSheetState extends State<AddBottomSheet> {
|
||||||
)
|
)
|
||||||
: CircleAvatar(
|
: CircleAvatar(
|
||||||
radius: 30,
|
radius: 30,
|
||||||
backgroundImage: FileImage(
|
backgroundImage: CachedNetworkImageProvider(
|
||||||
File(getIt.get<UserProfile>().avatar),
|
'$avatarsUrl/${getIt.get<UserProfile>().avatar}',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
|
@ -149,7 +150,10 @@ class _AddBottomSheetState extends State<AddBottomSheet> {
|
||||||
_selectedGroup = value!;
|
_selectedGroup = value!;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
items: friendGroup.map<DropdownMenuItem<String>>((String value) {
|
items: getIt
|
||||||
|
.get<Contact>()
|
||||||
|
.friendGroups
|
||||||
|
.map<DropdownMenuItem<String>>((String value) {
|
||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
value: value,
|
value: value,
|
||||||
child: Text(value),
|
child: Text(value),
|
||||||
|
@ -206,7 +210,14 @@ class _AddBottomSheetState extends State<AddBottomSheet> {
|
||||||
context.pop();
|
context.pop();
|
||||||
|
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
CherryToast.success(title: const Text('已发送添加申请')).show(context);
|
CherryToast.success(
|
||||||
|
title: const Text(
|
||||||
|
'已发送添加申请',
|
||||||
|
style: TextStyle(
|
||||||
|
color: kContentColorLight,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).show(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
import 'package:together_mobile/common/constants.dart';
|
import 'package:together_mobile/common/constants.dart';
|
||||||
|
import 'package:together_mobile/models/contact_model.dart';
|
||||||
import 'package:together_mobile/models/init_get_it.dart';
|
import 'package:together_mobile/models/init_get_it.dart';
|
||||||
import 'package:together_mobile/models/user_model.dart';
|
import 'package:together_mobile/models/user_model.dart';
|
||||||
import 'package:together_mobile/request/search_new.dart';
|
import 'package:together_mobile/request/search_new.dart';
|
||||||
|
@ -127,19 +128,33 @@ class _SearchNewScreenState extends State<SearchNewScreen> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_controller.text == getIt.get<UserAccount>().username ||
|
String searchValue = _controller.text;
|
||||||
_controller.text == getIt.get<UserAccount>().email) {
|
|
||||||
|
if (searchValue == getIt.get<UserAccount>().username ||
|
||||||
|
searchValue == getIt.get<UserAccount>().email) {
|
||||||
context.pushNamed('MainProfile');
|
context.pushNamed('MainProfile');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (isExisted, friendId) = getIt.get<ContactAccountProfile>().getIdBy(
|
||||||
|
'username',
|
||||||
|
searchValue,
|
||||||
|
);
|
||||||
|
if (isExisted) {
|
||||||
|
context.pushNamed(
|
||||||
|
'FriendProfile',
|
||||||
|
queryParameters: {'friendId': friendId},
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_isHttpSent = true;
|
_isHttpSent = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
Map<String, dynamic> res = await searchContactBy(
|
Map<String, dynamic> res = await searchContactBy(
|
||||||
condition,
|
condition,
|
||||||
_controller.text,
|
searchValue,
|
||||||
);
|
);
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:cherry_toast/cherry_toast.dart';
|
import 'package:cherry_toast/cherry_toast.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
import 'package:together_mobile/common/constants.dart';
|
import 'package:together_mobile/common/constants.dart';
|
||||||
import 'package:together_mobile/models/init_get_it.dart';
|
import 'package:together_mobile/models/init_get_it.dart';
|
||||||
import 'package:together_mobile/models/contact_model.dart';
|
import 'package:together_mobile/models/contact_model.dart';
|
||||||
|
import 'package:together_mobile/models/user_model.dart';
|
||||||
import 'package:together_mobile/request/contact.dart';
|
import 'package:together_mobile/request/contact.dart';
|
||||||
|
|
||||||
class FriendSettingScreen extends StatefulWidget {
|
class FriendSettingScreen extends StatefulWidget {
|
||||||
|
@ -48,7 +52,9 @@ class _FriendSettingScreenState extends State<FriendSettingScreen> {
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
title: const Text('好友设置'),
|
title: const Text('好友设置'),
|
||||||
),
|
),
|
||||||
body: SingleChildScrollView(
|
body: CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
SliverToBoxAdapter(
|
||||||
child: ExpansionPanelList(
|
child: ExpansionPanelList(
|
||||||
expansionCallback: (panelIndex, isExpanded) {
|
expansionCallback: (panelIndex, isExpanded) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@ -151,7 +157,8 @@ class _FriendSettingScreenState extends State<FriendSettingScreen> {
|
||||||
backgroundColor: _isRemarkChanged &&
|
backgroundColor: _isRemarkChanged &&
|
||||||
_remarkController.text.isNotEmpty
|
_remarkController.text.isNotEmpty
|
||||||
? kPrimaryColor
|
? kPrimaryColor
|
||||||
: Theme.of(context).brightness == Brightness.dark
|
: Theme.of(context).brightness ==
|
||||||
|
Brightness.dark
|
||||||
? kUnActivatedColor
|
? kUnActivatedColor
|
||||||
: kUnAvailableColor,
|
: kUnAvailableColor,
|
||||||
),
|
),
|
||||||
|
@ -238,17 +245,23 @@ class _FriendSettingScreenState extends State<FriendSettingScreen> {
|
||||||
if (res['code'] == 10700) {
|
if (res['code'] == 10700) {
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
CherryToast.success(
|
CherryToast.success(
|
||||||
title: const Text('已更改好友分组'),
|
title: const Text(
|
||||||
|
'已更改好友分组',
|
||||||
|
style: TextStyle(
|
||||||
|
color: kContentColorLight,
|
||||||
|
),
|
||||||
|
),
|
||||||
).show(context);
|
).show(context);
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_isGroupChanged = false;
|
_isGroupChanged = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
getIt.get<Contact>().changeFriendGroup(
|
// getIt.get<Contact>().changeFriendGroup(
|
||||||
widget.friendId,
|
// widget.friendId,
|
||||||
_group,
|
// _group,
|
||||||
);
|
// );
|
||||||
|
getIt.get<Contact>().init(res['data']);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
style: FilledButton.styleFrom(
|
style: FilledButton.styleFrom(
|
||||||
|
@ -259,7 +272,8 @@ class _FriendSettingScreenState extends State<FriendSettingScreen> {
|
||||||
),
|
),
|
||||||
backgroundColor: _isGroupChanged
|
backgroundColor: _isGroupChanged
|
||||||
? kPrimaryColor
|
? kPrimaryColor
|
||||||
: Theme.of(context).brightness == Brightness.dark
|
: Theme.of(context).brightness ==
|
||||||
|
Brightness.dark
|
||||||
? kUnActivatedColor
|
? kUnActivatedColor
|
||||||
: kUnAvailableColor,
|
: kUnAvailableColor,
|
||||||
),
|
),
|
||||||
|
@ -276,6 +290,81 @@ class _FriendSettingScreenState extends State<FriendSettingScreen> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
await _deleteFriend(context);
|
||||||
|
},
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
foregroundColor: kErrorColor.withOpacity(0.4),
|
||||||
|
),
|
||||||
|
child: const Text(
|
||||||
|
'删除好友',
|
||||||
|
style: TextStyle(
|
||||||
|
color: kErrorColor,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _deleteFriend(BuildContext context) async {
|
||||||
|
int? choose = await showDialog<int>(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('删除好友'),
|
||||||
|
content: const Text('删除好友后,你将会从对方好友列表中移除'),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => context.pop(0),
|
||||||
|
child: const Text(
|
||||||
|
'取消',
|
||||||
|
style: TextStyle(
|
||||||
|
color: kUnAvailableColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => context.pop(1),
|
||||||
|
child: const Text(
|
||||||
|
'确认',
|
||||||
|
style: TextStyle(
|
||||||
|
color: kErrorColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (choose == 1) {
|
||||||
|
Map<String, dynamic> res = await deleteFriend(
|
||||||
|
getIt.get<UserAccount>().id,
|
||||||
|
widget.friendId,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (res['code'] == 10700) {
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
|
context.goNamed(
|
||||||
|
'Contact',
|
||||||
|
queryParameters: {'deletedFriendId': widget.friendId},
|
||||||
|
);
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
|
CherryToast.success(
|
||||||
|
title: const Text(
|
||||||
|
'已删除好友',
|
||||||
|
style: TextStyle(
|
||||||
|
color: kContentColorLight,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).show(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
358
pubspec.lock
358
pubspec.lock
File diff suppressed because it is too large
Load Diff
|
@ -42,6 +42,7 @@ dependencies:
|
||||||
flutter_slidable: ^3.0.0
|
flutter_slidable: ^3.0.0
|
||||||
flutter_timezone: ^1.0.6
|
flutter_timezone: ^1.0.6
|
||||||
get_it: ^7.6.0
|
get_it: ^7.6.0
|
||||||
|
get_it_mixin: ^4.2.0
|
||||||
go_router: ^7.1.1
|
go_router: ^7.1.1
|
||||||
google_fonts: ^4.0.0
|
google_fonts: ^4.0.0
|
||||||
hive: ^2.2.3
|
hive: ^2.2.3
|
||||||
|
@ -55,7 +56,6 @@ dependencies:
|
||||||
shared_preferences: ^2.2.0
|
shared_preferences: ^2.2.0
|
||||||
timezone: ^0.9.2
|
timezone: ^0.9.2
|
||||||
video_player: ^2.6.1
|
video_player: ^2.6.1
|
||||||
visibility_detector: ^0.4.0+2
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_lints: ^2.0.0
|
flutter_lints: ^2.0.0
|
||||||
|
|
Loading…
Reference in New Issue