MCPcopy Index your code
hub / github.com/algoscienceacademy/RustUI / main

Function main

examples/src/responsive_app.rs:27–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25}
26
27fn main() {
28 let rust_native = RustUI::new();
29 let store = Store::new(AppState {
30 counter: 0,
31 theme: create_dark_theme(),
32 });
33
34 let responsive = ResponsiveLayout::new();
35 let store = Rc::new(RefCell::new(store));
36 let navigator = Rc::new(RefCell::new(Navigator::new()));
37
38 rust_native.run(move || {
39 let store_for_view = store.clone();
40 let navigator_for_view = navigator.clone();
41 let store_for_increment = store.clone();
42 let navigator_for_next = navigator.clone();
43
44 let view = View::new()
45 .with_responsive_layout(&responsive, vec![
46 (Breakpoint::Small, Stack::new(Direction::Vertical)),
47 (Breakpoint::Large, Stack::new(Direction::Horizontal)),
48 ])
49 .with_store(&*store_for_view.borrow())
50 .with_navigator(&*navigator_for_view.borrow())
51 .child(
52 Button::new("Next Page")
53 .on_click(move || {
54 navigator_for_next.borrow_mut().push(Route::new("details"));
55 })
56 )
57 .child(
58 Button::new("Increment")
59 .on_click(move || {
60 store_for_increment.borrow_mut().dispatch(|state| {
61 state.counter += 1;
62 });
63 })
64 );
65
66 Box::new(ResponsiveApp { view })
67 });
68}

Callers

nothing calls this directly

Calls 6

create_dark_themeFunction · 0.85
on_clickMethod · 0.80
pushMethod · 0.80
runMethod · 0.45
childMethod · 0.45
dispatchMethod · 0.45

Tested by

no test coverage detected