diff --git a/examples/counter.rs b/examples/counter.rs deleted file mode 100644 index 96ea46450..000000000 --- a/examples/counter.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2022 The Druid Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use xilem::{button, v_stack, Adapt, App, AppLauncher, LayoutObserver, Memoize, View}; - -#[derive(Default)] -struct AppData { - count: u32, -} - -fn count_button(count: u32) -> impl View { - button(format!("count: {}", count), |data| *data += 1) -} - -fn app_logic(data: &mut AppData) -> impl View { - v_stack(( - format!("count: {}", data.count), - button("reset", |data: &mut AppData| data.count = 0), - Memoize::new(data.count, |count| { - button(format!("count: {}", count), |data: &mut AppData| { - data.count += 1 - }) - }), - Adapt::new( - |data: &mut AppData, thunk| thunk.call(&mut data.count), - count_button(data.count), - ), - LayoutObserver::new(|size| format!("size: {:?}", size)), - )) -} - -pub fn main() { - let app = App::new(AppData::default(), app_logic); - AppLauncher::new(app).run(); -} diff --git a/examples/scroll.rs b/examples/scroll.rs deleted file mode 100644 index 54fac4d30..000000000 --- a/examples/scroll.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2022 The Druid Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use sha2::{Digest, Sha256}; -use xilem::{async_list, scroll_view, App, AppLauncher, View}; - -fn compute_hash(i: usize) -> String { - let mut s = format!("{}", i); - for _ in 0..i { - let mut hasher = Sha256::new(); - hasher.update(s.as_bytes()); - let result = hasher.finalize(); - s = hex::encode(result); - } - s -} - -fn app_logic(_: &mut ()) -> impl View<()> { - scroll_view(async_list(10_000, 16.0, |i| async move { - format!("{}: {}", i, compute_hash(i)) - })) -} - -fn main() { - let app = App::new((), app_logic); - AppLauncher::new(app).run(); -}