Browse Source

修复xs max 全屏没有"真"全屏的问题

Caijinglong 6 years ago
parent
commit
f6e1c85f45
3 changed files with 62 additions and 2 deletions
  1. 11 0
      BUG.md
  2. 49 0
      lib/src/route/fullscreen_route.dart
  3. 2 2
      lib/src/widget/controller_widget_builder.dart

+ 11 - 0
BUG.md

@@ -0,0 +1,11 @@
+## all
+
+- [ ] 全屏模式可自定义
+
+## iOS
+
+- [x] 全屏模式在 iphone xs max 上未全屏
+
+## android
+
+- [ ] 一些 m3u8 无声音

+ 49 - 0
lib/src/route/fullscreen_route.dart

@@ -0,0 +1,49 @@
+import 'package:flutter/material.dart';
+
+typedef Widget AnimationPageBuilder(BuildContext context,
+    Animation<double> animation, Animation<double> secondaryAnimation);
+
+class DialogRoute<T> extends PageRoute<T> {
+  final Color barrierColor;
+  final String barrierLabel;
+  final bool maintainState;
+  final Duration transitionDuration;
+  final AnimationPageBuilder builder;
+
+  DialogRoute({
+    this.barrierColor = const Color(0x44FFFFFF),
+    this.barrierLabel = "full",
+    this.maintainState = true,
+    this.transitionDuration = const Duration(milliseconds: 300),
+    @required this.builder,
+  }) : assert(barrierColor != Colors.transparent,
+            "The barrierColor must not be transparent.");
+
+  @override
+  Widget buildPage(BuildContext context, Animation<double> animation,
+      Animation<double> secondaryAnimation) {
+    return builder(context, animation, secondaryAnimation);
+  }
+}
+
+class FullScreenRoute<T> extends DialogRoute<T> {
+  FullScreenRoute({WidgetBuilder builder})
+      : super(builder: (ctx, a, s) => fullScreenBuilder(ctx, builder, a, s));
+
+  static Widget fullScreenBuilder(
+    BuildContext context,
+    WidgetBuilder builder,
+    Animation<double> animation,
+    Animation<double> secondaryAnimation,
+  ) {
+    return AnimatedBuilder(
+      animation: animation,
+      builder: (BuildContext context, Widget child) {
+        return Opacity(
+          opacity: animation.value,
+          child: builder(context),
+        );
+      },
+    );
+  }
+}

+ 2 - 2
lib/src/widget/controller_widget_builder.dart

@@ -7,6 +7,7 @@ import 'package:flutter_ijkplayer/flutter_ijkplayer.dart';
 import 'package:flutter_ijkplayer/src/helper/logutil.dart';
 import 'package:flutter_ijkplayer/src/helper/logutil.dart';
 import 'package:flutter_ijkplayer/src/helper/time_helper.dart';
 import 'package:flutter_ijkplayer/src/helper/time_helper.dart';
 import 'package:flutter_ijkplayer/src/helper/ui_helper.dart';
 import 'package:flutter_ijkplayer/src/helper/ui_helper.dart';
+import 'package:flutter_ijkplayer/src/route/fullscreen_route.dart';
 import 'package:flutter_ijkplayer/src/widget/progress_bar.dart';
 import 'package:flutter_ijkplayer/src/widget/progress_bar.dart';
 
 
 /// Using mediaController to Construct a Controller UI
 /// Using mediaController to Construct a Controller UI
@@ -637,7 +638,7 @@ showFullScreenIJKPlayer(
     BuildContext context, IjkMediaController controller) async {
     BuildContext context, IjkMediaController controller) async {
   Navigator.push(
   Navigator.push(
     context,
     context,
-    MaterialPageRoute(
+    FullScreenRoute(
       builder: (c) {
       builder: (c) {
         return IjkPlayer(
         return IjkPlayer(
           mediaController: controller,
           mediaController: controller,
@@ -645,7 +646,6 @@ showFullScreenIJKPlayer(
               _buildFullScreenMediaController(ctl, true),
               _buildFullScreenMediaController(ctl, true),
         );
         );
       },
       },
-      fullscreenDialog: true,
     ),
     ),
   ).then((_) {
   ).then((_) {
     IjkManager.unlockOrientation();
     IjkManager.unlockOrientation();