Skip to content

Commit 70f4fe5

Browse files
committed
dynamic notification dialog and a little cleanup
1 parent 7057519 commit 70f4fe5

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed
32.5 KB
Loading

services/modals/src/lib.rs

+39-4
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl Modals {
389389
/// <details>
390390
/// <summary>Example Image</summary>
391391
///
392-
/// ![Example Image - Initial](https://github.com/rowr111/xous-core/blob/main/docs/images/modals_start_progress.png?raw=true)
392+
/// ![Example Image](https://github.com/rowr111/xous-core/blob/main/docs/images/modals_start_progress.png?raw=true)
393393
///
394394
/// </details>
395395
///
@@ -428,7 +428,7 @@ impl Modals {
428428
/// <details>
429429
/// <summary>Example Image</summary>
430430
///
431-
/// ![Example Image - Initial](https://github.com/rowr111/xous-core/blob/main/docs/images/modals_slider.png?raw=true)
431+
/// ![Example Image](https://github.com/rowr111/xous-core/blob/main/docs/images/modals_slider.png?raw=true)
432432
///
433433
/// </details>
434434
///
@@ -616,7 +616,7 @@ impl Modals {
616616
/// <details>
617617
/// <summary>Example Image</summary>
618618
///
619-
/// ![Example Image - Initial](https://github.com/rowr111/xous-core/blob/main/docs/images/modals_get_radiobutton.png?raw=true)
619+
/// ![Example Image](https://github.com/rowr111/xous-core/blob/main/docs/images/modals_get_radiobutton.png?raw=true)
620620
///
621621
/// </details>
622622
///
@@ -692,7 +692,7 @@ impl Modals {
692692
/// <details>
693693
/// <summary>Example Image</summary>
694694
///
695-
/// ![Example Image - Initial](https://github.com/rowr111/xous-core/blob/main/docs/images/modals_get_checkbox.png?raw=true)
695+
/// ![Example Image](https://github.com/rowr111/xous-core/blob/main/docs/images/modals_get_checkbox.png?raw=true)
696696
///
697697
/// </details>
698698
///
@@ -789,6 +789,37 @@ impl Modals {
789789
}
790790
}
791791

792+
/// Notification modal with title and text that can be updated.
793+
/// - Modal cannot be dismissed by the user, you must close this dialog using `dynamic_notification_close`
794+
/// - Burden is on the consumer to not exceed available space.
795+
///
796+
/// <details>
797+
/// <summary>Example Image</summary>
798+
///
799+
/// ![Example Image](https://github.com/rowr111/xous-core/blob/main/docs/images/modals_dynamic_notification.png?raw=true)
800+
///
801+
/// </details>
802+
///
803+
/// # Example
804+
/// ```
805+
/// use modals::Modals;
806+
/// use xous_names::XousNames;
807+
/// let xns = XousNames::new().unwrap();
808+
/// let modals = Modals::new(&xns).unwrap();
809+
///
810+
/// modals
811+
/// .dynamic_notification(Some("TITLE OF NOTIFICATION"), Some("Important details go here..."))
812+
/// .unwrap();
813+
/// /// do some stuff
814+
/// modals
815+
/// .dynamic_notification_update(
816+
/// Some("Important update!"),
817+
/// Some("We're almost there, please hold.."),
818+
/// )
819+
/// .unwrap();
820+
/// /// do more stuff
821+
/// modals.dynamic_notification_close().unwrap();
822+
/// ```
792823
pub fn dynamic_notification(&self, title: Option<&str>, text: Option<&str>) -> Result<(), xous::Error> {
793824
self.lock();
794825
let spec = DynamicNotification {
@@ -802,6 +833,8 @@ impl Modals {
802833
Ok(())
803834
}
804835

836+
/// - Calling this to update the dynamic_notification dialog is optional.
837+
/// - See documentation for `dynamic_notification` for a code example.
805838
pub fn dynamic_notification_update(
806839
&self,
807840
title: Option<&str>,
@@ -818,6 +851,8 @@ impl Modals {
818851
Ok(())
819852
}
820853

854+
/// - You must call this method to dismiss `dynamic_notification` when it is no longer needed.
855+
/// - See documentation for `dynamic_notification` for a code example.
821856
pub fn dynamic_notification_close(&self) -> Result<(), xous::Error> {
822857
send_message(
823858
self.conn,

0 commit comments

Comments
 (0)