generated from element-hq/.github
-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework the presentation of the media browser quick look view to use SwiftUI. #3619
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
faaa897
Embed the media preview quick look inside a full screen cover
pixlwave 72600b4
Use a the representable coordinator properly.
pixlwave 443d9df
Fix a bug with the toolbar appearance.
pixlwave cf4a829
Format
pixlwave 7c3ee0b
Try prevent the zoom transition being upside down.
pixlwave 6a2309a
Fix the snapshot test configuration.
pixlwave File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
ElementX/Sources/Other/SwiftUI/Animation/ZoomTransition.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// Copyright 2024 New Vector Ltd. | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
// Please see LICENSE in the repository root for full details. | ||
// | ||
|
||
import SwiftUI | ||
|
||
extension View { | ||
/// A convenience modifier to conditionally apply `.navigationTransition(.zoom(…))` when available. | ||
@ViewBuilder | ||
func zoomTransition(sourceID: some Hashable, in namespace: Namespace.ID) -> some View { | ||
if #available(iOS 18.0, *) { | ||
navigationTransition(.zoom(sourceID: sourceID, in: namespace)) | ||
} else { | ||
self | ||
} | ||
} | ||
|
||
/// A convenience modifier to conditionally apply `.matchedTransitionSource(…)` when available. | ||
@ViewBuilder | ||
func zoomTransitionSource(id: some Hashable, in namespace: Namespace.ID) -> some View { | ||
if #available(iOS 18.0, *) { | ||
matchedTransitionSource(id: id, in: namespace) | ||
} else { | ||
self | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// Copyright 2024 New Vector Ltd. | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
// Please see LICENSE in the repository root for full details. | ||
// | ||
|
||
import SwiftUI | ||
|
||
/// A view that renders a `UIBlurEffect` as there is a larger range of | ||
/// effects available compared to using SwiftUI's `Material` type. | ||
struct BlurEffectView: UIViewRepresentable { | ||
var style: UIBlurEffect.Style | ||
|
||
func makeUIView(context: Context) -> UIVisualEffectView { | ||
UIVisualEffectView(effect: UIBlurEffect(style: style)) | ||
} | ||
|
||
func updateUIView(_ uiView: UIVisualEffectView, context: Context) { | ||
uiView.effect = UIBlurEffect(style: style) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
ElementX/Sources/Screens/FilePreviewScreen/MediaFileManager.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// | ||
// Copyright 2024 New Vector Ltd. | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
// Please see LICENSE in the repository root for full details. | ||
// | ||
|
||
import Foundation |
180 changes: 0 additions & 180 deletions
180
ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewController.swift
This file was deleted.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
ElementX/Sources/Screens/FilePreviewScreen/TimelineMediaPreviewCoordinator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// | ||
// Copyright 2024 New Vector Ltd. | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
// Please see LICENSE in the repository root for full details. | ||
// | ||
|
||
import Combine | ||
import SwiftUI | ||
|
||
struct TimelineMediaPreviewContext { | ||
/// The initial item to preview from the provided timeline. | ||
/// This item's `id` will be used as the navigation transition's `sourceID`. | ||
let item: EventBasedMessageTimelineItemProtocol | ||
/// The timeline that the preview comes from, to allow for swiping to other media. | ||
let viewModel: TimelineViewModelProtocol | ||
/// The namespace that the navigation transition's `sourceID` should be defined in. | ||
let namespace: Namespace.ID | ||
} | ||
|
||
struct TimelineMediaPreviewCoordinatorParameters { | ||
let context: TimelineMediaPreviewContext | ||
let mediaProvider: MediaProviderProtocol | ||
let userIndicatorController: UserIndicatorControllerProtocol | ||
} | ||
|
||
enum TimelineMediaPreviewCoordinatorAction { | ||
case viewInRoomTimeline(TimelineItemIdentifier) | ||
case dismiss | ||
} | ||
|
||
final class TimelineMediaPreviewCoordinator: CoordinatorProtocol { | ||
private let parameters: TimelineMediaPreviewCoordinatorParameters | ||
private let viewModel: TimelineMediaPreviewViewModel | ||
|
||
private var cancellables = Set<AnyCancellable>() | ||
|
||
private let actionsSubject: PassthroughSubject<TimelineMediaPreviewCoordinatorAction, Never> = .init() | ||
var actionsPublisher: AnyPublisher<TimelineMediaPreviewCoordinatorAction, Never> { | ||
actionsSubject.eraseToAnyPublisher() | ||
} | ||
|
||
init(parameters: TimelineMediaPreviewCoordinatorParameters) { | ||
self.parameters = parameters | ||
|
||
viewModel = TimelineMediaPreviewViewModel(context: parameters.context, | ||
mediaProvider: parameters.mediaProvider, | ||
userIndicatorController: parameters.userIndicatorController) | ||
} | ||
|
||
func start() { | ||
viewModel.actions.sink { [weak self] action in | ||
MXLog.info("Coordinator: received view model action: \(action)") | ||
|
||
guard let self else { return } | ||
switch action { | ||
case .viewInRoomTimeline(let itemID): | ||
actionsSubject.send(.viewInRoomTimeline(itemID)) | ||
case .dismiss: | ||
actionsSubject.send(.dismiss) | ||
} | ||
} | ||
.store(in: &cancellables) | ||
} | ||
|
||
func toPresentable() -> AnyView { | ||
AnyView(TimelineMediaPreviewView(context: viewModel.context)) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couldn't we pass the animation directly in presentRoom as a variable?