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

View file

@ -18,5 +18,9 @@
"chat.dict_empty": { "chat.dict_empty": {
"en": "no dialogues available to read", "en": "no dialogues available to read",
"en-tts": "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 /// Add a new MenuItem to the App menu
/// ///
/// # Arguments /// # Arguments
@ -364,6 +375,10 @@ pub fn server(
} }
} }
} }
Some(ChatOp::Help) => {
log::info!("ChatOp::Help");
ui.help();
}
Some(ChatOp::GamRedraw) => { Some(ChatOp::GamRedraw) => {
log::info!("ChatOp::GamRedraw"); log::info!("ChatOp::GamRedraw");
if allow_redraw { 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 /// Add a new MenuItem to the App menu
/// ///
/// # Arguments /// # Arguments