nfc_maker_text_input.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #pragma once
  2. #include <gui/view.h>
  3. #include "nfc_maker_validators.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /** Text input anonymous structure */
  8. typedef struct NFCMaker_TextInput NFCMaker_TextInput;
  9. typedef void (*NFCMaker_TextInputCallback)(void* context);
  10. typedef bool (
  11. *NFCMaker_TextInputValidatorCallback)(const char* text, FuriString* error, void* context);
  12. /** Allocate and initialize text input
  13. *
  14. * This text input is used to enter string
  15. *
  16. * @return NFCMaker_TextInput instance
  17. */
  18. NFCMaker_TextInput* nfc_maker_text_input_alloc();
  19. /** Deinitialize and free text input
  20. *
  21. * @param text_input NFCMaker_TextInput instance
  22. */
  23. void nfc_maker_text_input_free(NFCMaker_TextInput* text_input);
  24. /** Clean text input view Note: this function does not free memory
  25. *
  26. * @param text_input Text input instance
  27. */
  28. void nfc_maker_text_input_reset(NFCMaker_TextInput* text_input);
  29. /** Get text input view
  30. *
  31. * @param text_input NFCMaker_TextInput instance
  32. *
  33. * @return View instance that can be used for embedding
  34. */
  35. View* nfc_maker_text_input_get_view(NFCMaker_TextInput* text_input);
  36. /** Set text input result callback
  37. *
  38. * @param text_input NFCMaker_TextInput instance
  39. * @param callback callback fn
  40. * @param callback_context callback context
  41. * @param text_buffer pointer to YOUR text buffer, that we going
  42. * to modify
  43. * @param text_buffer_size YOUR text buffer size in bytes. Max string
  44. * length will be text_buffer_size-1.
  45. * @param clear_default_text clear text from text_buffer on first OK
  46. * event
  47. */
  48. void nfc_maker_text_input_set_result_callback(
  49. NFCMaker_TextInput* text_input,
  50. NFCMaker_TextInputCallback callback,
  51. void* callback_context,
  52. char* text_buffer,
  53. size_t text_buffer_size,
  54. bool clear_default_text);
  55. void nfc_maker_text_input_set_validator(
  56. NFCMaker_TextInput* text_input,
  57. NFCMaker_TextInputValidatorCallback callback,
  58. void* callback_context);
  59. void nfc_maker_text_input_set_minimum_length(NFCMaker_TextInput* text_input, size_t minimum_length);
  60. NFCMaker_TextInputValidatorCallback
  61. nfc_maker_text_input_get_validator_callback(NFCMaker_TextInput* text_input);
  62. void* nfc_maker_text_input_get_validator_callback_context(NFCMaker_TextInput* text_input);
  63. /** Set text input header text
  64. *
  65. * @param text_input NFCMaker_TextInput instance
  66. * @param text text to be shown
  67. */
  68. void nfc_maker_text_input_set_header_text(NFCMaker_TextInput* text_input, const char* text);
  69. #ifdef __cplusplus
  70. }
  71. #endif