Skip to content

Commit

Permalink
use dioxus main and resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Jan 21, 2025
2 parents 7998341 + 621f105 commit 489a6a8
Show file tree
Hide file tree
Showing 61 changed files with 1,629 additions and 694 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Check examples
run: cargo check --examples
- name: Lint
run: cargo clippy --workspace --examples --features docs -- -D warnings
run: cargo clippy --workspace --examples --features "docs, use_camera, devtools" -- -D warnings
- name: Format
run: cargo +nightly fmt --all --check -- --error-on-unformatted --unstable-features
- name: Run Linux tests
Expand Down
33 changes: 16 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ fade-cached-incremental-areas = ["freya/fade-cached-incremental-areas"]
disable-zoom-shortcuts = ["freya/disable-zoom-shortcuts"]
docs = ["freya/docs"]

# [patch.crates-io]
# dioxus = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" }
# dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" }
# dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" }
# dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" }
# dioxus-signals = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" }
# dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" }
# dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" }
# dioxus-lib = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" }
# generational-box = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.6.1" }
[patch.crates-io]
dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev = "640a3e00af272bfb3464f86ac3d175eaa80af182" }
dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus", rev = "640a3e00af272bfb3464f86ac3d175eaa80af182" }
dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", rev = "640a3e00af272bfb3464f86ac3d175eaa80af182" }
dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", rev = "640a3e00af272bfb3464f86ac3d175eaa80af182" }
dioxus-signals = { git = "https://github.com/DioxusLabs/dioxus", rev = "640a3e00af272bfb3464f86ac3d175eaa80af182" }
dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", rev = "640a3e00af272bfb3464f86ac3d175eaa80af182" }
dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", rev = "640a3e00af272bfb3464f86ac3d175eaa80af182" }
generational-box = { git = "https://github.com/DioxusLabs/dioxus", rev = "640a3e00af272bfb3464f86ac3d175eaa80af182" }

[workspace.dependencies]
freya = { path = "crates/freya", version = "0.3.0-rc.0" }
Expand All @@ -47,14 +46,14 @@ dioxus-i18n = "0.3"
freya-native-core-macro = { path = "crates/native-core-macro", version = "0.3.0-rc.0" }
freya-native-core = { path = "crates/native-core", version = "0.3.0-rc.0" }

dioxus = { version = "0.6.1", default-features = false, features = ["macro", "signals", "hooks"] }
dioxus-rsx = { version = "0.6.1" }
dioxus-core-macro = { version = "0.6.1" }
dioxus = { version = "0.6.1", default-features = false, features = ["macro", "signals", "hooks"]}
dioxus-rsx = { version = "0.6.1" }
dioxus-core-macro = { version = "0.6.1" }
dioxus-hooks = { version = "0.6.1" }
dioxus-signals = { version = "0.6.1" }
dioxus-core = { version = "0.6.1" }
generational-box = { version = "0.6.1" }
dioxus-router = { version = "0.6.1", default-features = false }
dioxus-signals = { version = "0.6.1" }
dioxus-core = { version = "0.6.1" }
dioxus-router = { version = "0.6.1", default-features = false }
generational-box = { version = "0.6.1" }

skia-safe = { version = "0.80.0", features = ["gl", "textlayout", "svg"] }

