Panics · P42 Misc: handlers in new; the web view shows wry's failures; kept state fits lists that changed

This commit is contained in:
ZacharyZhang-NY committed 2026-10-07 07:17:20 -04:00
1 parent 770d13575d
commit 3a0a4bb699
20 files changed
+362 -189

No files matched your search

+13 -15
View File
@@ -20,19 +20,19 @@ pub fn render(window: &mut Window, cx: &mut App) -> impl IntoElement + use<> {
"poll",
"Which chart should come next?",
["Sankey", "Sunburst", "Candlestick"],
move |vote, _, cx| {
tally.update(cx, |tally, cx| {
match (vote, tally.voted) {
(Some(ix), _) => tally.votes[ix] += 1,
(None, Some(ix)) => tally.votes[ix] -= 1,
(None, None) => panic!("gallery poll: no vote to take back"),
}
tally.voted = vote;
cx.notify();
})
},
)
.votes(votes)
.on_vote(move |vote, _, cx| {
tally.update(cx, |tally, cx| {
match (vote, tally.voted) {
(Some(ix), _) => tally.votes[ix] += 1,
(None, Some(ix)) => tally.votes[ix] -= 1,
(None, None) => panic!("gallery poll: no vote to take back"),
}
tally.voted = vote;
cx.notify();
})
});
.votes(votes);
let poll = match voted {
Some(ix) => poll.voted(ix),
None => poll,
@@ -62,9 +62,7 @@ pub fn render(window: &mut Window, cx: &mut App) -> impl IntoElement + use<> {
vec!["Forms".into(), "Charts".into(), "Tables".into()],
),
Question::Text("What should we build next?".into()),
],
)
.on_submit(|answers, _, _| log::info!("gallery: survey {answers:?}")),
], |answers, _, _| log::info!("gallery: survey {answers:?}")),
),
cx,
)),
+4 -6
View File
@@ -53,9 +53,8 @@ pub fn render(window: &mut Window, cx: &mut App) -> impl IntoElement + use<> {
)
.child(
div().w(px(280.0)).child(
QrCodeScanner::new("scanner", 1.5)
.frame(frame.read(cx).clone())
.on_scan(|text, _, _| log::info!("gallery: scanned {text}")),
QrCodeScanner::new("scanner", 1.5, |text, _, _| log::info!("gallery: scanned {text}"))
.frame(frame.read(cx).clone()),
),
),
)
@@ -68,9 +67,7 @@ pub fn render(window: &mut Window, cx: &mut App) -> impl IntoElement + use<> {
.child(probe(
"captcha",
div().w(px(280.0)).child(
Captcha::new("captcha", picture, 3.0)
.state(state)
.on_answer(move |text, _, cx| {
Captcha::new("captcha", picture, 3.0, move |text, _, cx| {
checked.update(cx, |desk, cx| {
desk.1 = match text.eq_ignore_ascii_case(answer) {
true => CaptchaState::Passed,
@@ -79,6 +76,7 @@ pub fn render(window: &mut Window, cx: &mut App) -> impl IntoElement + use<> {
cx.notify();
})
})
.state(state)
.on_refresh(move |_, cx| {
refreshed.update(cx, |desk, cx| {
*desk = ((desk.0 + 1) % ANSWERS.len(), CaptchaState::Asking);
+4 -6
View File
@@ -110,11 +110,7 @@ pub fn render(window: &mut Window, cx: &mut App) -> impl IntoElement + use<> {
div().w(px(360.0)).child(
CookieBanner::new(
"cookies",
"The help pages set cookies. Necessary ones keep them working; the rest are up to you.",
)
.kind("Analytics", "Counts which pages help, without names.")
.kind("Video", "Lets embedded tutorials play and remember where you stopped.")
.on_choose(move |kinds, _, cx| {
"The help pages set cookies. Necessary ones keep them working; the rest are up to you.", move |kinds, _, cx| {
let words = match kinds.len() {
0 => "Only necessary cookies.".to_string(),
_ => format!("Cookies on: {}.", kinds.join(", ")),
@@ -123,7 +119,9 @@ pub fn render(window: &mut Window, cx: &mut App) -> impl IntoElement + use<> {
*said = words.into();
cx.notify();
})
}),
})
.kind("Analytics", "Counts which pages help, without names.")
.kind("Video", "Lets embedded tutorials play and remember where you stopped."),
),
))
.child(