Various fixes

This commit is contained in:
Ilya Laktyushin 2023-08-08 22:58:45 +02:00
parent d6923ba451
commit 14fc46a196
5 changed files with 36 additions and 7 deletions

View File

@ -9752,3 +9752,5 @@ Sorry for the inconvenience.";
"StoryList.TooltipStoriesSavedToProfile_1" = "Story archived";
"StoryList.TooltipStoriesSavedToProfile_any" = "%d stories archived.";
"Premium.New" = "NEW";

View File

@ -1738,7 +1738,8 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent {
subtitle: perk.subtitle(strings: strings),
subtitleColor: subtitleColor,
arrowColor: arrowColor,
accentColor: accentColor
accentColor: accentColor,
badge: perk.identifier == "stories" ? strings.Premium_New : nil
)
)
),

View File

@ -413,7 +413,7 @@ final class MediaEditorScreenComponent: Component {
if let view = self.inputPanel.view as? MessageInputPanelComponent.View {
self.nextTransitionUserData = TextFieldComponent.AnimationHint(kind: .textFocusChanged)
if view.isActive {
view.deactivateInput()
view.deactivateInput(force: true)
} else {
self.endEditing(true)
}
@ -743,6 +743,9 @@ final class MediaEditorScreenComponent: Component {
guard let controller = environment.controller() as? MediaEditorScreen else {
return
}
guard controller.checkCaptionLimit() else {
return
}
if controller.isEditingStory {
controller.requestCompletion(animated: true)
} else {
@ -1197,9 +1200,11 @@ final class MediaEditorScreenComponent: Component {
self.deactivateInput()
}
case .text:
let text = self.getInputText()
if text.length > component.context.userLimits.maxStoryCaptionLength {
controller.presentCaptionLimitPremiumSuggestion(isPremium: self.state?.isPremium ?? false)
Queue.mainQueue().after(0.1) {
let text = self.getInputText()
if text.length > component.context.userLimits.maxStoryCaptionLength {
controller.presentCaptionLimitPremiumSuggestion(isPremium: self.state?.isPremium ?? false)
}
}
default:
break
@ -3892,6 +3897,20 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
})
}
}
fileprivate func checkCaptionLimit() -> Bool {
let caption = self.getCaption()
if caption.length > self.context.userLimits.maxStoryCaptionLength {
let _ = (self.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: self.context.account.peerId))
|> deliverOnMainQueue).start(next: { [weak self] peer in
if let self {
self.presentCaptionLimitPremiumSuggestion(isPremium: peer?.isPremium ?? false)
}
})
return false
}
return true
}
private var didComplete = false
func requestCompletion(animated: Bool) {
@ -4346,11 +4365,17 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
if let controller = controller as? TooltipScreen {
controller.dismiss()
}
if let controller = controller as? UndoOverlayController {
controller.dismiss()
}
})
self.forEachController({ controller in
if let controller = controller as? TooltipScreen {
controller.dismiss()
}
if let controller = controller as? UndoOverlayController {
controller.dismiss()
}
if let controller = controller as? SaveProgressScreen {
controller.dismiss()
}

View File

@ -462,8 +462,8 @@ public final class MessageInputPanelComponent: Component {
}
}
public func deactivateInput() {
if self.canDeactivateInput() {
public func deactivateInput(force: Bool = false) {
if self.canDeactivateInput() || force {
if let textFieldView = self.textField.view as? TextFieldComponent.View {
textFieldView.deactivateInput()
}

View File

@ -300,6 +300,7 @@ public final class TextFieldComponent: Component {
}
}
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(kind: .textChanged)))
component.paste(.text)
return false
}