| 353 | } |
| 354 | |
| 355 | void TermsBox::prepare() { |
| 356 | setTitle(tr::lng_terms_header()); |
| 357 | |
| 358 | auto check = std::make_unique<Ui::CheckView>(st::defaultCheck, false); |
| 359 | const auto ageCheck = check.get(); |
| 360 | const auto age = _data.minAge |
| 361 | ? Ui::CreateChild<Ui::PaddingWrap<Ui::Checkbox>>( |
| 362 | this, |
| 363 | object_ptr<Ui::Checkbox>( |
| 364 | this, |
| 365 | tr::lng_terms_age(tr::now, lt_count, *_data.minAge), |
| 366 | st::defaultCheckbox, |
| 367 | std::move(check)), |
| 368 | st::termsAgePadding) |
| 369 | : nullptr; |
| 370 | if (age) { |
| 371 | age->resizeToNaturalWidth(st::boxWideWidth); |
| 372 | } |
| 373 | |
| 374 | const auto content = setInnerWidget( |
| 375 | object_ptr<Ui::PaddingWrap<Ui::FlatLabel>>( |
| 376 | this, |
| 377 | object_ptr<Ui::FlatLabel> ( |
| 378 | this, |
| 379 | rpl::single(_data.text), |
| 380 | st::termsContent), |
| 381 | st::termsPadding), |
| 382 | 0, |
| 383 | age ? age->height() : 0); |
| 384 | const auto show = uiShow(); |
| 385 | content->entity()->setClickHandlerFilter([=]( |
| 386 | const ClickHandlerPtr &handler, |
| 387 | Qt::MouseButton button) { |
| 388 | const auto link = handler |
| 389 | ? handler->copyToClipboardText() |
| 390 | : QString(); |
| 391 | if (TextUtilities::RegExpMention().match(link).hasMatch()) { |
| 392 | _lastClickedMention = link; |
| 393 | show->showToast( |
| 394 | tr::lng_terms_agree_to_proceed(tr::now, lt_bot, link)); |
| 395 | return false; |
| 396 | } |
| 397 | return true; |
| 398 | }); |
| 399 | |
| 400 | const auto errorAnimationCallback = [=] { |
| 401 | const auto check = ageCheck; |
| 402 | const auto error = _ageErrorAnimation.value( |
| 403 | _ageErrorShown ? 1. : 0.); |
| 404 | if (error == 0.) { |
| 405 | check->setUntoggledOverride(std::nullopt); |
| 406 | } else { |
| 407 | const auto color = anim::color( |
| 408 | st::defaultCheck.untoggledFg, |
| 409 | st::boxTextFgError, |
| 410 | error); |
| 411 | check->setUntoggledOverride(color); |
| 412 | } |
nothing calls this directly
no test coverage detected