init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
1145
Telegram/SourceFiles/passport/ui/passport_details_row.cpp
Normal file
1145
Telegram/SourceFiles/passport/ui/passport_details_row.cpp
Normal file
File diff suppressed because it is too large
Load Diff
85
Telegram/SourceFiles/passport/ui/passport_details_row.h
Normal file
85
Telegram/SourceFiles/passport/ui/passport_details_row.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
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"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/wrap/padding_wrap.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
|
||||
namespace Ui {
|
||||
class BoxContent;
|
||||
class InputField;
|
||||
class FlatLabel;
|
||||
template <typename Widget>
|
||||
class SlideWrap;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Passport::Ui {
|
||||
|
||||
using namespace ::Ui;
|
||||
|
||||
enum class PanelDetailsType {
|
||||
Text,
|
||||
Postcode,
|
||||
Country,
|
||||
Date,
|
||||
Gender,
|
||||
};
|
||||
|
||||
class PanelDetailsRow : public RpWidget {
|
||||
public:
|
||||
using Type = PanelDetailsType;
|
||||
|
||||
PanelDetailsRow(
|
||||
QWidget *parent,
|
||||
const QString &label,
|
||||
int maxLabelWidth);
|
||||
|
||||
static object_ptr<PanelDetailsRow> Create(
|
||||
QWidget *parent,
|
||||
Fn<void(object_ptr<BoxContent>)> showBox,
|
||||
const QString &defaultCountry,
|
||||
Type type,
|
||||
const QString &label,
|
||||
int maxLabelWidth,
|
||||
const QString &value,
|
||||
const QString &error,
|
||||
int limit = 0);
|
||||
static int LabelWidth(const QString &label);
|
||||
|
||||
virtual bool setFocusFast();
|
||||
virtual rpl::producer<QString> value() const = 0;
|
||||
virtual QString valueCurrent() const = 0;
|
||||
void showError(std::optional<QString> error = std::nullopt);
|
||||
bool errorShown() const;
|
||||
void hideError();
|
||||
void finishAnimating();
|
||||
|
||||
protected:
|
||||
int resizeGetHeight(int newWidth) override;
|
||||
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
private:
|
||||
virtual int resizeInner(int left, int top, int width) = 0;
|
||||
virtual void showInnerError() = 0;
|
||||
virtual void finishInnerAnimating() = 0;
|
||||
|
||||
void startErrorAnimation(bool shown);
|
||||
|
||||
QString _label;
|
||||
int _maxLabelWidth = 0;
|
||||
object_ptr<SlideWrap<FlatLabel>> _error = { nullptr };
|
||||
bool _errorShown = false;
|
||||
bool _errorHideSubscription = false;
|
||||
Animations::Simple _errorAnimation;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Passport::Ui
|
||||
126
Telegram/SourceFiles/passport/ui/passport_form_row.cpp
Normal file
126
Telegram/SourceFiles/passport/ui/passport_form_row.cpp
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
#include "passport/ui/passport_form_row.h"
|
||||
|
||||
#include "ui/text/text_options.h"
|
||||
#include "ui/painter.h"
|
||||
#include "styles/style_passport.h"
|
||||
#include "styles/style_layers.h"
|
||||
|
||||
namespace Passport::Ui {
|
||||
|
||||
FormRow::FormRow(QWidget *parent)
|
||||
: RippleButton(parent, st::passportRowRipple)
|
||||
, _title(st::boxWideWidth / 2)
|
||||
, _description(st::boxWideWidth / 2) {
|
||||
}
|
||||
|
||||
void FormRow::updateContent(
|
||||
const QString &title,
|
||||
const QString &description,
|
||||
bool ready,
|
||||
bool error,
|
||||
anim::type animated) {
|
||||
_title.setText(
|
||||
st::semiboldTextStyle,
|
||||
title,
|
||||
NameTextOptions());
|
||||
_description.setText(
|
||||
st::defaultTextStyle,
|
||||
description,
|
||||
TextParseOptions {
|
||||
TextParseMultiline,
|
||||
0,
|
||||
0,
|
||||
Qt::LayoutDirectionAuto
|
||||
});
|
||||
_ready = ready && !error;
|
||||
if (_error != error) {
|
||||
_error = error;
|
||||
if (animated == anim::type::instant) {
|
||||
_errorAnimation.stop();
|
||||
} else {
|
||||
_errorAnimation.start(
|
||||
[=] { update(); },
|
||||
_error ? 0. : 1.,
|
||||
_error ? 1. : 0.,
|
||||
st::fadeWrapDuration);
|
||||
}
|
||||
}
|
||||
resizeToWidth(width());
|
||||
update();
|
||||
}
|
||||
|
||||
int FormRow::resizeGetHeight(int newWidth) {
|
||||
const auto availableWidth = countAvailableWidth(newWidth);
|
||||
_titleHeight = _title.countHeight(availableWidth);
|
||||
_descriptionHeight = _description.countHeight(availableWidth);
|
||||
const auto result = st::passportRowPadding.top()
|
||||
+ _titleHeight
|
||||
+ st::passportRowSkip
|
||||
+ _descriptionHeight
|
||||
+ st::passportRowPadding.bottom();
|
||||
return result;
|
||||
}
|
||||
|
||||
int FormRow::countAvailableWidth(int newWidth) const {
|
||||
return newWidth
|
||||
- st::passportRowPadding.left()
|
||||
- st::passportRowPadding.right()
|
||||
- (_ready
|
||||
? st::passportRowReadyIcon
|
||||
: st::passportRowEmptyIcon).width()
|
||||
- st::passportRowIconSkip;
|
||||
}
|
||||
|
||||
int FormRow::countAvailableWidth() const {
|
||||
return countAvailableWidth(width());
|
||||
}
|
||||
|
||||
void FormRow::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
|
||||
paintRipple(p, 0, 0);
|
||||
|
||||
const auto left = st::passportRowPadding.left();
|
||||
const auto availableWidth = countAvailableWidth();
|
||||
auto top = st::passportRowPadding.top();
|
||||
|
||||
const auto error = _errorAnimation.value(_error ? 1. : 0.);
|
||||
|
||||
p.setPen(st::passportRowTitleFg);
|
||||
_title.drawLeft(p, left, top, availableWidth, width());
|
||||
top += _titleHeight + st::passportRowSkip;
|
||||
|
||||
p.setPen(anim::pen(
|
||||
st::passportRowDescriptionFg,
|
||||
st::boxTextFgError,
|
||||
error));
|
||||
_description.drawLeft(p, left, top, availableWidth, width());
|
||||
top += _descriptionHeight + st::passportRowPadding.bottom();
|
||||
|
||||
const auto &icon = _ready
|
||||
? st::passportRowReadyIcon
|
||||
: st::passportRowEmptyIcon;
|
||||
if (error > 0. && !_ready) {
|
||||
icon.paint(
|
||||
p,
|
||||
width() - st::passportRowPadding.right() - icon.width(),
|
||||
(height() - icon.height()) / 2,
|
||||
width(),
|
||||
anim::color(st::menuIconFgOver, st::boxTextFgError, error));
|
||||
} else {
|
||||
icon.paint(
|
||||
p,
|
||||
width() - st::passportRowPadding.right() - icon.width(),
|
||||
(height() - icon.height()) / 2,
|
||||
width());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Passport::Ui
|
||||
48
Telegram/SourceFiles/passport/ui/passport_form_row.h
Normal file
48
Telegram/SourceFiles/passport/ui/passport_form_row.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
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/text/text.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
|
||||
namespace Passport::Ui {
|
||||
|
||||
using namespace ::Ui;
|
||||
|
||||
class FormRow : public RippleButton {
|
||||
public:
|
||||
explicit FormRow(QWidget *parent);
|
||||
|
||||
void updateContent(
|
||||
const QString &title,
|
||||
const QString &description,
|
||||
bool ready,
|
||||
bool error,
|
||||
anim::type animated);
|
||||
|
||||
protected:
|
||||
int resizeGetHeight(int newWidth) override;
|
||||
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
private:
|
||||
int countAvailableWidth() const;
|
||||
int countAvailableWidth(int newWidth) const;
|
||||
|
||||
Text::String _title;
|
||||
Text::String _description;
|
||||
int _titleHeight = 0;
|
||||
int _descriptionHeight = 0;
|
||||
bool _ready = false;
|
||||
bool _error = false;
|
||||
Animations::Simple _errorAnimation;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Passport::Ui
|
||||
Reference in New Issue
Block a user