Skip to content

Commit 1f5ca47

Browse files
committed
Update AccessKit, Parley, and Masonry
1 parent 07a4660 commit 1f5ca47

File tree

4 files changed

+59
-52
lines changed

4 files changed

+59
-52
lines changed

Cargo.lock

Lines changed: 38 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ name = "main"
88
crate-type = ["cdylib"]
99

1010
[dependencies]
11-
accesskit = "0.19.0"
12-
accesskit_android = "0.2.0"
11+
accesskit = "0.21.0"
12+
accesskit_android = "0.4.0"
1313
android-view = { path = ".." }
1414
android_logger = "0.15.0"
1515
anyhow = "1.0.96"
1616
log = "0.4.26"
17-
parley = { version = "0.5.0", features = ["accesskit"] }
17+
parley = { git = "https://github.com/linebender/parley", rev = "587b7634ae8601c10de7f0361bfd56085a5b7b4e", features = ["accesskit"] }
1818
peniko = { version = "0.4.0", default-features = false }
1919
pollster = "0.4.0"
2020
ui-events = "0.1.0"

masonry-demo/src/lib.rs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ use android_view::{
1111
*,
1212
};
1313
use masonry::{
14-
core::{Action, DefaultProperties, Widget, WidgetId},
14+
core::{Action, Properties, Widget, WidgetId, WidgetPod},
1515
properties::Padding,
1616
theme::default_property_set,
17-
widgets::{Button, Flex, Label, Portal, RootWidget, TextArea, Textbox},
17+
widgets::{Button, Flex, Label, Portal, TextArea, TextInput},
1818
};
1919
use masonry_android::{AppDriver, DriverCtx};
2020
use std::{ffi::c_void, sync::Arc};
@@ -31,18 +31,15 @@ impl AppDriver for Driver {
3131
match action {
3232
Action::ButtonPressed(_) => {
3333
ctx.render_root().edit_root_widget(|mut root| {
34-
let mut root = root.downcast::<RootWidget>();
35-
36-
let mut portal = RootWidget::child_mut(&mut root);
37-
let mut portal = portal.downcast::<Portal<Flex>>();
34+
let mut portal = root.downcast::<Portal<Flex>>();
3835
let mut flex = Portal::child_mut(&mut portal);
3936
Flex::add_child(&mut flex, Label::new(self.next_task.clone()));
4037

4138
let mut first_row = Flex::child_mut(&mut flex, 0).unwrap();
4239
let mut first_row = first_row.downcast::<Flex>();
43-
let mut textbox = Flex::child_mut(&mut first_row, 0).unwrap();
44-
let mut textbox = textbox.downcast::<Textbox>();
45-
let mut text_area = Textbox::text_mut(&mut textbox);
40+
let mut text_input = Flex::child_mut(&mut first_row, 0).unwrap();
41+
let mut text_input = text_input.downcast::<TextInput>();
42+
let mut text_area = TextInput::text_mut(&mut text_input);
4643
TextArea::reset_text(&mut text_area, "");
4744
});
4845
}
@@ -57,22 +54,19 @@ impl AppDriver for Driver {
5754
fn make_widget_tree() -> impl Widget {
5855
Portal::new(
5956
Flex::column()
60-
.with_child(
61-
Flex::row()
62-
.with_flex_child(Textbox::new(""), 1.0)
63-
.with_child(Button::new("Add task")),
57+
.with_child_pod(
58+
WidgetPod::new_with_props(
59+
Flex::row()
60+
.with_flex_child(TextInput::new(""), 1.0)
61+
.with_child(Button::new("Add task")),
62+
Properties::new().with(Padding::all(WIDGET_SPACING)),
63+
)
64+
.erased(),
6465
)
6566
.with_spacer(WIDGET_SPACING),
6667
)
6768
}
6869

69-
fn default_props() -> Arc<DefaultProperties> {
70-
let mut default_properties = default_property_set();
71-
default_properties.insert::<RootWidget, _>(Padding::all(WIDGET_SPACING));
72-
73-
Arc::new(default_properties)
74-
}
75-
7670
extern "system" fn new_view_peer<'local>(
7771
mut env: JNIEnv<'local>,
7872
_view: View<'local>,
@@ -81,11 +75,11 @@ extern "system" fn new_view_peer<'local>(
8175
masonry_android::new_view_peer(
8276
&mut env,
8377
&context,
84-
RootWidget::new(make_widget_tree()),
78+
make_widget_tree(),
8579
Driver {
8680
next_task: String::new(),
8781
},
88-
default_props(),
82+
Arc::new(default_property_set()),
8983
)
9084
}
9185

masonry/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ version = "0.1.0"
44
edition = "2024"
55

66
[dependencies]
7-
accesskit = "0.19.0"
8-
accesskit_android = "0.2.0"
7+
accesskit = "0.21.0"
8+
accesskit_android = "0.4.0"
99
android-view = { path = ".." }
1010
masonry = { git = "https://github.com/linebender/xilem" }
1111
pollster = "0.4.0"

0 commit comments

Comments
 (0)