mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-27 14:27:34 +00:00
fw sync: workspace check --all-features clean (review panel state literals, unused results and imports)
This commit is contained in:
@@ -58,7 +58,7 @@ fn a_wide_thumbnail_strip_keeps_pages_in_one_column() {
|
||||
let pages = DemoPages::new(3);
|
||||
let mut picked = Selection::default();
|
||||
let mut fixture = Fixture::new(move |ui| {
|
||||
PageThumbnails::new("Pages", &pages, &mut picked, 0, PAPER).show(ui);
|
||||
let _ = PageThumbnails::new("Pages", &pages, &mut picked, 0, PAPER).show(ui);
|
||||
});
|
||||
fixture.room(vec2(500.0, 800.0)).settle();
|
||||
let first = fixture.by_label("Page 1").expect("first page").rect;
|
||||
|
||||
@@ -8,7 +8,7 @@ use craft_ui::testing::{Drive, StoryData, StoryOutput, story};
|
||||
use egui::{Color32, Pos2, Rect, Ui};
|
||||
|
||||
use super::{BalloonItem, BalloonPlace, CommentBalloons};
|
||||
use crate::comments::{CommentAnchor, CommentMessage, CommentThread, ReviewStatus, ThreadId};
|
||||
use crate::comments::{CommentAnchor, CommentMessage, CommentThread, ThreadId};
|
||||
use crate::revisions::{Revision, RevisionKind};
|
||||
use crate::ui::comments::CommentsPanelState;
|
||||
|
||||
@@ -51,7 +51,11 @@ fn beside_page(
|
||||
place: BalloonPlace,
|
||||
read_only: bool,
|
||||
) -> StoryOutput {
|
||||
let state = data.value("state", CommentsPanelState { selected: selected.map_or_else(Selection::default, |id| Selection::single(ThreadId(id))), ..CommentsPanelState::default() });
|
||||
let state = data.value("state", {
|
||||
let mut state = CommentsPanelState::default();
|
||||
state.selected = selected.map_or_else(Selection::default, |id| Selection::single(ThreadId(id)));
|
||||
state
|
||||
});
|
||||
// design: allow[raw-colour/const](the demo page is white paper, document data and not a theme colour)
|
||||
let (fill, line) = (Color32::WHITE, accent(ui, 1.0));
|
||||
let shapes = [StoryShape::filled(&DocRect::new(0.0, 0.0, PAGE.0, PAGE.1), fill).outlined(OUTLINE, line)];
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use craft_pages::ui::PlacedPage;
|
||||
use craft_review::comments::{CommentAnchor, CommentMessage, CommentThread, ReviewStatus, ThreadId};
|
||||
use craft_review::comments::{CommentAnchor, CommentMessage, CommentThread, ThreadId};
|
||||
use craft_review::ui::{BalloonItem, BalloonPlace, CommentBalloons, CommentEdit, CommentsPanelState, CommentsWords};
|
||||
use craft_ui::runtime::env::Direction;
|
||||
use craft_ui::testing::{Fixture, trial};
|
||||
@@ -25,6 +25,13 @@ fn thread(id: u64, text: &str) -> CommentThread {
|
||||
}
|
||||
}
|
||||
|
||||
/// A panel state with thread `id` selected.
|
||||
fn selecting(id: u64) -> CommentsPanelState {
|
||||
let mut state = CommentsPanelState::default();
|
||||
state.selected = craft_behavior::Selection::single(ThreadId(id));
|
||||
state
|
||||
}
|
||||
|
||||
/// The page at (20, 20), 200 wide, at one screen point per page point.
|
||||
fn page() -> PlacedPage {
|
||||
PlacedPage::new(0, Rect::from_min_size(pos2(20.0, 20.0), vec2(200.0, 1200.0)), 1.0, (0.0, 1200.0))
|
||||
@@ -141,7 +148,8 @@ fn selecting_a_card_and_posting_a_reply_report_the_matching_edits() {
|
||||
fn reselecting_a_card_keeps_its_edit_draft() {
|
||||
let threads = vec![(thread(1, "First"), 100.0), (thread(2, "Second"), 400.0)];
|
||||
// The app left the balloon (no card selected) and kept the draft the document refused.
|
||||
let left = CommentsPanelState { editing: Some((ThreadId(1), 0, "Edited".into())), ..CommentsPanelState::default() };
|
||||
let mut left = CommentsPanelState::default();
|
||||
left.editing = Some((ThreadId(1), 0, "Edited".into()));
|
||||
let mut shown = Shown::new(threads, left, BalloonPlace::Column, room(), Direction::Ltr);
|
||||
// A click on the card's heading, above the open edit's field.
|
||||
let card = shown.card(1);
|
||||
@@ -160,7 +168,7 @@ fn reselecting_a_card_keeps_its_edit_draft() {
|
||||
#[trial]
|
||||
fn an_edit_that_opens_takes_the_keyboard() {
|
||||
let threads = vec![(thread(1, "First"), 100.0)];
|
||||
let selected = CommentsPanelState { selected: craft_behavior::Selection::single(ThreadId(1)), ..CommentsPanelState::default() };
|
||||
let selected = selecting(1);
|
||||
let mut shown = Shown::new(threads, selected, BalloonPlace::Column, room(), Direction::Ltr);
|
||||
let words = CommentsWords::default();
|
||||
// The app opens the edit of the selected card's comment, as on a click on its balloon.
|
||||
@@ -185,7 +193,7 @@ fn an_edit_that_opens_takes_the_keyboard() {
|
||||
#[trial]
|
||||
fn a_read_only_card_takes_no_typing() {
|
||||
let threads = vec![(thread(1, "First"), 100.0)];
|
||||
let selected = CommentsPanelState { selected: craft_behavior::Selection::single(ThreadId(1)), ..CommentsPanelState::default() };
|
||||
let selected = selecting(1);
|
||||
let mut shown = Shown::with(threads, selected, BalloonPlace::Column, room(), Direction::Ltr, true);
|
||||
let words = CommentsWords::default();
|
||||
assert!(shown.fixture.by_label(words.reply.as_str()).is_none(), "a read-only card shows no reply field");
|
||||
@@ -201,7 +209,7 @@ fn a_read_only_card_takes_no_typing() {
|
||||
#[trial]
|
||||
fn a_selected_card_in_buttons_form_reports_reply_resolve_reopen_and_delete() {
|
||||
let words = CommentsWords::default();
|
||||
let selected = || CommentsPanelState { selected: craft_behavior::Selection::single(ThreadId(1)), ..CommentsPanelState::default() };
|
||||
let selected = || selecting(1);
|
||||
let open = vec![(thread(1, "Open"), 100.0)];
|
||||
let mut shown = Shown::new(open.clone(), selected(), BalloonPlace::Column, room(), Direction::Ltr);
|
||||
|
||||
@@ -247,7 +255,7 @@ fn balloons_stack_without_overlap_clip_long_bodies_and_keep_the_next_card_in_vie
|
||||
let mut locked = thread(4, "Locked body");
|
||||
locked.locked = true;
|
||||
let threads = vec![(thread(1, &long), 100.0), (thread(2, "Short."), 110.0), (thread(3, &long), 120.0), (locked, 130.0)];
|
||||
let state = CommentsPanelState { selected: craft_behavior::Selection::single(ThreadId(3)), ..CommentsPanelState::default() };
|
||||
let state = selecting(3);
|
||||
let shown = Shown::new(threads, state, BalloonPlace::Column, vec2(900.0, 1100.0), Direction::Ltr);
|
||||
let texts = shown.fixture.texts().to_vec();
|
||||
let line = texts.iter().find(|text| text.text == "Short.").map(|text| text.rect.height()).expect("the short card's body");
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::viewer::{Catalog, GalleryCommands, GallerySettings, PanelId, Viewer,
|
||||
use craft_behavior::dock::{PanelState, Workspace as Dock};
|
||||
use craft_theme::AppSizes;
|
||||
use craft_theme_editor::{ThemeSubject, parse_sizes};
|
||||
use craft_ui::contract::{Bind, BodyCx, CommandSet as _, ShowContainer as _, Tracked};
|
||||
use craft_ui::contract::{Bind, BodyCx, CommandSet as _, Tracked};
|
||||
use craft_ui::docking::DockConfig;
|
||||
use craft_ui::patterns::dock::DockArea;
|
||||
use craft_ui::popover::DropVeil;
|
||||
|
||||
Reference in New Issue
Block a user