Skip to content

Commit

Permalink
wip - notification panel
Browse files Browse the repository at this point in the history
  • Loading branch information
aspect committed Jan 13, 2024
1 parent db99b30 commit f6669d5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
50 changes: 24 additions & 26 deletions core/src/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ pub enum UserNotifyKind {
Success,
Warning,
Error,
Basic,
}

impl std::fmt::Display for UserNotifyKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
UserNotifyKind::Info => write!(f, "info"),
UserNotifyKind::Success => write!(f, "success"),
UserNotifyKind::Warning => write!(f, "warning"),
UserNotifyKind::Error => write!(f, "error"),
}
}
}

#[derive(Clone)]
Expand Down Expand Up @@ -69,10 +79,6 @@ impl UserNotification {
Self::new(UserNotifyKind::Success, text)
}

pub fn basic(text: impl Into<String>) -> Self {
Self::new(UserNotifyKind::Basic, text)
}

pub fn duration(mut self, duration: Duration) -> Self {
self.duration = Some(duration);
self
Expand Down Expand Up @@ -113,13 +119,6 @@ impl UserNotification {
.set_show_progress_bar(self.progress)
.set_closable(self.closable);
}
UserNotifyKind::Basic => {
toasts
.basic(self.message)
.set_duration(self.duration)
.set_show_progress_bar(self.progress)
.set_closable(self.closable);
}
}
}

Expand All @@ -131,7 +130,6 @@ impl UserNotification {
UserNotifyKind::Success => RichText::new(INFO).color(strong_color()),
UserNotifyKind::Warning => RichText::new(WARNING).color(warning_color()),
UserNotifyKind::Error => RichText::new(SEAL_WARNING).color(error_color()),
UserNotifyKind::Basic => RichText::new(INFO).color(info_color()),
}
}

Expand All @@ -141,7 +139,6 @@ impl UserNotification {
UserNotifyKind::Success => RichText::new(&self.message),
UserNotifyKind::Warning => RichText::new(&self.message).color(warning_color()),
UserNotifyKind::Error => RichText::new(&self.message).color(error_color()),
UserNotifyKind::Basic => RichText::new(&self.message),
}
}
}
Expand Down Expand Up @@ -216,20 +213,18 @@ impl Notifications {
.auto_shrink([false; 2])
.stick_to_bottom(true)
.show(ui, |ui| {
Grid::new("notification_popup_grid")
.num_columns(2)
// .spacing([2.0,2.0])
.show(ui, |ui| {
for notification in self.notifications.iter() {
// ui.label(notification.icon().size(24.));
// ui.label(notification.text().size(16.));
ui.label(notification.icon().size(20.));
ui.vertical(|ui| {
for notification in self.notifications.iter() {
ui.horizontal(|ui| {
ui.horizontal(|ui| {
ui.label(notification.icon().size(20.));
});
ui.horizontal_wrapped(|ui| {
ui.label(notification.text().size(14.));
});
ui.end_row();
}
});
});
}
});
});

ui.separator();
Expand All @@ -249,7 +244,10 @@ impl Notifications {
let notifications = self
.notifications
.iter()
.map(|notification| notification.message.to_string())
.map(|notification| {
let UserNotification { message, kind, .. } = notification;
format!("[{}] {}", kind.to_string().to_uppercase(), message)
})
.collect::<Vec<String>>()
.join("\n");
ui.output_mut(|o| o.copied_text = notifications);
Expand Down
12 changes: 8 additions & 4 deletions resources/i18n/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"fil": "Filipino",
"fa": "Farsi",
"lt": "Lithuanian",
"sv": "Swedish",
"pa": "Panjabi",
"nl": "Dutch",
"es": "Español",
"uk": "Ukrainian",
"sv": "Swedish",
"af": "Afrikaans",
"et": "Esti",
"en": "English",
Expand Down Expand Up @@ -67,8 +67,8 @@
"sv": {},
"pa": {},
"nl": {},
"es": {},
"uk": {},
"es": {},
"af": {},
"et": {},
"en": {
Expand Down Expand Up @@ -123,9 +123,9 @@
"Settings": "Settings",
"Check for Updates": "Check for Updates",
"wRPC Connection Settings": "wRPC Connection Settings",
"p2p Rx/s": "p2p Rx/s",
"Theme Color": "Theme Color",
"Custom Public Node": "Custom Public Node",
"p2p Rx/s": "p2p Rx/s",
"Remote Connection:": "Remote Connection:",
"Difficulty": "Difficulty",
"Uptime:": "Uptime:",
Expand Down Expand Up @@ -197,6 +197,7 @@
"Json Active Connections": "Json Active Connections",
"Show DAA": "Show DAA",
"Your private key mnemonic is:": "Your private key mnemonic is:",
"Connecting to": "Connecting to",
"Kaspa p2p Node & Connection": "Kaspa p2p Node & Connection",
"Disable password score restrictions": "Disable password score restrictions",
"Database Headers": "Database Headers",
Expand All @@ -222,6 +223,7 @@
"Confirm wallet password": "Confirm wallet password",
"The node is currently syncing with the Kaspa p2p network.": "The node is currently syncing with the Kaspa p2p network.",
"A wallet is stored in a file on your computer.": "A wallet is stored in a file on your computer.",
"Unable to change node settings until the problem is resolved.": "Unable to change node settings until the problem is resolved.",
"Client RPC": "Client RPC",
"wRPC JSON Tx": "wRPC JSON Tx",
"Virtual DAA Score": "Virtual DAA Score",
Expand Down Expand Up @@ -351,6 +353,7 @@
"Market Cap": "Market Cap",
"File Handles": "File Handles",
"Select Available Server": "Select Available Server",
"Invalid network type - expected: testnet-10 connected to: testnet-11": "Invalid network type - expected: testnet-10 connected to: testnet-11",
"p2p RPC": "p2p RPC",
"wRPC Borsh Tx/s": "wRPC Borsh Tx/s",
"Private Key Mnemonic": "Private Key Mnemonic",
Expand All @@ -376,7 +379,8 @@
"Storage": "Storage",
"Enter phishing hint": "Enter phishing hint",
"Past Median Time": "Past Median Time",
"Import existing": "Import existing"
"Import existing": "Import existing",
"Invalid wRPC URL": "Invalid wRPC URL"
},
"el": {},
"it": {},
Expand Down

0 comments on commit f6669d5

Please sign in to comment.