Improve mobile accessibility on post page
This commit is contained in:
parent
bfe570a0fc
commit
b38d225540
|
@ -36,6 +36,7 @@ pub enum PostPageInput {
|
||||||
OpenPerson,
|
OpenPerson,
|
||||||
OpenCommunity,
|
OpenCommunity,
|
||||||
OpenLink,
|
OpenLink,
|
||||||
|
OpenImage,
|
||||||
OpenCreateCommentDialog,
|
OpenCreateCommentDialog,
|
||||||
CreateCommentRequest(EditorData),
|
CreateCommentRequest(EditorData),
|
||||||
EditPostRequest(EditorData),
|
EditPostRequest(EditorData),
|
||||||
|
@ -66,12 +67,22 @@ impl SimpleComponent for PostPage {
|
||||||
set_margin_top: 20,
|
set_margin_top: 20,
|
||||||
#[watch]
|
#[watch]
|
||||||
set_visible: model.info.post_view.post.thumbnail_url.is_some(),
|
set_visible: model.info.post_view.post.thumbnail_url.is_some(),
|
||||||
|
add_controller = gtk::GestureClick {
|
||||||
|
connect_pressed[sender] => move |_, _, _, _| {
|
||||||
|
sender.input(PostPageInput::OpenImage);
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
gtk::Label {
|
gtk::Label {
|
||||||
#[watch]
|
#[watch]
|
||||||
set_text: &model.info.post_view.post.name,
|
set_text: &model.info.post_view.post.name,
|
||||||
set_wrap: true,
|
set_wrap: true,
|
||||||
add_css_class: "font-very-bold",
|
add_css_class: "font-very-bold",
|
||||||
|
add_controller = gtk::GestureClick {
|
||||||
|
connect_pressed[sender] => move |_, _, _, _| {
|
||||||
|
sender.input(PostPageInput::OpenLink);
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
gtk::Label {
|
gtk::Label {
|
||||||
#[watch]
|
#[watch]
|
||||||
|
@ -121,20 +132,6 @@ impl SimpleComponent for PostPage {
|
||||||
connect_clicked => PostPageInput::OpenCommunity,
|
connect_clicked => PostPageInput::OpenCommunity,
|
||||||
},
|
},
|
||||||
|
|
||||||
gtk::Label {
|
|
||||||
set_margin_start: 10,
|
|
||||||
set_label: &util::format_elapsed_time(model.info.post_view.post.published),
|
|
||||||
},
|
|
||||||
|
|
||||||
gtk::Box {
|
|
||||||
set_hexpand: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
gtk::Button {
|
|
||||||
set_label: "View",
|
|
||||||
connect_clicked => PostPageInput::OpenLink,
|
|
||||||
},
|
|
||||||
|
|
||||||
gtk::Button {
|
gtk::Button {
|
||||||
set_icon_name: "document-edit",
|
set_icon_name: "document-edit",
|
||||||
connect_clicked => PostPageInput::OpenEditPostDialog,
|
connect_clicked => PostPageInput::OpenEditPostDialog,
|
||||||
|
@ -146,7 +143,6 @@ impl SimpleComponent for PostPage {
|
||||||
gtk::Button {
|
gtk::Button {
|
||||||
set_icon_name: "edit-delete",
|
set_icon_name: "edit-delete",
|
||||||
connect_clicked => PostPageInput::DeletePost,
|
connect_clicked => PostPageInput::DeletePost,
|
||||||
set_margin_start: 5,
|
|
||||||
#[watch]
|
#[watch]
|
||||||
set_visible: model.info.post_view.creator.id.0 == settings::get_current_account().id,
|
set_visible: model.info.post_view.creator.id.0 == settings::get_current_account().id,
|
||||||
}
|
}
|
||||||
|
@ -154,10 +150,14 @@ impl SimpleComponent for PostPage {
|
||||||
|
|
||||||
gtk::Box {
|
gtk::Box {
|
||||||
set_orientation: gtk::Orientation::Horizontal,
|
set_orientation: gtk::Orientation::Horizontal,
|
||||||
set_margin_top: 10,
|
set_margin_top: 15,
|
||||||
set_margin_bottom: 10,
|
set_margin_bottom: 10,
|
||||||
set_halign: gtk::Align::Center,
|
set_halign: gtk::Align::Center,
|
||||||
|
|
||||||
|
gtk::Label {
|
||||||
|
set_margin_end: 15,
|
||||||
|
set_label: &util::format_elapsed_time(model.info.post_view.post.published),
|
||||||
|
},
|
||||||
#[local_ref]
|
#[local_ref]
|
||||||
voting_row -> gtk::Box {
|
voting_row -> gtk::Box {
|
||||||
set_margin_end: 10,
|
set_margin_end: 10,
|
||||||
|
@ -165,6 +165,7 @@ impl SimpleComponent for PostPage {
|
||||||
gtk::Label {
|
gtk::Label {
|
||||||
#[watch]
|
#[watch]
|
||||||
set_text: &format!("{} comments", model.info.post_view.counts.comments),
|
set_text: &format!("{} comments", model.info.post_view.counts.comments),
|
||||||
|
set_margin_start: 10,
|
||||||
},
|
},
|
||||||
gtk::Button {
|
gtk::Button {
|
||||||
set_label: "Comment",
|
set_label: "Comment",
|
||||||
|
@ -275,17 +276,19 @@ impl SimpleComponent for PostPage {
|
||||||
PostPageInput::OpenLink => {
|
PostPageInput::OpenLink => {
|
||||||
let post = self.info.post_view.post.clone();
|
let post = self.info.post_view.post.clone();
|
||||||
let mut link = get_web_image_url(post.url);
|
let mut link = get_web_image_url(post.url);
|
||||||
if link.is_empty() {
|
|
||||||
link = get_web_image_url(post.thumbnail_url);
|
|
||||||
}
|
|
||||||
if link.is_empty() {
|
if link.is_empty() {
|
||||||
link = get_web_image_url(post.embed_video_url);
|
link = get_web_image_url(post.embed_video_url);
|
||||||
}
|
}
|
||||||
if link.is_empty() {
|
if !link.is_empty() {
|
||||||
return;
|
|
||||||
}
|
|
||||||
gtk::show_uri(None::<&relm4::gtk::Window>, &link, 0);
|
gtk::show_uri(None::<&relm4::gtk::Window>, &link, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
PostPageInput::OpenImage => {
|
||||||
|
let link = get_web_image_url(self.info.post_view.post.thumbnail_url.clone());
|
||||||
|
if !link.is_empty() {
|
||||||
|
gtk::show_uri(None::<&relm4::gtk::Window>, &link, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
PostPageInput::OpenCreateCommentDialog => {
|
PostPageInput::OpenCreateCommentDialog => {
|
||||||
let sender = self.create_comment_dialog.sender();
|
let sender = self.create_comment_dialog.sender();
|
||||||
sender.emit(DialogMsg::UpdateType(EditorType::Comment, true));
|
sender.emit(DialogMsg::UpdateType(EditorType::Comment, true));
|
||||||
|
|
Loading…
Reference in New Issue