mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Added ability to provide style to box for choosing date and time.
This commit is contained in:
parent
239c617818
commit
5298cf0e52
2 changed files with 34 additions and 6 deletions
|
@ -58,6 +58,15 @@ QString TimeString(QTime time) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
ChooseDateTimeStyleArgs::ChooseDateTimeStyleArgs()
|
||||||
|
: labelStyle(&st::boxLabel)
|
||||||
|
, dateFieldStyle(&st::scheduleDateField)
|
||||||
|
, timeFieldStyle(&st::scheduleTimeField)
|
||||||
|
, separatorStyle(&st::scheduleTimeSeparator)
|
||||||
|
, atStyle(&st::scheduleAtLabel)
|
||||||
|
, calendarStyle(&st::defaultCalendarColors) {
|
||||||
|
}
|
||||||
|
|
||||||
ChooseDateTimeBoxDescriptor ChooseDateTimeBox(
|
ChooseDateTimeBoxDescriptor ChooseDateTimeBox(
|
||||||
not_null<GenericBox*> box,
|
not_null<GenericBox*> box,
|
||||||
ChooseDateTimeBoxArgs &&args) {
|
ChooseDateTimeBoxArgs &&args) {
|
||||||
|
@ -76,25 +85,25 @@ ChooseDateTimeBoxDescriptor ChooseDateTimeBox(
|
||||||
box->addRow(object_ptr<FlatLabel>(
|
box->addRow(object_ptr<FlatLabel>(
|
||||||
box,
|
box,
|
||||||
std::move(args.description),
|
std::move(args.description),
|
||||||
st::boxLabel));
|
*args.style.labelStyle));
|
||||||
}
|
}
|
||||||
const auto parsed = base::unixtime::parse(args.time);
|
const auto parsed = base::unixtime::parse(args.time);
|
||||||
const auto state = box->lifetime().make_state<State>(State{
|
const auto state = box->lifetime().make_state<State>(State{
|
||||||
.date = parsed.date(),
|
.date = parsed.date(),
|
||||||
.day = CreateChild<InputField>(
|
.day = CreateChild<InputField>(
|
||||||
content,
|
content,
|
||||||
st::scheduleDateField),
|
*args.style.dateFieldStyle),
|
||||||
.time = CreateChild<TimeInput>(
|
.time = CreateChild<TimeInput>(
|
||||||
content,
|
content,
|
||||||
TimeString(parsed.time()),
|
TimeString(parsed.time()),
|
||||||
st::scheduleTimeField,
|
*args.style.timeFieldStyle,
|
||||||
st::scheduleDateField,
|
*args.style.dateFieldStyle,
|
||||||
st::scheduleTimeSeparator,
|
*args.style.separatorStyle,
|
||||||
st::scheduleTimeSeparatorPadding),
|
st::scheduleTimeSeparatorPadding),
|
||||||
.at = CreateChild<FlatLabel>(
|
.at = CreateChild<FlatLabel>(
|
||||||
content,
|
content,
|
||||||
tr::lng_schedule_at(),
|
tr::lng_schedule_at(),
|
||||||
st::scheduleAtLabel),
|
*args.style.atStyle),
|
||||||
});
|
});
|
||||||
|
|
||||||
state->date.value(
|
state->date.value(
|
||||||
|
@ -155,6 +164,7 @@ ChooseDateTimeBoxDescriptor ChooseDateTimeBox(
|
||||||
|
|
||||||
const auto calendar =
|
const auto calendar =
|
||||||
content->lifetime().make_state<QPointer<CalendarBox>>();
|
content->lifetime().make_state<QPointer<CalendarBox>>();
|
||||||
|
const auto calendarStyle = args.style.calendarStyle;
|
||||||
QObject::connect(state->day, &InputField::focused, [=] {
|
QObject::connect(state->day, &InputField::focused, [=] {
|
||||||
if (*calendar) {
|
if (*calendar) {
|
||||||
return;
|
return;
|
||||||
|
@ -169,6 +179,7 @@ ChooseDateTimeBoxDescriptor ChooseDateTimeBox(
|
||||||
}),
|
}),
|
||||||
.minDate = minDate(),
|
.minDate = minDate(),
|
||||||
.maxDate = maxDate(),
|
.maxDate = maxDate(),
|
||||||
|
.stColors = *calendarStyle,
|
||||||
}));
|
}));
|
||||||
(*calendar)->boxClosing(
|
(*calendar)->boxClosing(
|
||||||
) | rpl::start_with_next(crl::guard(state->time, [=] {
|
) | rpl::start_with_next(crl::guard(state->time, [=] {
|
||||||
|
|
|
@ -9,6 +9,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "ui/layers/generic_box.h"
|
#include "ui/layers/generic_box.h"
|
||||||
|
|
||||||
|
namespace style {
|
||||||
|
struct FlatLabel;
|
||||||
|
struct InputField;
|
||||||
|
struct CalendarColors;
|
||||||
|
} // namespace style
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
||||||
class RoundButton;
|
class RoundButton;
|
||||||
|
@ -19,6 +25,16 @@ struct ChooseDateTimeBoxDescriptor {
|
||||||
rpl::producer<TimeId> values;
|
rpl::producer<TimeId> values;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ChooseDateTimeStyleArgs {
|
||||||
|
ChooseDateTimeStyleArgs();
|
||||||
|
const style::FlatLabel *labelStyle;
|
||||||
|
const style::InputField *dateFieldStyle;
|
||||||
|
const style::InputField *timeFieldStyle;
|
||||||
|
const style::FlatLabel *separatorStyle;
|
||||||
|
const style::FlatLabel *atStyle;
|
||||||
|
const style::CalendarColors *calendarStyle;
|
||||||
|
};
|
||||||
|
|
||||||
struct ChooseDateTimeBoxArgs {
|
struct ChooseDateTimeBoxArgs {
|
||||||
rpl::producer<QString> title;
|
rpl::producer<QString> title;
|
||||||
rpl::producer<QString> submit;
|
rpl::producer<QString> submit;
|
||||||
|
@ -27,6 +43,7 @@ struct ChooseDateTimeBoxArgs {
|
||||||
TimeId time = 0;
|
TimeId time = 0;
|
||||||
Fn<TimeId()> max;
|
Fn<TimeId()> max;
|
||||||
rpl::producer<QString> description;
|
rpl::producer<QString> description;
|
||||||
|
ChooseDateTimeStyleArgs style;
|
||||||
};
|
};
|
||||||
|
|
||||||
ChooseDateTimeBoxDescriptor ChooseDateTimeBox(
|
ChooseDateTimeBoxDescriptor ChooseDateTimeBox(
|
||||||
|
|
Loading…
Add table
Reference in a new issue