Skip to content
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
16 changes: 15 additions & 1 deletion src/ui/components/amount_input.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::model::amount::Amount;
use crate::ui::components::{Component, ComponentResponse};
use dash_sdk::dpp::balances::credits::MAX_CREDITS;
use dash_sdk::dpp::fee::Credits;
use egui::{InnerResponse, Response, TextEdit, Ui, Vec2, WidgetText};

Expand Down Expand Up @@ -113,7 +114,7 @@ impl AmountInput {
unit_name: amount.unit_name().map(|s| s.to_string()),
label: None,
hint_text: None,
max_amount: None,
max_amount: Some(MAX_CREDITS),
min_amount: Some(1), // Default minimum is 1 (greater than zero)
show_max_button: false,
desired_width: None,
Expand Down Expand Up @@ -176,6 +177,17 @@ impl AmountInput {
self
}

/// Sets value of the input field.
///
/// This will update the internal state and mark the component as changed.
pub fn set_value(&mut self, value: Amount) -> &mut Self {
self.amount_str = value.to_string_without_unit();
self.decimal_places = value.decimal_places();
self.unit_name = value.unit_name().map(|s| s.to_string());
self.changed = true; // Mark as changed to trigger validation
self
}

/// Sets the hint text for the input field.
pub fn with_hint_text<T: Into<WidgetText>>(mut self, hint_text: T) -> Self {
self.hint_text = Some(hint_text.into());
Expand All @@ -197,6 +209,8 @@ impl AmountInput {

/// Sets the maximum amount allowed (mutable reference version).
/// Use this for dynamic configuration when the max amount changes at runtime (e.g., balance updates).
///
/// Defaults to [`MAX_CREDITS`](dash_sdk::dpp::balances::credits::MAX_CREDITS).
pub fn set_max_amount(&mut self, max_amount: Option<Credits>) -> &mut Self {
self.max_amount = max_amount;
self
Expand Down
4 changes: 3 additions & 1 deletion src/ui/contracts_documents/group_actions_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,9 @@ impl GroupActionsScreen {
}
TokenEvent::ChangePriceForDirectPurchase(schedule, note_opt) => {
let mut change_price_screen =
SetTokenPriceScreen::new(identity_token_info, &self.app_context);
SetTokenPriceScreen::new(identity_token_info, &self.app_context)
.with_schedule(schedule.clone());

change_price_screen.group_action_id = Some(action_id);
change_price_screen.token_pricing_schedule = format!("{:?}", schedule);
change_price_screen.public_note = note_opt.clone();
Expand Down
Loading
Loading