mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Avatar editor fixes
This commit is contained in:
parent
3f70f73f1c
commit
11d2a68cd1
@ -370,6 +370,7 @@ class StickerPickerScreen: ViewController {
|
|||||||
updateScrollingToItemGroup: { [weak self] in
|
updateScrollingToItemGroup: { [weak self] in
|
||||||
self?.update(isExpanded: true, transition: .animated(duration: 0.4, curve: .spring))
|
self?.update(isExpanded: true, transition: .animated(duration: 0.4, curve: .spring))
|
||||||
},
|
},
|
||||||
|
onScroll: {},
|
||||||
chatPeerId: nil,
|
chatPeerId: nil,
|
||||||
peekBehavior: nil,
|
peekBehavior: nil,
|
||||||
customLayout: nil,
|
customLayout: nil,
|
||||||
@ -447,6 +448,7 @@ class StickerPickerScreen: ViewController {
|
|||||||
updateScrollingToItemGroup: { [weak self] in
|
updateScrollingToItemGroup: { [weak self] in
|
||||||
self?.update(isExpanded: true, transition: .animated(duration: 0.4, curve: .spring))
|
self?.update(isExpanded: true, transition: .animated(duration: 0.4, curve: .spring))
|
||||||
},
|
},
|
||||||
|
onScroll: {},
|
||||||
chatPeerId: nil,
|
chatPeerId: nil,
|
||||||
peekBehavior: nil,
|
peekBehavior: nil,
|
||||||
customLayout: nil,
|
customLayout: nil,
|
||||||
@ -571,6 +573,7 @@ class StickerPickerScreen: ViewController {
|
|||||||
updateScrollingToItemGroup: { [weak self] in
|
updateScrollingToItemGroup: { [weak self] in
|
||||||
self?.update(isExpanded: true, transition: .animated(duration: 0.4, curve: .spring))
|
self?.update(isExpanded: true, transition: .animated(duration: 0.4, curve: .spring))
|
||||||
},
|
},
|
||||||
|
onScroll: {},
|
||||||
chatPeerId: nil,
|
chatPeerId: nil,
|
||||||
peekBehavior: stickerPeekBehavior,
|
peekBehavior: stickerPeekBehavior,
|
||||||
customLayout: nil,
|
customLayout: nil,
|
||||||
|
@ -1513,6 +1513,7 @@ public final class ReactionContextNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
},
|
},
|
||||||
updateScrollingToItemGroup: {
|
updateScrollingToItemGroup: {
|
||||||
},
|
},
|
||||||
|
onScroll: {},
|
||||||
chatPeerId: nil,
|
chatPeerId: nil,
|
||||||
peekBehavior: nil,
|
peekBehavior: nil,
|
||||||
customLayout: emojiContentLayout,
|
customLayout: emojiContentLayout,
|
||||||
|
@ -577,6 +577,12 @@ final class AvatarEditorScreenComponent: Component {
|
|||||||
},
|
},
|
||||||
updateScrollingToItemGroup: {
|
updateScrollingToItemGroup: {
|
||||||
},
|
},
|
||||||
|
onScroll: { [weak self] in
|
||||||
|
if let self, let state = self.state, state.expanded {
|
||||||
|
state.expanded = false
|
||||||
|
state.updated(transition: Transition(animation: .curve(duration: 0.45, curve: .spring)))
|
||||||
|
}
|
||||||
|
},
|
||||||
chatPeerId: nil,
|
chatPeerId: nil,
|
||||||
peekBehavior: nil,
|
peekBehavior: nil,
|
||||||
customLayout: nil,
|
customLayout: nil,
|
||||||
@ -586,18 +592,6 @@ final class AvatarEditorScreenComponent: Component {
|
|||||||
hideBackground: true
|
hideBackground: true
|
||||||
)
|
)
|
||||||
|
|
||||||
// var stickerPeekBehavior: EmojiContentPeekBehaviorImpl?
|
|
||||||
// if let controller = self.controller {
|
|
||||||
// stickerPeekBehavior = EmojiContentPeekBehaviorImpl(
|
|
||||||
// context: controller.context,
|
|
||||||
// interaction: nil,
|
|
||||||
// chatPeerId: nil,
|
|
||||||
// present: { [weak controller] c, a in
|
|
||||||
// controller?.presentInGlobalOverlay(c, with: a)
|
|
||||||
// }
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
|
|
||||||
data.stickers?.inputInteractionHolder.inputInteraction = EmojiPagerContentComponent.InputInteraction(
|
data.stickers?.inputInteractionHolder.inputInteraction = EmojiPagerContentComponent.InputInteraction(
|
||||||
performItemAction: { [weak self] _, item, _, _, _, _ in
|
performItemAction: { [weak self] _, item, _, _, _, _ in
|
||||||
guard let self, let _ = item.itemFile else {
|
guard let self, let _ = item.itemFile else {
|
||||||
@ -707,6 +701,12 @@ final class AvatarEditorScreenComponent: Component {
|
|||||||
},
|
},
|
||||||
updateScrollingToItemGroup: {
|
updateScrollingToItemGroup: {
|
||||||
},
|
},
|
||||||
|
onScroll: { [weak self] in
|
||||||
|
if let self, let state = self.state, state.expanded {
|
||||||
|
state.expanded = false
|
||||||
|
state.updated(transition: Transition(animation: .curve(duration: 0.45, curve: .spring)))
|
||||||
|
}
|
||||||
|
},
|
||||||
chatPeerId: nil,
|
chatPeerId: nil,
|
||||||
peekBehavior: nil,
|
peekBehavior: nil,
|
||||||
customLayout: nil,
|
customLayout: nil,
|
||||||
@ -747,10 +747,12 @@ final class AvatarEditorScreenComponent: Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let backgroundIsBright = UIColor(rgb: state.selectedBackground.colors.first ?? 0).lightness > 0.8
|
||||||
|
|
||||||
let navigationCancelButtonSize = self.navigationCancelButton.update(
|
let navigationCancelButtonSize = self.navigationCancelButton.update(
|
||||||
transition: transition,
|
transition: transition,
|
||||||
component: AnyComponent(Button(
|
component: AnyComponent(Button(
|
||||||
content: AnyComponent(Text(text: environment.strings.Common_Cancel, font: Font.regular(17.0), color: state.expanded ? .white : environment.theme.rootController.navigationBar.accentTextColor)),
|
content: AnyComponent(Text(text: environment.strings.Common_Cancel, font: Font.regular(17.0), color: state.expanded && !backgroundIsBright ? .white : environment.theme.rootController.navigationBar.accentTextColor)),
|
||||||
action: { [weak self] in
|
action: { [weak self] in
|
||||||
guard let self else {
|
guard let self else {
|
||||||
return
|
return
|
||||||
@ -772,7 +774,7 @@ final class AvatarEditorScreenComponent: Component {
|
|||||||
let navigationDoneButtonSize = self.navigationDoneButton.update(
|
let navigationDoneButtonSize = self.navigationDoneButton.update(
|
||||||
transition: transition,
|
transition: transition,
|
||||||
component: AnyComponent(Button(
|
component: AnyComponent(Button(
|
||||||
content: AnyComponent(Text(text: strings.AvatarEditor_Set, font: Font.semibold(17.0), color: state.isSearchActive ? environment.theme.rootController.navigationBar.accentTextColor : .white)),
|
content: AnyComponent(Text(text: strings.AvatarEditor_Set, font: Font.semibold(17.0), color: state.isSearchActive || (state.expanded && backgroundIsBright) ? environment.theme.rootController.navigationBar.accentTextColor : .white)),
|
||||||
action: { [weak self] in
|
action: { [weak self] in
|
||||||
guard let self else {
|
guard let self else {
|
||||||
return
|
return
|
||||||
@ -841,8 +843,13 @@ final class AvatarEditorScreenComponent: Component {
|
|||||||
context: component.context,
|
context: component.context,
|
||||||
background: state.selectedBackground,
|
background: state.selectedBackground,
|
||||||
file: state.selectedFile,
|
file: state.selectedFile,
|
||||||
tapped: { [weak state] in
|
tapped: { [weak state, weak self] in
|
||||||
if let state, !state.editingColor {
|
if let state, !state.editingColor {
|
||||||
|
if let emojiView = self?.keyboardView.findTaggedView(tag: EmojiPagerContentComponent.Tag(id: AnyHashable("emoji"))) as? EmojiPagerContentComponent.View {
|
||||||
|
emojiView.ensureSearchUnfocused()
|
||||||
|
} else if let emojiView = self?.keyboardView.findTaggedView(tag: EmojiPagerContentComponent.Tag(id: AnyHashable("stickers"))) as? EmojiPagerContentComponent.View {
|
||||||
|
emojiView.ensureSearchUnfocused()
|
||||||
|
}
|
||||||
state.expanded = !state.expanded
|
state.expanded = !state.expanded
|
||||||
state.updated(transition: Transition(animation: .curve(duration: 0.35, curve: .spring)))
|
state.updated(transition: Transition(animation: .curve(duration: 0.35, curve: .spring)))
|
||||||
}
|
}
|
||||||
|
@ -1084,6 +1084,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode {
|
|||||||
},
|
},
|
||||||
updateScrollingToItemGroup: {
|
updateScrollingToItemGroup: {
|
||||||
},
|
},
|
||||||
|
onScroll: {},
|
||||||
chatPeerId: chatPeerId,
|
chatPeerId: chatPeerId,
|
||||||
peekBehavior: stickerPeekBehavior,
|
peekBehavior: stickerPeekBehavior,
|
||||||
customLayout: nil,
|
customLayout: nil,
|
||||||
@ -1348,6 +1349,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode {
|
|||||||
},
|
},
|
||||||
updateScrollingToItemGroup: {
|
updateScrollingToItemGroup: {
|
||||||
},
|
},
|
||||||
|
onScroll: {},
|
||||||
chatPeerId: chatPeerId,
|
chatPeerId: chatPeerId,
|
||||||
peekBehavior: stickerPeekBehavior,
|
peekBehavior: stickerPeekBehavior,
|
||||||
customLayout: nil,
|
customLayout: nil,
|
||||||
@ -2168,6 +2170,7 @@ public final class EntityInputView: UIInputView, AttachmentTextInputPanelInputVi
|
|||||||
},
|
},
|
||||||
updateScrollingToItemGroup: {
|
updateScrollingToItemGroup: {
|
||||||
},
|
},
|
||||||
|
onScroll: {},
|
||||||
chatPeerId: nil,
|
chatPeerId: nil,
|
||||||
peekBehavior: nil,
|
peekBehavior: nil,
|
||||||
customLayout: nil,
|
customLayout: nil,
|
||||||
|
@ -610,6 +610,7 @@ public final class EmojiStatusSelectionController: ViewController {
|
|||||||
},
|
},
|
||||||
updateScrollingToItemGroup: {
|
updateScrollingToItemGroup: {
|
||||||
},
|
},
|
||||||
|
onScroll: {},
|
||||||
chatPeerId: nil,
|
chatPeerId: nil,
|
||||||
peekBehavior: nil,
|
peekBehavior: nil,
|
||||||
customLayout: nil,
|
customLayout: nil,
|
||||||
|
@ -2248,6 +2248,7 @@ public final class EmojiPagerContentComponent: Component {
|
|||||||
public let requestUpdate: (Transition) -> Void
|
public let requestUpdate: (Transition) -> Void
|
||||||
public let updateSearchQuery: (EmojiPagerContentComponent.SearchQuery?) -> Void
|
public let updateSearchQuery: (EmojiPagerContentComponent.SearchQuery?) -> Void
|
||||||
public let updateScrollingToItemGroup: () -> Void
|
public let updateScrollingToItemGroup: () -> Void
|
||||||
|
public let onScroll: () -> Void
|
||||||
public let chatPeerId: PeerId?
|
public let chatPeerId: PeerId?
|
||||||
public let peekBehavior: EmojiContentPeekBehavior?
|
public let peekBehavior: EmojiContentPeekBehavior?
|
||||||
public let customLayout: CustomLayout?
|
public let customLayout: CustomLayout?
|
||||||
@ -2271,6 +2272,7 @@ public final class EmojiPagerContentComponent: Component {
|
|||||||
requestUpdate: @escaping (Transition) -> Void,
|
requestUpdate: @escaping (Transition) -> Void,
|
||||||
updateSearchQuery: @escaping (SearchQuery?) -> Void,
|
updateSearchQuery: @escaping (SearchQuery?) -> Void,
|
||||||
updateScrollingToItemGroup: @escaping () -> Void,
|
updateScrollingToItemGroup: @escaping () -> Void,
|
||||||
|
onScroll: @escaping () -> Void,
|
||||||
chatPeerId: PeerId?,
|
chatPeerId: PeerId?,
|
||||||
peekBehavior: EmojiContentPeekBehavior?,
|
peekBehavior: EmojiContentPeekBehavior?,
|
||||||
customLayout: CustomLayout?,
|
customLayout: CustomLayout?,
|
||||||
@ -2293,6 +2295,7 @@ public final class EmojiPagerContentComponent: Component {
|
|||||||
self.requestUpdate = requestUpdate
|
self.requestUpdate = requestUpdate
|
||||||
self.updateSearchQuery = updateSearchQuery
|
self.updateSearchQuery = updateSearchQuery
|
||||||
self.updateScrollingToItemGroup = updateScrollingToItemGroup
|
self.updateScrollingToItemGroup = updateScrollingToItemGroup
|
||||||
|
self.onScroll = onScroll
|
||||||
self.chatPeerId = chatPeerId
|
self.chatPeerId = chatPeerId
|
||||||
self.peekBehavior = peekBehavior
|
self.peekBehavior = peekBehavior
|
||||||
self.customLayout = customLayout
|
self.customLayout = customLayout
|
||||||
@ -5007,6 +5010,14 @@ public final class EmojiPagerContentComponent: Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func ensureSearchUnfocused() {
|
||||||
|
if self.isSearchActivated, let visibleSearchHeader = self.visibleSearchHeader, visibleSearchHeader.currentPresetSearchTerm == nil {
|
||||||
|
self.visibleSearchHeader?.deactivate()
|
||||||
|
} else {
|
||||||
|
self.visibleSearchHeader?.endEditing(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||||
if self.ignoreScrolling {
|
if self.ignoreScrolling {
|
||||||
return
|
return
|
||||||
@ -5019,6 +5030,7 @@ public final class EmojiPagerContentComponent: Component {
|
|||||||
if self.isSearchActivated, let visibleSearchHeader = self.visibleSearchHeader, visibleSearchHeader.currentPresetSearchTerm == nil {
|
if self.isSearchActivated, let visibleSearchHeader = self.visibleSearchHeader, visibleSearchHeader.currentPresetSearchTerm == nil {
|
||||||
self.visibleSearchHeader?.deactivate()
|
self.visibleSearchHeader?.deactivate()
|
||||||
}
|
}
|
||||||
|
self.component?.inputInteractionHolder.inputInteraction?.onScroll()
|
||||||
}
|
}
|
||||||
|
|
||||||
public func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
|
public func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
|
||||||
|
@ -969,6 +969,7 @@ private final class ForumCreateTopicScreenComponent: CombinedComponent {
|
|||||||
},
|
},
|
||||||
updateScrollingToItemGroup: {
|
updateScrollingToItemGroup: {
|
||||||
},
|
},
|
||||||
|
onScroll: {},
|
||||||
chatPeerId: nil,
|
chatPeerId: nil,
|
||||||
peekBehavior: nil,
|
peekBehavior: nil,
|
||||||
customLayout: nil,
|
customLayout: nil,
|
||||||
|
@ -6727,18 +6727,22 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
let isPremium = self.context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: self.context.account.peerId))
|
let isPremium = self.context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: self.context.account.peerId))
|
||||||
|> map { peer -> Bool in
|
|> map { peer -> Bool in
|
||||||
return peer?.isPremium ?? false
|
return peer?.isPremium ?? false
|
||||||
}
|
} |> distinctUntilChanged
|
||||||
self.translationStateDisposable = (combineLatest(
|
|
||||||
queue: .concurrentDefaultQueue(),
|
let isHidden = self.chatDisplayNode.historyNode.cachedPeerDataAndMessages
|
||||||
isPremium,
|
|> map { cachedDataAndMessages -> Bool in
|
||||||
self.chatDisplayNode.historyNode.cachedPeerDataAndMessages
|
|
||||||
) |> mapToSignal { isPremium, cachedDataAndMessages -> Signal<ChatPresentationTranslationState?, NoError> in
|
|
||||||
let (cachedData, _) = cachedDataAndMessages
|
let (cachedData, _) = cachedDataAndMessages
|
||||||
var isHidden = false
|
var isHidden = false
|
||||||
if let cachedData = cachedData as? CachedChannelData, cachedData.flags.contains(.translationHidden) {
|
if let cachedData = cachedData as? CachedChannelData, cachedData.flags.contains(.translationHidden) {
|
||||||
isHidden = true
|
isHidden = true
|
||||||
}
|
}
|
||||||
|
return isHidden
|
||||||
|
} |> distinctUntilChanged
|
||||||
|
self.translationStateDisposable = (combineLatest(
|
||||||
|
queue: .concurrentDefaultQueue(),
|
||||||
|
isPremium,
|
||||||
|
isHidden
|
||||||
|
) |> mapToSignal { isPremium, isHidden -> Signal<ChatPresentationTranslationState?, NoError> in
|
||||||
if isPremium && !isHidden {
|
if isPremium && !isHidden {
|
||||||
return chatTranslationState(context: context, peerId: peerId)
|
return chatTranslationState(context: context, peerId: peerId)
|
||||||
|> map { translationState -> ChatPresentationTranslationState? in
|
|> map { translationState -> ChatPresentationTranslationState? in
|
||||||
|
@ -155,8 +155,11 @@ public func chatTranslationState(context: AccountContext, peerId: EnginePeer.Id)
|
|||||||
var fromLangs: [String: Int] = [:]
|
var fromLangs: [String: Int] = [:]
|
||||||
var count = 0
|
var count = 0
|
||||||
for message in messages {
|
for message in messages {
|
||||||
|
if let _ = URL(string: message.text) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if message.text.count > 10 {
|
if message.text.count > 10 {
|
||||||
let text = String(message.text.prefix(64))
|
let text = String(message.text.prefix(100))
|
||||||
languageRecognizer.processString(text)
|
languageRecognizer.processString(text)
|
||||||
let hypotheses = languageRecognizer.languageHypotheses(withMaximum: 3)
|
let hypotheses = languageRecognizer.languageHypotheses(withMaximum: 3)
|
||||||
languageRecognizer.reset()
|
languageRecognizer.reset()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user