tdesktop/Telegram/SourceFiles/passport/passport_form_view_controll...

78 lines
1.8 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
2018-04-03 18:24:31 +00:00
#include "passport/passport_form_controller.h"
2019-09-13 12:22:54 +00:00
#include "base/object_ptr.h"
2021-10-18 15:48:46 +00:00
#include "ui/layers/box_content.h"
2018-04-03 18:24:31 +00:00
namespace Passport {
2018-04-03 18:24:31 +00:00
struct Scope {
enum class Type {
2018-08-12 19:48:43 +00:00
PersonalDetails,
2018-04-03 18:24:31 +00:00
Identity,
2018-08-12 19:48:43 +00:00
AddressDetails,
2018-04-03 18:24:31 +00:00
Address,
Phone,
Email,
};
2018-08-12 19:48:43 +00:00
explicit Scope(Type type);
2018-04-03 18:24:31 +00:00
Type type;
2018-08-12 19:48:43 +00:00
const Value *details = nullptr;
2018-04-12 15:45:04 +00:00
std::vector<not_null<const Value*>> documents;
2018-04-03 18:24:31 +00:00
};
2018-04-12 15:45:04 +00:00
struct ScopeRow {
QString title;
QString description;
QString ready;
2018-04-13 17:42:28 +00:00
QString error;
2018-04-12 15:45:04 +00:00
};
bool CanHaveErrors(Value::Type type);
2018-08-12 19:48:43 +00:00
bool ValidateForm(const Form &form);
std::vector<Scope> ComputeScopes(const Form &form);
2018-04-12 15:45:04 +00:00
QString ComputeScopeRowReadyString(const Scope &scope);
ScopeRow ComputeScopeRow(const Scope &scope);
class ViewController {
public:
virtual void showAskPassword() = 0;
virtual void showNoPassword() = 0;
virtual void showCriticalError(const QString &error) = 0;
virtual void showUpdateAppBox() = 0;
2018-04-03 18:24:31 +00:00
virtual void editScope(int index) = 0;
2018-04-16 17:02:40 +00:00
virtual void showBox(
2019-09-18 11:19:05 +00:00
object_ptr<Ui::BoxContent> box,
Ui::LayerOptions options,
2018-04-16 17:02:40 +00:00
anim::type animated) = 0;
2018-04-13 10:54:17 +00:00
virtual void showToast(const QString &text) = 0;
virtual void suggestReset(Fn<void()> callback) = 0;
2018-04-06 16:23:09 +00:00
virtual int closeGetDuration() = 0;
virtual ~ViewController() {
}
2018-04-06 16:23:09 +00:00
template <typename BoxType>
2018-04-16 17:02:40 +00:00
QPointer<BoxType> show(
object_ptr<BoxType> box,
2019-09-18 11:19:05 +00:00
Ui::LayerOptions options = Ui::LayerOption::KeepOther,
2018-04-16 17:02:40 +00:00
anim::type animated = anim::type::normal) {
auto result = QPointer<BoxType>(box.data());
showBox(std::move(box), options, animated);
2018-04-06 16:23:09 +00:00
return result;
}
};
} // namespace Passport