nfc_maker_scene_contact_url.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include "../nfc_maker.h"
  2. enum TextInputResult {
  3. TextInputResultOk,
  4. };
  5. static void nfc_maker_scene_contact_url_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_url_on_enter(void* context) {
  10. NfcMaker* app = context;
  11. TextInput* text_input = app->text_input;
  12. text_input_set_header_text(text_input, "Enter URL Link:");
  13. strlcpy(
  14. app->big_buf,
  15. #ifdef FW_ORIGIN_Momentum
  16. "momentum-fw.dev",
  17. #else
  18. "flipperzero.one",
  19. #endif
  20. sizeof(app->big_buf));
  21. text_input_set_result_callback(
  22. text_input,
  23. nfc_maker_scene_contact_url_text_input_callback,
  24. app,
  25. app->big_buf,
  26. sizeof(app->big_buf),
  27. true);
  28. text_input_set_minimum_length(text_input, 0);
  29. text_input_show_illegal_symbols(text_input, true);
  30. view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewTextInput);
  31. }
  32. bool nfc_maker_scene_contact_url_on_event(void* context, SceneManagerEvent event) {
  33. NfcMaker* app = context;
  34. bool consumed = false;
  35. if(event.type == SceneManagerEventTypeCustom) {
  36. consumed = true;
  37. switch(event.event) {
  38. case TextInputResultOk:
  39. scene_manager_next_scene(app->scene_manager, NfcMakerSceneSaveGenerate);
  40. break;
  41. default:
  42. break;
  43. }
  44. }
  45. return consumed;
  46. }
  47. void nfc_maker_scene_contact_url_on_exit(void* context) {
  48. NfcMaker* app = context;
  49. text_input_reset(app->text_input);
  50. }