passport_panel_edit_contact.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "ui/rp_widget.h"
  9. #include "base/object_ptr.h"
  10. namespace Ui {
  11. class MaskedInputField;
  12. class PlainShadow;
  13. class RoundButton;
  14. class VerticalLayout;
  15. class BoxContent;
  16. } // namespace Ui
  17. namespace Passport {
  18. class PanelController;
  19. struct EditContactScheme {
  20. enum class ValueType {
  21. Phone,
  22. Text,
  23. };
  24. explicit EditContactScheme(ValueType type);
  25. ValueType type;
  26. QString aboutExisting;
  27. QString newHeader;
  28. rpl::producer<QString> newPlaceholder;
  29. QString aboutNew;
  30. Fn<bool(const QString &value)> validate;
  31. Fn<QString(const QString &value)> format;
  32. Fn<QString(const QString &value)> postprocess;
  33. };
  34. class PanelEditContact : public Ui::RpWidget {
  35. public:
  36. using Scheme = EditContactScheme;
  37. PanelEditContact(
  38. QWidget *parent,
  39. not_null<PanelController*> controller,
  40. Scheme scheme,
  41. const QString &data,
  42. const QString &existing);
  43. protected:
  44. void focusInEvent(QFocusEvent *e) override;
  45. void resizeEvent(QResizeEvent *e) override;
  46. private:
  47. void setupControls(
  48. const QString &data,
  49. const QString &existing);
  50. void updateControlsGeometry();
  51. void save();
  52. void save(const QString &value);
  53. not_null<PanelController*> _controller;
  54. Scheme _scheme;
  55. object_ptr<Ui::VerticalLayout> _content;
  56. QPointer<Ui::MaskedInputField> _field;
  57. object_ptr<Ui::PlainShadow> _bottomShadow;
  58. object_ptr<Ui::RoundButton> _done;
  59. };
  60. object_ptr<Ui::BoxContent> VerifyPhoneBox(
  61. const QString &phone,
  62. int codeLength,
  63. const QString &openUrl,
  64. Fn<void(QString code)> submit,
  65. rpl::producer<QString> call,
  66. rpl::producer<QString> error);
  67. object_ptr<Ui::BoxContent> VerifyEmailBox(
  68. const QString &email,
  69. int codeLength,
  70. Fn<void(QString code)> submit,
  71. Fn<void()> resend,
  72. rpl::producer<QString> error,
  73. rpl::producer<QString> resent);
  74. } // namespace Passport