liana-ui: add warning to form::Value

This commit is contained in:
pythcoiner 2025-07-06 05:33:31 +02:00
parent b9c2ac93b5
commit d9c540ad14
No known key found for this signature in database
GPG Key ID: C1048AEEDF303B88
9 changed files with 18 additions and 3 deletions

View File

@ -342,6 +342,7 @@ impl KeySetting {
pub fn to_form(&self) -> form::Value<String> {
form::Value {
value: self.name.clone(),
warning: None,
valid: true,
}
}

View File

@ -38,6 +38,7 @@ impl LabelsEdited {
item,
form::Value {
valid,
warning: None,
value: value.clone(),
},
);

View File

@ -245,6 +245,7 @@ impl BitcoindSettings {
RpcAuthValues {
cookie_path: form::Value {
valid: true,
warning: None,
value: path.to_str().unwrap().to_string(),
},
user: form::Value::default(),
@ -257,10 +258,12 @@ impl BitcoindSettings {
cookie_path: form::Value::default(),
user: form::Value {
valid: true,
warning: None,
value: user.clone(),
},
password: form::Value {
valid: true,
warning: None,
value: password.clone(),
},
},
@ -284,6 +287,7 @@ impl BitcoindSettings {
selected_auth_type,
addr: form::Value {
valid: true,
warning: None,
value: addr,
},
}
@ -423,6 +427,7 @@ impl ElectrumSettings {
processing: false,
addr: form::Value {
valid: true,
warning: None,
value: addr,
},
}

View File

@ -65,6 +65,7 @@ impl WalletSettingsState {
keys_aliases: Self::keys_aliases(&wallet),
wallet_alias: form::Value {
value: wallet.alias.clone().unwrap_or_default(),
warning: None,
valid: true,
},
wallet,
@ -86,6 +87,7 @@ impl WalletSettingsState {
fg,
form::Value {
value: name,
warning: None,
valid: true,
},
)

View File

@ -388,6 +388,7 @@ impl CreateRbfModal {
descendant_txids,
feerate_val: form::Value {
valid: true,
warning: None,
value: min_feerate_vb.to_string(),
},
// For cancel, we let `rbfpsbt` set the feerate.

View File

@ -250,6 +250,7 @@ impl Step for RemoteBackendLogin {
self.step = ConnectionStep::EnterEmail {
email: form::Value {
value: email.clone(),
warning: None,
valid: true,
},
};

View File

@ -73,8 +73,6 @@ pub struct EditXpubModal {
form_name: form::Value<String>,
form_xpub: form::Value<String>,
// TODO: Define new `form::Value` type with `Option<String>` instead of `bool` so that we can
// store `form_token_warning` directly in `form_token`.
form_token: form::Value<String>,
form_token_warning: Option<String>,
/// The `KeySourceKind` corresponding to the required form for entering a new key.
@ -115,10 +113,12 @@ impl EditXpubModal {
other_path_keys,
form_name: form::Value {
valid: true,
warning: None,
value: key.as_ref().map(|k| k.name.clone()).unwrap_or_default(),
},
form_xpub: form::Value {
valid: true,
warning: None,
value: key
.as_ref()
.filter(|k| k.source.is_manual())
@ -127,6 +127,7 @@ impl EditXpubModal {
},
form_token: form::Value {
valid: true,
warning: None,
value: key
.as_ref()
.and_then(|k| k.source.token().cloned())

View File

@ -520,6 +520,7 @@ impl EditSequenceModal {
path_index,
sequence: form::Value {
value: path_sequence.as_u16().to_string(),
warning: None,
valid: true,
},
}

View File

@ -7,6 +7,7 @@ use crate::{color, component::text, theme, widget::*};
#[derive(Debug, Clone)]
pub struct Value<T> {
pub value: T,
pub warning: Option<&'static str>,
pub valid: bool,
}
@ -14,6 +15,7 @@ impl std::default::Default for Value<String> {
fn default() -> Self {
Self {
value: "".to_string(),
warning: None,
valid: true,
}
}
@ -41,7 +43,7 @@ where
{
Self {
input: text_input::TextInput::new(placeholder, &value.value).on_input(on_change),
warning: None,
warning: value.warning,
valid: value.valid,
}
}