Skip to content

Commit

Permalink
Fix play button bad behavior (#1512)
Browse files Browse the repository at this point in the history
  • Loading branch information
EricBAndrews authored Dec 17, 2024
1 parent f8f06b5 commit 4cd9eb3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Mlem/App/Views/Pages/ImageViewer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct ImageViewer: View {
.padding(Constants.main.standardSpacing)
}
}
.simultaneousGesture(DragGesture(minimumDistance: 0.0)
.simultaneousGesture(DragGesture(minimumDistance: 1.0)
.updating($dragState) { value, state, _ in
state = true
if !isZoomed, !isDismissing {
Expand Down
9 changes: 6 additions & 3 deletions Mlem/App/Views/Shared/Images/Core/FixedImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct FixedImageView: View {
let fallback: Fallback
let showProgress: Bool
let blurred: Bool
let showPlayButton: Bool

/// Enumeration of placeholder images to use if image loading fails
enum Fallback {
Expand All @@ -44,12 +45,14 @@ struct FixedImageView: View {
size: CGSize,
fallback: Fallback,
showProgress: Bool,
blurred: Bool = false
blurred: Bool = false,
showPlayButton: Bool = true
) {
self.fallback = fallback
self.showProgress = showProgress
self._loader = .init(wrappedValue: .init(url: url, size: size))
self.blurred = blurred
self.showPlayButton = showPlayButton
}

var isMovie: Bool { loader.url?.proxyAwarePathExtension?.isMovieExtension ?? false }
Expand Down Expand Up @@ -79,7 +82,7 @@ struct FixedImageView: View {
|| (loader.loading == .loading && !showProgress) {
fallbackImage
.overlay {
if loader.isAnimated {
if loader.isAnimated, showPlayButton {
PlayButton(postSize: postSize)
}
}
Expand All @@ -92,7 +95,7 @@ struct FixedImageView: View {
.scaledToFill()
.dynamicBlur(blurred: blurred)
.overlay {
if loader.isAnimated {
if loader.isAnimated, showPlayButton {
PlayButton(postSize: postSize)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ struct CircleCroppedImageView: View {
size: .init(width: frame, height: frame),
fallback: fallback,
showProgress: showProgress,
blurred: blurred
blurred: blurred,
showPlayButton: false
)
.clipShape(Circle())
.geometryGroup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ struct ThumbnailImageView: View {
url: url,
size: frame,
fallback: url.proxyAwarePathExtension?.isMovieExtension ?? false ? .movie : .image,
showProgress: true
showProgress: true,
blurred: blurred && loading == .done
)
.dynamicBlur(blurred: blurred && loading == .done)
.clipShape(RoundedRectangle(cornerRadius: Constants.main.smallItemCornerRadius))
.onPreferenceChange(MediaLoadingPreferenceKey.self, perform: { loading = $0 })
} else {
Expand All @@ -125,9 +125,9 @@ struct ThumbnailImageView: View {
url: url,
size: frame,
fallback: .image,
showProgress: true
showProgress: true,
blurred: blurred && loading == .done
)
.dynamicBlur(blurred: blurred)
.onPreferenceChange(MediaLoadingPreferenceKey.self, perform: { loading = $0 })
} else {
Image(systemName: post.placeholderImageName)
Expand Down

0 comments on commit 4cd9eb3

Please sign in to comment.