Skip to content

Commit 16a49a8

Browse files
marc2332DogeDark
andauthored
feat: Dioxus 0.6 support (#57)
* feat: Dioxus 0.6 support * bump dioxus-signals * chore: clean up * update: alpha 5 * Fix Unnescessary Warning Messages (#62) * fix: allow window resize signal writes * progress: interval * fix: interval warnings, geolocation * remove: warnings dep * revision: change to 1 second * 0.6.0-rc.0 * update: dioxus 0.6 & final touches * fix: ci * fix: clippy & issues --------- Co-authored-by: Miles Murgaw <[email protected]>
1 parent 765dcfe commit 16a49a8

27 files changed

+78
-387
lines changed

.github/workflows/rust.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@ name: Rust
22

33
on:
44
push:
5-
branches: [ "master" ]
5+
branches:
6+
- main
7+
paths:
8+
- sdk/**
9+
- examples/**
10+
611
pull_request:
7-
branches: [ "master" ]
12+
types: [opened, synchronize, reopened, ready_for_review]
13+
branches:
14+
- main
15+
paths:
16+
- sdk/**
17+
- examples/**
818

919
env:
1020
CARGO_TERM_COLOR: always

.github/workflows/testing.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@ name: Testing
33

44
on:
55
push:
6-
branches: [ "master" ]
6+
branches:
7+
- main
8+
paths:
9+
- sdk/**
10+
- examples/**
11+
712
pull_request:
8-
branches: [ "master" ]
13+
types: [opened, synchronize, reopened, ready_for_review]
14+
branches:
15+
- main
16+
paths:
17+
- sdk/**
18+
- examples/**
919

1020
env:
1121
CARGO_TERM_COLOR: always

.vscode/settings.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
2-
"rust-analyzer.cargo.features": [
3-
"wasm-testing"
4-
],
5-
"rust-analyzer.cargo.target": "wasm32-unknown-unknown",
2+
"rust-analyzer.cargo.features": "all",
3+
"rust-analyzer.check.features": "all",
64
}

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
resolver = "2"
33
members = ["sdk", "examples/*"]
44

5-
65
[workspace.dependencies]
76
dioxus-sdk = { path = "./sdk" }
8-
dioxus = { version = "0.5" }
9-
dioxus-desktop = { version = "0.5" }
7+
dioxus = { version = "0.6.0" }
8+
dioxus-desktop = { version = "0.6.0" }
9+
dioxus-signals = { version = "0.6.0" }

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
- [x] Clipboard - (Desktop)
3535
- [x] Notifications - (Desktop)
3636
- [x] Color Scheme - (Web)
37-
- [x] i18n
3837
- [x] Utility Hooks
3938
- [x] use_channel
4039
- [x] use_window_size
@@ -82,7 +81,7 @@ sudo apt-get install xorg-dev
8281
You can add `dioxus-sdk` to your application by adding it to your dependencies.
8382
```toml
8483
[dependencies]
85-
dioxus-sdk = { version = "0.5", features = [] }
84+
dioxus-sdk = { version = "0.6", features = [] }
8685
```
8786

8887
## License

examples/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ Learn how to use `use_system_theme`.
66
### [`geolocation`](./geolocation/)
77
Learn how to use the `geolocation` abstraction.
88

9-
### [`i18n`](./i18n/)
10-
Learn how to use the `i18n` abstraction.
11-
129
### [`channel`](./channel/)
1310
Learn how to use the `channel` abstraction.
1411

examples/i18n/Cargo.toml

Lines changed: 0 additions & 14 deletions
This file was deleted.

examples/i18n/Dioxus.toml

Lines changed: 0 additions & 42 deletions
This file was deleted.

examples/i18n/README.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

examples/i18n/public/favicon.ico

-130 KB
Binary file not shown.

examples/i18n/src/en-US.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

examples/i18n/src/es-ES.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

examples/i18n/src/main.rs

Lines changed: 0 additions & 50 deletions
This file was deleted.

examples/storage/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ dioxus = { workspace = true, features = ["router"] }
1111
web = ["dioxus/web"]
1212
desktop = ["dioxus/desktop"]
1313
fullstack = ["dioxus/fullstack"]
14-
server = ["dioxus/axum"]
14+
server = ["dioxus/server"]

examples/timing/Cargo.toml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ edition = "2021"
55

66
[dependencies]
77
dioxus-sdk = { workspace = true, features = ["timing"] }
8-
dioxus = { workspace = true, features = ["desktop"] }
8+
dioxus = { workspace = true }
9+
dioxus-logger = "0.5.1"
910

10-
log = "0.4.6"
11-
12-
# WebAssembly Debug
13-
wasm-logger = "0.2.0"
14-
console_error_panic_hook = "0.1.7"
11+
[features]
12+
web = ["dioxus/web"]
13+
desktop = ["dioxus/desktop"]

examples/timing/src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
use dioxus::prelude::*;
2+
use dioxus_logger::tracing::{info, Level};
23
use dioxus_sdk::utils::timing::{use_debounce, use_interval};
34
use std::time::Duration;
45

56
fn main() {
6-
// init debug tool for WebAssembly
7-
wasm_logger::init(wasm_logger::Config::default());
8-
console_error_panic_hook::set_once();
9-
7+
dioxus_logger::init(Level::INFO).expect("logger failed to init");
108
launch(app);
119
}
1210

1311
fn app() -> Element {
1412
let mut count = use_signal(|| 0);
1513

16-
use_interval(Duration::from_millis(100), move || {
14+
// using `use_interval`, we increment the count by 1 every second.
15+
use_interval(Duration::from_secs(1), move || {
1716
count += 1;
1817
});
1918

19+
// using `use_debounce`, we reset the counter after 2 seconds since the last button click.
2020
let mut debounce = use_debounce(Duration::from_millis(2000), move |text| {
21-
println!("{text}");
21+
info!("{text}");
2222
count.set(0);
2323
});
2424

examples/window_size/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ dioxus = { workspace = true }
1010
[features]
1111
web = ["dioxus/web"]
1212
desktop = ["dioxus/desktop"]
13-
14-

sdk/Cargo.toml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "dioxus-sdk"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
authors = ["Jonathan Kelley", "Dioxus Labs", "ealmloff", "DogeDark", "marc2332"]
55
edition = "2021"
66
description = "Platform agnostic library for supercharging your productivity with Dioxus"
@@ -29,6 +29,7 @@ geolocation = [
2929
"windows/Devices_Geolocation",
3030

3131
# Wasm
32+
"web-sys/Window",
3233
"web-sys/Navigator",
3334
"web-sys/Geolocation",
3435
"web-sys/PositionOptions",
@@ -59,14 +60,6 @@ window_size = [
5960
"dep:wasm-bindgen",
6061
]
6162
channel = ["dep:async-broadcast", "uuid/v4"]
62-
i18n = [
63-
# Shared
64-
"dep:serde",
65-
"dep:serde_json",
66-
67-
# Non Shared
68-
"dep:unic-langid",
69-
]
7063
storage = [
7164
# Shared
7265
"dep:rustc-hash",
@@ -106,7 +99,6 @@ wasm-testing = [
10699
"channel",
107100
"window_size",
108101
"timing",
109-
"i18n",
110102
"storage",
111103
]
112104
desktop-testing = [
@@ -116,7 +108,6 @@ desktop-testing = [
116108
"geolocation",
117109
"channel",
118110
"window_size",
119-
"i18n",
120111
"timing",
121112
"storage",
122113
]
@@ -129,6 +120,7 @@ desktop-testing = [
129120
[dependencies]
130121
dioxus = { workspace = true }
131122
cfg-if = "1.0.0"
123+
warnings = "0.2.0"
132124

133125
# Used by: clipboard
134126
copypasta = { version = "0.8.2", optional = true }
@@ -145,18 +137,14 @@ async-broadcast = { version = "0.5.1", optional = true }
145137
futures = { version = "0.3.28", features = ["std"], optional = true }
146138
futures-util = { version = "0.3.28", optional = true }
147139

148-
# Used by: i18n
149-
serde = { version = "1.0.163", optional = true }
150-
serde_json = { version = "1.0.96", optional = true }
151-
unic-langid = { version = "0.9.1", features = ["serde"], optional = true }
152-
153140
# Used by: storage
154141
rustc-hash = { version = "1.1.0", optional = true }
155142
postcard = { version = "1.0.2", features = ["use-std"], optional = true }
156143
once_cell = { version = "1.17.0", optional = true }
157-
dioxus-signals = { version = "0.5.1", features = [
144+
dioxus-signals = { workspace = true, features = [
158145
"serialize",
159146
], optional = true }
147+
serde = { version = "1.0.163", optional = true }
160148

161149
yazi = { version = "0.1.4", optional = true }
162150
tracing = "0.1.40"

sdk/src/geolocation/platform/wasm.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,12 @@ pub fn listen(
184184

185185
/// Set the device's power mode.
186186
pub fn set_power_mode(geolocator: &mut Geolocator, power_mode: PowerMode) -> Result<(), Error> {
187-
match power_mode {
188-
PowerMode::High => geolocator.options.enable_high_accuracy(true),
189-
PowerMode::Low => geolocator.options.enable_high_accuracy(false),
187+
let value = match power_mode {
188+
PowerMode::High => true,
189+
PowerMode::Low => false,
190190
};
191191

192+
geolocator.options.set_enable_high_accuracy(value);
193+
192194
Ok(())
193195
}

sdk/src/geolocation/use_geolocation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn use_geolocation() -> ReadOnlySignal<Result<Geocoordinates, Error>> {
2020
use_signal(|| Err(Error::NotInitialized));
2121

2222
// Initialize the handler of events
23-
let listener = use_coroutine(|mut rx: UnboundedReceiver<Event>| async move {
23+
let listener = use_coroutine(move |mut rx: UnboundedReceiver<Event>| async move {
2424
while let Some(event) = rx.next().await {
2525
match event {
2626
Event::NewGeocoordinates(new_coords) => {

0 commit comments

Comments
 (0)