mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Various fixes
This commit is contained in:
parent
b91019c56e
commit
bd03935b42
@ -102,7 +102,7 @@ func contactContextMenuItems(context: AccountContext, peerId: EnginePeer.Id, con
|
|||||||
context: context,
|
context: context,
|
||||||
account: context.account,
|
account: context.account,
|
||||||
sharedContext: context.sharedContext,
|
sharedContext: context.sharedContext,
|
||||||
text: .markdown(text: "Stories from \(peer.compactDisplayTitle) will now be shown in Chats, not Contacts."),
|
text: .markdown(text: "Stories from **\(peer.compactDisplayTitle)** will now be shown in Chats, not Contacts."),
|
||||||
icon: .peer(peer: peer, isStory: true),
|
icon: .peer(peer: peer, isStory: true),
|
||||||
action: TooltipScreen.Action(
|
action: TooltipScreen.Action(
|
||||||
title: "Undo",
|
title: "Undo",
|
||||||
|
@ -17,6 +17,7 @@ import AsyncDisplayKit
|
|||||||
import AttachmentUI
|
import AttachmentUI
|
||||||
import simd
|
import simd
|
||||||
import VolumeButtons
|
import VolumeButtons
|
||||||
|
import TooltipUI
|
||||||
|
|
||||||
func hasFirstResponder(_ view: UIView) -> Bool {
|
func hasFirstResponder(_ view: UIView) -> Bool {
|
||||||
if view.isFirstResponder {
|
if view.isFirstResponder {
|
||||||
@ -827,7 +828,7 @@ private final class StoryContainerScreenComponent: Component {
|
|||||||
guard let self, let environment = self.environment else {
|
guard let self, let environment = self.environment else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if c is UndoOverlayController {
|
if c is UndoOverlayController || c is TooltipScreen {
|
||||||
environment.controller()?.present(c, in: .current)
|
environment.controller()?.present(c, in: .current)
|
||||||
} else {
|
} else {
|
||||||
environment.controller()?.present(c, in: .window(.root), with: a)
|
environment.controller()?.present(c, in: .window(.root), with: a)
|
||||||
|
@ -31,6 +31,7 @@ import SaveToCameraRoll
|
|||||||
import BundleIconComponent
|
import BundleIconComponent
|
||||||
import PeerListItemComponent
|
import PeerListItemComponent
|
||||||
import PremiumUI
|
import PremiumUI
|
||||||
|
import AttachmentUI
|
||||||
|
|
||||||
public final class StoryItemSetContainerComponent: Component {
|
public final class StoryItemSetContainerComponent: Component {
|
||||||
public final class ExternalState {
|
public final class ExternalState {
|
||||||
@ -755,7 +756,7 @@ public final class StoryItemSetContainerComponent: Component {
|
|||||||
}
|
}
|
||||||
if let navigationController = component.controller()?.navigationController as? NavigationController {
|
if let navigationController = component.controller()?.navigationController as? NavigationController {
|
||||||
let topViewController = navigationController.topViewController
|
let topViewController = navigationController.topViewController
|
||||||
if !(topViewController is StoryContainerScreen) && !(topViewController is MediaEditorScreen) && !(topViewController is ShareWithPeersScreen) {
|
if !(topViewController is StoryContainerScreen) && !(topViewController is MediaEditorScreen) && !(topViewController is ShareWithPeersScreen) && !(topViewController is AttachmentController) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3164,6 +3165,34 @@ public final class StoryItemSetContainerComponent: Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let _ = component.context.engine.peers.updatePeerStoriesHidden(id: component.slice.peer.id, isHidden: !isHidden)
|
let _ = component.context.engine.peers.updatePeerStoriesHidden(id: component.slice.peer.id, isHidden: !isHidden)
|
||||||
|
|
||||||
|
let text = isHidden ? "Stories from **\(component.slice.peer.compactDisplayTitle)** will now be shown in Chats, not Contacts." : "Stories from **\(component.slice.peer.compactDisplayTitle)** will now be shown in Contacts, not Chats."
|
||||||
|
let tooltipScreen = TooltipScreen(
|
||||||
|
context: component.context,
|
||||||
|
account: component.context.account,
|
||||||
|
sharedContext: component.context.sharedContext,
|
||||||
|
text: .markdown(text: text),
|
||||||
|
style: .customBlur(UIColor(rgb: 0x1c1c1c)),
|
||||||
|
icon: .peer(peer: component.slice.peer, isStory: true),
|
||||||
|
action: TooltipScreen.Action(
|
||||||
|
title: "Undo",
|
||||||
|
action: {
|
||||||
|
component.context.engine.peers.updatePeerStoriesHidden(id: component.slice.peer.id, isHidden: isHidden)
|
||||||
|
}
|
||||||
|
),
|
||||||
|
location: .bottom,
|
||||||
|
shouldDismissOnTouch: { _ in return .dismiss(consume: false) }
|
||||||
|
)
|
||||||
|
tooltipScreen.willBecomeDismissed = { [weak self] _ in
|
||||||
|
guard let self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self.sendMessageContext.tooltipScreen = nil
|
||||||
|
self.updateIsProgressPaused()
|
||||||
|
}
|
||||||
|
self.sendMessageContext.tooltipScreen = tooltipScreen
|
||||||
|
self.updateIsProgressPaused()
|
||||||
|
component.controller()?.present(tooltipScreen, in: .current)
|
||||||
})))
|
})))
|
||||||
|
|
||||||
items.append(.action(ContextMenuActionItem(text: "Report", icon: { theme in
|
items.append(.action(ContextMenuActionItem(text: "Report", icon: { theme in
|
||||||
|
@ -157,7 +157,7 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
|
|||||||
action: TooltipScreen.Action? = nil,
|
action: TooltipScreen.Action? = nil,
|
||||||
location: TooltipScreen.Location,
|
location: TooltipScreen.Location,
|
||||||
displayDuration: TooltipScreen.DisplayDuration,
|
displayDuration: TooltipScreen.DisplayDuration,
|
||||||
inset: CGFloat = 13.0,
|
inset: CGFloat = 12.0,
|
||||||
cornerRadius: CGFloat? = nil,
|
cornerRadius: CGFloat? = nil,
|
||||||
shouldDismissOnTouch: @escaping (CGPoint) -> TooltipScreen.DismissOnTouch, requestDismiss: @escaping () -> Void, openActiveTextItem: ((TooltipActiveTextItem, TooltipActiveTextAction) -> Void)?)
|
shouldDismissOnTouch: @escaping (CGPoint) -> TooltipScreen.DismissOnTouch, requestDismiss: @escaping () -> Void, openActiveTextItem: ((TooltipActiveTextItem, TooltipActiveTextAction) -> Void)?)
|
||||||
{
|
{
|
||||||
@ -229,18 +229,31 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
|
|||||||
|
|
||||||
self.arrowContainer = ASDisplayNode()
|
self.arrowContainer = ASDisplayNode()
|
||||||
|
|
||||||
let fontSize: CGFloat
|
var hasArrow = true
|
||||||
if case .top = location {
|
if case .top = location {
|
||||||
|
hasArrow = false
|
||||||
|
} else if case .bottom = location {
|
||||||
|
hasArrow = false
|
||||||
|
}
|
||||||
|
|
||||||
|
let fontSize: CGFloat
|
||||||
|
if !hasArrow {
|
||||||
let backgroundColor: UIColor
|
let backgroundColor: UIColor
|
||||||
if theme.overallDarkAppearance {
|
var enableSaturation = true
|
||||||
backgroundColor = theme.rootController.navigationBar.blurredBackgroundColor
|
if case let .customBlur(color) = style {
|
||||||
|
backgroundColor = color
|
||||||
|
enableSaturation = false
|
||||||
} else {
|
} else {
|
||||||
backgroundColor = UIColor(rgb: 0x000000, alpha: 0.6)
|
if theme.overallDarkAppearance {
|
||||||
|
backgroundColor = theme.rootController.navigationBar.blurredBackgroundColor
|
||||||
|
} else {
|
||||||
|
backgroundColor = UIColor(rgb: 0x000000, alpha: 0.6)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.effectNode = NavigationBackgroundNode(color: backgroundColor)
|
self.effectNode = NavigationBackgroundNode(color: backgroundColor, enableSaturation: enableSaturation)
|
||||||
self.backgroundMaskNode.addSubnode(self.backgroundClipNode)
|
self.backgroundMaskNode.addSubnode(self.backgroundClipNode)
|
||||||
self.backgroundClipNode.clipsToBounds = true
|
self.backgroundClipNode.clipsToBounds = true
|
||||||
if case let .point(_, arrowPosition) = location, case .right = arrowPosition {
|
if case .bottom = location {
|
||||||
self.backgroundClipNode.cornerRadius = 8.5
|
self.backgroundClipNode.cornerRadius = 8.5
|
||||||
} else {
|
} else {
|
||||||
self.backgroundClipNode.cornerRadius = 14.0
|
self.backgroundClipNode.cornerRadius = 14.0
|
||||||
@ -248,7 +261,6 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
|
|||||||
if #available(iOS 13.0, *) {
|
if #available(iOS 13.0, *) {
|
||||||
self.backgroundClipNode.layer.cornerCurve = .continuous
|
self.backgroundClipNode.layer.cornerCurve = .continuous
|
||||||
}
|
}
|
||||||
|
|
||||||
fontSize = 14.0
|
fontSize = 14.0
|
||||||
} else if case let .gradient(leftColor, rightColor) = style {
|
} else if case let .gradient(leftColor, rightColor) = style {
|
||||||
self.gradientNode = ASDisplayNode()
|
self.gradientNode = ASDisplayNode()
|
||||||
@ -545,12 +557,12 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
|
|||||||
switch self.tooltipStyle {
|
switch self.tooltipStyle {
|
||||||
case .default, .gradient, .customBlur:
|
case .default, .gradient, .customBlur:
|
||||||
backgroundHeight = max(animationSize.height, textSize.height) + contentVerticalInset * 2.0
|
backgroundHeight = max(animationSize.height, textSize.height) + contentVerticalInset * 2.0
|
||||||
if self.actionButtonNode != nil {
|
|
||||||
backgroundHeight += 2.0
|
|
||||||
}
|
|
||||||
case .light:
|
case .light:
|
||||||
backgroundHeight = max(28.0, max(animationSize.height, textSize.height) + 4.0 * 2.0)
|
backgroundHeight = max(28.0, max(animationSize.height, textSize.height) + 4.0 * 2.0)
|
||||||
}
|
}
|
||||||
|
if self.actionButtonNode != nil {
|
||||||
|
backgroundHeight += 4.0
|
||||||
|
}
|
||||||
|
|
||||||
var invertArrow = false
|
var invertArrow = false
|
||||||
switch self.location {
|
switch self.location {
|
||||||
@ -587,6 +599,9 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
|
|||||||
case .top:
|
case .top:
|
||||||
let backgroundWidth = containerWidth
|
let backgroundWidth = containerWidth
|
||||||
backgroundFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - backgroundWidth) / 2.0), y: layout.insets(options: [.statusBar]).top + 13.0), size: CGSize(width: backgroundWidth, height: backgroundHeight))
|
backgroundFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - backgroundWidth) / 2.0), y: layout.insets(options: [.statusBar]).top + 13.0), size: CGSize(width: backgroundWidth, height: backgroundHeight))
|
||||||
|
case .bottom:
|
||||||
|
let backgroundWidth = containerWidth
|
||||||
|
backgroundFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - backgroundWidth) / 2.0), y: layout.size.height - layout.insets(options: []).bottom - 12.0 - backgroundHeight), size: CGSize(width: backgroundWidth, height: backgroundHeight))
|
||||||
}
|
}
|
||||||
|
|
||||||
transition.updateFrame(node: self.containerNode, frame: backgroundFrame)
|
transition.updateFrame(node: self.containerNode, frame: backgroundFrame)
|
||||||
@ -756,11 +771,18 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
|
|||||||
|
|
||||||
func animateIn() {
|
func animateIn() {
|
||||||
switch self.location {
|
switch self.location {
|
||||||
case .top:
|
case .top, .bottom:
|
||||||
self.containerNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
self.containerNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||||
self.containerNode.layer.animateScale(from: 0.96, to: 1.0, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring)
|
self.containerNode.layer.animateScale(from: 0.96, to: 1.0, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring)
|
||||||
if let _ = self.validLayout {
|
|
||||||
self.containerNode.layer.animatePosition(from: CGPoint(x: 0.0, y: -13.0 - self.backgroundContainerNode.frame.height), to: CGPoint(), duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring, additive: true)
|
if let _ = self.validLayout, case .top = self.location {
|
||||||
|
let offset: CGFloat
|
||||||
|
if case .top = self.location {
|
||||||
|
offset = -13.0 - self.backgroundContainerNode.frame.height
|
||||||
|
} else {
|
||||||
|
offset = 13.0 + self.backgroundContainerNode.frame.height
|
||||||
|
}
|
||||||
|
self.containerNode.layer.animatePosition(from: CGPoint(x: 0.0, y: offset), to: CGPoint(), duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring, additive: true)
|
||||||
}
|
}
|
||||||
case let .point(_, arrowPosition):
|
case let .point(_, arrowPosition):
|
||||||
self.containerNode.layer.animateSpring(from: NSNumber(value: Float(0.01)), to: NSNumber(value: Float(1.0)), keyPath: "transform.scale", duration: 0.4, damping: 105.0)
|
self.containerNode.layer.animateSpring(from: NSNumber(value: Float(0.01)), to: NSNumber(value: Float(1.0)), keyPath: "transform.scale", duration: 0.4, damping: 105.0)
|
||||||
@ -795,13 +817,19 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
|
|||||||
|
|
||||||
func animateOut(completion: @escaping () -> Void) {
|
func animateOut(completion: @escaping () -> Void) {
|
||||||
switch self.location {
|
switch self.location {
|
||||||
case .top:
|
case .top, .bottom:
|
||||||
self.containerNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { _ in
|
self.containerNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.25, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, removeOnCompletion: false, completion: { _ in
|
||||||
completion()
|
completion()
|
||||||
})
|
})
|
||||||
self.containerNode.layer.animateScale(from: 1.0, to: 0.96, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false)
|
self.containerNode.layer.animateScale(from: 1.0, to: 0.96, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false)
|
||||||
if let _ = self.validLayout {
|
if let _ = self.validLayout, case .top = self.location {
|
||||||
self.containerNode.layer.animatePosition(from: CGPoint(), to: CGPoint(x: 0.0, y: -13.0 - self.backgroundContainerNode.frame.height), duration: 0.3, removeOnCompletion: false, additive: true)
|
let offset: CGFloat
|
||||||
|
if case .top = self.location {
|
||||||
|
offset = -13.0 - self.backgroundContainerNode.frame.height
|
||||||
|
} else {
|
||||||
|
offset = 13.0 + self.backgroundContainerNode.frame.height
|
||||||
|
}
|
||||||
|
self.containerNode.layer.animatePosition(from: CGPoint(), to: CGPoint(x: 0.0, y: offset), duration: 0.3, removeOnCompletion: false, additive: true)
|
||||||
}
|
}
|
||||||
case let .point(_, arrowPosition):
|
case let .point(_, arrowPosition):
|
||||||
self.containerNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { _ in
|
self.containerNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { _ in
|
||||||
@ -875,6 +903,7 @@ public final class TooltipScreen: ViewController {
|
|||||||
public enum Location {
|
public enum Location {
|
||||||
case point(CGRect, ArrowPosition)
|
case point(CGRect, ArrowPosition)
|
||||||
case top
|
case top
|
||||||
|
case bottom
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DisplayDuration {
|
public enum DisplayDuration {
|
||||||
@ -942,7 +971,7 @@ public final class TooltipScreen: ViewController {
|
|||||||
action: TooltipScreen.Action? = nil,
|
action: TooltipScreen.Action? = nil,
|
||||||
location: TooltipScreen.Location,
|
location: TooltipScreen.Location,
|
||||||
displayDuration: DisplayDuration = .default,
|
displayDuration: DisplayDuration = .default,
|
||||||
inset: CGFloat = 13.0,
|
inset: CGFloat = 12.0,
|
||||||
cornerRadius: CGFloat? = nil,
|
cornerRadius: CGFloat? = nil,
|
||||||
shouldDismissOnTouch: @escaping (CGPoint) -> TooltipScreen.DismissOnTouch,
|
shouldDismissOnTouch: @escaping (CGPoint) -> TooltipScreen.DismissOnTouch,
|
||||||
openActiveTextItem: ((TooltipActiveTextItem, TooltipActiveTextAction) -> Void)? = nil
|
openActiveTextItem: ((TooltipActiveTextItem, TooltipActiveTextAction) -> Void)? = nil
|
||||||
|
@ -1374,6 +1374,9 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
|||||||
} else {
|
} else {
|
||||||
self.panelNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
self.panelNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||||
self.panelWrapperNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
self.panelWrapperNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||||
|
|
||||||
|
self.panelNode.layer.animateScale(from: 0.96, to: 1.0, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring)
|
||||||
|
self.panelWrapperNode.layer.animateScale(from: 0.96, to: 1.0, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let iconCheckNode = self.iconCheckNode, self.iconNode != nil {
|
if let iconCheckNode = self.iconCheckNode, self.iconNode != nil {
|
||||||
@ -1403,6 +1406,8 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
|
|||||||
self.panelWrapperNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.25, delay: 0.0, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, removeOnCompletion: false) { _ in
|
self.panelWrapperNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.25, delay: 0.0, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, removeOnCompletion: false) { _ in
|
||||||
completion()
|
completion()
|
||||||
}
|
}
|
||||||
|
self.panelNode.layer.animateScale(from: 1.0, to: 0.96, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false)
|
||||||
|
self.panelWrapperNode.layer.animateScale(from: 1.0, to: 0.96, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func animateOutWithReplacement(completion: @escaping () -> Void) {
|
func animateOutWithReplacement(completion: @escaping () -> Void) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user