mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Improve passport styles.
This commit is contained in:
parent
d0ed75f3b5
commit
2a110f0d3e
8 changed files with 96 additions and 32 deletions
|
@ -494,8 +494,9 @@ void TopBarWidget::updateControlsGeometry() {
|
|||
buttonsWidth += buttonsLeft + st::topBarActionSkip * 3;
|
||||
|
||||
auto widthLeft = qMin(width() - buttonsWidth, -2 * st::defaultActiveButton.width);
|
||||
_forward->setFullWidth(-(widthLeft / 2));
|
||||
_delete->setFullWidth(-(widthLeft / 2));
|
||||
auto buttonFullWidth = qMin(-(widthLeft / 2), 0);
|
||||
_forward->setFullWidth(buttonFullWidth);
|
||||
_delete->setFullWidth(buttonFullWidth);
|
||||
|
||||
selectedButtonsTop += (height() - _forward->height()) / 2;
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ passportErrorLabel: FlatLabel(passportPasswordLabel) {
|
|||
textFg: boxTextFgError;
|
||||
}
|
||||
passportVerifyErrorLabel: FlatLabel(passportErrorLabel) {
|
||||
minWidth: 128px;
|
||||
align: align(topleft);
|
||||
}
|
||||
|
||||
|
@ -169,10 +170,11 @@ passportDetailsField: InputField(defaultInputField) {
|
|||
font: normalFont;
|
||||
}
|
||||
passportDetailsDateField: InputField(passportDetailsField) {
|
||||
textMargins: margins(2px, 8px, 2px, 0px);
|
||||
border: 0px;
|
||||
borderActive: 0px;
|
||||
heightMin: 30px;
|
||||
placeholderFont: font(semibold 14px);
|
||||
placeholderFont: semiboldFont;
|
||||
placeholderFgActive: placeholderFgActive;
|
||||
}
|
||||
passportDetailsSeparator: FlatLabel(passportPasswordLabelBold) {
|
||||
|
@ -189,7 +191,7 @@ passportDetailsFieldLeft: 116px;
|
|||
passportDetailsFieldTop: 2px;
|
||||
passportDetailsFieldSkipMin: 12px;
|
||||
passportDetailsSkip: 30px;
|
||||
passportDetailsGenderSkip: 30px;
|
||||
passportDetailsGenderSkip: 20px;
|
||||
|
||||
passportRequestTypeSkip: 16px;
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ EditDocumentScheme GetDocumentScheme(
|
|||
if (value.isEmpty() || value.size() > kMaxNameSize) {
|
||||
return QString();
|
||||
} else if (!QRegularExpression(
|
||||
"^[a-zA-Z\\- ]+$"
|
||||
"^[a-zA-Z0-9\\.,/&\\-' ]+$"
|
||||
).match(value).hasMatch()) {
|
||||
return lang(lng_passport_bad_name);
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ public:
|
|||
AbstractTextRow(
|
||||
QWidget *parent,
|
||||
const QString &label,
|
||||
int maxLabelWidth,
|
||||
const QString &value,
|
||||
int limit);
|
||||
|
||||
|
@ -101,6 +102,7 @@ public:
|
|||
QWidget *parent,
|
||||
not_null<PanelController*> controller,
|
||||
const QString &label,
|
||||
int maxLabelWidth,
|
||||
const QString &value);
|
||||
|
||||
rpl::producer<QString> value() const override;
|
||||
|
@ -152,7 +154,11 @@ private:
|
|||
|
||||
class DateRow : public PanelDetailsRow {
|
||||
public:
|
||||
DateRow(QWidget *parent, const QString &label, const QString &value);
|
||||
DateRow(
|
||||
QWidget *parent,
|
||||
const QString &label,
|
||||
int maxLabelWidth,
|
||||
const QString &value);
|
||||
|
||||
bool setFocusFast() override;
|
||||
rpl::producer<QString> value() const override;
|
||||
|
@ -206,6 +212,7 @@ public:
|
|||
GenderRow(
|
||||
QWidget *parent,
|
||||
const QString &label,
|
||||
int maxLabelWidth,
|
||||
const QString &value);
|
||||
|
||||
rpl::producer<QString> value() const override;
|
||||
|
@ -247,9 +254,10 @@ template <typename Input>
|
|||
AbstractTextRow<Input>::AbstractTextRow(
|
||||
QWidget *parent,
|
||||
const QString &label,
|
||||
int maxLabelWidth,
|
||||
const QString &value,
|
||||
int limit)
|
||||
: PanelDetailsRow(parent, label)
|
||||
: PanelDetailsRow(parent, label, maxLabelWidth)
|
||||
, _field(this, st::passportDetailsField, nullptr, value)
|
||||
, _value(value) {
|
||||
_field->setMaxLength(limit);
|
||||
|
@ -299,8 +307,9 @@ CountryRow::CountryRow(
|
|||
QWidget *parent,
|
||||
not_null<PanelController*> controller,
|
||||
const QString &label,
|
||||
int maxLabelWidth,
|
||||
const QString &value)
|
||||
: PanelDetailsRow(parent, label)
|
||||
: PanelDetailsRow(parent, label, maxLabelWidth)
|
||||
, _controller(controller)
|
||||
, _link(this, CountryString(value), st::boxLinkButton)
|
||||
, _value(value) {
|
||||
|
@ -505,8 +514,9 @@ void DateInput::correctValue(
|
|||
DateRow::DateRow(
|
||||
QWidget *parent,
|
||||
const QString &label,
|
||||
int maxLabelWidth,
|
||||
const QString &value)
|
||||
: PanelDetailsRow(parent, label)
|
||||
: PanelDetailsRow(parent, label, maxLabelWidth)
|
||||
, _day(
|
||||
this,
|
||||
st::passportDetailsDateField,
|
||||
|
@ -726,25 +736,26 @@ int DateRow::resizeInner(int left, int top, int width) {
|
|||
const auto right = left + width;
|
||||
const auto &_st = st::passportDetailsDateField;
|
||||
const auto &font = _st.placeholderFont;
|
||||
const auto addToWidth = st::passportDetailsSeparatorPadding.left();
|
||||
const auto dayWidth = _st.textMargins.left()
|
||||
+ _st.placeholderMargins.left()
|
||||
+ font->width(lang(lng_date_input_day))
|
||||
+ _st.placeholderMargins.right()
|
||||
+ _st.textMargins.right()
|
||||
+ st::lineWidth;
|
||||
+ addToWidth;
|
||||
const auto monthWidth = _st.textMargins.left()
|
||||
+ _st.placeholderMargins.left()
|
||||
+ font->width(lang(lng_date_input_month))
|
||||
+ _st.placeholderMargins.right()
|
||||
+ _st.textMargins.right()
|
||||
+ st::lineWidth;
|
||||
+ addToWidth;
|
||||
_day->setGeometry(left, top, dayWidth, _day->height());
|
||||
left += dayWidth - st::lineWidth;
|
||||
left += dayWidth - addToWidth;
|
||||
_separator1->resizeToNaturalWidth(width);
|
||||
_separator1->move(left, top);
|
||||
left += _separator1->width();
|
||||
_month->setGeometry(left, top, monthWidth, _month->height());
|
||||
left += monthWidth - st::lineWidth;
|
||||
left += monthWidth - addToWidth;
|
||||
_separator2->resizeToNaturalWidth(width);
|
||||
_separator2->move(left, top);
|
||||
left += _separator2->width();
|
||||
|
@ -829,8 +840,9 @@ void DateRow::startBorderAnimation() {
|
|||
GenderRow::GenderRow(
|
||||
QWidget *parent,
|
||||
const QString &label,
|
||||
int maxLabelWidth,
|
||||
const QString &value)
|
||||
: PanelDetailsRow(parent, label)
|
||||
: PanelDetailsRow(parent, label, maxLabelWidth)
|
||||
, _group(StringToGender(value).has_value()
|
||||
? std::make_shared<Ui::RadioenumGroup<Gender>>(*StringToGender(value))
|
||||
: std::make_shared<Ui::RadioenumGroup<Gender>>())
|
||||
|
@ -938,8 +950,10 @@ void GenderRow::errorAnimationCallback() {
|
|||
|
||||
PanelDetailsRow::PanelDetailsRow(
|
||||
QWidget *parent,
|
||||
const QString &label)
|
||||
: _label(label) {
|
||||
const QString &label,
|
||||
int maxLabelWidth)
|
||||
: _label(label)
|
||||
, _maxLabelWidth(maxLabelWidth) {
|
||||
}
|
||||
|
||||
object_ptr<PanelDetailsRow> PanelDetailsRow::Create(
|
||||
|
@ -947,6 +961,7 @@ object_ptr<PanelDetailsRow> PanelDetailsRow::Create(
|
|||
Type type,
|
||||
not_null<PanelController*> controller,
|
||||
const QString &label,
|
||||
int maxLabelWidth,
|
||||
const QString &value,
|
||||
const QString &error,
|
||||
int limit) {
|
||||
|
@ -956,20 +971,35 @@ object_ptr<PanelDetailsRow> PanelDetailsRow::Create(
|
|||
return object_ptr<AbstractTextRow<Ui::InputField>>(
|
||||
parent,
|
||||
label,
|
||||
maxLabelWidth,
|
||||
value,
|
||||
limit);
|
||||
case Type::Postcode:
|
||||
return object_ptr<AbstractTextRow<PostcodeInput>>(
|
||||
parent,
|
||||
label,
|
||||
maxLabelWidth,
|
||||
value,
|
||||
limit);
|
||||
case Type::Country:
|
||||
return object_ptr<CountryRow>(parent, controller, label, value);
|
||||
return object_ptr<CountryRow>(
|
||||
parent,
|
||||
controller,
|
||||
label,
|
||||
maxLabelWidth,
|
||||
value);
|
||||
case Type::Gender:
|
||||
return object_ptr<GenderRow>(parent, label, value);
|
||||
return object_ptr<GenderRow>(
|
||||
parent,
|
||||
label,
|
||||
maxLabelWidth,
|
||||
value);
|
||||
case Type::Date:
|
||||
return object_ptr<DateRow>(parent, label, value);
|
||||
return object_ptr<DateRow>(
|
||||
parent,
|
||||
label,
|
||||
maxLabelWidth,
|
||||
value);
|
||||
default:
|
||||
Unexpected("Type in PanelDetailsRow::Create.");
|
||||
}
|
||||
|
@ -981,13 +1011,19 @@ object_ptr<PanelDetailsRow> PanelDetailsRow::Create(
|
|||
return result;
|
||||
}
|
||||
|
||||
int PanelDetailsRow::LabelWidth(const QString &label) {
|
||||
return st::semiboldFont->width(label);
|
||||
}
|
||||
|
||||
bool PanelDetailsRow::setFocusFast() {
|
||||
return false;
|
||||
}
|
||||
|
||||
int PanelDetailsRow::resizeGetHeight(int newWidth) {
|
||||
const auto padding = st::passportDetailsPadding;
|
||||
const auto inputLeft = padding.left() + st::passportDetailsFieldLeft;
|
||||
const auto inputLeft = padding.left() + std::max(
|
||||
st::passportDetailsFieldLeft,
|
||||
_maxLabelWidth + st::passportDetailsFieldSkipMin);
|
||||
const auto inputTop = st::passportDetailsFieldTop;
|
||||
const auto inputRight = padding.right();
|
||||
const auto inputWidth = std::max(newWidth - inputLeft - inputRight, 0);
|
||||
|
@ -997,6 +1033,7 @@ int PanelDetailsRow::resizeGetHeight(int newWidth) {
|
|||
+ (_error ? _error->height() : 0)
|
||||
+ padding.bottom();
|
||||
if (_error) {
|
||||
_error->resizeToWidth(inputWidth);
|
||||
_error->moveToLeft(inputLeft, result - _error->height());
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -37,16 +37,19 @@ public:
|
|||
|
||||
PanelDetailsRow(
|
||||
QWidget *parent,
|
||||
const QString &label);
|
||||
const QString &label,
|
||||
int maxLabelWidth);
|
||||
|
||||
static object_ptr<PanelDetailsRow> Create(
|
||||
QWidget *parent,
|
||||
Type type,
|
||||
not_null<PanelController*> controller,
|
||||
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;
|
||||
|
@ -69,6 +72,7 @@ private:
|
|||
void startErrorAnimation(bool shown);
|
||||
|
||||
QString _label;
|
||||
int _maxLabelWidth = 0;
|
||||
object_ptr<Ui::SlideWrap<Ui::FlatLabel>> _error = { nullptr };
|
||||
bool _errorShown = false;
|
||||
bool _errorHideSubscription = false;
|
||||
|
|
|
@ -326,24 +326,42 @@ not_null<Ui::RpWidget*> PanelEditDocument::setupContent(
|
|||
return ValueField();
|
||||
};
|
||||
|
||||
for (auto i = 0, count = int(_scheme.rows.size()); i != count; ++i) {
|
||||
const auto &row = _scheme.rows[i];
|
||||
auto fields = (row.valueClass == Scheme::ValueClass::Fields)
|
||||
? &data
|
||||
: scanData;
|
||||
if (!fields) {
|
||||
continue;
|
||||
const auto enumerateRows = [&](auto &&callback) {
|
||||
for (auto i = 0, count = int(_scheme.rows.size()); i != count; ++i) {
|
||||
const auto &row = _scheme.rows[i];
|
||||
auto fields = (row.valueClass == Scheme::ValueClass::Fields)
|
||||
? &data
|
||||
: scanData;
|
||||
if (!fields) {
|
||||
continue;
|
||||
}
|
||||
callback(i, row, *fields);
|
||||
}
|
||||
const auto current = valueOrEmpty(*fields, row.key);
|
||||
};
|
||||
auto maxLabelWidth = 0;
|
||||
enumerateRows([&](
|
||||
int i,
|
||||
const EditDocumentScheme::Row &row,
|
||||
const ValueMap &fields) {
|
||||
accumulate_max(
|
||||
maxLabelWidth,
|
||||
PanelDetailsRow::LabelWidth(row.label));
|
||||
});
|
||||
enumerateRows([&](
|
||||
int i,
|
||||
const EditDocumentScheme::Row &row,
|
||||
const ValueMap &fields) {
|
||||
const auto current = valueOrEmpty(fields, row.key);
|
||||
_details.emplace(i, inner->add(PanelDetailsRow::Create(
|
||||
inner,
|
||||
row.inputType,
|
||||
_controller,
|
||||
row.label,
|
||||
maxLabelWidth,
|
||||
current.text,
|
||||
current.error,
|
||||
row.lengthLimit)));
|
||||
}
|
||||
});
|
||||
|
||||
inner->add(
|
||||
object_ptr<Ui::FixedHeightWidget>(inner, st::passportDetailsSkip));
|
||||
|
|
|
@ -326,7 +326,7 @@ void PanelForm::updateControlsGeometry() {
|
|||
_topShadow->moveToLeft(0, 0);
|
||||
_bottomShadow->resizeToWidth(width());
|
||||
_bottomShadow->moveToLeft(0, submitTop - st::lineWidth);
|
||||
_submit->resizeToWidth(width());
|
||||
_submit->setFullWidth(width());
|
||||
_submit->moveToLeft(0, submitTop);
|
||||
|
||||
_scroll->updateBars();
|
||||
|
|
|
@ -281,7 +281,9 @@ QString RoundButton::computeFullText() const {
|
|||
|
||||
void RoundButton::resizeToText() {
|
||||
int innerWidth = contentWidth();
|
||||
if (_fullWidthOverride < 0) {
|
||||
if (_fullWidthOverride > 0) {
|
||||
resize(_fullWidthOverride, _st.height + _st.padding.top() + _st.padding.bottom());
|
||||
} else if (_fullWidthOverride < 0) {
|
||||
resize(innerWidth - _fullWidthOverride, _st.height + _st.padding.top() + _st.padding.bottom());
|
||||
} else if (_st.width <= 0) {
|
||||
resize(innerWidth - _st.width + _st.padding.left() + _st.padding.right(), _st.height + _st.padding.top() + _st.padding.bottom());
|
||||
|
|
Loading…
Add table
Reference in a new issue