| 327 | } |
| 328 | |
| 329 | void BoostBox( |
| 330 | not_null<GenericBox*> box, |
| 331 | BoostBoxData data, |
| 332 | Fn<void(Fn<void(BoostCounters)>)> boost) { |
| 333 | box->setWidth(st::boxWideWidth); |
| 334 | box->setStyle(st::boostBox); |
| 335 | |
| 336 | //AssertIsDebug(); |
| 337 | //data.boost = { |
| 338 | // .level = 2, |
| 339 | // .boosts = 3, |
| 340 | // .thisLevelBoosts = 2, |
| 341 | // .nextLevelBoosts = 5, |
| 342 | // .mine = 2, |
| 343 | //}; |
| 344 | |
| 345 | struct State { |
| 346 | rpl::variable<BoostCounters> data; |
| 347 | rpl::variable<bool> full; |
| 348 | bool submitted = false; |
| 349 | }; |
| 350 | const auto state = box->lifetime().make_state<State>(); |
| 351 | state->data = std::move(data.boost); |
| 352 | |
| 353 | FillBoostLimit( |
| 354 | BoxShowFinishes(box), |
| 355 | box->verticalLayout(), |
| 356 | state->data.value(), |
| 357 | st::boxRowPadding); |
| 358 | |
| 359 | box->setMaxHeight(st::boostBoxMaxHeight); |
| 360 | const auto close = box->addTopButton( |
| 361 | st::boxTitleClose, |
| 362 | [=] { box->closeBox(); }); |
| 363 | |
| 364 | const auto name = data.name; |
| 365 | |
| 366 | auto title = state->data.value( |
| 367 | ) | rpl::map([=](BoostCounters counters) { |
| 368 | return (counters.mine > 0) |
| 369 | ? tr::lng_boost_channel_you_title( |
| 370 | lt_channel, |
| 371 | rpl::single(name)) |
| 372 | : !counters.nextLevelBoosts |
| 373 | ? tr::lng_boost_channel_title_max() |
| 374 | : counters.level |
| 375 | ? (data.group |
| 376 | ? tr::lng_boost_channel_title_more_group() |
| 377 | : tr::lng_boost_channel_title_more()) |
| 378 | : (data.group |
| 379 | ? tr::lng_boost_channel_title_first_group() |
| 380 | : tr::lng_boost_channel_title_first()); |
| 381 | }) | rpl::flatten_latest(); |
| 382 | auto repeated = state->data.value( |
| 383 | ) | rpl::map([=](BoostCounters counters) { |
| 384 | return (counters.mine > 1) ? u"x%1"_q.arg(counters.mine) : u""_q; |
| 385 | }); |
| 386 |
nothing calls this directly
no test coverage detected