feat(dtmm): Add tooltip to update button

Fixes #71.
This commit is contained in:
Lucas Schwiderski 2023-03-16 09:56:27 +01:00
parent 60780656cf
commit 705ecd8b59
Signed by: lucas
GPG key ID: AA12679AAA6DF4D8
3 changed files with 37 additions and 10 deletions

21
Cargo.lock generated
View file

@ -685,7 +685,8 @@ dependencies = [
[[package]]
name = "druid"
version = "0.8.3"
source = "git+https://github.com/linebender/druid.git#c02452ddeebc527992e8f112f434f23ce24c934d"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ece41814b410c87e6379441caa7316539500b2e387b8d691f2ba5c0f4aff631"
dependencies = [
"console_error_panic_hook",
"druid-derive",
@ -710,7 +711,8 @@ dependencies = [
[[package]]
name = "druid-derive"
version = "0.5.0"
source = "git+https://github.com/linebender/druid.git#c02452ddeebc527992e8f112f434f23ce24c934d"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1234fc14b0c07e3d4ff2ae8862eb2c24c87e1f3d6eeef0ec6b9d564fe13cef2"
dependencies = [
"proc-macro2",
"quote",
@ -720,7 +722,8 @@ dependencies = [
[[package]]
name = "druid-shell"
version = "0.8.3"
source = "git+https://github.com/linebender/druid.git#c02452ddeebc527992e8f112f434f23ce24c934d"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7682d9c8fbf934504c30970775bfcfba7858a600f2f6e56bed331989958350fc"
dependencies = [
"anyhow",
"bitflags",
@ -749,6 +752,17 @@ dependencies = [
"wio",
]
[[package]]
name = "druid-widget-nursery"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fe4e3cbc027e5c9a4f1c135b339ac92aaf99681a7c1b51ff63111b5719194e5"
dependencies = [
"druid",
"log",
"tracing",
]
[[package]]
name = "dtmm"
version = "0.1.0"
@ -759,6 +773,7 @@ dependencies = [
"colors-transform",
"confy",
"druid",
"druid-widget-nursery",
"dtmt-shared",
"futures",
"lazy_static",

View file

@ -10,7 +10,7 @@ bitflags = "1.3.2"
clap = { version = "4.0.15", features = ["color", "derive", "std", "cargo", "string", "unicode"] }
color-eyre = "0.6.2"
confy = "0.5.1"
druid = { git = "https://github.com/linebender/druid.git", features = ["im", "serde", "image", "png", "jpeg", "bmp", "webp", "svg"] }
druid = { version = "0.8", features = ["im", "serde", "image", "png", "jpeg", "bmp", "webp", "svg"] }
dtmt-shared = { path = "../../lib/dtmt-shared", version = "*" }
futures = "0.3.25"
oodle-sys = { path = "../../lib/oodle-sys", version = "*" }
@ -30,3 +30,4 @@ strip-ansi-escapes = "0.1.1"
lazy_static = "1.4.0"
colors-transform = "0.2.11"
usvg = "0.25.0"
druid-widget-nursery = "0.1"

View file

@ -2,16 +2,17 @@ use std::str::FromStr;
use std::sync::Arc;
use druid::im::Vector;
use druid::lens;
use druid::widget::{
Checkbox, CrossAxisAlignment, Either, Flex, Image, Label, LineBreaking, List,
MainAxisAlignment, Maybe, Scroll, SizedBox, Split, Svg, SvgData, TextBox, ViewSwitcher,
};
use druid::{lens, Env};
use druid::{
Color, FileDialogOptions, FileSpec, FontDescriptor, FontFamily, LensExt, SingleUse, Widget,
WidgetExt, WindowDesc, WindowId,
};
use druid::{Data, ImageBuf, LifeCycleCtx};
use druid_widget_nursery::WidgetExt as _;
use lazy_static::lazy_static;
use crate::state::{
@ -50,11 +51,21 @@ fn build_top_bar() -> impl Widget<State> {
state.current_view = View::Settings;
});
let check_update_button = Button::with_label("Check for updates")
.on_click(|ctx, _: &mut State, _| {
let check_update_button = {
let make_button = || {
Button::with_label("Check for updates").on_click(|ctx, _: &mut State, _| {
ctx.submit_command(ACTION_START_CHECK_UPDATE);
})
.disabled_if(|data, _| data.nexus_api_key.is_empty() || data.is_update_in_progress);
};
Either::new(
|data, _| data.nexus_api_key.is_empty(),
make_button()
.tooltip(|_: &State, _: &Env| "A Nexus API key is required")
.disabled_if(|_, _| true),
make_button().disabled_if(|data, _| data.is_update_in_progress),
)
};
let deploy_button = {
let icon = Svg::new(SvgData::from_str(theme::icons::ALERT_CIRCLE).expect("invalid SVG"))