2018-03-31 05:45:40 +04:00
|
|
|
/*
|
|
|
|
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
|
|
|
|
|
|
|
|
#include "ui/rp_widget.h"
|
2019-04-02 13:13:30 +04:00
|
|
|
#include "ui/effects/animations.h"
|
2018-04-06 15:54:01 +04:00
|
|
|
#include "ui/wrap/padding_wrap.h"
|
|
|
|
#include "ui/widgets/labels.h"
|
|
|
|
#include "boxes/abstract_box.h"
|
2018-03-31 05:45:40 +04:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class InputField;
|
2018-04-10 15:26:21 +04:00
|
|
|
class FlatLabel;
|
|
|
|
template <typename Widget>
|
|
|
|
class SlideWrap;
|
2018-03-31 05:45:40 +04:00
|
|
|
} // namespace Ui
|
|
|
|
|
|
|
|
namespace Passport {
|
|
|
|
|
2018-04-10 15:26:21 +04:00
|
|
|
class PanelController;
|
|
|
|
|
|
|
|
enum class PanelDetailsType {
|
|
|
|
Text,
|
2018-05-15 16:35:59 +03:00
|
|
|
Postcode,
|
2018-04-10 15:26:21 +04:00
|
|
|
Country,
|
|
|
|
Date,
|
|
|
|
Gender,
|
|
|
|
};
|
|
|
|
|
2018-03-31 05:45:40 +04:00
|
|
|
class PanelDetailsRow : public Ui::RpWidget {
|
|
|
|
public:
|
2018-04-10 15:26:21 +04:00
|
|
|
using Type = PanelDetailsType;
|
|
|
|
|
2018-03-31 05:45:40 +04:00
|
|
|
PanelDetailsRow(
|
|
|
|
QWidget *parent,
|
2018-06-08 22:26:08 +03:00
|
|
|
const QString &label,
|
|
|
|
int maxLabelWidth);
|
2018-04-10 15:26:21 +04:00
|
|
|
|
|
|
|
static object_ptr<PanelDetailsRow> Create(
|
|
|
|
QWidget *parent,
|
|
|
|
Type type,
|
|
|
|
not_null<PanelController*> controller,
|
2018-03-31 05:45:40 +04:00
|
|
|
const QString &label,
|
2018-06-08 22:26:08 +03:00
|
|
|
int maxLabelWidth,
|
2018-04-10 15:26:21 +04:00
|
|
|
const QString &value,
|
2018-04-13 15:15:07 +04:00
|
|
|
const QString &error,
|
|
|
|
int limit = 0);
|
2018-06-08 22:26:08 +03:00
|
|
|
static int LabelWidth(const QString &label);
|
2018-03-31 05:45:40 +04:00
|
|
|
|
2018-04-10 15:26:21 +04:00
|
|
|
virtual bool setFocusFast();
|
|
|
|
virtual rpl::producer<QString> value() const = 0;
|
|
|
|
virtual QString valueCurrent() const = 0;
|
2018-09-21 19:28:46 +03:00
|
|
|
void showError(std::optional<QString> error = std::nullopt);
|
2018-04-17 21:54:52 +04:00
|
|
|
bool errorShown() const;
|
2018-04-10 15:26:21 +04:00
|
|
|
void hideError();
|
|
|
|
void finishAnimating();
|
2018-03-31 05:45:40 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
int resizeGetHeight(int newWidth) override;
|
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
|
|
|
|
private:
|
2018-04-10 15:26:21 +04:00
|
|
|
virtual int resizeInner(int left, int top, int width) = 0;
|
|
|
|
virtual void showInnerError() = 0;
|
|
|
|
virtual void finishInnerAnimating() = 0;
|
|
|
|
|
|
|
|
void startErrorAnimation(bool shown);
|
|
|
|
|
2018-03-31 05:45:40 +04:00
|
|
|
QString _label;
|
2018-06-08 22:26:08 +03:00
|
|
|
int _maxLabelWidth = 0;
|
2018-04-10 15:26:21 +04:00
|
|
|
object_ptr<Ui::SlideWrap<Ui::FlatLabel>> _error = { nullptr };
|
|
|
|
bool _errorShown = false;
|
2018-04-13 14:10:09 +04:00
|
|
|
bool _errorHideSubscription = false;
|
2019-04-02 13:13:30 +04:00
|
|
|
Ui::Animations::Simple _errorAnimation;
|
2018-03-31 05:45:40 +04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Passport
|