mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
f1753011e1
commit
fcc48b47f5
@ -691,7 +691,14 @@ public class AttachmentController: ViewController {
|
|||||||
|
|
||||||
let insets = layout.insets(options: [.input])
|
let insets = layout.insets(options: [.input])
|
||||||
let masterWidth = min(max(320.0, floor(layout.size.width / 3.0)), floor(layout.size.width / 2.0))
|
let masterWidth = min(max(320.0, floor(layout.size.width / 3.0)), floor(layout.size.width / 2.0))
|
||||||
let position: CGPoint = CGPoint(x: masterWidth - 174.0, y: layout.size.height - size.height - insets.bottom - 40.0)
|
|
||||||
|
let position: CGPoint
|
||||||
|
let positionY = layout.size.height - size.height - insets.bottom - 40.0
|
||||||
|
if let sourceRect = controller.getSourceRect?() {
|
||||||
|
position = CGPoint(x: floor(sourceRect.midX - size.width / 2.0), y: min(positionY, sourceRect.minY - size.height))
|
||||||
|
} else {
|
||||||
|
position = CGPoint(x: masterWidth - 174.0, y: positionY)
|
||||||
|
}
|
||||||
|
|
||||||
if controller.isStandalone {
|
if controller.isStandalone {
|
||||||
var containerY = floorToScreenPixels((layout.size.height - size.height) / 2.0)
|
var containerY = floorToScreenPixels((layout.size.height - size.height) / 2.0)
|
||||||
@ -847,6 +854,8 @@ public class AttachmentController: ViewController {
|
|||||||
|
|
||||||
public var getInputContainerNode: () -> (CGFloat, ASDisplayNode, () -> AttachmentController.InputPanelTransition?)? = { return nil }
|
public var getInputContainerNode: () -> (CGFloat, ASDisplayNode, () -> AttachmentController.InputPanelTransition?)? = { return nil }
|
||||||
|
|
||||||
|
public var getSourceRect: (() -> CGRect?)?
|
||||||
|
|
||||||
public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, chatLocation: ChatLocation, buttons: [AttachmentButtonType], initialButton: AttachmentButtonType = .gallery, fromMenu: Bool = false, makeEntityInputView: @escaping () -> AttachmentTextInputPanelInputView?) {
|
public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, chatLocation: ChatLocation, buttons: [AttachmentButtonType], initialButton: AttachmentButtonType = .gallery, fromMenu: Bool = false, makeEntityInputView: @escaping () -> AttachmentTextInputPanelInputView?) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.updatedPresentationData = updatedPresentationData
|
self.updatedPresentationData = updatedPresentationData
|
||||||
|
@ -1259,7 +1259,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
|||||||
if let undoOverlayController = strongSelf.undoOverlayController {
|
if let undoOverlayController = strongSelf.undoOverlayController {
|
||||||
undoOverlayController.content = .image(image: image ?? UIImage(), text: text)
|
undoOverlayController.content = .image(image: image ?? UIImage(), text: text)
|
||||||
} else {
|
} else {
|
||||||
let undoOverlayController = UndoOverlayController(presentationData: presentationData, content: .image(image: image ?? UIImage(), text: text), elevatedLayout: true, action: { [weak self] action in
|
let undoOverlayController = UndoOverlayController(presentationData: presentationData, content: .image(image: image ?? UIImage(), text: text), elevatedLayout: false, action: { [weak self] action in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -1271,7 +1271,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
strongSelf.present(undoOverlayController, in: .window(.root))
|
strongSelf.present(undoOverlayController, in: .current)
|
||||||
strongSelf.undoOverlayController = undoOverlayController
|
strongSelf.undoOverlayController = undoOverlayController
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1151,7 +1151,7 @@ private final class PremiumGiftScreenComponent: CombinedComponent {
|
|||||||
)
|
)
|
||||||
|
|
||||||
let bottomPanelAlpha: CGFloat
|
let bottomPanelAlpha: CGFloat
|
||||||
if let bottomContentOffset = state.bottomContentOffset {
|
if let bottomContentOffset = state.bottomContentOffset, context.availableSize.width > 320.0 {
|
||||||
bottomPanelAlpha = min(16.0, bottomContentOffset) / 16.0
|
bottomPanelAlpha = min(16.0, bottomContentOffset) / 16.0
|
||||||
} else {
|
} else {
|
||||||
bottomPanelAlpha = 0.0
|
bottomPanelAlpha = 0.0
|
||||||
@ -1205,45 +1205,47 @@ private final class PremiumGiftScreenComponent: CombinedComponent {
|
|||||||
let availableWidth = context.availableSize.width
|
let availableWidth = context.availableSize.width
|
||||||
let sideInsets = sideInset * 2.0 + environment.safeInsets.left + environment.safeInsets.right
|
let sideInsets = sideInset * 2.0 + environment.safeInsets.left + environment.safeInsets.right
|
||||||
|
|
||||||
let termsFont = Font.regular(13.0)
|
if availableWidth > 320.0 {
|
||||||
let termsTextColor = environment.theme.list.freeTextColor
|
let termsFont = Font.regular(13.0)
|
||||||
let termsMarkdownAttributes = MarkdownAttributes(body: MarkdownAttributeSet(font: termsFont, textColor: termsTextColor), bold: MarkdownAttributeSet(font: termsFont, textColor: termsTextColor), link: MarkdownAttributeSet(font: termsFont, textColor: environment.theme.list.itemAccentColor), linkAttribute: { contents in
|
let termsTextColor = environment.theme.list.freeTextColor
|
||||||
return (TelegramTextAttributes.URL, contents)
|
let termsMarkdownAttributes = MarkdownAttributes(body: MarkdownAttributeSet(font: termsFont, textColor: termsTextColor), bold: MarkdownAttributeSet(font: termsFont, textColor: termsTextColor), link: MarkdownAttributeSet(font: termsFont, textColor: environment.theme.list.itemAccentColor), linkAttribute: { contents in
|
||||||
})
|
return (TelegramTextAttributes.URL, contents)
|
||||||
|
})
|
||||||
let termsString: MultilineTextComponent.TextContent = .markdown(
|
|
||||||
text: environment.strings.Premium_Gift_Info,
|
let termsString: MultilineTextComponent.TextContent = .markdown(
|
||||||
attributes: termsMarkdownAttributes
|
text: environment.strings.Premium_Gift_Info,
|
||||||
)
|
attributes: termsMarkdownAttributes
|
||||||
|
)
|
||||||
let termsText = termsText.update(
|
|
||||||
component: MultilineTextComponent(
|
let termsText = termsText.update(
|
||||||
text: termsString,
|
component: MultilineTextComponent(
|
||||||
horizontalAlignment: .center,
|
text: termsString,
|
||||||
maximumNumberOfLines: 0,
|
horizontalAlignment: .center,
|
||||||
lineSpacing: 0.0,
|
maximumNumberOfLines: 0,
|
||||||
highlightColor: environment.theme.list.itemAccentColor.withAlphaComponent(0.3),
|
lineSpacing: 0.0,
|
||||||
highlightAction: { attributes in
|
highlightColor: environment.theme.list.itemAccentColor.withAlphaComponent(0.3),
|
||||||
if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] {
|
highlightAction: { attributes in
|
||||||
return NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)
|
if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] {
|
||||||
} else {
|
return NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)
|
||||||
return nil
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tapAction: { attributes, _ in
|
||||||
|
if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? String {
|
||||||
|
let controller = PremiumIntroScreen(context: accountContext, source: .giftTerms)
|
||||||
|
present(controller)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
),
|
||||||
tapAction: { attributes, _ in
|
environment: {},
|
||||||
if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? String {
|
availableSize: CGSize(width: availableWidth - sideInsets - textSideInset * 2.0, height: .greatestFiniteMagnitude),
|
||||||
let controller = PremiumIntroScreen(context: accountContext, source: .giftTerms)
|
transition: context.transition
|
||||||
present(controller)
|
)
|
||||||
}
|
context.add(termsText
|
||||||
}
|
.position(CGPoint(x: sideInset + environment.safeInsets.left + textSideInset + termsText.size.width / 2.0, y: context.availableSize.height - bottomPanel.size.height - termsText.size.height))
|
||||||
),
|
)
|
||||||
environment: {},
|
}
|
||||||
availableSize: CGSize(width: availableWidth - sideInsets - textSideInset * 2.0, height: .greatestFiniteMagnitude),
|
|
||||||
transition: context.transition
|
|
||||||
)
|
|
||||||
context.add(termsText
|
|
||||||
.position(CGPoint(x: sideInset + environment.safeInsets.left + textSideInset + termsText.size.width / 2.0, y: context.availableSize.height - bottomPanel.size.height - termsText.size.height))
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return context.availableSize
|
return context.availableSize
|
||||||
@ -1311,12 +1313,19 @@ public final class PremiumGiftScreen: ViewControllerComponentContainer {
|
|||||||
if let strongSelf = self, let navigationController = strongSelf.navigationController as? NavigationController {
|
if let strongSelf = self, let navigationController = strongSelf.navigationController as? NavigationController {
|
||||||
var controllers = navigationController.viewControllers
|
var controllers = navigationController.viewControllers
|
||||||
controllers = controllers.filter { !($0 is PeerInfoScreen) && !($0 is PremiumGiftScreen) }
|
controllers = controllers.filter { !($0 is PeerInfoScreen) && !($0 is PremiumGiftScreen) }
|
||||||
|
var foundController = false
|
||||||
for controller in controllers.reversed() {
|
for controller in controllers.reversed() {
|
||||||
if let chatController = controller as? ChatController, case .peer(id: peerId) = chatController.chatLocation {
|
if let chatController = controller as? ChatController, case .peer(id: peerId) = chatController.chatLocation {
|
||||||
chatController.hintPlayNextOutgoingGift()
|
chatController.hintPlayNextOutgoingGift()
|
||||||
|
foundController = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !foundController {
|
||||||
|
let chatController = context.sharedContext.makeChatController(context: context, chatLocation: .peer(id: peerId), subject: nil, botStart: nil, mode: .standard(previewing: false))
|
||||||
|
chatController.hintPlayNextOutgoingGift()
|
||||||
|
controllers.append(chatController)
|
||||||
|
}
|
||||||
navigationController.setViewControllers(controllers, animated: true)
|
navigationController.setViewControllers(controllers, animated: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -646,7 +646,7 @@ class TabBarNode: ASDisplayNode {
|
|||||||
transition.updateFrame(node: self.backgroundNode, frame: CGRect(origin: CGPoint(), size: size))
|
transition.updateFrame(node: self.backgroundNode, frame: CGRect(origin: CGPoint(), size: size))
|
||||||
self.backgroundNode.update(size: size, transition: transition)
|
self.backgroundNode.update(size: size, transition: transition)
|
||||||
|
|
||||||
transition.updateFrame(node: self.separatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: -separatorHeight), size: CGSize(width: size.width, height: separatorHeight)))
|
transition.updateFrame(node: self.separatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: size.width, height: separatorHeight)))
|
||||||
|
|
||||||
let horizontal = !leftInset.isZero
|
let horizontal = !leftInset.isZero
|
||||||
if self.horizontal != horizontal {
|
if self.horizontal != horizontal {
|
||||||
|
@ -408,7 +408,7 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
|
|||||||
|
|
||||||
let rootTabBar = PresentationThemeRootTabBar(
|
let rootTabBar = PresentationThemeRootTabBar(
|
||||||
backgroundColor: rootNavigationBar.blurredBackgroundColor,
|
backgroundColor: rootNavigationBar.blurredBackgroundColor,
|
||||||
separatorColor: UIColor(rgb: 0xa3a3a3),
|
separatorColor: UIColor(rgb: 0xb2b2b2),
|
||||||
iconColor: UIColor(rgb: 0x959595),
|
iconColor: UIColor(rgb: 0x959595),
|
||||||
selectedIconColor: defaultDayAccentColor,
|
selectedIconColor: defaultDayAccentColor,
|
||||||
textColor: UIColor(rgb: 0x959595),
|
textColor: UIColor(rgb: 0x959595),
|
||||||
|
@ -11210,6 +11210,13 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
return EntityInputView(context: strongSelf.context, isDark: false, isSecret: strongSelf.chatLocation.peerId?.namespace == Namespaces.Peer.SecretChat)
|
return EntityInputView(context: strongSelf.context, isDark: false, isSecret: strongSelf.chatLocation.peerId?.namespace == Namespaces.Peer.SecretChat)
|
||||||
})
|
})
|
||||||
|
attachmentController.getSourceRect = { [weak self] in
|
||||||
|
if let strongSelf = self {
|
||||||
|
return strongSelf.chatDisplayNode.frameForAttachmentButton()?.offsetBy(dx: strongSelf.chatDisplayNode.supernode?.frame.minX ?? 0.0, dy: 0.0)
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
attachmentController.requestController = { [weak self, weak attachmentController] type, completion in
|
attachmentController.requestController = { [weak self, weak attachmentController] type, completion in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
|
@ -2504,6 +2504,15 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func frameForMenuButton() -> CGRect? {
|
||||||
|
if let textInputPanelNode = self.textInputPanelNode, self.inputPanelNode === textInputPanelNode {
|
||||||
|
return textInputPanelNode.frameForMenuButton().flatMap {
|
||||||
|
return $0.offsetBy(dx: textInputPanelNode.frame.minX, dy: textInputPanelNode.frame.minY)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func frameForStickersButton() -> CGRect? {
|
func frameForStickersButton() -> CGRect? {
|
||||||
if let textInputPanelNode = self.textInputPanelNode, self.inputPanelNode === textInputPanelNode {
|
if let textInputPanelNode = self.textInputPanelNode, self.inputPanelNode === textInputPanelNode {
|
||||||
return textInputPanelNode.frameForStickersButton().flatMap {
|
return textInputPanelNode.frameForStickersButton().flatMap {
|
||||||
|
@ -3148,6 +3148,13 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func frameForMenuButton() -> CGRect? {
|
||||||
|
if !self.menuButton.alpha.isZero {
|
||||||
|
return self.menuButton.frame
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func frameForInputActionButton() -> CGRect? {
|
func frameForInputActionButton() -> CGRect? {
|
||||||
if !self.actionButtons.alpha.isZero {
|
if !self.actionButtons.alpha.isZero {
|
||||||
if self.actionButtons.micButton.alpha.isZero {
|
if self.actionButtons.micButton.alpha.isZero {
|
||||||
|
@ -4060,7 +4060,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
|||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
||||||
if !user.isDeleted && user.botInfo == nil && !user.flags.contains(.isSupport), let cachedData = data.cachedData as? CachedUserData, !cachedData.premiumGiftOptions.isEmpty {
|
if strongSelf.peerId.namespace == Namespaces.Peer.CloudUser, !user.isDeleted && user.botInfo == nil && !user.flags.contains(.isSupport), let cachedData = data.cachedData as? CachedUserData, !cachedData.premiumGiftOptions.isEmpty {
|
||||||
items.append(.action(ContextMenuActionItem(text: presentationData.strings.PeerInfo_GiftPremium, icon: { theme in
|
items.append(.action(ContextMenuActionItem(text: presentationData.strings.PeerInfo_GiftPremium, icon: { theme in
|
||||||
generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Gift"), color: theme.contextMenu.primaryColor)
|
generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Gift"), color: theme.contextMenu.primaryColor)
|
||||||
}, action: { [weak self] _, f in
|
}, action: { [weak self] _, f in
|
||||||
|
@ -1273,7 +1273,7 @@ private final class WebAppContextReferenceContentSource: ContextReferenceContent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func standaloneWebAppController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, params: WebAppParameters, openUrl: @escaping (String) -> Void, getInputContainerNode: @escaping () -> (CGFloat, ASDisplayNode, () -> AttachmentController.InputPanelTransition?)? = { return nil }, completion: @escaping () -> Void = {}, willDismiss: @escaping () -> Void = {}, didDismiss: @escaping () -> Void = {}, getNavigationController: @escaping () -> NavigationController? = { return nil }) -> ViewController {
|
public func standaloneWebAppController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, params: WebAppParameters, openUrl: @escaping (String) -> Void, getInputContainerNode: @escaping () -> (CGFloat, ASDisplayNode, () -> AttachmentController.InputPanelTransition?)? = { return nil }, completion: @escaping () -> Void = {}, willDismiss: @escaping () -> Void = {}, didDismiss: @escaping () -> Void = {}, getNavigationController: @escaping () -> NavigationController? = { return nil }, getSourceRect: (() -> CGRect?)? = nil) -> ViewController {
|
||||||
let controller = AttachmentController(context: context, updatedPresentationData: updatedPresentationData, chatLocation: .peer(id: params.peerId), buttons: [.standalone], initialButton: .standalone, fromMenu: params.fromMenu, makeEntityInputView: {
|
let controller = AttachmentController(context: context, updatedPresentationData: updatedPresentationData, chatLocation: .peer(id: params.peerId), buttons: [.standalone], initialButton: .standalone, fromMenu: params.fromMenu, makeEntityInputView: {
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -1287,5 +1287,6 @@ public func standaloneWebAppController(context: AccountContext, updatedPresentat
|
|||||||
}
|
}
|
||||||
controller.willDismiss = willDismiss
|
controller.willDismiss = willDismiss
|
||||||
controller.didDismiss = didDismiss
|
controller.didDismiss = didDismiss
|
||||||
|
controller.getSourceRect = getSourceRect
|
||||||
return controller
|
return controller
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user