#pragma once // Spec: FR-AUTH-01, PG-11, INV-shell 13. Create account, pushed inside the sign in navigation stack. #include #include #include #include "ui/Controls.hpp" #include "ui/Navigation.hpp" #include "ui/TextInput.hpp" namespace dp { class SignUpScreen : public ui::Screen { public: SignUpScreen(); ~SignUpScreen() override { *alive_ = false; } ui::ViewPtr body() override; std::string title() const override; TitleMode titleMode() const override { return TitleMode::Inline; } bool busy() const override { return isLoading_; } bool canSubmit() const; // First failing rule in the order of the Swift view model, nullopt when valid. std::optional validationError() const; void signUp(); void setUsername(std::string v) { username_ = std::move(v); } void setEmail(std::string v) { email_ = std::move(v); } void setPassword(std::string v) { password_ = std::move(v); } void setConfirm(std::string v) { confirm_ = std::move(v); } void setTosAccepted(bool v) { tosAccepted_ = v; } private: ui::ViewPtr field(const std::string& placeholder, std::string* value, bool secure, int minCount, int maxCount, std::shared_ptr handle, std::shared_ptr next); std::shared_ptr alive_ = std::make_shared(true); std::string username_, email_, password_, confirm_; bool tosAccepted_ = false; bool isLoading_ = false; ui::CivilDate birth_ = ui::CivilDate::today(); std::shared_ptr hUser_ = std::make_shared(); std::shared_ptr hEmail_ = std::make_shared(); std::shared_ptr hPass_ = std::make_shared(); std::shared_ptr hConfirm_ = std::make_shared(); }; } // namespace dp