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
1b9e7a43a8
commit
6f60e7c89e
@ -13121,5 +13121,5 @@ Sorry for the inconvenience.";
|
|||||||
"ChatList.Search.TopAppsInfo" = "Which apps are included here? [Learn >]()";
|
"ChatList.Search.TopAppsInfo" = "Which apps are included here? [Learn >]()";
|
||||||
|
|
||||||
"TopApps.Info.Title" = "Top Mini Apps";
|
"TopApps.Info.Title" = "Top Mini Apps";
|
||||||
"TopApps.Info.Text" = "This catalogue ranks mini apps based on their daily revenue, measured in Stars. To be listed, developers must set their main mini app in [@botfather]() (as described [here]()), have over **1,000** daily users, and earn a daily revenue above **1,000** Stars, based on weekly average.";
|
"TopApps.Info.Text" = "This catalogue ranks mini apps based on their daily revenue, measured in Stars. To be listed, developers must set their main mini app in [@botfather]() (as described [here](https://core.telegram.org/bots/webapps#launching-the-main-mini-app)), have over **1,000** daily users, and earn a daily revenue above **1,000** Stars, based on weekly average.";
|
||||||
"TopApps.Info.Done" = "Understood";
|
"TopApps.Info.Done" = "Understood";
|
||||||
|
@ -14,8 +14,8 @@ public final class AlertControllerContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func textAlertController(alertContext: AlertControllerContext, title: String?, text: String, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout = .horizontal, allowInputInset: Bool = true, parseMarkdown: Bool = false, dismissOnOutsideTap: Bool = true) -> AlertController {
|
public func textAlertController(alertContext: AlertControllerContext, title: String?, text: String, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout = .horizontal, allowInputInset: Bool = true, parseMarkdown: Bool = false, dismissOnOutsideTap: Bool = true, linkAction: (([NSAttributedString.Key: Any], Int) -> Void)? = nil) -> AlertController {
|
||||||
let controller = standardTextAlertController(theme: alertContext.theme, title: title, text: text, actions: actions, actionLayout: actionLayout, allowInputInset: allowInputInset, parseMarkdown: parseMarkdown, dismissOnOutsideTap: dismissOnOutsideTap)
|
let controller = standardTextAlertController(theme: alertContext.theme, title: title, text: text, actions: actions, actionLayout: actionLayout, allowInputInset: allowInputInset, parseMarkdown: parseMarkdown, dismissOnOutsideTap: dismissOnOutsideTap, linkAction: linkAction)
|
||||||
let presentationDataDisposable = alertContext.themeSignal.start(next: { [weak controller] theme in
|
let presentationDataDisposable = alertContext.themeSignal.start(next: { [weak controller] theme in
|
||||||
controller?.theme = theme
|
controller?.theme = theme
|
||||||
})
|
})
|
||||||
|
@ -312,6 +312,7 @@ private enum ChatListRecentEntry: Comparable, Identifiable {
|
|||||||
buttonAction: buttonAction,
|
buttonAction: buttonAction,
|
||||||
index: nil,
|
index: nil,
|
||||||
header: header,
|
header: header,
|
||||||
|
alwaysShowLastSeparator: key == .apps,
|
||||||
action: { _ in
|
action: { _ in
|
||||||
if let chatPeer = peer.peer.peers[peer.peer.peerId] {
|
if let chatPeer = peer.peer.peers[peer.peer.peerId] {
|
||||||
peerSelected(EnginePeer(chatPeer), nil, section == .recommendedChannels || section == .popularApps)
|
peerSelected(EnginePeer(chatPeer), nil, section == .recommendedChannels || section == .popularApps)
|
||||||
@ -3832,14 +3833,48 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
|||||||
}, animationCache: strongSelf.animationCache, animationRenderer: strongSelf.animationRenderer, openStories: { peerId, avatarNode in
|
}, animationCache: strongSelf.animationCache, animationRenderer: strongSelf.animationRenderer, openStories: { peerId, avatarNode in
|
||||||
interaction.openStories?(peerId, avatarNode)
|
interaction.openStories?(peerId, avatarNode)
|
||||||
}, openTopAppsInfo: {
|
}, openTopAppsInfo: {
|
||||||
|
var dismissImpl: (() -> Void)?
|
||||||
let alertController = textAlertController(
|
let alertController = textAlertController(
|
||||||
context: context,
|
context: context,
|
||||||
title: presentationData.strings.TopApps_Info_Title,
|
title: presentationData.strings.TopApps_Info_Title,
|
||||||
text: presentationData.strings.TopApps_Info_Text,
|
text: presentationData.strings.TopApps_Info_Text,
|
||||||
actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.TopApps_Info_Done, action: {})],
|
actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.TopApps_Info_Done, action: {})],
|
||||||
parseMarkdown: true
|
parseMarkdown: true,
|
||||||
|
linkAction: { attributes, _ in
|
||||||
|
guard let self, let navigationController = self.navigationController else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dismissImpl?()
|
||||||
|
if let value = attributes[NSAttributedString.Key(rawValue: "URL")] as? String {
|
||||||
|
if !value.isEmpty {
|
||||||
|
context.sharedContext.openExternalUrl(context: context, urlContext: .generic, url: value, forceExternal: false, presentationData: context.sharedContext.currentPresentationData.with { $0 }, navigationController: navigationController, dismissInput: {})
|
||||||
|
} else {
|
||||||
|
let _ = (context.engine.peers.resolvePeerByName(name: "botfather")
|
||||||
|
|> mapToSignal { result -> Signal<EnginePeer?, NoError> in
|
||||||
|
guard case let .result(result) = result else {
|
||||||
|
return .complete()
|
||||||
|
}
|
||||||
|
return .single(result)
|
||||||
|
}
|
||||||
|
|> deliverOnMainQueue).start(next: { [weak navigationController] peer in
|
||||||
|
guard let navigationController, let peer else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(
|
||||||
|
navigationController: navigationController,
|
||||||
|
context: context,
|
||||||
|
chatLocation: .peer(peer),
|
||||||
|
keepStack: .always
|
||||||
|
))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
interaction.present(alertController, nil)
|
interaction.present(alertController, nil)
|
||||||
|
dismissImpl = { [weak alertController] in
|
||||||
|
alertController?.dismissAnimated()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
isChannelsTabExpanded: recentItems.isChannelsTabExpanded,
|
isChannelsTabExpanded: recentItems.isChannelsTabExpanded,
|
||||||
toggleChannelsTabExpanded: {
|
toggleChannelsTabExpanded: {
|
||||||
|
@ -187,6 +187,7 @@ public class ContactsPeerItem: ItemListItem, ListViewItemWithHeader {
|
|||||||
let actionIcon: ContactsPeerItemActionIcon
|
let actionIcon: ContactsPeerItemActionIcon
|
||||||
let buttonAction: ContactsPeerItemButtonAction?
|
let buttonAction: ContactsPeerItemButtonAction?
|
||||||
let searchQuery: String?
|
let searchQuery: String?
|
||||||
|
let alwaysShowLastSeparator: Bool
|
||||||
let action: ((ContactsPeerItemPeer) -> Void)?
|
let action: ((ContactsPeerItemPeer) -> Void)?
|
||||||
let disabledAction: ((ContactsPeerItemPeer) -> Void)?
|
let disabledAction: ((ContactsPeerItemPeer) -> Void)?
|
||||||
let setPeerIdWithRevealedOptions: ((EnginePeer.Id?, EnginePeer.Id?) -> Void)?
|
let setPeerIdWithRevealedOptions: ((EnginePeer.Id?, EnginePeer.Id?) -> Void)?
|
||||||
@ -229,6 +230,7 @@ public class ContactsPeerItem: ItemListItem, ListViewItemWithHeader {
|
|||||||
index: SortIndex?,
|
index: SortIndex?,
|
||||||
header: ListViewItemHeader?,
|
header: ListViewItemHeader?,
|
||||||
searchQuery: String? = nil,
|
searchQuery: String? = nil,
|
||||||
|
alwaysShowLastSeparator: Bool = false,
|
||||||
action: ((ContactsPeerItemPeer) -> Void)?,
|
action: ((ContactsPeerItemPeer) -> Void)?,
|
||||||
disabledAction: ((ContactsPeerItemPeer) -> Void)? = nil,
|
disabledAction: ((ContactsPeerItemPeer) -> Void)? = nil,
|
||||||
setPeerIdWithRevealedOptions: ((EnginePeer.Id?, EnginePeer.Id?) -> Void)? = nil,
|
setPeerIdWithRevealedOptions: ((EnginePeer.Id?, EnginePeer.Id?) -> Void)? = nil,
|
||||||
@ -261,6 +263,7 @@ public class ContactsPeerItem: ItemListItem, ListViewItemWithHeader {
|
|||||||
self.actionIcon = actionIcon
|
self.actionIcon = actionIcon
|
||||||
self.buttonAction = buttonAction
|
self.buttonAction = buttonAction
|
||||||
self.searchQuery = searchQuery
|
self.searchQuery = searchQuery
|
||||||
|
self.alwaysShowLastSeparator = alwaysShowLastSeparator
|
||||||
self.action = action
|
self.action = action
|
||||||
self.disabledAction = disabledAction
|
self.disabledAction = disabledAction
|
||||||
self.setPeerIdWithRevealedOptions = setPeerIdWithRevealedOptions
|
self.setPeerIdWithRevealedOptions = setPeerIdWithRevealedOptions
|
||||||
@ -1675,7 +1678,9 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
|
|||||||
strongSelf.highlightedBackgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -nodeLayout.insets.top - topHighlightInset), size: CGSize(width: nodeLayout.size.width, height: nodeLayout.size.height + topHighlightInset))
|
strongSelf.highlightedBackgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -nodeLayout.insets.top - topHighlightInset), size: CGSize(width: nodeLayout.size.width, height: nodeLayout.size.height + topHighlightInset))
|
||||||
strongSelf.topSeparatorNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -min(nodeLayout.insets.top, separatorHeight)), size: CGSize(width: nodeLayout.contentSize.width, height: separatorHeight))
|
strongSelf.topSeparatorNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -min(nodeLayout.insets.top, separatorHeight)), size: CGSize(width: nodeLayout.contentSize.width, height: separatorHeight))
|
||||||
strongSelf.separatorNode.frame = CGRect(origin: CGPoint(x: leftInset, y: nodeLayout.contentSize.height - separatorHeight), size: CGSize(width: max(0.0, nodeLayout.size.width - leftInset), height: separatorHeight))
|
strongSelf.separatorNode.frame = CGRect(origin: CGPoint(x: leftInset, y: nodeLayout.contentSize.height - separatorHeight), size: CGSize(width: max(0.0, nodeLayout.size.width - leftInset), height: separatorHeight))
|
||||||
|
if !item.alwaysShowLastSeparator {
|
||||||
strongSelf.separatorNode.isHidden = last
|
strongSelf.separatorNode.isHidden = last
|
||||||
|
}
|
||||||
|
|
||||||
if let userPresence = userPresence {
|
if let userPresence = userPresence {
|
||||||
strongSelf.peerPresenceManager?.reset(presence: userPresence)
|
strongSelf.peerPresenceManager?.reset(presence: userPresence)
|
||||||
|
@ -188,7 +188,7 @@ public final class TextAlertContentNode: AlertContentNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(theme: AlertControllerTheme, title: NSAttributedString?, text: NSAttributedString, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout, dismissOnOutsideTap: Bool) {
|
public init(theme: AlertControllerTheme, title: NSAttributedString?, text: NSAttributedString, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout, dismissOnOutsideTap: Bool, linkAction: (([NSAttributedString.Key: Any], Int) -> Void)? = nil) {
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
self.actionLayout = actionLayout
|
self.actionLayout = actionLayout
|
||||||
self._dismissOnOutsideTap = dismissOnOutsideTap
|
self._dismissOnOutsideTap = dismissOnOutsideTap
|
||||||
@ -214,6 +214,15 @@ public final class TextAlertContentNode: AlertContentNode {
|
|||||||
self.textNode.isAccessibilityElement = true
|
self.textNode.isAccessibilityElement = true
|
||||||
self.textNode.accessibilityLabel = text.string
|
self.textNode.accessibilityLabel = text.string
|
||||||
self.textNode.insets = UIEdgeInsets(top: 1.0, left: 1.0, bottom: 1.0, right: 1.0)
|
self.textNode.insets = UIEdgeInsets(top: 1.0, left: 1.0, bottom: 1.0, right: 1.0)
|
||||||
|
self.textNode.tapAttributeAction = linkAction
|
||||||
|
self.textNode.highlightAttributeAction = { attributes in
|
||||||
|
if let _ = attributes[NSAttributedString.Key(rawValue: "URL")] {
|
||||||
|
return NSAttributedString.Key(rawValue: "URL")
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.textNode.linkHighlightColor = theme.accentColor.withMultipliedAlpha(0.1)
|
||||||
if text.length != 0 {
|
if text.length != 0 {
|
||||||
if let paragraphStyle = text.attribute(.paragraphStyle, at: 0, effectiveRange: nil) as? NSParagraphStyle {
|
if let paragraphStyle = text.attribute(.paragraphStyle, at: 0, effectiveRange: nil) as? NSParagraphStyle {
|
||||||
self.textNode.textAlignment = paragraphStyle.alignment
|
self.textNode.textAlignment = paragraphStyle.alignment
|
||||||
@ -450,7 +459,7 @@ public func textAlertController(theme: AlertControllerTheme, title: NSAttributed
|
|||||||
return AlertController(theme: theme, contentNode: TextAlertContentNode(theme: theme, title: title, text: text, actions: actions, actionLayout: actionLayout, dismissOnOutsideTap: dismissOnOutsideTap))
|
return AlertController(theme: theme, contentNode: TextAlertContentNode(theme: theme, title: title, text: text, actions: actions, actionLayout: actionLayout, dismissOnOutsideTap: dismissOnOutsideTap))
|
||||||
}
|
}
|
||||||
|
|
||||||
public func standardTextAlertController(theme: AlertControllerTheme, title: String?, text: String, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout = .horizontal, allowInputInset: Bool = true, parseMarkdown: Bool = false, dismissOnOutsideTap: Bool = true) -> AlertController {
|
public func standardTextAlertController(theme: AlertControllerTheme, title: String?, text: String, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout = .horizontal, allowInputInset: Bool = true, parseMarkdown: Bool = false, dismissOnOutsideTap: Bool = true, linkAction: (([NSAttributedString.Key: Any], Int) -> Void)? = nil) -> AlertController {
|
||||||
var dismissImpl: (() -> Void)?
|
var dismissImpl: (() -> Void)?
|
||||||
let attributedText: NSAttributedString
|
let attributedText: NSAttributedString
|
||||||
if parseMarkdown {
|
if parseMarkdown {
|
||||||
@ -470,7 +479,7 @@ public func standardTextAlertController(theme: AlertControllerTheme, title: Stri
|
|||||||
dismissImpl?()
|
dismissImpl?()
|
||||||
action.action()
|
action.action()
|
||||||
})
|
})
|
||||||
}, actionLayout: actionLayout, dismissOnOutsideTap: dismissOnOutsideTap), allowInputInset: allowInputInset)
|
}, actionLayout: actionLayout, dismissOnOutsideTap: dismissOnOutsideTap, linkAction: linkAction), allowInputInset: allowInputInset)
|
||||||
dismissImpl = { [weak controller] in
|
dismissImpl = { [weak controller] in
|
||||||
controller?.dismissAnimated()
|
controller?.dismissAnimated()
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@ import AccountContext
|
|||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
|
||||||
public func textAlertController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, forceTheme: PresentationTheme? = nil, title: String?, text: String, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout = .horizontal, allowInputInset: Bool = true, parseMarkdown: Bool = false, dismissOnOutsideTap: Bool = true) -> AlertController {
|
public func textAlertController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, forceTheme: PresentationTheme? = nil, title: String?, text: String, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout = .horizontal, allowInputInset: Bool = true, parseMarkdown: Bool = false, dismissOnOutsideTap: Bool = true, linkAction: (([NSAttributedString.Key: Any], Int) -> Void)? = nil) -> AlertController {
|
||||||
return textAlertController(sharedContext: context.sharedContext, updatedPresentationData: updatedPresentationData, forceTheme: forceTheme, title: title, text: text, actions: actions, actionLayout: actionLayout, allowInputInset: allowInputInset, parseMarkdown: parseMarkdown, dismissOnOutsideTap: dismissOnOutsideTap)
|
return textAlertController(sharedContext: context.sharedContext, updatedPresentationData: updatedPresentationData, forceTheme: forceTheme, title: title, text: text, actions: actions, actionLayout: actionLayout, allowInputInset: allowInputInset, parseMarkdown: parseMarkdown, dismissOnOutsideTap: dismissOnOutsideTap, linkAction: linkAction)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func textAlertController(sharedContext: SharedAccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, forceTheme: PresentationTheme? = nil, title: String?, text: String, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout = .horizontal, allowInputInset: Bool = true, parseMarkdown: Bool = false, dismissOnOutsideTap: Bool = true) -> AlertController {
|
public func textAlertController(sharedContext: SharedAccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, forceTheme: PresentationTheme? = nil, title: String?, text: String, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout = .horizontal, allowInputInset: Bool = true, parseMarkdown: Bool = false, dismissOnOutsideTap: Bool = true, linkAction: (([NSAttributedString.Key: Any], Int) -> Void)? = nil) -> AlertController {
|
||||||
var presentationData = updatedPresentationData?.initial ?? sharedContext.currentPresentationData.with { $0 }
|
var presentationData = updatedPresentationData?.initial ?? sharedContext.currentPresentationData.with { $0 }
|
||||||
if let forceTheme = forceTheme {
|
if let forceTheme = forceTheme {
|
||||||
presentationData = presentationData.withUpdated(theme: forceTheme)
|
presentationData = presentationData.withUpdated(theme: forceTheme)
|
||||||
@ -21,7 +21,7 @@ public func textAlertController(sharedContext: SharedAccountContext, updatedPres
|
|||||||
presentationData = presentationData.withUpdated(theme: forceTheme)
|
presentationData = presentationData.withUpdated(theme: forceTheme)
|
||||||
}
|
}
|
||||||
return AlertControllerTheme(presentationData: presentationData)
|
return AlertControllerTheme(presentationData: presentationData)
|
||||||
}), title: title, text: text, actions: actions, actionLayout: actionLayout, allowInputInset: allowInputInset, parseMarkdown: parseMarkdown, dismissOnOutsideTap: dismissOnOutsideTap)
|
}), title: title, text: text, actions: actions, actionLayout: actionLayout, allowInputInset: allowInputInset, parseMarkdown: parseMarkdown, dismissOnOutsideTap: dismissOnOutsideTap, linkAction: linkAction)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func textAlertController(sharedContext: SharedAccountContext, title: String?, text: String, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout = .horizontal, allowInputInset: Bool = true, dismissOnOutsideTap: Bool = true) -> AlertController {
|
public func textAlertController(sharedContext: SharedAccountContext, title: String?, text: String, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout = .horizontal, allowInputInset: Bool = true, dismissOnOutsideTap: Bool = true) -> AlertController {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user