页面与路由完善
This commit is contained in:
@@ -30,7 +30,7 @@ class PrivateController extends GetxController {
|
||||
currentFriend.value.isFriend =
|
||||
info.relation == UserRelationEnum.V2TIM_FRIEND_RELATION_TYPE_BOTH_WAY;
|
||||
|
||||
currentFriend.value.friendRemark = info.friendInfo!.friendRemark!;
|
||||
currentFriend.value.friendRemark = info.friendInfo!.friendRemark ?? '';
|
||||
currentFriend.value.userProfile = info.friendInfo!.userProfile;
|
||||
|
||||
/// 通过自定义Staffer字段,判断是否是客服,属于哪个店铺
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import 'package:chat/middleware/auth_middleware.dart';
|
||||
import 'package:chat/views/contact/firend/profile/index_page.dart';
|
||||
import 'package:chat/views/contact/firend/profile/more_page.dart';
|
||||
import 'package:chat/views/contact/firend/recommend/friend_page.dart';
|
||||
import 'package:chat/views/contact/firend/recommend/group_page.dart';
|
||||
import 'package:chat/views/contact/firend/recommend/index_page.dart';
|
||||
import 'package:chat/views/contact/firend/remark/index_page.dart';
|
||||
import 'package:chat/views/contact/firend/search/index_page.dart';
|
||||
import 'package:chat/views/contact/group/create/index_page.dart';
|
||||
import 'package:chat/views/contact/group/index_page.dart';
|
||||
import 'package:chat/views/contact/group/manage/index_page.dart';
|
||||
@@ -13,10 +20,13 @@ abstract class ContactRoutes {
|
||||
static const String friend = '/contact/friend';
|
||||
static const String friendSearch = '/contact/friend/search';
|
||||
static const String friendProfile = '/contact/friend/profile';
|
||||
static const String friendProfileMore = '/contact/friend/profile';
|
||||
static const String friendRemark = '/contact/friend/profile';
|
||||
static const String friendProfileMore = '/contact/friend/profile/more';
|
||||
static const String friendRemark = '/contact/friend/remark';
|
||||
static const String friendApply = '/contact/friend/profile';
|
||||
static const String friendRecommend = '/contact/friend/profile';
|
||||
static const String friendRecommend = '/contact/friend/recommend';
|
||||
static const String friendRecommendFriend =
|
||||
'/contact/friend/recommend/friend';
|
||||
static const String friendRecommendGroup = '/contact/friend/recommend/group';
|
||||
|
||||
static const String group = '/contact/group';
|
||||
static const String groupQrCode = '/contact/group/qrCode';
|
||||
@@ -40,7 +50,35 @@ abstract class ContactRoutes {
|
||||
children: [
|
||||
GetPage(
|
||||
name: '/search',
|
||||
page: () => const ContactGroupCreatePage(),
|
||||
page: () => const ContactFriendSearchPage(),
|
||||
),
|
||||
GetPage(
|
||||
name: '/profile',
|
||||
page: () => const ContactFriendProfilePage(),
|
||||
children: [
|
||||
GetPage(
|
||||
name: '/more',
|
||||
page: () => const ContactFriendProfileMorePage(),
|
||||
),
|
||||
],
|
||||
),
|
||||
GetPage(
|
||||
name: '/remark',
|
||||
page: () => const ContactFriendRemarkPage(),
|
||||
),
|
||||
GetPage(
|
||||
name: '/recommend',
|
||||
page: () => const ContactFriendRecommendPage(),
|
||||
children: [
|
||||
GetPage(
|
||||
name: '/friend',
|
||||
page: () => const ContactFriendRecommendFriendPage(),
|
||||
),
|
||||
GetPage(
|
||||
name: '/group',
|
||||
page: () => const ContactFriendRecommendGroupPage(),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -30,8 +30,9 @@ class ImTools {
|
||||
}
|
||||
|
||||
static String parseNicknameFromInfo(V2TimFriendInfo infoResult) {
|
||||
if (infoResult.friendRemark != '') {
|
||||
return infoResult.friendRemark!;
|
||||
if (infoResult.friendRemark != null &&
|
||||
infoResult.friendRemark!.isNotEmpty) {
|
||||
return infoResult.friendRemark ?? '';
|
||||
}
|
||||
|
||||
return infoResult.userProfile!.nickName!;
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:chat/configs/app_colors.dart';
|
||||
import 'package:chat/controllers/private_controller.dart';
|
||||
import 'package:chat/routes/contact_routes.dart';
|
||||
import 'package:chat/routes/conversation_routes.dart';
|
||||
import 'package:chat/routes/moments_routes.dart';
|
||||
import 'package:chat/services/tim/conversation_service.dart';
|
||||
import 'package:chat/utils/im_tools.dart';
|
||||
import 'package:chat/views/home/widgets/action_button.dart';
|
||||
@@ -11,8 +10,8 @@ import 'package:chat/widgets/custom_avatar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class ImFriendProfilePage extends StatelessWidget {
|
||||
const ImFriendProfilePage({Key? key}) : super(key: key);
|
||||
class ContactFriendProfilePage extends StatelessWidget {
|
||||
const ContactFriendProfilePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -76,18 +75,18 @@ class ImFriendProfilePage extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
ActionItem(
|
||||
'他的动态',
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
MomentsRoutes.user,
|
||||
arguments: {
|
||||
'userId': _.currentFriend.value.userID,
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
// const SizedBox(height: 8),
|
||||
// ActionItem(
|
||||
// '他的动态',
|
||||
// onTap: () {
|
||||
// Get.toNamed(
|
||||
// MomentsRoutes.user,
|
||||
// arguments: {
|
||||
// 'userId': _.currentFriend.value.userID,
|
||||
// },
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
const SizedBox(height: 8),
|
||||
Visibility(
|
||||
visible: !_.currentFriend.value.isFriend,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:chat/controllers/private_controller.dart';
|
||||
import 'package:chat/routes/contact_routes.dart';
|
||||
import 'package:chat/services/tim/block_service.dart';
|
||||
import 'package:chat/services/tim/friend_service.dart';
|
||||
import 'package:chat/utils/ui_tools.dart';
|
||||
import 'package:chat/views/home/widgets/action_button.dart';
|
||||
@@ -8,8 +9,8 @@ import 'package:chat/views/home/widgets/action_item.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class ImFriendProfileMorePage extends StatelessWidget {
|
||||
const ImFriendProfileMorePage({Key? key}) : super(key: key);
|
||||
class ContactFriendProfileMorePage extends StatelessWidget {
|
||||
const ContactFriendProfileMorePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:chat/controllers/private_controller.dart';
|
||||
import 'package:chat/models/im/contact_info_model.dart';
|
||||
import 'package:chat/models/im/name_card_model.dart';
|
||||
import 'package:chat/models/im/private_conversation_model.dart';
|
||||
import 'package:chat/routes/contact_routes.dart';
|
||||
import 'package:chat/services/tim/conversation_service.dart';
|
||||
import 'package:chat/services/tim/friend_service.dart';
|
||||
import 'package:chat/utils/im_tools.dart';
|
||||
@@ -14,8 +15,8 @@ import 'package:get/get.dart';
|
||||
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_conversation.dart';
|
||||
|
||||
class ImFriendRecommendFriendsPage extends StatelessWidget {
|
||||
const ImFriendRecommendFriendsPage({Key? key}) : super(key: key);
|
||||
class ContactFriendRecommendFriendPage extends StatelessWidget {
|
||||
const ContactFriendRecommendFriendPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -65,7 +66,7 @@ class ImFriendRecommendFriendsPage extends StatelessWidget {
|
||||
InkWell(
|
||||
onTap: () {
|
||||
FocusScope.of(Get.context!).requestFocus(FocusNode());
|
||||
// Get.offNamed(ImRoutes.friendRecommendGroups);
|
||||
Get.offNamed(ContactRoutes.friendRecommendGroup);
|
||||
},
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
@@ -11,8 +11,8 @@ import 'package:get/get.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_conversation.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_group_info.dart';
|
||||
|
||||
class ImFriendRecommendGroupsPage extends StatelessWidget {
|
||||
const ImFriendRecommendGroupsPage({Key? key}) : super(key: key);
|
||||
class ContactFriendRecommendGroupPage extends StatelessWidget {
|
||||
const ContactFriendRecommendGroupPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -4,6 +4,7 @@ import 'package:chat/configs/app_size.dart';
|
||||
import 'package:chat/controllers/private_controller.dart';
|
||||
import 'package:chat/models/im/name_card_model.dart';
|
||||
import 'package:chat/models/im/private_conversation_model.dart';
|
||||
import 'package:chat/routes/contact_routes.dart';
|
||||
import 'package:chat/services/tim/conversation_service.dart';
|
||||
import 'package:chat/views/home/widgets/group_avatar.dart';
|
||||
import 'package:chat/widgets/custom_avatar.dart';
|
||||
@@ -12,8 +13,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tencent_im_sdk_plugin/enum/conversation_type.dart';
|
||||
|
||||
class ImFriendRecommendPage extends StatelessWidget {
|
||||
const ImFriendRecommendPage({Key? key}) : super(key: key);
|
||||
class ContactFriendRecommendPage extends StatelessWidget {
|
||||
const ContactFriendRecommendPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -68,7 +69,7 @@ class ImFriendRecommendPage extends StatelessWidget {
|
||||
InkWell(
|
||||
onTap: () {
|
||||
FocusScope.of(Get.context!).requestFocus(FocusNode());
|
||||
// Get.offNamed(ImRoutes.friendRecommendFriends);
|
||||
Get.offNamed(ContactRoutes.friendRecommendFriend);
|
||||
},
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
|
||||
@@ -3,14 +3,15 @@ import 'package:chat/controllers/private_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class ImFriendRemarkPage extends StatefulWidget {
|
||||
const ImFriendRemarkPage({Key? key}) : super(key: key);
|
||||
class ContactFriendRemarkPage extends StatefulWidget {
|
||||
const ContactFriendRemarkPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ImFriendRemarkPage> createState() => _ImFriendRemarkPageState();
|
||||
State<ContactFriendRemarkPage> createState() =>
|
||||
_ContactFriendRemarkPageState();
|
||||
}
|
||||
|
||||
class _ImFriendRemarkPageState extends State<ImFriendRemarkPage> {
|
||||
class _ContactFriendRemarkPageState extends State<ContactFriendRemarkPage> {
|
||||
final TextEditingController _controller = TextEditingController();
|
||||
|
||||
@override
|
||||
|
||||
@@ -5,15 +5,16 @@ import 'package:chat/widgets/custom_primary_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class ImFriendRequestApplyPage extends StatefulWidget {
|
||||
const ImFriendRequestApplyPage({Key? key}) : super(key: key);
|
||||
class ContactFriendRequestApplyPage extends StatefulWidget {
|
||||
const ContactFriendRequestApplyPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ImFriendRequestApplyPage> createState() =>
|
||||
_ImFriendRequestApplyPageState();
|
||||
State<ContactFriendRequestApplyPage> createState() =>
|
||||
_ContactFriendRequestApplyPageState();
|
||||
}
|
||||
|
||||
class _ImFriendRequestApplyPageState extends State<ImFriendRequestApplyPage> {
|
||||
class _ContactFriendRequestApplyPageState
|
||||
extends State<ContactFriendRequestApplyPage> {
|
||||
late final String userID;
|
||||
String _remark = '';
|
||||
String _wording = '';
|
||||
|
||||
@@ -11,14 +11,14 @@ import 'package:tencent_im_sdk_plugin/enum/friend_type.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_friend_application.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_friend_check_result.dart';
|
||||
|
||||
class ImFriendRequestPage extends StatefulWidget {
|
||||
const ImFriendRequestPage({Key? key}) : super(key: key);
|
||||
class ContactFriendRequestPage extends StatefulWidget {
|
||||
const ContactFriendRequestPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ImFriendRequestPage> createState() => _ImFriendRequestState();
|
||||
State<ContactFriendRequestPage> createState() => _ImFriendRequestState();
|
||||
}
|
||||
|
||||
class _ImFriendRequestState extends State<ImFriendRequestPage> {
|
||||
class _ImFriendRequestState extends State<ContactFriendRequestPage> {
|
||||
List<SearchUserModel>? searchList;
|
||||
|
||||
@override
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import 'package:chat/configs/app_colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ImFriendSearchPage extends StatefulWidget {
|
||||
const ImFriendSearchPage({Key? key}) : super(key: key);
|
||||
class ContactFriendSearchPage extends StatefulWidget {
|
||||
const ContactFriendSearchPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ImFriendSearchPage> createState() => _ImFriendSearchPageState();
|
||||
State<ContactFriendSearchPage> createState() =>
|
||||
_ContactFriendSearchPageState();
|
||||
}
|
||||
|
||||
class _ImFriendSearchPageState extends State<ImFriendSearchPage> {
|
||||
class _ContactFriendSearchPageState extends State<ContactFriendSearchPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
||||
@@ -1,15 +1,174 @@
|
||||
import 'package:chat/configs/app_colors.dart';
|
||||
import 'package:chat/routes/conversation_routes.dart';
|
||||
import 'package:chat/services/tim/conversation_service.dart';
|
||||
import 'package:chat/services/tim/friend_service.dart';
|
||||
import 'package:chat/services/tim/group_service.dart';
|
||||
import 'package:chat/views/home/widgets/friend_selector.dart';
|
||||
import 'package:chat/widgets/custom_avatar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tencent_im_sdk_plugin/enum/group_type.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_friend_info.dart';
|
||||
|
||||
class ContactGroupCreatePage extends StatefulWidget {
|
||||
const ContactGroupCreatePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ContactGroupCreatePageState createState() => _ContactGroupCreatePageState();
|
||||
State<ContactGroupCreatePage> createState() => _ContactGroupCreatePageState();
|
||||
}
|
||||
|
||||
class _ContactGroupCreatePageState extends State<ContactGroupCreatePage> {
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
|
||||
/// 选中的好友列表
|
||||
List<V2TimFriendInfo> _selectList =
|
||||
List<V2TimFriendInfo>.empty(growable: true);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
TimFriendService.to.fetchList();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text(
|
||||
'发起群聊',
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
top: false,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
color: Colors.white,
|
||||
height: 58,
|
||||
padding: const EdgeInsets.all(
|
||||
4,
|
||||
),
|
||||
child: ListView.builder(
|
||||
controller: _scrollController,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: _selectList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_selectList.removeAt(index);
|
||||
});
|
||||
},
|
||||
child: CustomAvatar(
|
||||
_selectList[index].userProfile!.faceUrl,
|
||||
size: 42,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const Divider(height: 0),
|
||||
Container(
|
||||
color: AppColors.unactive.withOpacity(0.1),
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: const EdgeInsets.only(
|
||||
left: 16,
|
||||
),
|
||||
height: 40,
|
||||
width: double.infinity,
|
||||
child: const Text(
|
||||
'选择群成员',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: FriendSelector(
|
||||
onChanged: onChanged,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.only(
|
||||
right: 16,
|
||||
left: 16,
|
||||
top: 4,
|
||||
),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: Colors.black12,
|
||||
width: 0.4,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'已选 ${_selectList.length}',
|
||||
style: const TextStyle(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed:
|
||||
_selectList.isNotEmpty && _selectList.length < 200
|
||||
? _createGroup
|
||||
: null,
|
||||
child: const Text(
|
||||
'完成',
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 好友选择,添加到选择列表
|
||||
Future onChanged(e) async {
|
||||
setState(() {
|
||||
_selectList = e;
|
||||
|
||||
Future.delayed(const Duration(milliseconds: 200), () {
|
||||
_scrollController.animateTo(
|
||||
_scrollController.position.maxScrollExtent,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.bounceIn,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// 创建群聊
|
||||
Future<void> _createGroup() async {
|
||||
String groupName = '创建的群聊';
|
||||
var result = await TimGroupService.to.create(
|
||||
groupName,
|
||||
_selectList,
|
||||
groupType: GroupType.Public,
|
||||
);
|
||||
|
||||
if (result != null) {
|
||||
Get.offNamed(
|
||||
ConversationRoutes.index,
|
||||
arguments: {
|
||||
'conversation': await TimConversationService.to.getById(
|
||||
'group_' + result,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
179
lib/views/contact/group/create/user_page.dart
Normal file
179
lib/views/contact/group/create/user_page.dart
Normal file
@@ -0,0 +1,179 @@
|
||||
import 'package:chat/configs/app_colors.dart';
|
||||
import 'package:chat/routes/conversation_routes.dart';
|
||||
import 'package:chat/services/tim/conversation_service.dart';
|
||||
import 'package:chat/services/tim/friend_service.dart';
|
||||
import 'package:chat/services/tim/group_service.dart';
|
||||
import 'package:chat/views/home/widgets/friend_selector.dart';
|
||||
import 'package:chat/widgets/custom_avatar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tencent_im_sdk_plugin/enum/group_type.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_friend_info.dart';
|
||||
|
||||
class ContactGroupCreateUserPage extends StatefulWidget {
|
||||
const ContactGroupCreateUserPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ContactGroupCreateUserPage> createState() =>
|
||||
_ContactGroupCreateUserPageState();
|
||||
}
|
||||
|
||||
class _ContactGroupCreateUserPageState
|
||||
extends State<ContactGroupCreateUserPage> {
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
|
||||
late final String groupType;
|
||||
|
||||
/// 选中的好友列表
|
||||
List<V2TimFriendInfo> _selectList =
|
||||
List<V2TimFriendInfo>.empty(growable: true);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
groupType = Get.arguments['groupType'];
|
||||
TimFriendService.to.fetchList();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text(
|
||||
'发起群聊',
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
top: false,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
color: Colors.white,
|
||||
height: 58,
|
||||
padding: const EdgeInsets.all(
|
||||
4,
|
||||
),
|
||||
child: ListView.builder(
|
||||
controller: _scrollController,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: _selectList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_selectList.removeAt(index);
|
||||
});
|
||||
},
|
||||
child: CustomAvatar(
|
||||
_selectList[index].userProfile!.faceUrl,
|
||||
size: 42,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const Divider(height: 0),
|
||||
Container(
|
||||
color: AppColors.unactive.withOpacity(0.1),
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: const EdgeInsets.only(
|
||||
left: 16,
|
||||
),
|
||||
height: 40,
|
||||
width: double.infinity,
|
||||
child: const Text(
|
||||
'选择群成员',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: FriendSelector(
|
||||
onChanged: onChanged,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.only(
|
||||
right: 16,
|
||||
left: 16,
|
||||
top: 4,
|
||||
),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: Colors.black12,
|
||||
width: 0.4,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'已选 ${_selectList.length}',
|
||||
style: const TextStyle(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed:
|
||||
_selectList.isNotEmpty && _selectList.length < 200
|
||||
? _createGroup
|
||||
: null,
|
||||
child: const Text(
|
||||
'完成',
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 好友选择,添加到选择列表
|
||||
Future onChanged(e) async {
|
||||
setState(() {
|
||||
_selectList = e;
|
||||
|
||||
Future.delayed(const Duration(milliseconds: 200), () {
|
||||
_scrollController.animateTo(
|
||||
_scrollController.position.maxScrollExtent,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.bounceIn,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// 创建群聊
|
||||
Future<void> _createGroup() async {
|
||||
String groupName = '创建的群聊';
|
||||
var result = await TimGroupService.to.create(
|
||||
groupName,
|
||||
_selectList,
|
||||
groupType: GroupType.Public,
|
||||
);
|
||||
|
||||
if (result != null) {
|
||||
Get.offNamed(
|
||||
ConversationRoutes.index,
|
||||
arguments: {
|
||||
'conversation': await TimConversationService.to.getById(
|
||||
'group_' + result,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import 'package:chat/configs/app_colors.dart';
|
||||
import 'package:chat/services/tabbar_service.dart';
|
||||
import 'package:chat/views/contact/index/index_page.dart';
|
||||
import 'package:chat/views/home/index_page.dart';
|
||||
import 'package:chat/views/moments/index/index_page.dart';
|
||||
import 'package:chat/views/user/index/user_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -14,7 +13,7 @@ class AppPage extends StatelessWidget {
|
||||
final List<IndexedStackChild> _tabBarPageList = [
|
||||
IndexedStackChild(child: const HomePage()),
|
||||
IndexedStackChild(child: const ContactPage()),
|
||||
IndexedStackChild(child: const MomentsPage()),
|
||||
// IndexedStackChild(child: const MomentsPage()),
|
||||
IndexedStackChild(child: const UserPage()),
|
||||
];
|
||||
|
||||
@@ -29,11 +28,11 @@ class AppPage extends StatelessWidget {
|
||||
'active_icon': Icons.contact_page,
|
||||
'label': '通讯录',
|
||||
},
|
||||
{
|
||||
'icon': Icons.explore_outlined,
|
||||
'active_icon': Icons.explore,
|
||||
'label': '发现',
|
||||
},
|
||||
// {
|
||||
// 'icon': Icons.explore_outlined,
|
||||
// 'active_icon': Icons.explore,
|
||||
// 'label': '发现',
|
||||
// },
|
||||
{
|
||||
'icon': Icons.person_outline,
|
||||
'active_icon': Icons.person,
|
||||
|
||||
@@ -1,15 +1,131 @@
|
||||
import 'package:chat/configs/app_colors.dart';
|
||||
import 'package:chat/views/home/widgets/pop_menu_item.dart';
|
||||
import 'package:chat/views/public/scan_page.dart';
|
||||
import 'package:chat/widgets/custom_avatar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
|
||||
class UserQrCodePage extends StatefulWidget {
|
||||
const UserQrCodePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_UserQrCodePageState createState() => _UserQrCodePageState();
|
||||
State<UserQrCodePage> createState() => _UserQrCodePageState();
|
||||
}
|
||||
|
||||
class _UserQrCodePageState extends State<UserQrCodePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('我的二维码'),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
_showLongPressMenu();
|
||||
},
|
||||
icon: const Icon(Icons.more_horiz),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Center(
|
||||
child: Container(
|
||||
width: Get.width - 32,
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
CustomAvatar(
|
||||
'',
|
||||
size: 64,
|
||||
radius: 6,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: const [
|
||||
Text(
|
||||
'Jason',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
QrImage(
|
||||
data: 'BEFRIEND|5',
|
||||
version: 3,
|
||||
size: Get.width * 0.8,
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
const Text(
|
||||
'扫一扫上面的二维码,加我共力好友',
|
||||
style: TextStyle(
|
||||
color: AppColors.unactive,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _showLongPressMenu() async {
|
||||
showModalBottomSheet(
|
||||
context: Get.context!,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: AppColors.white,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(8)),
|
||||
),
|
||||
builder: (context) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
PopMenuItem(
|
||||
'保存到手机',
|
||||
onTap: () {},
|
||||
),
|
||||
const Divider(height: 0),
|
||||
PopMenuItem(
|
||||
'扫描二维码',
|
||||
onTap: () {
|
||||
Get.back();
|
||||
Permission.camera.request().isGranted.then((value) {
|
||||
if (value) {
|
||||
Get.to(const ScanPage());
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
const Divider(height: 0),
|
||||
const Divider(height: 0.4),
|
||||
Container(
|
||||
color: AppColors.page,
|
||||
height: 8,
|
||||
),
|
||||
const Divider(height: 0.4),
|
||||
PopMenuItem(
|
||||
'取消',
|
||||
onTap: () {
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class CustomAvatar extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (avtarUrl == null || avtarUrl == '') {
|
||||
avtarUrl = 'assets/chats/default_avatar.png';
|
||||
avtarUrl = 'assets/images/default_avatar.png';
|
||||
}
|
||||
|
||||
avtarUrl = avtarUrl!.trim();
|
||||
|
||||
Reference in New Issue
Block a user