mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fixed width of tabs for different boosts lists.
This commit is contained in:
parent
c9cad4186b
commit
27e2a4b5d2
1 changed files with 21 additions and 13 deletions
|
@ -410,12 +410,25 @@ void InnerWidget::fill() {
|
||||||
header->setSubTitle({});
|
header->setSubTitle({});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Slider final : public Ui::SettingsSlider {
|
||||||
|
public:
|
||||||
|
using Ui::SettingsSlider::SettingsSlider;
|
||||||
|
void setNaturalWidth(int w) {
|
||||||
|
_naturalWidth = w;
|
||||||
|
}
|
||||||
|
int naturalWidth() const override {
|
||||||
|
return _naturalWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int _naturalWidth = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
const auto slider = inner->add(
|
const auto slider = inner->add(
|
||||||
object_ptr<Ui::SlideWrap<Ui::SettingsSlider>>(
|
object_ptr<Ui::SlideWrap<Slider>>(
|
||||||
inner,
|
inner,
|
||||||
object_ptr<Ui::SettingsSlider>(
|
object_ptr<Slider>(inner, st::defaultTabsSlider)),
|
||||||
inner,
|
|
||||||
st::defaultTabsSlider)),
|
|
||||||
st::boxRowPadding);
|
st::boxRowPadding);
|
||||||
slider->toggle(!hasOneTab, anim::type::instant);
|
slider->toggle(!hasOneTab, anim::type::instant);
|
||||||
|
|
||||||
|
@ -424,15 +437,10 @@ void InnerWidget::fill() {
|
||||||
|
|
||||||
{
|
{
|
||||||
const auto &st = st::defaultTabsSlider;
|
const auto &st = st::defaultTabsSlider;
|
||||||
const auto sliderWidth = st.labelStyle.font->width(boostsTabText)
|
slider->entity()->setNaturalWidth(0
|
||||||
|
+ st.labelStyle.font->width(boostsTabText)
|
||||||
+ st.labelStyle.font->width(giftsTabText)
|
+ st.labelStyle.font->width(giftsTabText)
|
||||||
+ rect::m::sum::h(st::boxRowPadding);
|
+ rect::m::sum::h(st::boxRowPadding));
|
||||||
fakeShowed->events() | rpl::take(1) | rpl::map_to(-1) | rpl::then(
|
|
||||||
slider->entity()->widthValue()
|
|
||||||
) | rpl::distinct_until_changed(
|
|
||||||
) | rpl::start_with_next([=](int) {
|
|
||||||
slider->entity()->resizeToWidth(sliderWidth);
|
|
||||||
}, slider->lifetime());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto boostsWrap = inner->add(
|
const auto boostsWrap = inner->add(
|
||||||
|
@ -444,7 +452,7 @@ void InnerWidget::fill() {
|
||||||
inner,
|
inner,
|
||||||
object_ptr<Ui::VerticalLayout>(inner)));
|
object_ptr<Ui::VerticalLayout>(inner)));
|
||||||
|
|
||||||
rpl::single(hasGifts ? 1 : 0) | rpl::then(
|
rpl::single(hasOneTab ? (hasGifts ? 1 : 0) : 0) | rpl::then(
|
||||||
slider->entity()->sectionActivated()
|
slider->entity()->sectionActivated()
|
||||||
) | rpl::start_with_next([=](int index) {
|
) | rpl::start_with_next([=](int index) {
|
||||||
boostsWrap->toggle(!index, anim::type::instant);
|
boostsWrap->toggle(!index, anim::type::instant);
|
||||||
|
|
Loading…
Add table
Reference in a new issue