nfc_maker_scene_contact_mail.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "../nfc_maker.h"
  2. enum TextInputResult {
  3. TextInputResultOk,
  4. };
  5. static void nfc_maker_scene_contact_mail_text_input_callback(void* context) {
  6. NfcMaker* app = context;
  7. view_dispatcher_send_custom_event(app->view_dispatcher, TextInputResultOk);
  8. }
  9. void nfc_maker_scene_contact_mail_on_enter(void* context) {
  10. NfcMaker* app = context;
  11. TextInput* text_input = app->text_input;
  12. text_input_set_header_text(text_input, "Enter Mail Address:");
  13. strlcpy(app->mail_buf, "johnsmith@email.com", sizeof(app->mail_buf));
  14. text_input_set_result_callback(
  15. text_input,
  16. nfc_maker_scene_contact_mail_text_input_callback,
  17. app,
  18. app->mail_buf,
  19. sizeof(app->mail_buf),
  20. true);
  21. text_input_set_minimum_length(text_input, 0);
  22. text_input_show_illegal_symbols(text_input, true);
  23. view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewTextInput);
  24. }
  25. bool nfc_maker_scene_contact_mail_on_event(void* context, SceneManagerEvent event) {
  26. NfcMaker* app = context;
  27. bool consumed = false;
  28. if(event.type == SceneManagerEventTypeCustom) {
  29. consumed = true;
  30. switch(event.event) {
  31. case TextInputResultOk:
  32. scene_manager_next_scene(app->scene_manager, NfcMakerSceneContactPhone);
  33. break;
  34. default:
  35. break;
  36. }
  37. }
  38. return consumed;
  39. }
  40. void nfc_maker_scene_contact_mail_on_exit(void* context) {
  41. NfcMaker* app = context;
  42. text_input_reset(app->text_input);
  43. }