Expand Down
4 changes: 2 additions & 2 deletions book/src/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Make sure you have [Rust](https://www.rust-lang.org/) and your OS dependencies installed.

### Windows

You will need C++ build tools which you can get through Visual Studio 2022, learn more [here](https://learn.microsoft.com/en-us/windows/dev-environment/rust/setup#install-visual-studio-recommended-or-the-microsoft-c-build-tools).
Install Visual Studio 2022 with the `Desktop Development with C++` workflow.
You can learn learn more [here](https://learn.microsoft.com/en-us/windows/dev-environment/rust/setup#install-visual-studio-recommended-or-the-microsoft-c-build-tools).

### Linux

Expand Down
14 changes: 6 additions & 8 deletions crates/components/src/accordion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,16 @@ pub struct AccordionProps {
pub fn Accordion(props: AccordionProps) -> Element {
let theme = use_applied_theme!(&props.theme, accordion);
let mut open = use_signal(|| false);
let animation = use_animation(move |ctx| {
ctx.with(
AnimNum::new(0., 100.)
.time(300)
.function(Function::Expo)
.ease(Ease::Out),
)
let animation = use_animation(move |_conf| {
AnimNum::new(0., 100.)
.time(300)
.function(Function::Expo)
.ease(Ease::Out)
});
let mut status = use_signal(AccordionStatus::default);
let platform = use_platform();

let animation_value = animation.get().read().as_f32();
let animation_value = animation.get().read().read();
let AccordionTheme {
background,
color,
Expand Down
34 changes: 15 additions & 19 deletions crates/components/src/animated_position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,26 @@ pub fn AnimatedPosition(
let mut render_element = use_signal(|| false);
let (reference, size, old_size) = use_node_signal_with_prev();

let animations = use_animation_with_dependencies(
let animation = use_animation_with_dependencies(
&(function, duration, ease),
move |ctx, (function, duration, ease)| {
move |_conf, (function, duration, ease)| {
let old_size = old_size().unwrap_or_default();
let size = size().unwrap_or_default();
(
ctx.with(
AnimNum::new(size.area.origin.x, old_size.area.origin.x)
.duration(duration)
.ease(ease)
.function(function),
),
ctx.with(
AnimNum::new(size.area.origin.y, old_size.area.origin.y)
.duration(duration)
.ease(ease)
.function(function),
),
AnimNum::new(size.area.origin.x, old_size.area.origin.x)
.duration(duration)
.ease(ease)
.function(function),
AnimNum::new(size.area.origin.y, old_size.area.origin.y)
.duration(duration)
.ease(ease)
.function(function),
)
},
);

use_effect(move || {
if animations.is_running() {
if animation.is_running() {
render_element.set(true);
}
});
Expand All @@ -55,15 +51,15 @@ pub fn AnimatedPosition(
let has_size = size.read().is_some();
let has_old_size = old_size.read().is_some();
if has_size && has_old_size {
animations.run(AnimDirection::Reverse);
animation.run(AnimDirection::Reverse);
} else if has_size {
render_element.set(true);
}
});

let (offset_x, offset_y) = animations.get();
let offset_x = offset_x.read().as_f32();
let offset_y = offset_y.read().as_f32();
let (offset_x, offset_y) = &*animation.get().read_unchecked();
let offset_x = offset_x.read();
let offset_y = offset_y.read();

rsx!(
rect {
Expand Down
40 changes: 30 additions & 10 deletions crates/components/src/dropdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use freya_hooks::{
use_applied_theme,
use_focus,
use_platform,
DropdownItemTheme,
DropdownItemThemeWith,
DropdownTheme,
DropdownThemeWith,
Expand Down Expand Up @@ -70,13 +71,25 @@ where
let is_focused = focus.is_focused();
let is_selected = *selected.read() == value;

let DropdownItemTheme {
font_theme,
background,
hover_background,
select_background,
border_fill,
select_border_fill,
} = &theme;

let background = match *status.read() {
_ if is_selected => theme.select_background,
_ if is_focused => theme.hover_background,
DropdownItemStatus::Hovering => theme.hover_background,
DropdownItemStatus::Idle => theme.background,
_ if is_selected => select_background,
DropdownItemStatus::Hovering => hover_background,
DropdownItemStatus::Idle => background,
};
let border = if focus.is_selected() {
format!("2 inner {select_border_fill}")
} else {
format!("1 inner {border_fill}")
};
let color = theme.font_theme.color;

use_drop(move || {
if *status.peek() == DropdownItemStatus::Hovering {
Expand Down Expand Up @@ -114,10 +127,11 @@ where
rsx!(
rect {
width: "fill-min",
color: "{color}",
color: "{font_theme.color}",
a11y_id,
a11y_role:"button",
a11y_role: "button",
background: "{background}",
border,
padding: "6 22 6 16",
corner_radius: "6",
main_align: "center",
Expand Down Expand Up @@ -249,13 +263,19 @@ where
background_button,
hover_background,
border_fill,
focus_border_fill,
arrow_fill,
} = &theme;

let button_background = match *status.read() {
let background = match *status.read() {
DropdownStatus::Hovering => hover_background,
DropdownStatus::Idle => background_button,
};
let border = if focus.is_selected() {
format!("2 inner {focus_border_fill}")
} else {
format!("1 inner {border_fill}")
};

let selected = selected.read().to_string();

Expand All @@ -270,11 +290,11 @@ where
onglobalkeydown,
margin: "{margin}",
a11y_id,
background: "{button_background}",
background: "{background}",
color: "{font_theme.color}",
corner_radius: "8",
padding: "8 16",
border: "1 inner {border_fill}",
border,
shadow: "0 4 5 0 rgb(0, 0, 0, 0.1)",
direction: "horizontal",
main_align: "center",
Expand Down
10 changes: 5 additions & 5 deletions crates/components/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ pub struct LoaderProps {
#[allow(non_snake_case)]
pub fn Loader(props: LoaderProps) -> Element {
let theme = use_applied_theme!(&props.theme, loader);
let anim = use_animation(|ctx| {
ctx.auto_start(true);
ctx.on_finish(OnFinish::Restart);
ctx.with(AnimNum::new(0.0, 360.0).time(650))
let animation = use_animation(|conf| {
conf.auto_start(true);
conf.on_finish(OnFinish::Restart);
AnimNum::new(0.0, 360.0).time(650)
});

let LoaderTheme { primary_color } = theme;

let degrees = anim.get().read().as_f32();
let degrees = animation.get().read().read();

rsx!(svg {
rotate: "{degrees}deg",
Expand Down
Loading

0 comments on commit 489a6a8

Please sign in to comment.