nfc_maker_scene_contact_phone.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include "../nfc_maker.h"
  2. enum TextInputResult {
  3. TextInputResultOk,
  4. };
  5. static void nfc_maker_scene_contact_phone_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_phone_on_enter(void* context) {
  10. NfcMaker* app = context;
  11. TextInput* text_input = app->text_input;
  12. text_input_set_header_text(text_input, "Enter Phone Number:");
  13. strlcpy(app->phone_buf, "+", sizeof(app->phone_buf));
  14. text_input_set_result_callback(
  15. text_input,
  16. nfc_maker_scene_contact_phone_text_input_callback,
  17. app,
  18. app->phone_buf,
  19. sizeof(app->phone_buf),
  20. false);
  21. text_input_set_minimum_length(text_input, 0);
  22. view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewTextInput);
  23. }
  24. bool nfc_maker_scene_contact_phone_on_event(void* context, SceneManagerEvent event) {
  25. NfcMaker* app = context;
  26. bool consumed = false;
  27. if(event.type == SceneManagerEventTypeCustom) {
  28. consumed = true;
  29. switch(event.event) {
  30. case TextInputResultOk:
  31. scene_manager_next_scene(app->scene_manager, NfcMakerSceneContactUrl);
  32. break;
  33. default:
  34. break;
  35. }
  36. }
  37. return consumed;
  38. }
  39. void nfc_maker_scene_contact_phone_on_exit(void* context) {
  40. NfcMaker* app = context;
  41. text_input_reset(app->text_input);
  42. }