From 4a0d84ee008aecd1f6c609b3dfb3e806ae5b69d7 Mon Sep 17 00:00:00 2001 From: fuenmao <980740792@qq.com> Date: Mon, 9 Dec 2024 11:13:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=8A=E8=A7=86=E9=A2=91=E9=A1=B5=E6=8F=90?= =?UTF-8?q?=E5=87=BA=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/pages/metting/meeting_main_logic.dart | 7 +- .../lib/pages/metting/meeting_main_state.dart | 2 + .../lib/pages/metting/meeting_main_view.dart | 247 ++++++++++++++++-- 3 files changed, 235 insertions(+), 21 deletions(-) diff --git a/wgshare/lib/pages/metting/meeting_main_logic.dart b/wgshare/lib/pages/metting/meeting_main_logic.dart index ae808da..bd5e27b 100644 --- a/wgshare/lib/pages/metting/meeting_main_logic.dart +++ b/wgshare/lib/pages/metting/meeting_main_logic.dart @@ -427,8 +427,11 @@ class MeetingMainLogic extends GetxController with RequestToolMixin{ muteLocalVideoStream(false); // 开始本地预览 startPreview(); - // 打开本地预览悬浮窗 - state.floating.value?.open(state.context.value!); + // 只有在视频大屏的时候 + if(state.pageIndex.value == 0){ + // 打开本地预览悬浮窗 + state.floating.value?.open(state.context.value!); + } changePageState(1); } }else{ diff --git a/wgshare/lib/pages/metting/meeting_main_state.dart b/wgshare/lib/pages/metting/meeting_main_state.dart index f7209fe..43a0c94 100644 --- a/wgshare/lib/pages/metting/meeting_main_state.dart +++ b/wgshare/lib/pages/metting/meeting_main_state.dart @@ -33,6 +33,8 @@ class MeetingMainState { /// 当前页面状态,0:语音,1:视频,2,共享 late RxInt pageState = 0.obs; + /// 视频页面状态时,pageview指示器 + late RxInt pageIndex = 0.obs; /// 会议室编号 late RxString roomNumber = "".obs; diff --git a/wgshare/lib/pages/metting/meeting_main_view.dart b/wgshare/lib/pages/metting/meeting_main_view.dart index 596003b..14c1d01 100644 --- a/wgshare/lib/pages/metting/meeting_main_view.dart +++ b/wgshare/lib/pages/metting/meeting_main_view.dart @@ -8,6 +8,7 @@ import 'package:flutter_floating/floating/floating.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:liquid_progress_indicator_v2/liquid_progress_indicator.dart'; +import 'package:preload_page_view/preload_page_view.dart'; import 'package:wgshare/common/store/user_store.dart'; import 'package:wgshare/pages/metting/share/meeting_main_share_view.dart'; import 'package:wgshare/pages/metting/video/meeting_main_video_view.dart'; @@ -223,25 +224,55 @@ class MeetingMainPageState extends State { Visibility( visible: state.pageState.value == 1, child: null != state.rctEngine.value - ? MeetingMainVideoComponent( - rtcEngine: state.rctEngine.value!, - channelId: state.roomNumber.value, - isOpenCamera: state.isOpenCamera.value, - remoteUid: state.remoteUid.value, - users: state.cacheUsers.value - .where((user) => - user.enableCamera == true) - .toList(), - onHangUpTap: () { - logic.hangUpVideo(); - }, - onPageViewIndexChange: (index) { - if(index == 0){ - state.floating.value?.open(context); - }else{ - state.floating.value?.close(); - } - }, + ? Stack( + alignment: Alignment.center, + children: [ + PreloadPageView.builder( + preloadPagesCount: 2, + itemCount: 2, + itemBuilder: (BuildContext context, int position) => returnPage(position), + controller: PreloadPageController(initialPage: 0), + onPageChanged: (int position) { + state.pageIndex.value = position; + if(state.isSpeak.value == true && state.isOpenCamera.value == true){ + if(position == 0){ + state.floating.value?.open(context); + }else{ + state.floating.value?.close(); + } + } + }, + ), + + /// pageview 指示器 + Positioned( + bottom: 16, + child: Row( + children: [ + Container( + width: 8.w, + height: 8.h, + margin: const EdgeInsets.only(right: 6), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8), + color: state.pageIndex.value == 0 + ? ColorUtil.Color_255_255_255 + : ColorUtil.Color_108_108_108), + ), + Container( + width: 8.w, + height: 8.h, + margin: const EdgeInsets.only(left: 6), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8), + color: state.pageIndex.value == 1 + ? ColorUtil.Color_255_255_255 + : ColorUtil.Color_108_108_108), + ) + ], + ), + ), + ], ) : Container()), @@ -1440,4 +1471,182 @@ class MeetingMainPageState extends State { ], ); } + + /// 然后对应页数的界面 + Widget returnPage(int position){ + var pageList = []; + /// 大屏 + pageList.add(Stack( + alignment: Alignment.center, + children: [ + state.remoteUid.value != "" + ? AgoraVideoView( + controller: VideoViewController( + rtcEngine: state.rctEngine.value!, + canvas: VideoCanvas(uid: int.tryParse(state.remoteUid.value), setupMode: VideoViewSetupMode.videoViewSetupAdd) + ), + ) + : const CircularProgressIndicator(), + Positioned( + bottom: 110, + child: GestureDetector( + child: Image.asset( + 'assets/images/meeting_main_hang_up.png', + width: 50.w, + height: 50.h, + ), + onTap: () { + + }, + ), + ), + Positioned( + top: 16, + right: 16, + child: Container( + height: 30, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8), + color: ColorUtil.Color_0_0_0_96), + padding: const EdgeInsets.only(left: 12, right: 12), + child: Row( + children: [ + Text( + '正在讲话:', + style: TextStyle( + fontSize: 10.sp, + color: ColorUtil.Color_185_184_184), + ), + Image.asset( + 'assets/images/meeting_main_speak2.png', + width: 20.w, + height: 20.h, + ), + Text( + '晓晓', + style: TextStyle( + fontSize: 10.sp, + color: ColorUtil.Color_185_184_184), + ) + ], + ), + ), + ), + ], + )); + /// gridview + pageList.add(Container( + color: ColorUtil.Color_57_57_57, + child: GridView.builder( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + childAspectRatio: 0.8, + crossAxisSpacing: 0), + itemCount: state.cacheUsers.value.where((user) => user.enableCamera == true).toList().length, + itemBuilder: (BuildContext ctx, index) { + return Stack( + children: [ + state.cacheUsers.value[index].uid == + UserStore.to.userInfoEntity.value!.uid + ? AgoraVideoView( + controller: VideoViewController( + rtcEngine: state.rctEngine.value!, + canvas: const VideoCanvas(uid: 0, setupMode: VideoViewSetupMode.videoViewSetupAdd) + ), + ) + : AgoraVideoView( + controller: VideoViewController.remote( + rtcEngine: state.rctEngine.value!, + canvas: VideoCanvas( + uid: int.tryParse( + state.cacheUsers.value[index].uid), setupMode: VideoViewSetupMode.videoViewSetupAdd), + connection: RtcConnection( + channelId: state.roomNumber.value), + ), + ), + Positioned( + left: 4, + bottom: 4, + child: Row( + children: [ + Visibility( + visible: state.cacheUsers.value[index].uid == UserStore.to.userInfoEntity.value!.uid, + child: Image.asset( + 'assets/images/meeting_main_own.png', + width: 24.w, + height: 24.h, + ), + ), + Container( + height: 20, + margin: const EdgeInsets.only(left: 4), + padding: + const EdgeInsets.only(left: 4, right: 4), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2), + color: ColorUtil.Color_0_0_0_96), + child: state.cacheUsers.value[index].enableMicr == true + ? Row( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + SizedBox( + width: 20.w, + height: 20.h, + child: LiquidCustomProgressIndicator( + value: + state.cacheUsers.value[index] + .volume ?? + 0.0, + valueColor: + const AlwaysStoppedAnimation( + ColorUtil + .Color_2_177_136), + backgroundColor: + ColorUtil.Color_255_255_255, + direction: Axis.vertical, + shapePath: ViewSvgPath + .getMicrpphonePath()), + ), + Text( + state.cacheUsers.value[index].userName, + style: TextStyle( + fontSize: 12.sp, + color: ColorUtil + .Color_255_255_255), + ) + ], + ) + : Row( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Image.asset( + 'assets/images/meeting_main_microphone_open.png', + width: 20.w, + height: 20.h, + ), + Text( + state.cacheUsers.value[index].userName, + style: TextStyle( + fontSize: 12.sp, + color: ColorUtil + .Color_255_255_255), + ) + ], + ), + ) + ], + ), + ) + ], + ); + }), + )); + return pageList[position]; + } }