mod: 滑动手势进入/退出全屏模式

This commit is contained in:
guozhigq
2023-08-03 22:54:37 +08:00
parent ffd1f0a24a
commit 99a3ff81e0
2 changed files with 92 additions and 72 deletions

View File

@ -7,7 +7,9 @@ import 'package:pilipala/plugin/pl_player/widgets/play_pause_btn.dart';
class BottomControl extends StatelessWidget implements PreferredSizeWidget {
final PlPlayerController? controller;
const BottomControl({this.controller, Key? key}) : super(key: key);
final Function? triggerFullScreen;
const BottomControl({this.controller, this.triggerFullScreen, Key? key})
: super(key: key);
@override
Size get preferredSize => const Size(double.infinity, kToolbarHeight);
@ -136,52 +138,18 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
// ),
// const SizedBox(width: 4),
// 全屏
Obx(() => ComBtn(
icon: Icon(
_.isFullScreen.value
? FontAwesomeIcons.a
: FontAwesomeIcons.expand,
size: 15,
color: Colors.white,
),
fuc: () async {
if (!_.isFullScreen.value) {
/// 按照视频宽高比决定全屏方向
if (_.direction.value == 'horizontal') {
/// 进入全屏
await enterFullScreen();
// 横屏
await landScape();
} else {
// 竖屏
await verticalScreen();
}
_.toggleFullScreen(true);
var result = await showDialog(
context: Get.context!,
builder: (context) => Dialog.fullscreen(
backgroundColor: Colors.black,
child: PLVideoPlayer(
controller: _,
headerControl: _.headerControl,
),
),
);
if (result == null) {
// 退出全屏
exitFullScreen();
await verticalScreen();
_.toggleFullScreen(false);
}
} else {
Get.back();
exitFullScreen();
await verticalScreen();
_.toggleFullScreen(false);
}
},
)),
Obx(
() => ComBtn(
icon: Icon(
_.isFullScreen.value
? FontAwesomeIcons.a
: FontAwesomeIcons.expand,
size: 15,
color: Colors.white,
),
fuc: () => triggerFullScreen!(),
),
),
],
),
],