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

View File

@ -1,5 +1,9 @@
import 'package:get/get.dart';
class MeetingMainVideoState {
MeetingMainVideoState() {
///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';
class MeetingMainVideoComponent extends StatefulWidget {
const MeetingMainVideoComponent({super.key,
required this.rtcEngine,
required this.channelId,
required this.isOpenCamera,
required this.remoteUid,
required this.onHangUpTap,
required this.users});
const MeetingMainVideoComponent(
{super.key,
required this.rtcEngine,
required this.channelId,
required this.isOpenCamera,
required this.remoteUid,
required this.onHangUpTap,
required this.users,
required this.onPageViewIndexChange});
final RtcEngine rtcEngine;
final String channelId;
@ -26,13 +28,14 @@ class MeetingMainVideoComponent extends StatefulWidget {
final bool isOpenCamera;
final List<MeetingRoomUser> users;
final Function onHangUpTap;
final Function onPageViewIndexChange;
@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 MeetingMainVideoState state = Get.find<MeetingMainVideoLogic>().state;
@ -52,8 +55,8 @@ class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> w
physics: const BouncingScrollPhysics(),
pageSnapping: true,
onPageChanged: (index) {
//
debugPrint('wgs输出===$index');
state.pageIndex.value = index;
widget.onPageViewIndexChange(index);
},
children: <Widget>[
Stack(
@ -61,10 +64,9 @@ class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> w
children: [
widget.remoteUid != ""
? AgoraVideoView(
controller: VideoViewController.remote(
rtcEngine: widget.rtcEngine,
canvas: VideoCanvas(uid: int.tryParse(widget.remoteUid)),
connection: RtcConnection(channelId: widget.channelId),
controller: VideoViewController(
rtcEngine: widget.rtcEngine,
canvas: const VideoCanvas(uid: 0)
),
)
: const CircularProgressIndicator(),
@ -156,12 +158,12 @@ class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> w
color: ColorUtil.Color_0_0_0_96),
child: Row(
children: [
*//*Image.asset(
*/ /*Image.asset(
'assets/images/meeting_main_microphone_open.png',
width: 13.w,
height: 14.h,
),
SizedBox(width: 4.w),*//*
SizedBox(width: 4.w),*/ /*
Text(
UserStore
.to.userInfoEntity.value!.userName,
@ -193,22 +195,23 @@ class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> w
return Stack(
children: [
widget.users[index].uid ==
UserStore.to.userInfoEntity.value!.uid
UserStore.to.userInfoEntity.value!.uid
? AgoraVideoView(
controller: VideoViewController(
rtcEngine: widget.rtcEngine,
canvas: const VideoCanvas(uid: 0),
),
)
controller: VideoViewController(
rtcEngine: widget.rtcEngine,
canvas: const VideoCanvas(uid: 0)
),
)
: AgoraVideoView(
controller: VideoViewController.remote(
rtcEngine: widget.rtcEngine,
canvas: VideoCanvas(
uid: int.tryParse(widget.users[index].uid)),
connection:
RtcConnection(channelId: widget.channelId),
),
),
controller: VideoViewController.remote(
rtcEngine: widget.rtcEngine,
canvas: VideoCanvas(
uid: int.tryParse(
widget.users[index].uid)),
connection: RtcConnection(
channelId: widget.channelId),
),
),
Positioned(
left: 4,
bottom: 4,
@ -217,57 +220,70 @@ class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> w
Image.asset(
'assets/images/meeting_main_own.png',
width: 24.w,
height: 24 .h,
height: 24.h,
),
Container(
height: 20,
margin: const EdgeInsets.only(left: 4),
padding:
const EdgeInsets.only(left: 4, right: 4),
const EdgeInsets.only(left: 4, right: 4),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: ColorUtil.Color_0_0_0_96),
child: widget.users[index].enableMicr == true
? Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
width: 20.w,
height: 20.h,
child: LiquidCustomProgressIndicator(
value: widget.users[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(
widget.users[index].userName,
style: TextStyle(
fontSize: 12.sp,
color: ColorUtil.Color_255_255_255),
)
],
)
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
SizedBox(
width: 20.w,
height: 20.h,
child: LiquidCustomProgressIndicator(
value:
widget.users[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(
widget.users[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(
widget.users[index].userName,
style: TextStyle(
fontSize: 12.sp,
color: ColorUtil.Color_255_255_255),
)
],
),
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Image.asset(
'assets/images/meeting_main_microphone_open.png',
width: 20.w,
height: 20.h,
),
Text(
widget.users[index].userName,
style: TextStyle(
fontSize: 12.sp,
color: ColorUtil
.Color_255_255_255),
)
],
),
)
],
),
@ -288,7 +304,9 @@ class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> w
margin: const EdgeInsets.only(right: 6),
decoration: BoxDecoration(
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(
width: 8.w,
@ -296,7 +314,9 @@ class _MeetingMainVideoComponentState extends State<MeetingMainVideoComponent> w
margin: const EdgeInsets.only(left: 6),
decoration: BoxDecoration(
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;
}