1.本地预览悬浮窗参数优化

2.pageview增加切换回调
This commit is contained in:
fuenmao 2024-12-06 10:55:23 +08:00
parent 44c789e2f1
commit 5669b0123c
3 changed files with 119 additions and 100 deletions

View File

@ -28,15 +28,13 @@ class MeetingMainPage extends StatefulWidget {
} }
class MeetingMainPageState extends State<MeetingMainPage> { class MeetingMainPageState extends State<MeetingMainPage> {
final MeetingMainLogic logic = Get.put(MeetingMainLogic()); final MeetingMainLogic logic = Get.put(MeetingMainLogic());
final MeetingMainState state = Get.find<MeetingMainLogic>().state; final MeetingMainState state = Get.find<MeetingMainLogic>().state;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
state.floating.value = Floating( state.floating.value = Floating(previewFloatingWidget(),
previewFloatingWidget(),
slideType: FloatingSlideType.onRightAndTop, slideType: FloatingSlideType.onRightAndTop,
moveOpacity: 1, moveOpacity: 1,
isShowLog: false, isShowLog: false,
@ -87,10 +85,11 @@ class MeetingMainPageState extends State<MeetingMainPage> {
width: 20.w, width: 20.w,
height: 20.h, height: 20.h,
), ),
onTap: (){ onTap: () {
if(state.floating.value?.isShowing == true){ if (state.floating.value?.isShowing ==
true) {
state.floating.value?.close(); state.floating.value?.close();
}else{ } else {
state.floating.value?.open(context); state.floating.value?.open(context);
} }
}, },
@ -236,6 +235,9 @@ class MeetingMainPageState extends State<MeetingMainPage> {
onHangUpTap: () { onHangUpTap: () {
logic.hangUpVideo(); logic.hangUpVideo();
}, },
onPageViewIndexChange: (index) {
},
) )
: Container()), : Container()),
@ -1378,7 +1380,7 @@ class MeetingMainPageState extends State<MeetingMainPage> {
} }
/// ///
Widget previewFloatingWidget(){ Widget previewFloatingWidget() {
return Stack( return Stack(
children: [ children: [
SizedBox( SizedBox(
@ -1408,8 +1410,7 @@ class MeetingMainPageState extends State<MeetingMainPage> {
Container( Container(
height: 15, height: 15,
margin: const EdgeInsets.only(left: 4), margin: const EdgeInsets.only(left: 4),
padding: padding: const EdgeInsets.only(left: 4, right: 4),
const EdgeInsets.only(left: 4, right: 4),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2), borderRadius: BorderRadius.circular(2),
color: ColorUtil.Color_0_0_0_96), color: ColorUtil.Color_0_0_0_96),
@ -1422,11 +1423,9 @@ class MeetingMainPageState extends State<MeetingMainPage> {
), ),
SizedBox(width: 4.w),*/ SizedBox(width: 4.w),*/
Text( Text(
UserStore UserStore.to.userInfoEntity.value!.userName,
.to.userInfoEntity.value!.userName,
style: TextStyle( style: TextStyle(
fontSize: 10.sp, fontSize: 10.sp, color: ColorUtil.Color_185_184_184),
color: ColorUtil.Color_185_184_184),
) )
], ],
), ),

View File

@ -1,5 +1,9 @@
import 'package:get/get.dart';
class MeetingMainVideoState { class MeetingMainVideoState {
MeetingMainVideoState() { MeetingMainVideoState() {
///Initialize variables ///Initialize variables
} }
late RxInt pageIndex = 0.obs;
} }

View File

@ -12,13 +12,15 @@ import 'meeting_main_video_logic.dart';
import 'meeting_main_video_state.dart'; import 'meeting_main_video_state.dart';
class MeetingMainVideoComponent extends StatefulWidget { class MeetingMainVideoComponent extends StatefulWidget {
const MeetingMainVideoComponent({super.key, const MeetingMainVideoComponent(
{super.key,
required this.rtcEngine, required this.rtcEngine,
required this.channelId, required this.channelId,
required this.isOpenCamera, required this.isOpenCamera,
required this.remoteUid, required this.remoteUid,
required this.onHangUpTap, required this.onHangUpTap,
required this.users}); required this.users,
required this.onPageViewIndexChange});
final RtcEngine rtcEngine; final RtcEngine rtcEngine;
final String channelId; final String channelId;
@ -26,13 +28,14 @@ class MeetingMainVideoComponent extends StatefulWidget {
final bool isOpenCamera; final bool isOpenCamera;
final List<MeetingRoomUser> users; final List<MeetingRoomUser> users;
final Function onHangUpTap; final Function onHangUpTap;
final Function onPageViewIndexChange;
@override @override
State<MeetingMainVideoComponent> createState() => _MeetingMainVideoComponentState(); State<MeetingMainVideoComponent> createState() =>
_MeetingMainVideoComponentState();
} }
class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> with AutomaticKeepAliveClientMixin { class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent>{
final MeetingMainVideoLogic logic = Get.put(MeetingMainVideoLogic()); final MeetingMainVideoLogic logic = Get.put(MeetingMainVideoLogic());
final MeetingMainVideoState state = Get.find<MeetingMainVideoLogic>().state; final MeetingMainVideoState state = Get.find<MeetingMainVideoLogic>().state;
@ -52,8 +55,8 @@ class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> w
physics: const BouncingScrollPhysics(), physics: const BouncingScrollPhysics(),
pageSnapping: true, pageSnapping: true,
onPageChanged: (index) { onPageChanged: (index) {
// state.pageIndex.value = index;
debugPrint('wgs输出===$index'); widget.onPageViewIndexChange(index);
}, },
children: <Widget>[ children: <Widget>[
Stack( Stack(
@ -61,10 +64,9 @@ class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> w
children: [ children: [
widget.remoteUid != "" widget.remoteUid != ""
? AgoraVideoView( ? AgoraVideoView(
controller: VideoViewController.remote( controller: VideoViewController(
rtcEngine: widget.rtcEngine, rtcEngine: widget.rtcEngine,
canvas: VideoCanvas(uid: int.tryParse(widget.remoteUid)), canvas: const VideoCanvas(uid: 0)
connection: RtcConnection(channelId: widget.channelId),
), ),
) )
: const CircularProgressIndicator(), : const CircularProgressIndicator(),
@ -156,12 +158,12 @@ class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> w
color: ColorUtil.Color_0_0_0_96), color: ColorUtil.Color_0_0_0_96),
child: Row( child: Row(
children: [ children: [
*//*Image.asset( */ /*Image.asset(
'assets/images/meeting_main_microphone_open.png', 'assets/images/meeting_main_microphone_open.png',
width: 13.w, width: 13.w,
height: 14.h, height: 14.h,
), ),
SizedBox(width: 4.w),*//* SizedBox(width: 4.w),*/ /*
Text( Text(
UserStore UserStore
.to.userInfoEntity.value!.userName, .to.userInfoEntity.value!.userName,
@ -197,16 +199,17 @@ class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> w
? AgoraVideoView( ? AgoraVideoView(
controller: VideoViewController( controller: VideoViewController(
rtcEngine: widget.rtcEngine, rtcEngine: widget.rtcEngine,
canvas: const VideoCanvas(uid: 0), canvas: const VideoCanvas(uid: 0)
), ),
) )
: AgoraVideoView( : AgoraVideoView(
controller: VideoViewController.remote( controller: VideoViewController.remote(
rtcEngine: widget.rtcEngine, rtcEngine: widget.rtcEngine,
canvas: VideoCanvas( canvas: VideoCanvas(
uid: int.tryParse(widget.users[index].uid)), uid: int.tryParse(
connection: widget.users[index].uid)),
RtcConnection(channelId: widget.channelId), connection: RtcConnection(
channelId: widget.channelId),
), ),
), ),
Positioned( Positioned(
@ -217,7 +220,7 @@ class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> w
Image.asset( Image.asset(
'assets/images/meeting_main_own.png', 'assets/images/meeting_main_own.png',
width: 24.w, width: 24.w,
height: 24 .h, height: 24.h,
), ),
Container( Container(
height: 20, height: 20,
@ -229,31 +232,43 @@ class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> w
color: ColorUtil.Color_0_0_0_96), color: ColorUtil.Color_0_0_0_96),
child: widget.users[index].enableMicr == true child: widget.users[index].enableMicr == true
? Row( ? Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment:
crossAxisAlignment: CrossAxisAlignment.center, MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [ children: [
SizedBox( SizedBox(
width: 20.w, width: 20.w,
height: 20.h, height: 20.h,
child: LiquidCustomProgressIndicator( child: LiquidCustomProgressIndicator(
value: widget.users[index].volume ?? 0.0, value:
valueColor: const AlwaysStoppedAnimation(ColorUtil.Color_2_177_136), widget.users[index]
backgroundColor: ColorUtil.Color_255_255_255, .volume ??
0.0,
valueColor:
const AlwaysStoppedAnimation(
ColorUtil
.Color_2_177_136),
backgroundColor:
ColorUtil.Color_255_255_255,
direction: Axis.vertical, direction: Axis.vertical,
shapePath: ViewSvgPath.getMicrpphonePath() shapePath: ViewSvgPath
), .getMicrpphonePath()),
), ),
Text( Text(
widget.users[index].userName, widget.users[index].userName,
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
color: ColorUtil.Color_255_255_255), color: ColorUtil
.Color_255_255_255),
) )
], ],
) )
: Row( : Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment:
crossAxisAlignment: CrossAxisAlignment.center, MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [ children: [
Image.asset( Image.asset(
'assets/images/meeting_main_microphone_open.png', 'assets/images/meeting_main_microphone_open.png',
@ -264,7 +279,8 @@ class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> w
widget.users[index].userName, widget.users[index].userName,
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
color: ColorUtil.Color_255_255_255), color: ColorUtil
.Color_255_255_255),
) )
], ],
), ),
@ -288,7 +304,9 @@ class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> w
margin: const EdgeInsets.only(right: 6), margin: const EdgeInsets.only(right: 6),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
color: ColorUtil.Color_255_255_255), color: state.pageIndex.value == 0
? ColorUtil.Color_255_255_255
: ColorUtil.Color_108_108_108),
), ),
Container( Container(
width: 8.w, width: 8.w,
@ -296,7 +314,9 @@ class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> w
margin: const EdgeInsets.only(left: 6), margin: const EdgeInsets.only(left: 6),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
color: ColorUtil.Color_108_108_108), color: state.pageIndex.value == 1
? ColorUtil.Color_255_255_255
: ColorUtil.Color_108_108_108),
) )
], ],
), ),
@ -304,8 +324,4 @@ class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> w
], ],
); );
} }
@override
bool get wantKeepAlive => true;
} }