| 434 | } |
| 435 | |
| 436 | void ConfirmInviteBox( |
| 437 | not_null<Ui::GenericBox*> box, |
| 438 | not_null<Main::Session*> session, |
| 439 | const MTPDchatInvite *invitePtr, |
| 440 | ChannelData *invitePeekChannel, |
| 441 | Fn<void()> submit) { |
| 442 | auto invite = ParseInvite(session, *invitePtr); |
| 443 | const auto isChannel = invite.isChannel && !invite.isMegagroup; |
| 444 | const auto requestApprove = invite.isRequestNeeded; |
| 445 | const auto count = invite.participantsCount; |
| 446 | |
| 447 | struct State { |
| 448 | std::shared_ptr<Data::PhotoMedia> photoMedia; |
| 449 | std::unique_ptr<Ui::EmptyUserpic> photoEmpty; |
| 450 | std::vector<InviteParticipant> participants; |
| 451 | }; |
| 452 | const auto state = box->lifetime().make_state<State>(); |
| 453 | state->participants = std::move(invite.participants); |
| 454 | |
| 455 | const auto status = [&] { |
| 456 | return invitePeekChannel |
| 457 | ? tr::lng_channel_invite_private(tr::now) |
| 458 | : (!state->participants.empty() |
| 459 | && int(state->participants.size()) < count) |
| 460 | ? tr::lng_group_invite_members(tr::now, lt_count, count) |
| 461 | : (count > 0 && isChannel) |
| 462 | ? tr::lng_chat_status_subscribers( |
| 463 | tr::now, |
| 464 | lt_count_decimal, |
| 465 | count) |
| 466 | : (count > 0) |
| 467 | ? tr::lng_chat_status_members(tr::now, lt_count_decimal, count) |
| 468 | : isChannel |
| 469 | ? tr::lng_channel_status(tr::now) |
| 470 | : tr::lng_group_status(tr::now); |
| 471 | }(); |
| 472 | |
| 473 | box->setNoContentMargin(true); |
| 474 | box->setWidth(st::boxWideWidth); |
| 475 | const auto content = box->verticalLayout(); |
| 476 | |
| 477 | Ui::AddSkip(content, st::confirmInvitePhotoTop); |
| 478 | const auto userpic = content->add( |
| 479 | object_ptr<Ui::RpWidget>(content), |
| 480 | style::al_top); |
| 481 | const auto photoSize = st::confirmInvitePhotoSize; |
| 482 | userpic->resize(Size(photoSize)); |
| 483 | userpic->setNaturalWidth(photoSize); |
| 484 | userpic->paintRequest( |
| 485 | ) | rpl::on_next([=, small = Data::PhotoSize::Small] { |
| 486 | auto p = QPainter(userpic); |
| 487 | if (state->photoMedia) { |
| 488 | if (const auto image = state->photoMedia->image(small)) { |
| 489 | p.drawPixmap( |
| 490 | 0, |
| 491 | 0, |
| 492 | image->pix( |
| 493 | Size(photoSize), |
nothing calls this directly
no test coverage detected