Skip to content

Commit

Permalink
improve: images/videos viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
sherlockvn authored and hoangdat committed Oct 5, 2023
1 parent b011162 commit a18dcf2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 27 deletions.
7 changes: 7 additions & 0 deletions lib/pages/image_viewer/image_viewer_style.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/material.dart';

class ImageViewerStyle {
static const double minScaleInteractiveViewer = 1.0;
static const double maxScaleInteractiveViewer = 10.0;
static double? appBarHeight = PlatformInfos.isWeb ? 56 : null;
static EdgeInsetsGeometry paddingTopAppBar = EdgeInsetsDirectional.only(
top: PlatformInfos.isWeb ? 0 : 56,
);
}
3 changes: 2 additions & 1 deletion lib/pages/image_viewer/image_viewer_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ class ImageViewerView extends StatelessWidget {

Widget _buildAppBarPreview() {
return Container(
padding: ImageViewerStyle.paddingTopAppBar,
height: ImageViewerStyle.appBarHeight,
color: LinagoraSysColors.material().onTertiaryContainer.withOpacity(0.5),
padding: const EdgeInsets.only(top: 56),
child: ValueListenableBuilder<bool>(
valueListenable: controller.showAppbarPreview,
builder: (context, showAppbar, _) {
Expand Down
33 changes: 9 additions & 24 deletions lib/presentation/mixins/play_video_action_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,16 @@ mixin PlayVideoActionMixin {
String uriOrFilePath, {
String? eventId,
}) async {
if (!PlatformInfos.isWeb) {
Navigator.of(context).push(
HeroPageRoute(
builder: (context) {
return InteractiveViewerGallery(
itemBuilder: VideoViewerMobileTheme(
path: uriOrFilePath,
eventId: eventId,
),
);
},
),
);
} else {
await showDialog(
context: context,
useRootNavigator: PlatformInfos.isWeb,
useSafeArea: false,
Navigator.of(context, rootNavigator: PlatformInfos.isWeb).push(
HeroPageRoute(
builder: (context) {
if (PlatformInfos.isWeb || PlatformInfos.isDesktop) {
return VideoViewerDesktopTheme(path: uriOrFilePath);
}
return VideoViewerMobileTheme(path: uriOrFilePath, eventId: eventId);
return InteractiveViewerGallery(
itemBuilder: PlatformInfos.isMobile
? VideoViewerMobileTheme(path: uriOrFilePath)
: VideoViewerDesktopTheme(path: uriOrFilePath),
);
},
);
}
),
);
}
}
3 changes: 2 additions & 1 deletion lib/utils/interactive_viewer_gallery.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:fluffychat/utils/custom_dismissable.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/material.dart';

/// A callback for the [InteractiveViewerBoundary] that is called when the scale
Expand Down Expand Up @@ -81,7 +82,7 @@ class _InteractiveViewerGalleryState extends State<InteractiveViewerGallery>
Widget build(BuildContext context) {
return CustomDismissible(
onDismissed: () => Navigator.of(context).pop(),
enabled: _enableDismiss,
enabled: _enableDismiss && !PlatformInfos.isWeb,
child: widget.itemBuilder,
);
}
Expand Down
7 changes: 6 additions & 1 deletion lib/widgets/video_viewer_desktop_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ class VideoViewerDesktopTheme extends StatelessWidget {
seekBarHeight: VideoViewerStyle.seekBarHeight,
seekBarThumbColor: Theme.of(context).colorScheme.primary,
),
fullscreen: const MaterialDesktopVideoControlsThemeData(),
fullscreen: MaterialDesktopVideoControlsThemeData(
seekBarColor: Theme.of(context).colorScheme.onSurfaceVariant,
seekBarPositionColor: Theme.of(context).colorScheme.primary,
seekBarHeight: VideoViewerStyle.seekBarHeight,
seekBarThumbColor: Theme.of(context).colorScheme.primary,
),
child: VideoPlayer(
path: path,
),
Expand Down

0 comments on commit a18dcf2

Please sign in to comment.