|
4 | 4 | //! ImageViewerRef has 4 public methods, `configure_zoom`, `display_using_background_thread`, `display_using_texture` and `reset`. |
5 | 5 | use std::sync::{mpsc::Receiver, Arc}; |
6 | 6 |
|
| 7 | +use chrono::{DateTime, Local}; |
7 | 8 | use makepad_widgets::{ |
8 | 9 | event::TouchUpdateEvent, |
9 | 10 | image_cache::{ImageBuffer, ImageError}, |
10 | 11 | rotated_image::RotatedImageWidgetExt, |
11 | 12 | *, |
12 | 13 | }; |
13 | 14 |
|
14 | | -use crate::shared::avatar::{AvatarRef, AvatarWidgetRefExt}; |
| 15 | +use crate::shared::{avatar::{AvatarRef, AvatarWidgetRefExt}, timestamp::TimestampWidgetRefExt}; |
15 | 16 |
|
16 | 17 | /// Loads the given image `data` into an `ImageBuffer` as either a PNG or JPEG, using the `imghdr` library to determine which format it is. |
17 | 18 | /// |
@@ -925,7 +926,13 @@ impl ImageViewer { |
925 | 926 | let display_text = format!("{} ({})", truncated_name, human_readable_size); |
926 | 927 | meta_view.label(ids!(image_name_and_size)) |
927 | 928 | .set_text(cx, &display_text); |
| 929 | + if let Some(timestamp) = metadata.timestamp { |
| 930 | + meta_view.view(ids!(top_left_container.content.timestamp_view)).set_visible(cx, true); |
| 931 | + meta_view.timestamp(ids!(top_left_container.content.timestamp_view.timestamp)).set_date_time(cx, timestamp); |
| 932 | + } |
| 933 | + |
928 | 934 | meta_view.label(ids!(top_left_container.content.username)).set_text(cx, &metadata.sender); |
| 935 | + |
929 | 936 | metadata.avatar_ref.copy_content_to(cx, &mut meta_view.avatar(ids!(top_left_container.avatar))); |
930 | 937 | } |
931 | 938 | } |
@@ -1013,7 +1020,7 @@ pub enum LoadState { |
1013 | 1020 | pub struct MetaData { |
1014 | 1021 | pub avatar_ref: AvatarRef, |
1015 | 1022 | pub sender: String, |
1016 | | - pub timestamp: String, |
| 1023 | + pub timestamp: Option<DateTime<Local>>, |
1017 | 1024 | pub image_name: String, |
1018 | 1025 | pub image_size: i32, |
1019 | 1026 | } |
|
0 commit comments