nfc_maker_scene_contact.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "../nfc_maker.h"
  2. enum TextInputResult {
  3. TextInputResultOk,
  4. };
  5. static void nfc_maker_scene_contact_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_on_enter(void* context) {
  10. NfcMaker* app = context;
  11. TextInput* text_input = app->text_input;
  12. text_input_set_header_text(text_input, "Enter First Name:");
  13. strlcpy(app->small_buf1, "John", sizeof(app->small_buf1));
  14. text_input_set_result_callback(
  15. text_input,
  16. nfc_maker_scene_contact_text_input_callback,
  17. app,
  18. app->small_buf1,
  19. sizeof(app->small_buf1),
  20. true);
  21. view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewTextInput);
  22. }
  23. bool nfc_maker_scene_contact_on_event(void* context, SceneManagerEvent event) {
  24. NfcMaker* app = context;
  25. bool consumed = false;
  26. if(event.type == SceneManagerEventTypeCustom) {
  27. consumed = true;
  28. switch(event.event) {
  29. case TextInputResultOk:
  30. scene_manager_next_scene(app->scene_manager, NfcMakerSceneContactLast);
  31. break;
  32. default:
  33. break;
  34. }
  35. }
  36. return consumed;
  37. }
  38. void nfc_maker_scene_contact_on_exit(void* context) {
  39. NfcMaker* app = context;
  40. text_input_reset(app->text_input);
  41. }