mtxchat add navigation help on first login

chat add help navigation modal
This commit is contained in:
nworbnhoj 2023-09-09 10:24:52 +10:00
parent 07ef4d16c2
commit c50cc73610
4 changed files with 45 additions and 5 deletions

View file

@ -78,13 +78,14 @@ pub struct MtxChat<'a> {
since: String,
listening: bool,
modals: Modals,
new_username: bool,
new_room: bool,
}
impl<'a> MtxChat<'a> {
pub fn new(chat: &Chat) -> MtxChat {
let xns = xous_names::XousNames::new().unwrap();
let modals = Modals::new(&xns).expect("can't connect to Modals server");
let trng = Trng::new(&xns).unwrap();
let trng = Trng::new(&xns).unwrap();
let pddb = pddb::Pddb::new();
pddb.try_mount();
MtxChat {
@ -104,6 +105,7 @@ impl<'a> MtxChat<'a> {
since: EMPTY.to_string(),
listening: false,
modals: modals,
new_username: false,
new_room: false,
}
}
@ -251,6 +253,10 @@ impl<'a> MtxChat<'a> {
.show_notification(t!("mtxchat.listen.patience", locales::LANG), None)
.expect("notification failed");
}
if self.new_username {
self.new_username = false;
self.help();
}
return true;
} else {
self.modals
@ -332,10 +338,13 @@ impl<'a> MtxChat<'a> {
let builder = match self.get(USER_NAME_KEY) {
// TODO add TextValidationFn
Ok(Some(user)) => builder.field_placeholder_persist(Some(user), None),
_ => builder.field(
Some(t!("mtxchat.user_name", locales::LANG).to_string()),
None,
),
_ => {
self.new_username = true;
builder.field(
Some(t!("mtxchat.user_name", locales::LANG).to_string()),
None,
)
}
};
let builder = match self.get(USER_DOMAIN_KEY) {
// TODO add TextValidationFn
@ -449,6 +458,10 @@ impl<'a> MtxChat<'a> {
.expect("failed to set dialogue");
}
pub fn help(&self) {
self.chat.help();
}
// assume logged in, token is valid, room_id is valid, user is valid
pub fn get_filter(&mut self) -> bool {
if self.filter.len() > 0 {

View file

@ -18,5 +18,9 @@
"chat.dict_empty": {
"en": "no dialogues available to read",
"en-tts": "no dialogues available to read"
},
"chat.help.navigation": {
"en": "use ↑ & ↓ to scroll thru old posts\nuse ← & → to show menus\nF1-F4 dont do anything yet.",
"en-tts": "use ↑ & ↓ to scroll thru old posts\nuse ← & → to show menus\nF1-F4 dont do anything yet."
}
}

View file

@ -97,6 +97,17 @@ impl Chat {
}
}
/// Show some user help
///
pub fn help(&self) {
xous::send_message(
self.cid,
xous::Message::new_scalar(ChatOp::Help as usize, 0, 0, 0, 0),
)
.map(|_| ())
.expect("failed to get help");
}
/// Add a new MenuItem to the App menu
///
/// # Arguments
@ -364,6 +375,10 @@ pub fn server(
}
}
}
Some(ChatOp::Help) => {
log::info!("ChatOp::Help");
ui.help();
}
Some(ChatOp::GamRedraw) => {
log::info!("ChatOp::GamRedraw");
if allow_redraw {

View file

@ -310,6 +310,14 @@ impl Ui {
}
}
/// Show some user help
///
pub fn help(&self) {
self.modals
.show_notification(t!("chat.help.navigation", locales::LANG), None)
.expect("notification failed");
}
/// Add a new MenuItem to the App menu
///
/// # Arguments