-
Notifications
You must be signed in to change notification settings - Fork 41
Show clicked-on images in a full-screen view with zoom/pan #565
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
Merged
Merged
Changes from all commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
e51b874
move MEDIA_CACHE to global
alanpoon f323303
Merge branch 'main' into image_viewer#327
alanpoon e1d2aaf
some testing
alanpoon e4fe2c8
Merge branch 'main' into image_viewer#327
alanpoon 440bde3
changed default image
alanpoon d029bbc
Merge branch 'main' into image_viewer#327
alanpoon ddd04b9
Image Viewer with zoom and pann
alanpoon d641657
fix spelling
alanpoon 9fe9ddc
simplify code for populate_image_modal
alanpoon 27ebbd7
Deallocate image buffer
alanpoon 92d78b3
Merge branch 'main' into image_viewer#327
alanpoon de263cc
remove default_image
alanpoon 43137a1
Merge branch 'main' into image_viewer#327
alanpoon 03e4120
Merge branch 'main' into image_viewer#327
alanpoon c9f2484
code improvement image_viewer
alanpoon 81cf00a
Merge branch 'main' into image_viewer#327
alanpoon ec774a0
update makepad
alanpoon d85a312
fix
alanpoon 09b9772
image_viewer_modal improvement
alanpoon 8269f0a
remove global singleton for image_viewer_modal
alanpoon 6ea6026
Merge branch 'main' into image_viewer#327
alanpoon 4e4f34d
Friendly Error improvement
alanpoon ee6b8e7
change to more friendly error message
alanpoon 0e10331
ImageViewer improvement
alanpoon 4febe14
Minor code improvement
alanpoon 4efdf4b
format improvement
alanpoon 85cfb9b
update makepad version
alanpoon 5188571
update mouse cursor
alanpoon c3cfc21
timeout error update
alanpoon 932c318
ImageViewerModalAction
alanpoon 9bd6dbb
Merge branch 'image_viewer#327' of https://github.com/alanpoon/robrix…
alanpoon 048c3d3
Change to rotated_image
alanpoon 816fae5
Merge branch 'main' into image_viewer#327
alanpoon f0cecc1
Added Image detail for Image Viewer
alanpoon 2ca47a3
move image_buffer to background thread
alanpoon 082de67
Fix image viewer size for thumbnail image
alanpoon bdf8cfc
Merge branch 'main' into image_viewer#327
alanpoon 68179c5
added room_image_viewer_footer
alanpoon e55568c
fix clippy
alanpoon 30ca041
Fix remove_cache_entry
alanpoon 1a35f45
removed ImageViewer opening LinkPreview's image
alanpoon 964b798
combine into room_image_viewer.rs
alanpoon 1136030
revert LinkPreview
alanpoon 897952c
minor code improvement
alanpoon 571c888
Merge branch 'main' into image_viewer#327
alanpoon b43a96e
remove get_texture_and_size
alanpoon b4f81ab
Merge branch 'main' into image_viewer#327
alanpoon dd6555b
fix clippy
alanpoon 9226992
fix grammar issues
alanpoon 784a08b
Merge branch 'main' into image_viewer#327
alanpoon 89d01b6
revert import statement
alanpoon 348b6c5
code improvment
alanpoon 8ae8291
doc improvement
alanpoon 75a7ce1
improve doc in find_previous_profile_in_condensed_message
alanpoon 932036c
avatar_ref
alanpoon b24a3d1
change to using avatar_placeholder
alanpoon 1c66b16
doc fixed
alanpoon baf936a
media fetch param improvement
alanpoon 69a2a7f
Update src/shared/image_viewer.rs
alanpoon e4f53c0
added thiserror
alanpoon 5648d1e
added this error
alanpoon 378760a
Merge branch 'image_viewer#327' of https://github.com/alanpoon/robrix…
alanpoon 0c1fb66
removed rotation_animation duration
alanpoon 555e883
empty_right_container_fixed.
alanpoon 7e4f899
Merge branch 'main' into image_viewer#327
alanpoon 54b1fc1
improvement to image_viewer, remove avatar_placeholder, remove unnecc…
alanpoon afb70eb
Merge branch 'main' into image_viewer#327
alanpoon 70e1b71
fix clippy::LoadState
alanpoon 336ae03
image_viewer improvement
alanpoon 58ee525
image_viewer_modal_inner
alanpoon f72f37b
change to image_viewer_modal_inner
alanpoon b131e0e
fix clippy
alanpoon 1ef175f
fix clippy
alanpoon 12d5b22
update show's comment
alanpoon 62c9672
Added ImageViewerModalActions
alanpoon 5fb5079
fix clippy
alanpoon b7b8099
removed ImageViewerModalAction
alanpoon 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,63 @@ | ||
| use makepad_widgets::*; | ||
| use matrix_sdk_ui::timeline::EventTimelineItem; | ||
| use matrix_sdk::{ | ||
| media::MediaFormat, | ||
| ruma::events::room::{message::MessageType, MediaSource}, | ||
| }; | ||
| use reqwest::StatusCode; | ||
|
|
||
| use crate::{media_cache::{MediaCache, MediaCacheEntry}, shared::image_viewer::{ImageViewerAction, ImageViewerError, LoadState}}; | ||
|
|
||
| /// Populates the image viewer modal with the given media content. | ||
| /// | ||
| /// * If the media is already cached, it will be immediately displayed. | ||
| /// * If the media is not cached, it will be fetched from the server. | ||
| /// * If the media fetch fails, an error message will be displayed. | ||
| pub fn populate_matrix_image_modal( | ||
| cx: &mut Cx, | ||
| media_source: MediaSource, | ||
| media_cache: &mut MediaCache, | ||
| ) { | ||
| let MediaSource::Plain(mxc_uri) = media_source else { | ||
| return; | ||
| }; | ||
| // Try to get media from cache or trigger fetch | ||
| let media_entry = media_cache.try_get_media_or_fetch(mxc_uri.clone(), MediaFormat::File); | ||
|
|
||
| // Handle the different media states | ||
| match media_entry { | ||
| (MediaCacheEntry::Loaded(data), MediaFormat::File) => { | ||
| cx.action(ImageViewerAction::Show(LoadState::Loaded(data))); | ||
| } | ||
| (MediaCacheEntry::Failed(status_code), MediaFormat::File) => { | ||
| let error = match status_code { | ||
| StatusCode::NOT_FOUND => ImageViewerError::NotFound, | ||
| StatusCode::INTERNAL_SERVER_ERROR => ImageViewerError::ConnectionFailed, | ||
| StatusCode::PARTIAL_CONTENT => ImageViewerError::BadData, | ||
| StatusCode::UNAUTHORIZED => ImageViewerError::Unauthorized, | ||
| _ => ImageViewerError::Unknown, | ||
| }; | ||
| cx.action(ImageViewerAction::Show(LoadState::Error(error))); | ||
| // Remove failed media entry from cache for MediaFormat::File so as to start all over again from loading Thumbnail. | ||
| media_cache.remove_cache_entry(&mxc_uri, Some(MediaFormat::File)); | ||
| } | ||
| _ => {} | ||
| } | ||
| } | ||
|
|
||
| /// Gets image name and file size in bytes from an event timeline item. | ||
| pub fn get_image_name_and_filesize(event_tl_item: &EventTimelineItem) -> (String, u64) { | ||
| if let Some(message) = event_tl_item.content().as_message() { | ||
| if let MessageType::Image(image_content) = message.msgtype() { | ||
| let name = message.body().to_string(); | ||
| let size = image_content | ||
| .info | ||
| .as_ref() | ||
| .and_then(|info| info.size) | ||
| .map(u64::from) | ||
| .unwrap_or(0); | ||
| return (name, size); | ||
| } | ||
| } | ||
| ("Unknown Image".to_string(), 0) | ||
| } |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.