mirror of https://github.com/procxx/kepka.git
				
				
				
			Use Ui::PhoneInput for passport phone edit.
This commit is contained in:
		
							parent
							
								
									1c48f33dc1
								
							
						
					
					
						commit
						11fd757e99
					
				| 
						 | 
					@ -188,7 +188,7 @@ PanelEditContact::Scheme GetContactScheme(Scope::Type type) {
 | 
				
			||||||
	using Scheme = PanelEditContact::Scheme;
 | 
						using Scheme = PanelEditContact::Scheme;
 | 
				
			||||||
	switch (type) {
 | 
						switch (type) {
 | 
				
			||||||
	case Scope::Type::Phone: {
 | 
						case Scope::Type::Phone: {
 | 
				
			||||||
		auto result = Scheme();
 | 
							auto result = Scheme(Scheme::ValueType::Phone);
 | 
				
			||||||
		result.aboutExisting = lang(lng_passport_use_existing_phone);
 | 
							result.aboutExisting = lang(lng_passport_use_existing_phone);
 | 
				
			||||||
		result.newHeader = lang(lng_passport_new_phone);
 | 
							result.newHeader = lang(lng_passport_new_phone);
 | 
				
			||||||
		result.aboutNew = lang(lng_passport_new_phone_code);
 | 
							result.aboutNew = lang(lng_passport_new_phone_code);
 | 
				
			||||||
| 
						 | 
					@ -207,7 +207,7 @@ PanelEditContact::Scheme GetContactScheme(Scope::Type type) {
 | 
				
			||||||
	} break;
 | 
						} break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case Scope::Type::Email: {
 | 
						case Scope::Type::Email: {
 | 
				
			||||||
		auto result = Scheme();
 | 
							auto result = Scheme(Scheme::ValueType::Text);
 | 
				
			||||||
		result.aboutExisting = lang(lng_passport_use_existing_email);
 | 
							result.aboutExisting = lang(lng_passport_use_existing_email);
 | 
				
			||||||
		result.newHeader = lang(lng_passport_new_email);
 | 
							result.newHeader = lang(lng_passport_new_email);
 | 
				
			||||||
		result.newPlaceholder = langFactory(lng_passport_email_title);
 | 
							result.newPlaceholder = langFactory(lng_passport_email_title);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -154,6 +154,9 @@ void VerifyBox::prepare() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace
 | 
					} // namespace
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PanelEditContact::Scheme::Scheme(ValueType type) : type(type) {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PanelEditContact::PanelEditContact(
 | 
					PanelEditContact::PanelEditContact(
 | 
				
			||||||
	QWidget*,
 | 
						QWidget*,
 | 
				
			||||||
	not_null<PanelController*> controller,
 | 
						not_null<PanelController*> controller,
 | 
				
			||||||
| 
						 | 
					@ -216,22 +219,42 @@ void PanelEditContact::setupControls(
 | 
				
			||||||
				Ui::FlatLabel::InitType::Simple,
 | 
									Ui::FlatLabel::InitType::Simple,
 | 
				
			||||||
				st::passportFormHeader),
 | 
									st::passportFormHeader),
 | 
				
			||||||
			st::passportDetailsHeaderPadding);
 | 
								st::passportDetailsHeaderPadding);
 | 
				
			||||||
		_field = _content->add(
 | 
					 | 
				
			||||||
			object_ptr<Ui::InputField>(
 | 
					 | 
				
			||||||
				_content,
 | 
					 | 
				
			||||||
				st::passportDetailsField,
 | 
					 | 
				
			||||||
				nullptr,
 | 
					 | 
				
			||||||
				data),
 | 
					 | 
				
			||||||
			st::passportContactNewFieldPadding);
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		_field = _content->add(
 | 
					 | 
				
			||||||
			object_ptr<Ui::InputField>(
 | 
					 | 
				
			||||||
				_content,
 | 
					 | 
				
			||||||
				st::passportContactField,
 | 
					 | 
				
			||||||
				_scheme.newPlaceholder,
 | 
					 | 
				
			||||||
				data),
 | 
					 | 
				
			||||||
			st::passportContactFieldPadding);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						const auto &fieldStyle = existing.isEmpty()
 | 
				
			||||||
 | 
							? st::passportContactField
 | 
				
			||||||
 | 
							: st::passportDetailsField;
 | 
				
			||||||
 | 
						const auto fieldPadding = existing.isEmpty()
 | 
				
			||||||
 | 
							? st::passportContactFieldPadding
 | 
				
			||||||
 | 
							: st::passportContactNewFieldPadding;
 | 
				
			||||||
 | 
						const auto fieldPlaceholder = existing.isEmpty()
 | 
				
			||||||
 | 
							? _scheme.newPlaceholder
 | 
				
			||||||
 | 
							: nullptr;
 | 
				
			||||||
 | 
						auto wrap = object_ptr<Ui::RpWidget>(_content);
 | 
				
			||||||
 | 
						if (_scheme.type == Scheme::ValueType::Phone) {
 | 
				
			||||||
 | 
							_field = Ui::CreateChild<Ui::PhoneInput>(
 | 
				
			||||||
 | 
								wrap.data(),
 | 
				
			||||||
 | 
								fieldStyle,
 | 
				
			||||||
 | 
								fieldPlaceholder,
 | 
				
			||||||
 | 
								data);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							_field = Ui::CreateChild<Ui::MaskedInputField>(
 | 
				
			||||||
 | 
								wrap.data(),
 | 
				
			||||||
 | 
								fieldStyle,
 | 
				
			||||||
 | 
								fieldPlaceholder,
 | 
				
			||||||
 | 
								data);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_field->move(0, 0);
 | 
				
			||||||
 | 
						_field->heightValue(
 | 
				
			||||||
 | 
						) | rpl::start_with_next([=, pointer = wrap.data()](int height) {
 | 
				
			||||||
 | 
							pointer->resize(pointer->width(), height);
 | 
				
			||||||
 | 
						}, _field->lifetime());
 | 
				
			||||||
 | 
						wrap->widthValue(
 | 
				
			||||||
 | 
						) | rpl::start_with_next([=](int width) {
 | 
				
			||||||
 | 
							_field->resize(width, _field->height());
 | 
				
			||||||
 | 
						}, _field->lifetime());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_content->add(std::move(wrap), fieldPadding);
 | 
				
			||||||
	_content->add(
 | 
						_content->add(
 | 
				
			||||||
		object_ptr<PanelLabel>(
 | 
							object_ptr<PanelLabel>(
 | 
				
			||||||
			_content,
 | 
								_content,
 | 
				
			||||||
| 
						 | 
					@ -247,7 +270,7 @@ void PanelEditContact::setupControls(
 | 
				
			||||||
			save();
 | 
								save();
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	connect(_field, &Ui::InputField::submitted, submit);
 | 
						connect(_field, &Ui::MaskedInputField::submitted, submit);
 | 
				
			||||||
	_done->addClickHandler(submit);
 | 
						_done->addClickHandler(submit);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
#include "ui/rp_widget.h"
 | 
					#include "ui/rp_widget.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Ui {
 | 
					namespace Ui {
 | 
				
			||||||
class InputField;
 | 
					class MaskedInputField;
 | 
				
			||||||
class PlainShadow;
 | 
					class PlainShadow;
 | 
				
			||||||
class RoundButton;
 | 
					class RoundButton;
 | 
				
			||||||
class VerticalLayout;
 | 
					class VerticalLayout;
 | 
				
			||||||
| 
						 | 
					@ -27,7 +27,9 @@ public:
 | 
				
			||||||
			Phone,
 | 
								Phone,
 | 
				
			||||||
			Text,
 | 
								Text,
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
		ValueType type = ValueType::Phone;
 | 
							explicit Scheme(ValueType type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							ValueType type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		QString aboutExisting;
 | 
							QString aboutExisting;
 | 
				
			||||||
		QString newHeader;
 | 
							QString newHeader;
 | 
				
			||||||
| 
						 | 
					@ -63,7 +65,7 @@ private:
 | 
				
			||||||
	Scheme _scheme;
 | 
						Scheme _scheme;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	object_ptr<Ui::VerticalLayout> _content;
 | 
						object_ptr<Ui::VerticalLayout> _content;
 | 
				
			||||||
	QPointer<Ui::InputField> _field;
 | 
						QPointer<Ui::MaskedInputField> _field;
 | 
				
			||||||
	object_ptr<Ui::PlainShadow> _bottomShadow;
 | 
						object_ptr<Ui::PlainShadow> _bottomShadow;
 | 
				
			||||||
	object_ptr<Ui::RoundButton> _done;
 | 
						object_ptr<Ui::RoundButton> _done;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue