Skip to content

Commit

Permalink
Adds address input field
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashy5000 committed Mar 19, 2024
1 parent 3d0926b commit 64816c6
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion gui_wallet/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ pub fn main() -> iced::Result {
struct App {
balance: f64,
amount: f64,
address: String,
}

#[derive(Debug, Clone)]
enum Message {
Sync,
AmountChanged(String),
AddressChanged(String),
}

impl Sandbox for App {
Expand All @@ -24,6 +26,7 @@ impl Sandbox for App {
Self {
balance: -1.0,
amount: 0.0,
address: "".to_string(),
}
}

Expand All @@ -49,11 +52,15 @@ impl Sandbox for App {
}
}
}
Message::AddressChanged(new_address) => {
self.address = new_address;
}
}
}

fn view(&self) -> Element<Message> {
column![
text("Balance: ").size(15),
container(
row![
text({
Expand All @@ -74,15 +81,22 @@ impl Sandbox for App {
.padding(0)
.align_items(Alignment::End)
),
Space::with_height(10),
button("Sync").on_press(Message::Sync),
Space::with_height(20),
rule::Rule::horizontal(0.0),
Space::with_height(20),
text("Amount").size(10),
text("Amount").size(15),
text_input("Enter an amount...", self.amount.to_string().as_str())
.on_input(Message::AmountChanged)
.padding(10)
.size(30),
Space::with_height(10),
text("Address").size(15),
text_input("Enter an address...", self.address.as_str())
.on_input(Message::AddressChanged)
.padding(10)
.size(30),
]
.padding(20)
.align_items(Alignment::Start)
Expand Down

0 comments on commit 64816c6

Please sign in to comment.