@@ -12,7 +12,6 @@ For license and copyright information please follow this link:
1212#include " base/unixtime.h"
1313#include " base/weak_ptr.h"
1414#include " boxes/peer_list_box.h"
15- #include " core/click_handler_types.h"
1615#include " data/data_channel.h"
1716#include " data/data_session.h"
1817#include " data/data_user.h"
@@ -688,11 +687,6 @@ class InnerWidget final : public Ui::RpWidget {
688687 not_null<ListController*> setupSuggested ();
689688 void setupSort (not_null<Ui::RpWidget*> label);
690689
691- [[nodiscard]] object_ptr<Ui::RpWidget> infoRow (
692- rpl::producer<QString> title,
693- rpl::producer<QString> text,
694- not_null<const style::icon*> icon);
695-
696690 const not_null<Controller*> _controller;
697691 const not_null<Ui::VerticalLayout*> _container;
698692 rpl::variable<SuggestedSort> _sort = SuggestedSort::Profitability;
@@ -721,17 +715,20 @@ void InnerWidget::prepare() {
721715void InnerWidget::setupInfo () {
722716 AddSkip (_container, st::defaultVerticalListSkip * 2 );
723717
724- _container->add (infoRow (
718+ _container->add (MakeInfoRow (
719+ _container,
725720 tr::lng_star_ref_reliable_title (),
726721 tr::lng_star_ref_reliable_about (),
727722 &st::menuIconAntispam));
728723
729- _container->add (infoRow (
724+ _container->add (MakeInfoRow (
725+ _container,
730726 tr::lng_star_ref_transparent_title (),
731727 tr::lng_star_ref_transparent_about (),
732728 &st::menuIconTransparent));
733729
734- _container->add (infoRow (
730+ _container->add (MakeInfoRow (
731+ _container,
735732 tr::lng_star_ref_simple_title (),
736733 tr::lng_star_ref_simple_about (),
737734 &st::menuIconLike));
@@ -861,33 +858,6 @@ not_null<ListController*> InnerWidget::setupSuggested() {
861858 return controller;
862859}
863860
864- object_ptr<Ui::RpWidget> InnerWidget::infoRow (
865- rpl::producer<QString> title,
866- rpl::producer<QString> text,
867- not_null<const style::icon*> icon) {
868- auto result = object_ptr<Ui::VerticalLayout>(_container);
869- const auto raw = result.data ();
870-
871- raw->add (
872- object_ptr<Ui::FlatLabel>(
873- raw,
874- std::move (title) | rpl::map (tr::bold),
875- st::defaultFlatLabel),
876- st::settingsPremiumRowTitlePadding);
877- raw->add (
878- object_ptr<Ui::FlatLabel>(
879- raw,
880- std::move (text),
881- st::boxDividerLabel),
882- st::settingsPremiumRowAboutPadding);
883- object_ptr<Info::Profile::FloatingIcon>(
884- raw,
885- *icon,
886- st::starrefInfoIconPosition);
887-
888- return result;
889- }
890-
891861not_null<PeerData*> InnerWidget::peer () const {
892862 return _controller->key ().starrefPeer ();
893863}
@@ -993,56 +963,19 @@ void Widget::restoreState(not_null<Memento*> memento) {
993963
994964std::unique_ptr<Ui::Premium::TopBarAbstract> Widget::setupTop () {
995965 auto title = tr::lng_star_ref_list_title ();
996- auto about = tr::lng_star_ref_list_about_channel (tr::marked);
997966
998967 const auto controller = this ->controller ();
999- const auto weak = base::make_weak (controller->parentController ());
1000- const auto clickContextOther = [=] {
1001- return QVariant::fromValue (ClickHandlerContext{
1002- .sessionWindow = weak,
1003- .botStartAutoSubmit = true ,
1004- });
1005- };
1006- auto result = std::make_unique<Ui::Premium::TopBar>(
1007- this ,
1008- st::starrefCover,
1009- Ui::Premium::TopBarDescriptor{
1010- .clickContextOther = clickContextOther,
1011- .logo = u" affiliate" _q,
1012- .title = std::move (title),
1013- .about = std::move (about),
1014- .light = true ,
1015- });
1016- const auto raw = result.get ();
1017-
1018- controller->wrapValue (
1019- ) | rpl::on_next ([=](Info::Wrap wrap) {
1020- raw->setRoundEdges (wrap == Info::Wrap::Layer);
1021- }, raw->lifetime ());
1022-
1023- const auto baseHeight = st::starrefCoverHeight;
1024- raw->resize (width (), baseHeight);
1025- const auto updateTopSkip = [=] {
1026- const auto height = raw->height ();
968+ const auto updateTopSkip = [=](int height) {
1027969 setPaintPadding ({ 0 , height, 0 , 0 });
1028970 setScrollTopSkip (height);
1029971 };
1030- const auto setTopHeight = [=](int height) {
1031- if (height > raw->maximumHeight ()) {
1032- raw->setMaximumHeight (height);
1033- raw->setMinimumHeight (height);
1034- } else {
1035- raw->setMinimumHeight (height);
1036- raw->setMaximumHeight (height);
1037- }
1038- raw->resize (raw->width (), height);
1039- updateTopSkip ();
1040- };
1041-
1042- raw->additionalHeight (
1043- ) | rpl::on_next ([=](int additionalHeight) {
1044- setTopHeight (baseHeight + additionalHeight);
1045- }, raw->lifetime ());
972+ auto result = MakeTopBar (
973+ this ,
974+ controller,
975+ std::move (title),
976+ tr::lng_star_ref_list_about_channel (tr::marked),
977+ updateTopSkip);
978+ const auto raw = result.get ();
1046979
1047980 controller->wrapValue (
1048981 ) | rpl::on_next ([=](Info::Wrap wrap) {
@@ -1094,7 +1027,7 @@ std::unique_ptr<Ui::Premium::TopBarAbstract> Widget::setupTop() {
10941027 raw->move (0 , 0 );
10951028 widthValue () | rpl::on_next ([=](int width) {
10961029 raw->resizeToWidth (width);
1097- updateTopSkip ();
1030+ updateTopSkip (raw-> height () );
10981031 }, raw->lifetime ());
10991032
11001033 return result;
0 commit comments