Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Dioxus 0.6 support #57

Merged
merged 12 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ name: Rust

on:
push:
branches: [ "master" ]
branches:
- main
paths:
- sdk/**
- examples/**

pull_request:
branches: [ "master" ]
types: [opened, synchronize, reopened, ready_for_review]
branches:
- main
paths:
- sdk/**
- examples/**

env:
CARGO_TERM_COLOR: always
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@ name: Testing

on:
push:
branches: [ "master" ]
branches:
- main
paths:
- sdk/**
- examples/**

pull_request:
branches: [ "master" ]
types: [opened, synchronize, reopened, ready_for_review]
branches:
- main
paths:
- sdk/**
- examples/**

env:
CARGO_TERM_COLOR: always
Expand Down
6 changes: 2 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"rust-analyzer.cargo.features": [
"wasm-testing"
],
"rust-analyzer.cargo.target": "wasm32-unknown-unknown",
"rust-analyzer.cargo.features": "all",
"rust-analyzer.check.features": "all",
}
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
resolver = "2"
members = ["sdk", "examples/*"]


[workspace.dependencies]
dioxus-sdk = { path = "./sdk" }
dioxus = { version = "0.5" }
dioxus-desktop = { version = "0.5" }
dioxus = { version = "0.6.0" }
dioxus-desktop = { version = "0.6.0" }
dioxus-signals = { version = "0.6.0" }
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
- [x] Clipboard - (Desktop)
- [x] Notifications - (Desktop)
- [x] Color Scheme - (Web)
- [x] i18n
- [x] Utility Hooks
- [x] use_channel
- [x] use_window_size
Expand Down Expand Up @@ -82,7 +81,7 @@ sudo apt-get install xorg-dev
You can add `dioxus-sdk` to your application by adding it to your dependencies.
```toml
[dependencies]
dioxus-sdk = { version = "0.5", features = [] }
dioxus-sdk = { version = "0.6", features = [] }
```

## License
Expand Down
3 changes: 0 additions & 3 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ Learn how to use `use_system_theme`.
### [`geolocation`](./geolocation/)
Learn how to use the `geolocation` abstraction.

### [`i18n`](./i18n/)
Learn how to use the `i18n` abstraction.

### [`channel`](./channel/)
Learn how to use the `channel` abstraction.

Expand Down
14 changes: 0 additions & 14 deletions examples/i18n/Cargo.toml

This file was deleted.

42 changes: 0 additions & 42 deletions examples/i18n/Dioxus.toml

This file was deleted.

7 changes: 0 additions & 7 deletions examples/i18n/README.md

This file was deleted.

Binary file removed examples/i18n/public/favicon.ico
Binary file not shown.
9 changes: 0 additions & 9 deletions examples/i18n/src/en-US.json

This file was deleted.

9 changes: 0 additions & 9 deletions examples/i18n/src/es-ES.json

This file was deleted.

50 changes: 0 additions & 50 deletions examples/i18n/src/main.rs

This file was deleted.

2 changes: 1 addition & 1 deletion examples/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ dioxus = { workspace = true, features = ["router"] }
web = ["dioxus/web"]
desktop = ["dioxus/desktop"]
fullstack = ["dioxus/fullstack"]
server = ["dioxus/axum"]
server = ["dioxus/server"]
11 changes: 5 additions & 6 deletions examples/timing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ edition = "2021"

[dependencies]
dioxus-sdk = { workspace = true, features = ["timing"] }
dioxus = { workspace = true, features = ["desktop"] }
dioxus = { workspace = true }
dioxus-logger = "0.5.1"

log = "0.4.6"

# WebAssembly Debug
wasm-logger = "0.2.0"
console_error_panic_hook = "0.1.7"
[features]
web = ["dioxus/web"]
desktop = ["dioxus/desktop"]
12 changes: 6 additions & 6 deletions examples/timing/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
use dioxus::prelude::*;
use dioxus_logger::tracing::{info, Level};
use dioxus_sdk::utils::timing::{use_debounce, use_interval};
use std::time::Duration;

fn main() {
// init debug tool for WebAssembly
wasm_logger::init(wasm_logger::Config::default());
console_error_panic_hook::set_once();

dioxus_logger::init(Level::INFO).expect("logger failed to init");
launch(app);
}

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

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

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

Expand Down
2 changes: 0 additions & 2 deletions examples/window_size/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ dioxus = { workspace = true }
[features]
web = ["dioxus/web"]
desktop = ["dioxus/desktop"]


22 changes: 5 additions & 17 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dioxus-sdk"
version = "0.5.0"
version = "0.6.0"
authors = ["Jonathan Kelley", "Dioxus Labs", "ealmloff", "DogeDark", "marc2332"]
edition = "2021"
description = "Platform agnostic library for supercharging your productivity with Dioxus"
Expand Down Expand Up @@ -29,6 +29,7 @@ geolocation = [
"windows/Devices_Geolocation",

# Wasm
"web-sys/Window",
"web-sys/Navigator",
"web-sys/Geolocation",
"web-sys/PositionOptions",
Expand Down Expand Up @@ -59,14 +60,6 @@ window_size = [
"dep:wasm-bindgen",
]
channel = ["dep:async-broadcast", "uuid/v4"]
i18n = [
# Shared
"dep:serde",
"dep:serde_json",

# Non Shared
"dep:unic-langid",
]
storage = [
# Shared
"dep:rustc-hash",
Expand Down Expand Up @@ -106,7 +99,6 @@ wasm-testing = [
"channel",
"window_size",
"timing",
"i18n",
"storage",
]
desktop-testing = [
Expand All @@ -116,7 +108,6 @@ desktop-testing = [
"geolocation",
"channel",
"window_size",
"i18n",
"timing",
"storage",
]
Expand All @@ -129,6 +120,7 @@ desktop-testing = [
[dependencies]
dioxus = { workspace = true }
cfg-if = "1.0.0"
warnings = "0.2.0"

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

# Used by: i18n
serde = { version = "1.0.163", optional = true }
serde_json = { version = "1.0.96", optional = true }
unic-langid = { version = "0.9.1", features = ["serde"], optional = true }

# Used by: storage
rustc-hash = { version = "1.1.0", optional = true }
postcard = { version = "1.0.2", features = ["use-std"], optional = true }
once_cell = { version = "1.17.0", optional = true }
dioxus-signals = { version = "0.5.1", features = [
dioxus-signals = { workspace = true, features = [
"serialize",
], optional = true }
serde = { version = "1.0.163", optional = true }

yazi = { version = "0.1.4", optional = true }
tracing = "0.1.40"
Expand Down
8 changes: 5 additions & 3 deletions sdk/src/geolocation/platform/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,12 @@ pub fn listen(

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

geolocator.options.set_enable_high_accuracy(value);

Ok(())
}
2 changes: 1 addition & 1 deletion sdk/src/geolocation/use_geolocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn use_geolocation() -> ReadOnlySignal<Result<Geocoordinates, Error>> {
use_signal(|| Err(Error::NotInitialized));

// Initialize the handler of events
let listener = use_coroutine(|mut rx: UnboundedReceiver<Event>| async move {
let listener = use_coroutine(move |mut rx: UnboundedReceiver<Event>| async move {
while let Some(event) = rx.next().await {
match event {
Event::NewGeocoordinates(new_coords) => {
Expand Down
Loading
Loading