Slightly improved style of giveaway box.

This commit is contained in:
23rd 2023-11-01 04:45:18 +03:00 committed by John Preston
parent 36a91dd32b
commit 2b1a46356a
6 changed files with 137 additions and 93 deletions

View file

@ -41,8 +41,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
#include "styles/style_giveaway.h" #include "styles/style_giveaway.h"
#include "styles/style_layers.h"
#include "styles/style_info.h" #include "styles/style_info.h"
#include "styles/style_layers.h"
#include "styles/style_premium.h" #include "styles/style_premium.h"
#include <QtGui/QGuiApplication> #include <QtGui/QGuiApplication>

View file

@ -73,19 +73,20 @@ void CreateGiveawayBox(
bar->setMinimumHeight(st::infoLayerTopBarHeight); bar->setMinimumHeight(st::infoLayerTopBarHeight);
bar->resize(bar->width(), bar->maximumHeight()); bar->resize(bar->width(), bar->maximumHeight());
Settings::AddSkip(box->verticalLayout()); const auto container = box->verticalLayout();
Settings::AddDivider(box->verticalLayout()); const auto &padding = st::giveawayGiftCodeCoverDividerPadding;
Settings::AddSkip(box->verticalLayout()); Settings::AddSkip(container, padding.top());
Settings::AddDivider(container);
Settings::AddSkip(container, padding.bottom());
const auto close = Ui::CreateChild<Ui::IconButton>( const auto close = Ui::CreateChild<Ui::IconButton>(
box->verticalLayout().get(), container.get(),
st::boxTitleClose); st::boxTitleClose);
close->setClickedCallback([=] { close->setClickedCallback([=] { box->closeBox(); });
box->closeBox();
});
box->widthValue( box->widthValue(
) | rpl::start_with_next([=](int) { ) | rpl::start_with_next([=](int) {
close->moveToRight(0, 0); const auto &pos = st::giveawayGiftCodeCoverClosePosition;
close->moveToRight(pos.x(), pos.y());
}, box->lifetime()); }, box->lifetime());
} }
@ -197,9 +198,12 @@ void CreateGiveawayBox(
}); });
} }
Settings::AddSkip(contentWrap->entity()); {
Settings::AddDivider(contentWrap->entity()); const auto &padding = st::giveawayGiftCodeTypeDividerPadding;
Settings::AddSkip(contentWrap->entity()); Settings::AddSkip(contentWrap->entity(), padding.top());
Settings::AddDivider(contentWrap->entity());
Settings::AddSkip(contentWrap->entity(), padding.bottom());
}
const auto randomWrap = contentWrap->entity()->add( const auto randomWrap = contentWrap->entity()->add(
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>( object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
@ -245,12 +249,12 @@ void CreateGiveawayBox(
rightLabel->moveToRight(st::boxRowPadding.right(), p.y()); rightLabel->moveToRight(st::boxRowPadding.right(), p.y());
}, rightLabel->lifetime()); }, rightLabel->lifetime());
Settings::AddSkip(sliderContainer); const auto &padding = st::giveawayGiftCodeSliderPadding;
Settings::AddSkip(sliderContainer); Settings::AddSkip(sliderContainer, padding.top());
const auto slider = sliderContainer->add( const auto slider = sliderContainer->add(
object_ptr<Ui::MediaSlider>(sliderContainer, st::settingsScale), object_ptr<Ui::MediaSlider>(sliderContainer, st::settingsScale),
st::boxRowPadding); st::boxRowPadding);
Settings::AddSkip(sliderContainer); Settings::AddSkip(sliderContainer, padding.bottom());
slider->resize(slider->width(), st::settingsScale.seekSize.height()); slider->resize(slider->width(), st::settingsScale.seekSize.height());
slider->setPseudoDiscrete( slider->setPseudoDiscrete(
availablePresets.size(), availablePresets.size(),
@ -275,7 +279,9 @@ void CreateGiveawayBox(
+ x + x
+ st::settingsScale.seekSize.width() / 2 + st::settingsScale.seekSize.width() / 2
- floatLabel->width() / 2, - floatLabel->width() / 2,
slider->y() - floatLabel->height()); slider->y()
- floatLabel->height()
- st::giveawayGiftCodeSliderFloatSkip);
break; break;
} }
} }
@ -295,7 +301,8 @@ void CreateGiveawayBox(
object_ptr<Ui::VerticalLayout>(randomWrap)); object_ptr<Ui::VerticalLayout>(randomWrap));
Settings::AddSubsectionTitle( Settings::AddSubsectionTitle(
channelsContainer, channelsContainer,
tr::lng_giveaway_channels_title()); tr::lng_giveaway_channels_title(),
st::giveawayGiftCodeChannelsSubsectionPadding);
struct ListState final { struct ListState final {
ListState(not_null<PeerData*> p) : controller(p) { ListState(not_null<PeerData*> p) : controller(p) {
@ -326,7 +333,7 @@ void CreateGiveawayBox(
Settings::AddButton( Settings::AddButton(
channelsContainer, channelsContainer,
tr::lng_giveaway_channels_add(), tr::lng_giveaway_channels_add(),
st::settingsButtonActive, st::giveawayGiftCodeChannelsAddButton,
{ &st::settingsIconAdd, IconType::Round, &st::windowBgActive } { &st::settingsIconAdd, IconType::Round, &st::windowBgActive }
)->setClickedCallback([=] { )->setClickedCallback([=] {
auto initBox = [=](not_null<PeerListBox*> peersBox) { auto initBox = [=](not_null<PeerListBox*> peersBox) {
@ -352,56 +359,12 @@ void CreateGiveawayBox(
Ui::LayerOption::KeepOther); Ui::LayerOption::KeepOther);
}); });
Settings::AddSkip(channelsContainer); const auto &padding = st::giveawayGiftCodeChannelsDividerPadding;
Settings::AddSkip(channelsContainer, padding.top());
Settings::AddDividerText( Settings::AddDividerText(
channelsContainer, channelsContainer,
tr::lng_giveaway_channels_about()); tr::lng_giveaway_channels_about());
Settings::AddSkip(channelsContainer); Settings::AddSkip(channelsContainer, padding.bottom());
}
{
const auto dateContainer = randomWrap->entity()->add(
object_ptr<Ui::VerticalLayout>(randomWrap));
Settings::AddSubsectionTitle(
dateContainer,
tr::lng_giveaway_date_title());
state->dateValue = ThreeDaysAfterToday().toSecsSinceEpoch();
const auto button = Settings::AddButtonWithLabel(
dateContainer,
tr::lng_giveaway_date(),
state->dateValue.value() | rpl::map(
base::unixtime::parse
) | rpl::map(Ui::FormatDateTime),
st::defaultSettingsButton);
button->setClickedCallback([=] {
constexpr auto kSevenDays = 3600 * 24 * 7;
box->uiShow()->showBox(Box([=](not_null<Ui::GenericBox*> b) {
Ui::ChooseDateTimeBox(b, {
.title = tr::lng_giveaway_date_select(),
.submit = tr::lng_settings_save(),
.done = [=](TimeId time) {
state->dateValue = time;
b->closeBox();
},
.min = QDateTime::currentSecsSinceEpoch,
.time = state->dateValue.current(),
.max = [=] {
return QDateTime::currentSecsSinceEpoch()
+ kSevenDays;
},
});
}));
});
Settings::AddSkip(dateContainer);
Settings::AddDividerText(
dateContainer,
tr::lng_giveaway_date_about(
lt_count,
state->sliderValue.value() | tr::to_count()));
Settings::AddSkip(dateContainer);
} }
const auto membersGroup = std::make_shared<GiveawayGroup>(); const auto membersGroup = std::make_shared<GiveawayGroup>();
@ -488,6 +451,52 @@ void CreateGiveawayBox(
Settings::AddSkip(countriesContainer); Settings::AddSkip(countriesContainer);
} }
{
const auto dateContainer = randomWrap->entity()->add(
object_ptr<Ui::VerticalLayout>(randomWrap));
Settings::AddSubsectionTitle(
dateContainer,
tr::lng_giveaway_date_title(),
st::giveawayGiftCodeChannelsSubsectionPadding);
state->dateValue = ThreeDaysAfterToday().toSecsSinceEpoch();
const auto button = Settings::AddButtonWithLabel(
dateContainer,
tr::lng_giveaway_date(),
state->dateValue.value() | rpl::map(
base::unixtime::parse
) | rpl::map(Ui::FormatDateTime),
st::defaultSettingsButton);
button->setClickedCallback([=] {
constexpr auto kSevenDays = 3600 * 24 * 7;
box->uiShow()->showBox(Box([=](not_null<Ui::GenericBox*> b) {
Ui::ChooseDateTimeBox(b, {
.title = tr::lng_giveaway_date_select(),
.submit = tr::lng_settings_save(),
.done = [=](TimeId time) {
state->dateValue = time;
b->closeBox();
},
.min = QDateTime::currentSecsSinceEpoch,
.time = state->dateValue.current(),
.max = [=] {
return QDateTime::currentSecsSinceEpoch()
+ kSevenDays;
},
});
}));
});
Settings::AddSkip(dateContainer);
Settings::AddDividerText(
dateContainer,
tr::lng_giveaway_date_about(
lt_count,
state->sliderValue.value() | tr::to_count()));
Settings::AddSkip(dateContainer);
}
const auto durationGroup = std::make_shared<Ui::RadiobuttonGroup>(0); const auto durationGroup = std::make_shared<Ui::RadiobuttonGroup>(0);
const auto listOptions = contentWrap->entity()->add( const auto listOptions = contentWrap->entity()->add(
object_ptr<Ui::VerticalLayout>(box)); object_ptr<Ui::VerticalLayout>(box));
@ -499,7 +508,8 @@ void CreateGiveawayBox(
listOptions, listOptions,
tr::lng_giveaway_duration_title( tr::lng_giveaway_duration_title(
lt_count, lt_count,
rpl::single(amountUsers) | tr::to_count())); rpl::single(amountUsers) | tr::to_count()),
st::giveawayGiftCodeChannelsSubsectionPadding);
Ui::Premium::AddGiftOptions( Ui::Premium::AddGiftOptions(
listOptions, listOptions,
durationGroup, durationGroup,
@ -507,6 +517,8 @@ void CreateGiveawayBox(
st::giveawayGiftCodeGiftOption, st::giveawayGiftCodeGiftOption,
true); true);
Settings::AddSkip(listOptions);
auto terms = object_ptr<Ui::FlatLabel>( auto terms = object_ptr<Ui::FlatLabel>(
listOptions, listOptions,
tr::lng_premium_gift_terms( tr::lng_premium_gift_terms(

View file

@ -8,6 +8,27 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
using "ui/basic.style"; using "ui/basic.style";
using "boxes/boxes.style"; using "boxes/boxes.style";
using "ui/effects/premium.style"; using "ui/effects/premium.style";
using "statistics/statistics.style";
giveawayTypeListItem: PeerListItem(defaultPeerListItem) {
height: 52px;
photoPosition: point(58px, 6px);
namePosition: point(110px, 8px);
statusPosition: point(110px, 28px);
photoSize: 42px;
}
giveawayUserpic: icon {{ "boosts/filled_gift", windowFgActive }};
giveawayUserpicSkip: 1px;
giveawayUserpicGroup: icon {{ "limits/groups", windowFgActive }};
giveawayRadioPosition: point(21px, 16px);
giveawayGiftCodeCountryButton: SettingsButton(reportReasonButton) {
}
giveawayGiftCodeCountrySelect: MultiSelect(defaultMultiSelect) {
}
giveawayGiftCodeChannelDeleteIcon: icon {{ "dialogs/dialogs_cancel_search", dialogsMenuIconFg }};
giveawayGiftCodeChannelDeleteIconOver: icon {{ "dialogs/dialogs_cancel_search", dialogsMenuIconFgOver }};
giveawayLoadingLabel: FlatLabel(membersAbout) { giveawayLoadingLabel: FlatLabel(membersAbout) {
} }
@ -94,6 +115,33 @@ giveawayGiftCodeCover: PremiumCover(userPremiumCover) {
} }
} }
} }
giveawayGiftCodeCoverClosePosition: point(5px, 0px);
giveawayGiftCodeCoverDividerPadding: margins(0px, 11px, 0px, 5px);
giveawayGiftCodeTypeDividerPadding: margins(0px, 7px, 0px, 5px);
giveawayGiftCodeSliderPadding: margins(0px, 24px, 0px, 10px);
giveawayGiftCodeSliderFloatSkip: 6px;
giveawayGiftCodeChannelsSubsectionPadding: margins(0px, -1px, 0px, -4px);
giveawayGiftCodeChannelsPeerList: PeerList(boostsListBox) {
padding: margins(0px, 7px, 0px, 0px);
}
giveawayGiftCodeMembersPeerList: PeerList(defaultPeerList) {
item: PeerListItem(defaultPeerListItem) {
height: 50px;
namePosition: point(62px, 7px);
statusPosition: point(62px, 27px);
}
}
giveawayRadioMembersPosition: point(21px, 14px);
giveawayGiftCodeChannelsAddButton: SettingsButton(defaultSettingsButton) {
textFg: lightButtonFg;
textFgOver: lightButtonFgOver;
padding: margins(70px, 10px, 22px, 8px);
iconLeft: 28px;
}
giveawayGiftCodeChannelsDividerPadding: margins(0px, 5px, 0px, 5px);
giveawayGiftCodeFooter: FlatLabel(defaultFlatLabel) { giveawayGiftCodeFooter: FlatLabel(defaultFlatLabel) {
align: align(top); align: align(top);
textFg: windowBoldFg; textFg: windowBoldFg;

View file

@ -17,7 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/boxes/confirm_box.h" #include "ui/boxes/confirm_box.h"
#include "ui/effects/ripple_animation.h" #include "ui/effects/ripple_animation.h"
#include "ui/painter.h" #include "ui/painter.h"
#include "styles/style_statistics.h" #include "styles/style_giveaway.h"
namespace Giveaway { namespace Giveaway {
namespace { namespace {
@ -53,9 +53,10 @@ QSize ChannelRow::rightActionSize() const {
} }
QMargins ChannelRow::rightActionMargins() const { QMargins ChannelRow::rightActionMargins() const {
const auto itemHeight = st::giveawayGiftCodeChannelsPeerList.item.height;
return QMargins( return QMargins(
0, 0,
(st::defaultPeerListItem.height - rightActionSize().height()) / 2, (itemHeight - rightActionSize().height()) / 2,
st::giveawayRadioPosition.x() / 2, st::giveawayRadioPosition.x() / 2,
0); 0);
} }
@ -239,6 +240,8 @@ std::unique_ptr<PeerListRow> MyChannelsListController::createRow(
SelectedChannelsListController::SelectedChannelsListController( SelectedChannelsListController::SelectedChannelsListController(
not_null<PeerData*> peer) not_null<PeerData*> peer)
: _peer(peer) { : _peer(peer) {
PeerListController::setStyleOverrides(
&st::giveawayGiftCodeChannelsPeerList);
} }
void SelectedChannelsListController::setTopStatus(rpl::producer<QString> s) { void SelectedChannelsListController::setTopStatus(rpl::producer<QString> s) {

View file

@ -13,7 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_options.h" #include "ui/text/text_options.h"
#include "ui/widgets/checkbox.h" #include "ui/widgets/checkbox.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
#include "styles/style_statistics.h" #include "styles/style_giveaway.h"
namespace Giveaway { namespace Giveaway {
@ -28,7 +28,7 @@ GiveawayTypeRow::GiveawayTypeRow(
, _type(type) , _type(type)
, _st((_type == Type::SpecificUsers || _type == Type::Random) , _st((_type == Type::SpecificUsers || _type == Type::Random)
? st::giveawayTypeListItem ? st::giveawayTypeListItem
: st::defaultPeerListItem) : st::giveawayGiftCodeMembersPeerList.item)
, _userpic( , _userpic(
Ui::EmptyUserpic::UserpicColor((_type == Type::SpecificUsers) Ui::EmptyUserpic::UserpicColor((_type == Type::SpecificUsers)
? kColorIndexSpecific ? kColorIndexSpecific
@ -112,9 +112,10 @@ void GiveawayTypeRow::addRadio(
_type, _type,
QString(), QString(),
st); st);
radio->moveToLeft( const auto pos = (_type == Type::SpecificUsers || _type == Type::Random)
st::giveawayRadioPosition.x(), ? st::giveawayRadioPosition
st::giveawayRadioPosition.y()); : st::giveawayRadioMembersPosition;
radio->moveToLeft(pos.x(), pos.y());
radio->setAttribute(Qt::WA_TransparentForMouseEvents); radio->setAttribute(Qt::WA_TransparentForMouseEvents);
radio->show(); radio->show();
} }

View file

@ -148,23 +148,3 @@ getBoostsButton: SettingsButton(reportReasonButton) {
textFgOver: lightButtonFg; textFgOver: lightButtonFg;
} }
getBoostsButtonIcon: icon {{ "menu/gift_premium", lightButtonFg }}; getBoostsButtonIcon: icon {{ "menu/gift_premium", lightButtonFg }};
giveawayTypeListItem: PeerListItem(defaultPeerListItem) {
height: 52px;
photoPosition: point(58px, 6px);
namePosition: point(110px, 8px);
statusPosition: point(110px, 28px);
photoSize: 42px;
}
giveawayUserpic: icon {{ "boosts/filled_gift", windowFgActive }};
giveawayUserpicSkip: 1px;
giveawayUserpicGroup: icon {{ "limits/groups", windowFgActive }};
giveawayRadioPosition: point(21px, 16px);
giveawayGiftCodeCountryButton: SettingsButton(reportReasonButton) {
}
giveawayGiftCodeCountrySelect: MultiSelect(defaultMultiSelect) {
}
giveawayGiftCodeChannelDeleteIcon: icon {{ "dialogs/dialogs_cancel_search", dialogsMenuIconFg }};
giveawayGiftCodeChannelDeleteIconOver: icon {{ "dialogs/dialogs_cancel_search", dialogsMenuIconFgOver }};