mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-25 23:49:35 +00:00
stories: start and metadata stories bind their story value through ValueAt
They copied the value out and wrote it back, so their binds named the copy by address.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
//! Stories of `StartScreen`.
|
||||
|
||||
use super::{StartLink, StartScreen};
|
||||
use crate::contract::Bind;
|
||||
use crate::primitives::{FakeThumbSource, ThumbnailOptions, Thumbnails};
|
||||
use crate::runtime::env::Label;
|
||||
use crate::shell::{RecentFile, RecentSort, RecentView, ScreenModeCommands, Template, ThumbKey};
|
||||
@@ -95,9 +94,9 @@ fn screen(
|
||||
templates: &[Template],
|
||||
extras: Extras<'_>,
|
||||
) -> StoryOutput {
|
||||
let mut choice = data.value("choice", choice).clone();
|
||||
let (choice, choice_at) = data.value_at("choice", choice);
|
||||
let thumbnails = Thumbnails::<ThumbKey>::in_context(ui.ctx(), "start-stories", ThumbnailOptions::new());
|
||||
let mut start = StartScreen::new(Bind::bound(&mut choice.view), Bind::bound(&mut choice.sort), files)
|
||||
let mut start = StartScreen::new(choice_at.bind(&mut choice.view), choice_at.bind(&mut choice.sort), files)
|
||||
.pinned(pinned)
|
||||
.templates(templates)
|
||||
.now(NOW)
|
||||
@@ -108,9 +107,7 @@ fn screen(
|
||||
if let Some(hint) = extras.drop_hint {
|
||||
start = start.drop_hint(Label::from(hint.to_owned()));
|
||||
}
|
||||
let shown = start.show(ui).into();
|
||||
*data.value("choice", Choice::default()) = choice;
|
||||
shown
|
||||
start.show(ui).into()
|
||||
}
|
||||
|
||||
#[story(StartScreen<'static>, covers = [], drive = Drive::Never)]
|
||||
|
||||
@@ -33,10 +33,8 @@ fn groups() -> Vec<MetadataGroup> {
|
||||
|
||||
#[story(MetadataTable<'static>, covers = [Default], drive = Drive::Never)]
|
||||
fn metadata_table(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let mut filter = data.value("filter", String::new()).clone();
|
||||
let out = MetadataTable::new("Metadata", &groups()).filter(Bind::bound(&mut filter)).show(ui);
|
||||
*data.value("filter", String::new()) = filter;
|
||||
out.into()
|
||||
let (filter, filter_at) = data.value_at("filter", String::new());
|
||||
MetadataTable::new("Metadata", &groups()).filter(filter_at.bind(filter)).show(ui).into()
|
||||
}
|
||||
|
||||
#[story(MetadataTable<'static>, covers = [], drive = Drive::Never)]
|
||||
@@ -51,8 +49,6 @@ fn metadata_table_chooser(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
|
||||
#[story(MetadataTable<'static>, covers = [Empty], drive = Drive::Never)]
|
||||
fn metadata_table_no_match(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let mut filter = data.value("filter", "zzz".to_owned()).clone();
|
||||
let out = MetadataTable::new("Metadata", &groups()).filter(Bind::bound(&mut filter)).show(ui);
|
||||
*data.value("filter", String::new()) = filter;
|
||||
out.into()
|
||||
let (filter, filter_at) = data.value_at("filter", "zzz".to_owned());
|
||||
MetadataTable::new("Metadata", &groups()).filter(filter_at.bind(filter)).show(ui).into()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user