Intro improvements

This commit is contained in:
Isaac
2024-03-15 20:13:14 +04:00
parent 925665b88b
commit 1caa0e9db2
6 changed files with 56 additions and 27 deletions

View File

@@ -40,6 +40,7 @@ swift_library(
"//submodules/TelegramUI/Components/EntityKeyboard",
"//submodules/TelegramUI/Components/PeerAllowedReactionsScreen",
"//submodules/TelegramUI/Components/EmojiActionIconComponent",
"//submodules/TelegramUI/Components/TextFieldComponent",
],
visibility = [
"//visibility:public",

View File

@@ -21,6 +21,7 @@ import LottieComponent
import EntityKeyboard
import PeerAllowedReactionsScreen
import EmojiActionIconComponent
import TextFieldComponent
final class BusinessIntroSetupScreenComponent: Component {
typealias EnvironmentType = ViewControllerComponentContainer.Environment
@@ -70,6 +71,8 @@ final class BusinessIntroSetupScreenComponent: Component {
private let textInputTag = NSObject()
private var resetText: String?
private var recenterOnTag: NSObject?
private var stickerFile: TelegramMediaFile?
private var stickerContent: EmojiPagerContentComponent?
private var stickerContentDisposable: Disposable?
@@ -170,8 +173,8 @@ final class BusinessIntroSetupScreenComponent: Component {
stickerNamespaces: [Namespaces.ItemCollection.CloudStickerPacks],
stickerOrderedItemListCollectionIds: [Namespaces.OrderedItemList.CloudSavedStickers, Namespaces.OrderedItemList.CloudRecentStickers, Namespaces.OrderedItemList.CloudAllPremiumStickers],
chatPeerId: nil,
hasSearch: true,
hasTrending: true,
hasSearch: false,
hasTrending: false,
forceHasPremium: true
)
self.stickerContentDisposable = (stickerContent
@@ -297,6 +300,20 @@ final class BusinessIntroSetupScreenComponent: Component {
contentHeight += environment.navigationHeight
contentHeight += 26.0
self.recenterOnTag = nil
if let hint = transition.userData(TextFieldComponent.AnimationHint.self), let targetView = hint.view {
if let titleView = self.introSection.findTaggedView(tag: self.titleInputTag) {
if targetView.isDescendant(of: titleView) {
self.recenterOnTag = self.titleInputTag
}
}
if let textView = self.introSection.findTaggedView(tag: self.textInputTag) {
if targetView.isDescendant(of: textView) {
self.recenterOnTag = self.textInputTag
}
}
}
var introSectionItems: [AnyComponentWithIdentity<Empty>] = []
introSectionItems.append(AnyComponentWithIdentity(id: introSectionItems.count, component: AnyComponent(Rectangle(color: .clear, height: 346.0, tag: self.introPlaceholderTag))))
introSectionItems.append(AnyComponentWithIdentity(id: introSectionItems.count, component: AnyComponent(ListMultilineTextFieldItemComponent(
@@ -572,7 +589,8 @@ final class BusinessIntroSetupScreenComponent: Component {
}
}
contentHeight += max(inputHeight, environment.safeInsets.bottom)
let combinedBottomInset = max(inputHeight, environment.safeInsets.bottom)
contentHeight += combinedBottomInset
let previousBounds = self.scrollView.bounds
@@ -596,6 +614,25 @@ final class BusinessIntroSetupScreenComponent: Component {
}
}
if let recenterOnTag = self.recenterOnTag {
self.recenterOnTag = nil
if let targetView = self.introSection.findTaggedView(tag: recenterOnTag) {
let caretRect = targetView.convert(targetView.bounds, to: self.scrollView)
var scrollViewBounds = self.scrollView.bounds
let minButtonDistance: CGFloat = 16.0
if -scrollViewBounds.minY + caretRect.maxY > availableSize.height - combinedBottomInset - minButtonDistance {
scrollViewBounds.origin.y = -(availableSize.height - combinedBottomInset - minButtonDistance - caretRect.maxY)
if scrollViewBounds.origin.y < 0.0 {
scrollViewBounds.origin.y = 0.0
}
}
if self.scrollView.bounds != scrollViewBounds {
transition.setBounds(view: self.scrollView, bounds: scrollViewBounds)
}
}
}
self.topOverscrollLayer.frame = CGRect(origin: CGPoint(x: 0.0, y: -3000.0), size: CGSize(width: availableSize.width, height: 3000.0))
self.updateScrolling(transition: transition)