Skip to content

Commit

Permalink
improve: add separate theme for desktop and mobile for video player
Browse files Browse the repository at this point in the history
  • Loading branch information
sherlockvn authored and hoangdat committed Sep 28, 2023
1 parent eb6d55d commit 33269f7
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/presentation/mixins/play_video_action_mixin.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/widgets/video_viewer_dialog.dart';
import 'package:fluffychat/widgets/video_viewer_desktop_theme.dart';
import 'package:fluffychat/widgets/video_viewer_mobile_theme.dart';
import 'package:flutter/material.dart';

mixin PlayVideoActionMixin {
Expand All @@ -9,7 +10,10 @@ mixin PlayVideoActionMixin {
useRootNavigator: PlatformInfos.isWeb,
useSafeArea: false,
builder: (context) {
return VideoViewerDialog(path: uriOrFilePath);
if (PlatformInfos.isWeb || PlatformInfos.isDesktop) {
return VideoViewerDesktopTheme(path: uriOrFilePath);
}
return VideoViewerMobileTheme(path: uriOrFilePath);
},
);
}
Expand Down
40 changes: 40 additions & 0 deletions lib/widgets/video_viewer_desktop_theme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:fluffychat/widgets/twake_components/twake_icon_button.dart';
import 'package:fluffychat/widgets/video_player.dart';
import 'package:fluffychat/widgets/video_viewer_style.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:media_kit_video/media_kit_video.dart';

class VideoViewerDesktopTheme extends StatelessWidget {
const VideoViewerDesktopTheme({
super.key,
required this.path,
});

final String path;

@override
Widget build(BuildContext context) {
return MaterialDesktopVideoControlsTheme(
normal: MaterialDesktopVideoControlsThemeData(
topButtonBar: [
TwakeIconButton(
tooltip: L10n.of(context)!.back,
icon: Icons.close,
onTap: () => context.pop(),
iconColor: Theme.of(context).colorScheme.surface,
)
],
seekBarColor: Theme.of(context).colorScheme.onSurfaceVariant,
seekBarPositionColor: Theme.of(context).colorScheme.primary,
seekBarHeight: VideoViewerStyle.seekBarHeight,
seekBarThumbColor: Theme.of(context).colorScheme.primary,
),
fullscreen: const MaterialDesktopVideoControlsThemeData(),
child: VideoPlayer(
path: path,
),
);
}
}
47 changes: 47 additions & 0 deletions lib/widgets/video_viewer_mobile_theme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'package:fluffychat/widgets/twake_components/twake_icon_button.dart';
import 'package:fluffychat/widgets/video_player.dart';
import 'package:fluffychat/widgets/video_viewer_style.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:media_kit_video/media_kit_video.dart';

class VideoViewerMobileTheme extends StatelessWidget {
const VideoViewerMobileTheme({
super.key,
required this.path,
});

final String path;

@override
Widget build(BuildContext context) {
return MaterialVideoControlsTheme(
normal: MaterialVideoControlsThemeData(
topButtonBarMargin: VideoViewerStyle.topButtonBarMargin(context),
topButtonBar: [
TwakeIconButton(
tooltip: L10n.of(context)!.back,
icon: Icons.close,
onTap: () => context.pop(),
iconColor: Theme.of(context).colorScheme.surface,
)
],
bottomButtonBar: const [
MaterialPositionIndicator(),
Spacer(),
],
seekBarColor: Theme.of(context).colorScheme.onSurfaceVariant,
seekBarPositionColor: Theme.of(context).colorScheme.primary,
bottomButtonBarMargin: VideoViewerStyle.bottomBarMargin(context),
seekBarMargin: VideoViewerStyle.bottomBarMargin(context),
seekBarHeight: VideoViewerStyle.seekBarHeight,
seekBarThumbColor: Theme.of(context).colorScheme.primary,
),
fullscreen: const MaterialVideoControlsThemeData(),
child: VideoPlayer(
path: path,
),
);
}
}

0 comments on commit 33269f7

Please sign in to comment.