mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge commit 'baad76d260f27d2afc3718087a889c84d82c5d31'
This commit is contained in:
commit
218aca3ef4
@ -150,6 +150,7 @@ public class ItemListInviteRequestItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
private let subtitleNode: TextNode
|
private let subtitleNode: TextNode
|
||||||
private let expandedSubtitleNode: TextNode
|
private let expandedSubtitleNode: TextNode
|
||||||
private let dateNode: TextNode
|
private let dateNode: TextNode
|
||||||
|
private let measureAddNode: TextNode
|
||||||
private let addButton: SolidRoundedButtonNode
|
private let addButton: SolidRoundedButtonNode
|
||||||
private let dismissButton: HighlightableButtonNode
|
private let dismissButton: HighlightableButtonNode
|
||||||
|
|
||||||
@ -208,6 +209,8 @@ public class ItemListInviteRequestItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
self.dateNode.contentMode = .left
|
self.dateNode.contentMode = .left
|
||||||
self.dateNode.contentsScale = UIScreen.main.scale
|
self.dateNode.contentsScale = UIScreen.main.scale
|
||||||
|
|
||||||
|
self.measureAddNode = TextNode()
|
||||||
|
|
||||||
self.addButton = SolidRoundedButtonNode(theme: SolidRoundedButtonTheme(backgroundColor: .black, foregroundColor: .white), fontSize: 15.0, height: 32.0, cornerRadius: 16.0)
|
self.addButton = SolidRoundedButtonNode(theme: SolidRoundedButtonTheme(backgroundColor: .black, foregroundColor: .white), fontSize: 15.0, height: 32.0, cornerRadius: 16.0)
|
||||||
self.dismissButton = HighlightableButtonNode()
|
self.dismissButton = HighlightableButtonNode()
|
||||||
|
|
||||||
@ -514,6 +517,7 @@ public class ItemListInviteRequestItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
let makeSubtitleLayout = TextNode.asyncLayout(self.subtitleNode)
|
let makeSubtitleLayout = TextNode.asyncLayout(self.subtitleNode)
|
||||||
let makeExpandedSubtitleLayout = TextNode.asyncLayout(self.expandedSubtitleNode)
|
let makeExpandedSubtitleLayout = TextNode.asyncLayout(self.expandedSubtitleNode)
|
||||||
let makeDateLayout = TextNode.asyncLayout(self.dateNode)
|
let makeDateLayout = TextNode.asyncLayout(self.dateNode)
|
||||||
|
let makeMeasureAddLayout = TextNode.asyncLayout(self.measureAddNode)
|
||||||
|
|
||||||
let currentItem = self.layoutParams?.0
|
let currentItem = self.layoutParams?.0
|
||||||
|
|
||||||
@ -564,6 +568,10 @@ public class ItemListInviteRequestItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
let (expandedSubtitleLayout, expandedSubtitleApply) = makeExpandedSubtitleLayout(TextNodeLayoutArguments(attributedString: expnadedSubtitleAttributedString, backgroundColor: nil, maximumNumberOfLines: 5, truncationType: .end, constrainedSize: CGSize(width: expandedMaxWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
let (expandedSubtitleLayout, expandedSubtitleApply) = makeExpandedSubtitleLayout(TextNodeLayoutArguments(attributedString: expnadedSubtitleAttributedString, backgroundColor: nil, maximumNumberOfLines: 5, truncationType: .end, constrainedSize: CGSize(width: expandedMaxWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||||
let (dateLayout, dateApply) = makeDateLayout(TextNodeLayoutArguments(attributedString: dateAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - rightInset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
let (dateLayout, dateApply) = makeDateLayout(TextNodeLayoutArguments(attributedString: dateAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - rightInset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||||
|
|
||||||
|
let addButtonTitle = item.isGroup ? item.presentationData.strings.MemberRequests_AddToGroup : item.presentationData.strings.MemberRequests_AddToChannel
|
||||||
|
|
||||||
|
let (measureAddLayout, _) = makeMeasureAddLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: addButtonTitle, font: Font.semibold(15.0), textColor: .black), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - rightInset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||||
|
|
||||||
let titleSpacing: CGFloat = 1.0
|
let titleSpacing: CGFloat = 1.0
|
||||||
|
|
||||||
let minHeight: CGFloat = titleLayout.size.height + verticalInset * 2.0
|
let minHeight: CGFloat = titleLayout.size.height + verticalInset * 2.0
|
||||||
@ -734,17 +742,19 @@ public class ItemListInviteRequestItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
|
|
||||||
strongSelf.highlightedBackgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -UIScreenPixel), size: CGSize(width: params.width, height: contentSize.height + UIScreenPixel + UIScreenPixel))
|
strongSelf.highlightedBackgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -UIScreenPixel), size: CGSize(width: params.width, height: contentSize.height + UIScreenPixel + UIScreenPixel))
|
||||||
|
|
||||||
strongSelf.addButton.title = item.isGroup ? item.presentationData.strings.MemberRequests_AddToGroup : item.presentationData.strings.MemberRequests_AddToChannel
|
strongSelf.addButton.title = addButtonTitle
|
||||||
if let _ = updatedTheme {
|
if let _ = updatedTheme {
|
||||||
strongSelf.addButton.updateTheme(SolidRoundedButtonTheme(theme: item.presentationData.theme))
|
strongSelf.addButton.updateTheme(SolidRoundedButtonTheme(theme: item.presentationData.theme))
|
||||||
}
|
}
|
||||||
strongSelf.dismissButton.setTitle(item.presentationData.strings.MemberRequests_Dismiss, with: Font.bold(15.0), with: item.presentationData.theme.list.itemAccentColor, for: .normal)
|
strongSelf.dismissButton.setTitle(item.presentationData.strings.MemberRequests_Dismiss, with: Font.bold(15.0), with: item.presentationData.theme.list.itemAccentColor, for: .normal)
|
||||||
|
|
||||||
let addHeight = strongSelf.addButton.updateLayout(width: 138.0, transition: .immediate)
|
let addWidth = measureAddLayout.size.width + 10.0
|
||||||
strongSelf.addButton.frame = CGRect(x: leftInset, y: contentSize.height - addHeight - 12.0, width: 138.0, height: addHeight)
|
let addHeight = strongSelf.addButton.updateLayout(width: addWidth, transition: .immediate)
|
||||||
|
let addButtonFrame = CGRect(x: leftInset, y: contentSize.height - addHeight - 12.0, width: addWidth, height: addHeight)
|
||||||
|
strongSelf.addButton.frame = addButtonFrame
|
||||||
|
|
||||||
let dismissSize = strongSelf.dismissButton.measure(layout.size)
|
let dismissSize = strongSelf.dismissButton.measure(layout.size)
|
||||||
strongSelf.dismissButton.frame = CGRect(origin: CGPoint(x: leftInset + 138.0 + 24.0, y: verticalInset + contentSize.height - addHeight - 14.0), size: dismissSize)
|
strongSelf.dismissButton.frame = CGRect(origin: CGPoint(x: leftInset + addWidth + 24.0, y: verticalInset + contentSize.height - addHeight - 14.0), size: dismissSize)
|
||||||
|
|
||||||
if item.importer == nil {
|
if item.importer == nil {
|
||||||
let shimmerNode: ShimmerEffectNode
|
let shimmerNode: ShimmerEffectNode
|
||||||
@ -780,7 +790,7 @@ public class ItemListInviteRequestItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
shapes.append(.roundedRectLine(startPoint: CGPoint(x: dateFrame.maxX - dateLineWidth, y: dateFrame.minY + floor((dateFrame.height - lineDiameter) / 2.0)), width: dateLineWidth, diameter: lineDiameter))
|
shapes.append(.roundedRectLine(startPoint: CGPoint(x: dateFrame.maxX - dateLineWidth, y: dateFrame.minY + floor((dateFrame.height - lineDiameter) / 2.0)), width: dateLineWidth, diameter: lineDiameter))
|
||||||
|
|
||||||
let addFrame = strongSelf.addButton.frame
|
let addFrame = strongSelf.addButton.frame
|
||||||
shapes.append(.roundedRectLine(startPoint: CGPoint(x: addFrame.minX, y: addFrame.minY + floor((addFrame.height - strongSelf.addButton.frame.height) / 2.0)), width: strongSelf.addButton.frame.width, diameter: strongSelf.addButton.frame.height))
|
shapes.append(.roundedRectLine(startPoint: CGPoint(x: addFrame.minX, y: addFrame.minY + floor((addFrame.height - addFrame.height) / 2.0)), width: addFrame.width, diameter: addFrame.height))
|
||||||
|
|
||||||
let dismissFrame = strongSelf.dismissButton.frame
|
let dismissFrame = strongSelf.dismissButton.frame
|
||||||
shapes.append(.roundedRectLine(startPoint: CGPoint(x: dismissFrame.minX, y: dismissFrame.minY + floor((dismissFrame.height - lineDiameter) / 2.0)), width: 60.0, diameter: lineDiameter))
|
shapes.append(.roundedRectLine(startPoint: CGPoint(x: dismissFrame.minX, y: dismissFrame.minY + floor((dismissFrame.height - lineDiameter) / 2.0)), width: 60.0, diameter: lineDiameter))
|
||||||
|
@ -6,7 +6,7 @@ import AccountContext
|
|||||||
import OverlayStatusController
|
import OverlayStatusController
|
||||||
import UrlWhitelist
|
import UrlWhitelist
|
||||||
|
|
||||||
public func openUserGeneratedUrl(context: AccountContext, peerId: PeerId?, url: String, concealed: Bool, skipUrlAuth: Bool = false, present: @escaping (ViewController) -> Void, openResolved: @escaping (ResolvedUrl) -> Void) {
|
public func openUserGeneratedUrl(context: AccountContext, peerId: PeerId?, url: String, concealed: Bool, skipUrlAuth: Bool = false, skipConcealedAlert: Bool = false, present: @escaping (ViewController) -> Void, openResolved: @escaping (ResolvedUrl) -> Void) {
|
||||||
var concealed = concealed
|
var concealed = concealed
|
||||||
|
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
@ -47,7 +47,7 @@ public func openUserGeneratedUrl(context: AccountContext, peerId: PeerId?, url:
|
|||||||
let (parsedString, parsedConcealed) = parseUrl(url: url, wasConcealed: concealed)
|
let (parsedString, parsedConcealed) = parseUrl(url: url, wasConcealed: concealed)
|
||||||
concealed = parsedConcealed
|
concealed = parsedConcealed
|
||||||
|
|
||||||
if concealed {
|
if concealed && !skipConcealedAlert {
|
||||||
var rawDisplayUrl: String = parsedString
|
var rawDisplayUrl: String = parsedString
|
||||||
let maxLength = 180
|
let maxLength = 180
|
||||||
if rawDisplayUrl.count > maxLength {
|
if rawDisplayUrl.count > maxLength {
|
||||||
|
@ -24,6 +24,8 @@ private struct ThemeCarouselThemeEntry: Comparable, Identifiable {
|
|||||||
let emojiFile: TelegramMediaFile?
|
let emojiFile: TelegramMediaFile?
|
||||||
let themeReference: PresentationThemeReference
|
let themeReference: PresentationThemeReference
|
||||||
let nightMode: Bool
|
let nightMode: Bool
|
||||||
|
let themeSpecificAccentColors: [Int64: PresentationThemeAccentColor]
|
||||||
|
let themeSpecificChatWallpapers: [Int64: TelegramWallpaper]
|
||||||
var selected: Bool
|
var selected: Bool
|
||||||
let theme: PresentationTheme
|
let theme: PresentationTheme
|
||||||
let strings: PresentationStrings
|
let strings: PresentationStrings
|
||||||
@ -43,6 +45,12 @@ private struct ThemeCarouselThemeEntry: Comparable, Identifiable {
|
|||||||
if lhs.nightMode != rhs.nightMode {
|
if lhs.nightMode != rhs.nightMode {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if lhs.themeSpecificAccentColors != rhs.themeSpecificAccentColors {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if lhs.themeSpecificChatWallpapers != rhs.themeSpecificChatWallpapers {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if lhs.selected != rhs.selected {
|
if lhs.selected != rhs.selected {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -63,7 +71,7 @@ private struct ThemeCarouselThemeEntry: Comparable, Identifiable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func item(context: AccountContext, action: @escaping (PresentationThemeReference) -> Void, contextAction: ((PresentationThemeReference, ASDisplayNode, ContextGesture?) -> Void)?) -> ListViewItem {
|
func item(context: AccountContext, action: @escaping (PresentationThemeReference) -> Void, contextAction: ((PresentationThemeReference, ASDisplayNode, ContextGesture?) -> Void)?) -> ListViewItem {
|
||||||
return ThemeCarouselThemeIconItem(context: context, emojiFile: self.emojiFile, themeReference: self.themeReference, nightMode: self.nightMode, selected: self.selected, theme: self.theme, strings: self.strings, wallpaper: self.wallpaper, action: action, contextAction: contextAction)
|
return ThemeCarouselThemeIconItem(context: context, emojiFile: self.emojiFile, themeReference: self.themeReference, nightMode: self.nightMode, themeSpecificAccentColors: self.themeSpecificAccentColors, themeSpecificChatWallpapers: self.themeSpecificChatWallpapers, selected: self.selected, theme: self.theme, strings: self.strings, wallpaper: self.wallpaper, action: action, contextAction: contextAction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,6 +81,8 @@ class ThemeCarouselThemeIconItem: ListViewItem {
|
|||||||
let emojiFile: TelegramMediaFile?
|
let emojiFile: TelegramMediaFile?
|
||||||
let themeReference: PresentationThemeReference
|
let themeReference: PresentationThemeReference
|
||||||
let nightMode: Bool
|
let nightMode: Bool
|
||||||
|
let themeSpecificAccentColors: [Int64: PresentationThemeAccentColor]
|
||||||
|
let themeSpecificChatWallpapers: [Int64: TelegramWallpaper]
|
||||||
let selected: Bool
|
let selected: Bool
|
||||||
let theme: PresentationTheme
|
let theme: PresentationTheme
|
||||||
let strings: PresentationStrings
|
let strings: PresentationStrings
|
||||||
@ -80,11 +90,13 @@ class ThemeCarouselThemeIconItem: ListViewItem {
|
|||||||
let action: (PresentationThemeReference) -> Void
|
let action: (PresentationThemeReference) -> Void
|
||||||
let contextAction: ((PresentationThemeReference, ASDisplayNode, ContextGesture?) -> Void)?
|
let contextAction: ((PresentationThemeReference, ASDisplayNode, ContextGesture?) -> Void)?
|
||||||
|
|
||||||
public init(context: AccountContext, emojiFile: TelegramMediaFile?, themeReference: PresentationThemeReference, nightMode: Bool, selected: Bool, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper?, action: @escaping (PresentationThemeReference) -> Void, contextAction: ((PresentationThemeReference, ASDisplayNode, ContextGesture?) -> Void)?) {
|
public init(context: AccountContext, emojiFile: TelegramMediaFile?, themeReference: PresentationThemeReference, nightMode: Bool, themeSpecificAccentColors: [Int64: PresentationThemeAccentColor], themeSpecificChatWallpapers: [Int64: TelegramWallpaper], selected: Bool, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper?, action: @escaping (PresentationThemeReference) -> Void, contextAction: ((PresentationThemeReference, ASDisplayNode, ContextGesture?) -> Void)?) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.emojiFile = emojiFile
|
self.emojiFile = emojiFile
|
||||||
self.themeReference = themeReference
|
self.themeReference = themeReference
|
||||||
self.nightMode = nightMode
|
self.nightMode = nightMode
|
||||||
|
self.themeSpecificAccentColors = themeSpecificAccentColors
|
||||||
|
self.themeSpecificChatWallpapers = themeSpecificChatWallpapers
|
||||||
self.selected = selected
|
self.selected = selected
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
self.strings = strings
|
self.strings = strings
|
||||||
@ -175,30 +187,6 @@ private func generateBorderImage(theme: PresentationTheme, bordered: Bool, selec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func createThemeImage(theme: PresentationTheme) -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> {
|
|
||||||
return .single(theme)
|
|
||||||
|> map { theme -> (TransformImageArguments) -> DrawingContext? in
|
|
||||||
return { arguments in
|
|
||||||
let context = DrawingContext(size: arguments.drawingSize, scale: arguments.scale ?? 0.0, clear: true)
|
|
||||||
let drawingRect = arguments.drawingRect
|
|
||||||
|
|
||||||
context.withContext { c in
|
|
||||||
c.clear(CGRect(origin: CGPoint(), size: drawingRect.size))
|
|
||||||
|
|
||||||
c.translateBy(x: drawingRect.width / 2.0, y: drawingRect.height / 2.0)
|
|
||||||
c.scaleBy(x: 1.0, y: -1.0)
|
|
||||||
c.translateBy(x: -drawingRect.width / 2.0, y: -drawingRect.height / 2.0)
|
|
||||||
|
|
||||||
if let icon = generateTintedImage(image: UIImage(bundleImageName: "Settings/CreateThemeIcon"), color: theme.list.itemAccentColor) {
|
|
||||||
c.draw(icon.cgImage!, in: CGRect(origin: CGPoint(x: floor((drawingRect.width - icon.size.width) / 2.0) - 3.0, y: floor((drawingRect.height - icon.size.height) / 2.0)), size: icon.size))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addCorners(context, arguments: arguments)
|
|
||||||
return context
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private final class ThemeCarouselThemeItemIconNode : ListViewItemNode {
|
private final class ThemeCarouselThemeItemIconNode : ListViewItemNode {
|
||||||
private let containerNode: ASDisplayNode
|
private let containerNode: ASDisplayNode
|
||||||
@ -379,7 +367,11 @@ private final class ThemeCarouselThemeItemIconNode : ListViewItemNode {
|
|||||||
if case .builtin = themeReference, item.nightMode {
|
if case .builtin = themeReference, item.nightMode {
|
||||||
themeReference = .builtin(.night)
|
themeReference = .builtin(.night)
|
||||||
}
|
}
|
||||||
strongSelf.imageNode.setSignal(themeIconImage(account: item.context.account, accountManager: item.context.sharedContext.accountManager, theme: themeReference, color: nil, wallpaper: item.wallpaper, nightMode: item.nightMode, emoticon: true))
|
|
||||||
|
let color = item.themeSpecificAccentColors[themeReference.index]
|
||||||
|
let wallpaper = item.themeSpecificChatWallpapers[themeReference.index]
|
||||||
|
|
||||||
|
strongSelf.imageNode.setSignal(themeIconImage(account: item.context.account, accountManager: item.context.sharedContext.accountManager, theme: themeReference, color: color, wallpaper: wallpaper ?? item.wallpaper, nightMode: item.nightMode, emoticon: true))
|
||||||
strongSelf.imageNode.backgroundColor = nil
|
strongSelf.imageNode.backgroundColor = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -768,12 +760,12 @@ class ThemeCarouselThemeItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
hasCurrentTheme = true
|
hasCurrentTheme = true
|
||||||
}
|
}
|
||||||
let emojiFile = theme.emoticon.flatMap { item.animatedEmojiStickers[$0]?.first?.file }
|
let emojiFile = theme.emoticon.flatMap { item.animatedEmojiStickers[$0]?.first?.file }
|
||||||
entries.append(ThemeCarouselThemeEntry(index: index, emojiFile: emojiFile, themeReference: theme, nightMode: item.nightMode, selected: selected, theme: item.theme, strings: item.strings, wallpaper: nil))
|
entries.append(ThemeCarouselThemeEntry(index: index, emojiFile: emojiFile, themeReference: theme, nightMode: item.nightMode, themeSpecificAccentColors: item.themeSpecificAccentColors, themeSpecificChatWallpapers: item.themeSpecificChatWallpapers, selected: selected, theme: item.theme, strings: item.strings, wallpaper: nil))
|
||||||
index += 1
|
index += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if !hasCurrentTheme {
|
if !hasCurrentTheme {
|
||||||
entries.append(ThemeCarouselThemeEntry(index: index, emojiFile: nil, themeReference: item.currentTheme, nightMode: false, selected: true, theme: item.theme, strings: item.strings, wallpaper: nil))
|
entries.append(ThemeCarouselThemeEntry(index: index, emojiFile: nil, themeReference: item.currentTheme, nightMode: false, themeSpecificAccentColors: item.themeSpecificAccentColors, themeSpecificChatWallpapers: item.themeSpecificChatWallpapers, selected: true, theme: item.theme, strings: item.strings, wallpaper: nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
let action: (PresentationThemeReference) -> Void = { [weak self] themeReference in
|
let action: (PresentationThemeReference) -> Void = { [weak self] themeReference in
|
||||||
|
@ -23,7 +23,7 @@ import AnimationUI
|
|||||||
private final class ThemePickerControllerArguments {
|
private final class ThemePickerControllerArguments {
|
||||||
let context: AccountContext
|
let context: AccountContext
|
||||||
let selectTheme: (TelegramBaseTheme?, PresentationThemeReference, Bool) -> Void
|
let selectTheme: (TelegramBaseTheme?, PresentationThemeReference, Bool) -> Void
|
||||||
let previewTheme: (PresentationThemeReference, Bool, Bool) -> Void
|
let previewTheme: (PresentationThemeReference, Bool, Bool, [Int64: PresentationThemeAccentColor]) -> Void
|
||||||
let selectAccentColor: (TelegramBaseTheme?, PresentationThemeAccentColor?) -> Void
|
let selectAccentColor: (TelegramBaseTheme?, PresentationThemeAccentColor?) -> Void
|
||||||
let openAccentColorPicker: (PresentationThemeReference, Bool) -> Void
|
let openAccentColorPicker: (PresentationThemeReference, Bool) -> Void
|
||||||
let editTheme: (PresentationCloudTheme) -> Void
|
let editTheme: (PresentationCloudTheme) -> Void
|
||||||
@ -32,7 +32,7 @@ private final class ThemePickerControllerArguments {
|
|||||||
let themeContextAction: (Bool, PresentationThemeReference, ASDisplayNode, ContextGesture?) -> Void
|
let themeContextAction: (Bool, PresentationThemeReference, ASDisplayNode, ContextGesture?) -> Void
|
||||||
let colorContextAction: (Bool, PresentationThemeReference, ThemeSettingsColorOption?, ASDisplayNode, ContextGesture?) -> Void
|
let colorContextAction: (Bool, PresentationThemeReference, ThemeSettingsColorOption?, ASDisplayNode, ContextGesture?) -> Void
|
||||||
|
|
||||||
init(context: AccountContext, selectTheme: @escaping (TelegramBaseTheme?, PresentationThemeReference, Bool) -> Void, previewTheme: @escaping (PresentationThemeReference, Bool, Bool) -> Void, selectAccentColor: @escaping (TelegramBaseTheme?, PresentationThemeAccentColor?) -> Void, openAccentColorPicker: @escaping (PresentationThemeReference, Bool) -> Void, editTheme: @escaping (PresentationCloudTheme) -> Void, editCurrentTheme: @escaping () -> Void, createNewTheme: @escaping () -> Void, themeContextAction: @escaping (Bool, PresentationThemeReference, ASDisplayNode, ContextGesture?) -> Void, colorContextAction: @escaping (Bool, PresentationThemeReference, ThemeSettingsColorOption?, ASDisplayNode, ContextGesture?) -> Void) {
|
init(context: AccountContext, selectTheme: @escaping (TelegramBaseTheme?, PresentationThemeReference, Bool) -> Void, previewTheme: @escaping (PresentationThemeReference, Bool, Bool, [Int64: PresentationThemeAccentColor]) -> Void, selectAccentColor: @escaping (TelegramBaseTheme?, PresentationThemeAccentColor?) -> Void, openAccentColorPicker: @escaping (PresentationThemeReference, Bool) -> Void, editTheme: @escaping (PresentationCloudTheme) -> Void, editCurrentTheme: @escaping () -> Void, createNewTheme: @escaping () -> Void, themeContextAction: @escaping (Bool, PresentationThemeReference, ASDisplayNode, ContextGesture?) -> Void, colorContextAction: @escaping (Bool, PresentationThemeReference, ThemeSettingsColorOption?, ASDisplayNode, ContextGesture?) -> Void) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.selectTheme = selectTheme
|
self.selectTheme = selectTheme
|
||||||
self.previewTheme = previewTheme
|
self.previewTheme = previewTheme
|
||||||
@ -54,7 +54,7 @@ private enum ThemePickerControllerSection: Int32 {
|
|||||||
|
|
||||||
private enum ThemePickerControllerEntry: ItemListNodeEntry {
|
private enum ThemePickerControllerEntry: ItemListNodeEntry {
|
||||||
case themesHeader(PresentationTheme, String)
|
case themesHeader(PresentationTheme, String)
|
||||||
case themes(PresentationTheme, PresentationStrings, [PresentationThemeReference], PresentationThemeReference, Bool, [String: [StickerPackItem]])
|
case themes(PresentationTheme, PresentationStrings, [PresentationThemeReference], PresentationThemeReference, Bool, [String: [StickerPackItem]], [Int64: PresentationThemeAccentColor], [Int64: TelegramWallpaper])
|
||||||
case customHeader(PresentationTheme, String)
|
case customHeader(PresentationTheme, String)
|
||||||
case chatPreview(PresentationTheme, TelegramWallpaper, PresentationFontSize, PresentationChatBubbleCorners, PresentationStrings, PresentationDateTimeFormat, PresentationPersonNameOrder, [ChatPreviewMessageItem])
|
case chatPreview(PresentationTheme, TelegramWallpaper, PresentationFontSize, PresentationChatBubbleCorners, PresentationStrings, PresentationDateTimeFormat, PresentationPersonNameOrder, [ChatPreviewMessageItem])
|
||||||
case theme(PresentationTheme, PresentationStrings, [PresentationThemeReference], [PresentationThemeReference], PresentationThemeReference, [Int64: PresentationThemeAccentColor], [Int64: TelegramWallpaper], PresentationThemeAccentColor?, [Int64: TelegramBaseTheme])
|
case theme(PresentationTheme, PresentationStrings, [PresentationThemeReference], [PresentationThemeReference], PresentationThemeReference, [Int64: PresentationThemeAccentColor], [Int64: TelegramWallpaper], PresentationThemeAccentColor?, [Int64: TelegramBaseTheme])
|
||||||
@ -102,8 +102,8 @@ private enum ThemePickerControllerEntry: ItemListNodeEntry {
|
|||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
case let .themes(lhsTheme, lhsStrings, lhsThemes, lhsCurrentTheme, lhsNightMode, lhsAnimatedEmojiStickers):
|
case let .themes(lhsTheme, lhsStrings, lhsThemes, lhsCurrentTheme, lhsNightMode, lhsAnimatedEmojiStickers, lhsThemeAccentColors, lhsThemeSpecificChatWallpapers):
|
||||||
if case let .themes(rhsTheme, rhsStrings, rhsThemes, rhsCurrentTheme, rhsNightMode, rhsAnimatedEmojiStickers) = rhs, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsThemes == rhsThemes, lhsCurrentTheme == rhsCurrentTheme, lhsNightMode == rhsNightMode, lhsAnimatedEmojiStickers == rhsAnimatedEmojiStickers {
|
if case let .themes(rhsTheme, rhsStrings, rhsThemes, rhsCurrentTheme, rhsNightMode, rhsAnimatedEmojiStickers, rhsThemeAccentColors, rhsThemeSpecificChatWallpapers) = rhs, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsThemes == rhsThemes, lhsCurrentTheme == rhsCurrentTheme, lhsNightMode == rhsNightMode, lhsAnimatedEmojiStickers == rhsAnimatedEmojiStickers, lhsThemeAccentColors == rhsThemeAccentColors, lhsThemeSpecificChatWallpapers == rhsThemeSpecificChatWallpapers {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
@ -156,9 +156,9 @@ private enum ThemePickerControllerEntry: ItemListNodeEntry {
|
|||||||
switch self {
|
switch self {
|
||||||
case let .themesHeader(_, text):
|
case let .themesHeader(_, text):
|
||||||
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
|
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
|
||||||
case let .themes(theme, strings, themes, currentTheme, nightMode, animatedEmojiStickers):
|
case let .themes(theme, strings, themes, currentTheme, nightMode, animatedEmojiStickers, themeSpecificAccentColors, themeSpecificChatWallpapers):
|
||||||
return ThemeGridThemeItem(context: arguments.context, theme: theme, strings: strings, sectionId: self.section, themes: themes, animatedEmojiStickers: animatedEmojiStickers, themeSpecificAccentColors: [:], themeSpecificChatWallpapers: [:], nightMode: nightMode, currentTheme: currentTheme, updatedTheme: { theme in
|
return ThemeGridThemeItem(context: arguments.context, theme: theme, strings: strings, sectionId: self.section, themes: themes, animatedEmojiStickers: animatedEmojiStickers, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, nightMode: nightMode, currentTheme: currentTheme, updatedTheme: { theme in
|
||||||
arguments.previewTheme(theme, nightMode, true)
|
arguments.previewTheme(theme, nightMode, true, themeSpecificAccentColors)
|
||||||
}, contextAction: { theme, node, gesture in
|
}, contextAction: { theme, node, gesture in
|
||||||
arguments.themeContextAction(false, theme, node, gesture)
|
arguments.themeContextAction(false, theme, node, gesture)
|
||||||
}, tag: nil)
|
}, tag: nil)
|
||||||
@ -286,7 +286,7 @@ private func themePickerControllerEntries(presentationData: PresentationData, pr
|
|||||||
var entries: [ThemePickerControllerEntry] = []
|
var entries: [ThemePickerControllerEntry] = []
|
||||||
|
|
||||||
entries.append(.themesHeader(presentationData.theme, presentationData.strings.Themes_SelectTheme.uppercased()))
|
entries.append(.themesHeader(presentationData.theme, presentationData.strings.Themes_SelectTheme.uppercased()))
|
||||||
entries.append(.themes(presentationData.theme, presentationData.strings, chatThemes, themeReference, nightMode, animatedEmojiStickers))
|
entries.append(.themes(presentationData.theme, presentationData.strings, chatThemes, themeReference, nightMode, animatedEmojiStickers, presentationThemeSettings.themeSpecificAccentColors, presentationThemeSettings.themeSpecificChatWallpapers))
|
||||||
|
|
||||||
entries.append(.customHeader(presentationData.theme, presentationData.strings.Themes_BuildOwn.uppercased()))
|
entries.append(.customHeader(presentationData.theme, presentationData.strings.Themes_BuildOwn.uppercased()))
|
||||||
entries.append(.chatPreview(presentationData.theme, presentationData.chatWallpaper, presentationData.chatFontSize, presentationData.chatBubbleCorners, presentationData.strings, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, [ChatPreviewMessageItem(outgoing: false, reply: (presentationData.strings.Appearance_PreviewReplyAuthor, presentationData.strings.Appearance_PreviewReplyText), text: presentationData.strings.Appearance_PreviewIncomingText), ChatPreviewMessageItem(outgoing: true, reply: nil, text: presentationData.strings.Appearance_PreviewOutgoingText)]))
|
entries.append(.chatPreview(presentationData.theme, presentationData.chatWallpaper, presentationData.chatFontSize, presentationData.chatBubbleCorners, presentationData.strings, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, [ChatPreviewMessageItem(outgoing: false, reply: (presentationData.strings.Appearance_PreviewReplyAuthor, presentationData.strings.Appearance_PreviewReplyText), text: presentationData.strings.Appearance_PreviewIncomingText), ChatPreviewMessageItem(outgoing: true, reply: nil, text: presentationData.strings.Appearance_PreviewOutgoingText)]))
|
||||||
@ -395,12 +395,17 @@ public func themePickerController(context: AccountContext, focusOnItemTag: Theme
|
|||||||
|
|
||||||
let arguments = ThemePickerControllerArguments(context: context, selectTheme: { baseTheme, theme, preset in
|
let arguments = ThemePickerControllerArguments(context: context, selectTheme: { baseTheme, theme, preset in
|
||||||
selectThemeImpl?(baseTheme, theme, preset)
|
selectThemeImpl?(baseTheme, theme, preset)
|
||||||
}, previewTheme: { themeReference, nightMode, custom in
|
}, previewTheme: { initialThemeReference, nightMode, custom, themeSpecificAccentColors in
|
||||||
if let theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: themeReference, baseTheme: nightMode ? .night : .classic ) {
|
var themeReference = initialThemeReference
|
||||||
|
if nightMode, case .builtin(.dayClassic) = themeReference {
|
||||||
|
themeReference = .builtin(.night)
|
||||||
|
}
|
||||||
|
let themeSpecificColor = themeSpecificAccentColors[themeReference.index]
|
||||||
|
if let theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: themeReference, baseTheme: nightMode ? .night : .classic, accentColor: themeSpecificColor?.accentColor.flatMap { UIColor(rgb: $0) }, bubbleColors: themeSpecificColor?.bubbleColors ?? []) {
|
||||||
let controller = ThemePreviewController(context: context, previewTheme: theme, source: .settings(themeReference, nil, false))
|
let controller = ThemePreviewController(context: context, previewTheme: theme, source: .settings(themeReference, nil, false))
|
||||||
if custom {
|
if custom {
|
||||||
controller.customApply = {
|
controller.customApply = {
|
||||||
selectThemeImpl?(nil, themeReference, true)
|
selectThemeImpl?(nil, initialThemeReference, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pushControllerImpl?(controller)
|
pushControllerImpl?(controller)
|
||||||
@ -884,9 +889,10 @@ public func themePickerController(context: AccountContext, focusOnItemTag: Theme
|
|||||||
})
|
})
|
||||||
|
|
||||||
let switchNode = SwitchIconNode(theme: context.sharedContext.currentPresentationData.with({ $0 }).theme)
|
let switchNode = SwitchIconNode(theme: context.sharedContext.currentPresentationData.with({ $0 }).theme)
|
||||||
|
let previousNightModePreview = Atomic<Bool>(value: false)
|
||||||
|
|
||||||
let signal = combineLatest(queue: .mainQueue(), context.sharedContext.presentationData, context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.presentationThemeSettings, SharedDataKeys.chatThemes]), cloudThemes.get(), removedThemeIndexesPromise.get(), animatedEmojiStickers, nightModePreviewPromise.get())
|
let signal = combineLatest(queue: .mainQueue(), context.sharedContext.presentationData, context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.presentationThemeSettings, SharedDataKeys.chatThemes]), cloudThemes.get(), removedThemeIndexesPromise.get(), animatedEmojiStickers, nightModePreviewPromise.get())
|
||||||
|> map { presentationData, sharedData, cloudThemes, removedThemeIndexes, animatedEmojiStickers, nightModePreview -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
|> map { [weak switchNode] presentationData, sharedData, cloudThemes, removedThemeIndexes, animatedEmojiStickers, nightModePreview -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
||||||
let settings = sharedData.entries[ApplicationSpecificSharedDataKeys.presentationThemeSettings]?.get(PresentationThemeSettings.self) ?? PresentationThemeSettings.defaultSettings
|
let settings = sharedData.entries[ApplicationSpecificSharedDataKeys.presentationThemeSettings]?.get(PresentationThemeSettings.self) ?? PresentationThemeSettings.defaultSettings
|
||||||
|
|
||||||
var presentationData = presentationData
|
var presentationData = presentationData
|
||||||
@ -919,17 +925,23 @@ public func themePickerController(context: AccountContext, focusOnItemTag: Theme
|
|||||||
|
|
||||||
presentationData = presentationData.withUpdated(theme: darkTheme).withUpdated(chatWallpaper: darkWallpaper)
|
presentationData = presentationData.withUpdated(theme: darkTheme).withUpdated(chatWallpaper: darkWallpaper)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let previousNightModePreview = previousNightModePreview.swap(nightModePreview)
|
||||||
|
if previousNightModePreview != nightModePreview {
|
||||||
|
switchNode?.play(isDark: !nightModePreview, theme: presentationData.theme)
|
||||||
|
} else {
|
||||||
|
switchNode?.updateTheme(presentationData.theme)
|
||||||
|
}
|
||||||
|
|
||||||
var themeReference = settings.theme
|
var themeReference = settings.theme
|
||||||
if presentationData.autoNightModeTriggered {
|
if presentationData.autoNightModeTriggered {
|
||||||
themeReference = settings.automaticThemeSwitchSetting.theme
|
themeReference = settings.automaticThemeSwitchSetting.theme
|
||||||
}
|
}
|
||||||
|
|
||||||
let rightNavigationButton: ItemListNavigationButton?
|
let rightNavigationButton: ItemListNavigationButton?
|
||||||
if !presentationData.autoNightModeTriggered {
|
if !presentationData.autoNightModeTriggered, let switchNode = switchNode {
|
||||||
rightNavigationButton = ItemListNavigationButton(content: .node(switchNode), style: .regular, enabled: true, action: { [weak switchNode] in
|
rightNavigationButton = ItemListNavigationButton(content: .node(switchNode), style: .regular, enabled: true, action: {
|
||||||
nightModePreviewPromise.set(!nightModePreview)
|
nightModePreviewPromise.set(!nightModePreview)
|
||||||
switchNode?.play(isDark: presentationData.theme.overallDarkAppearance, theme: presentationData.theme)
|
|
||||||
presentCrossfadeControllerImpl?(false)
|
presentCrossfadeControllerImpl?(false)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -965,6 +977,8 @@ public func themePickerController(context: AccountContext, focusOnItemTag: Theme
|
|||||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: themePickerControllerEntries(presentationData: presentationData, presentationThemeSettings: settings, themeReference: themeReference, availableThemes: availableThemes, chatThemes: chatThemes, nightMode: nightMode, animatedEmojiStickers: animatedEmojiStickers), style: .blocks, ensureVisibleItemTag: focusOnItemTag, animateChanges: false)
|
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: themePickerControllerEntries(presentationData: presentationData, presentationThemeSettings: settings, themeReference: themeReference, availableThemes: availableThemes, chatThemes: chatThemes, nightMode: nightMode, animatedEmojiStickers: animatedEmojiStickers), style: .blocks, ensureVisibleItemTag: focusOnItemTag, animateChanges: false)
|
||||||
|
|
||||||
return (controllerState, (listState, arguments))
|
return (controllerState, (listState, arguments))
|
||||||
|
} |> afterDisposed {
|
||||||
|
let _ = switchNode.description
|
||||||
}
|
}
|
||||||
|
|
||||||
let controller = ThemePickerControllerImpl(context: context, state: signal)
|
let controller = ThemePickerControllerImpl(context: context, state: signal)
|
||||||
@ -1121,6 +1135,20 @@ public func themePickerController(context: AccountContext, focusOnItemTag: Theme
|
|||||||
var updatedAutomaticThemeSwitchSetting = current.automaticThemeSwitchSetting
|
var updatedAutomaticThemeSwitchSetting = current.automaticThemeSwitchSetting
|
||||||
if case let .cloud(info) = updatedTheme, info.theme.settings?.contains(where: { $0.baseTheme == .night || $0.baseTheme == .tinted }) ?? false {
|
if case let .cloud(info) = updatedTheme, info.theme.settings?.contains(where: { $0.baseTheme == .night || $0.baseTheme == .tinted }) ?? false {
|
||||||
updatedAutomaticThemeSwitchSetting.theme = updatedTheme
|
updatedAutomaticThemeSwitchSetting.theme = updatedTheme
|
||||||
|
} else if autoNightModeTriggered {
|
||||||
|
var updatedThemeSpecificAccentColors = current.themeSpecificAccentColors
|
||||||
|
if let baseThemeIndex = baseThemeIndex {
|
||||||
|
updatedThemeSpecificAccentColors[baseThemeIndex] = PresentationThemeAccentColor(themeIndex: updatedTheme.index)
|
||||||
|
}
|
||||||
|
|
||||||
|
if autoNightModeTriggered {
|
||||||
|
var updatedAutomaticThemeSwitchSetting = current.automaticThemeSwitchSetting
|
||||||
|
updatedAutomaticThemeSwitchSetting.theme = updatedTheme
|
||||||
|
|
||||||
|
return current.withUpdatedAutomaticThemeSwitchSetting(updatedAutomaticThemeSwitchSetting).withUpdatedThemeSpecificAccentColors(updatedThemeSpecificAccentColors)
|
||||||
|
} else {
|
||||||
|
return current.withUpdatedTheme(updatedTheme).withUpdatedThemeSpecificAccentColors(updatedThemeSpecificAccentColors)
|
||||||
|
}
|
||||||
} else if case let .builtin(theme) = updatedTheme {
|
} else if case let .builtin(theme) = updatedTheme {
|
||||||
if [.day, .dayClassic].contains(theme) {
|
if [.day, .dayClassic].contains(theme) {
|
||||||
updatedAutomaticThemeSwitchSetting.theme = .builtin(.night)
|
updatedAutomaticThemeSwitchSetting.theme = .builtin(.night)
|
||||||
@ -1129,19 +1157,6 @@ public func themePickerController(context: AccountContext, focusOnItemTag: Theme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return current.withUpdatedTheme(updatedTheme).withUpdatedThemePreferredBaseTheme(updatedThemePreferredBaseTheme).withUpdatedAutomaticThemeSwitchSetting(updatedAutomaticThemeSwitchSetting)
|
return current.withUpdatedTheme(updatedTheme).withUpdatedThemePreferredBaseTheme(updatedThemePreferredBaseTheme).withUpdatedAutomaticThemeSwitchSetting(updatedAutomaticThemeSwitchSetting)
|
||||||
// var updatedThemeSpecificAccentColors = current.themeSpecificAccentColors
|
|
||||||
// if let baseThemeIndex = baseThemeIndex {
|
|
||||||
// updatedThemeSpecificAccentColors[baseThemeIndex] = PresentationThemeAccentColor(themeIndex: updatedTheme.index)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if autoNightModeTriggered {
|
|
||||||
// var updatedAutomaticThemeSwitchSetting = current.automaticThemeSwitchSetting
|
|
||||||
// updatedAutomaticThemeSwitchSetting.theme = updatedTheme
|
|
||||||
//
|
|
||||||
// return current.withUpdatedAutomaticThemeSwitchSetting(updatedAutomaticThemeSwitchSetting).withUpdatedThemeSpecificAccentColors(updatedThemeSpecificAccentColors)
|
|
||||||
// } else {
|
|
||||||
// return current.withUpdatedTheme(updatedTheme).withUpdatedThemeSpecificAccentColors(updatedThemeSpecificAccentColors)
|
|
||||||
// }
|
|
||||||
}).start()
|
}).start()
|
||||||
|
|
||||||
return currentThemeBaseIndex != updatedThemeBaseIndex
|
return currentThemeBaseIndex != updatedThemeBaseIndex
|
||||||
@ -1276,6 +1291,8 @@ private class SwitchIconNode: ASDisplayNode {
|
|||||||
private let animationContainerNode: ASDisplayNode
|
private let animationContainerNode: ASDisplayNode
|
||||||
private var animationNode: AnimationNode
|
private var animationNode: AnimationNode
|
||||||
|
|
||||||
|
private var isDark = true
|
||||||
|
|
||||||
init(theme: PresentationTheme) {
|
init(theme: PresentationTheme) {
|
||||||
let switchThemeSize = CGSize(width: 26.0, height: 26.0)
|
let switchThemeSize = CGSize(width: 26.0, height: 26.0)
|
||||||
|
|
||||||
@ -1296,10 +1313,15 @@ private class SwitchIconNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func play(isDark: Bool, theme: PresentationTheme) {
|
func play(isDark: Bool, theme: PresentationTheme) {
|
||||||
|
self.isDark = isDark
|
||||||
self.animationNode.setAnimation(name: isDark ? "anim_sun_reverse" : "anim_sun", colors: iconColors(theme: theme))
|
self.animationNode.setAnimation(name: isDark ? "anim_sun_reverse" : "anim_sun", colors: iconColors(theme: theme))
|
||||||
self.animationNode.playOnce()
|
self.animationNode.playOnce()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateTheme(_ theme: PresentationTheme) {
|
||||||
|
self.animationNode.setAnimation(name: self.isDark ? "anim_sun" : "anim_sun_reverse", colors: iconColors(theme: theme))
|
||||||
|
}
|
||||||
|
|
||||||
override public func calculateSizeThatFits(_ constrainedSize: CGSize) -> CGSize {
|
override public func calculateSizeThatFits(_ constrainedSize: CGSize) -> CGSize {
|
||||||
return self.animationContainerNode.frame.size
|
return self.animationContainerNode.frame.size
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,11 @@ private final class ThemeGridThemeItemIconNode : ASDisplayNode {
|
|||||||
if case .builtin = themeReference, item.nightMode {
|
if case .builtin = themeReference, item.nightMode {
|
||||||
themeReference = .builtin(.night)
|
themeReference = .builtin(.night)
|
||||||
}
|
}
|
||||||
self.imageNode.setSignal(themeIconImage(account: item.context.account, accountManager: item.context.sharedContext.accountManager, theme: themeReference, color: nil, wallpaper: item.wallpaper, nightMode: item.nightMode, emoticon: true, large: true))
|
|
||||||
|
let color = item.themeSpecificAccentColors[themeReference.index]
|
||||||
|
let wallpaper = item.themeSpecificChatWallpapers[themeReference.index]
|
||||||
|
|
||||||
|
self.imageNode.setSignal(themeIconImage(account: item.context.account, accountManager: item.context.sharedContext.accountManager, theme: themeReference, color: color, wallpaper: wallpaper ?? item.wallpaper, nightMode: item.nightMode, emoticon: true, large: true))
|
||||||
self.imageNode.backgroundColor = nil
|
self.imageNode.backgroundColor = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,7 +499,7 @@ class ThemeGridThemeItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
for theme in item.themes {
|
for theme in item.themes {
|
||||||
let selected = item.currentTheme.index == theme.index
|
let selected = item.currentTheme.index == theme.index
|
||||||
|
|
||||||
let iconItem = ThemeCarouselThemeIconItem(context: item.context, emojiFile: theme.emoticon.flatMap { item.animatedEmojiStickers[$0]?.first?.file }, themeReference: theme, nightMode: item.nightMode, selected: selected, theme: item.theme, strings: item.strings, wallpaper: nil, action: { theme in
|
let iconItem = ThemeCarouselThemeIconItem(context: item.context, emojiFile: theme.emoticon.flatMap { item.animatedEmojiStickers[$0]?.first?.file }, themeReference: theme, nightMode: item.nightMode, themeSpecificAccentColors: item.themeSpecificAccentColors, themeSpecificChatWallpapers: item.themeSpecificChatWallpapers, selected: selected, theme: item.theme, strings: item.strings, wallpaper: nil, action: { theme in
|
||||||
item.updatedTheme(theme)
|
item.updatedTheme(theme)
|
||||||
}, contextAction: nil)
|
}, contextAction: nil)
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ public enum ThemeSettingsEntryTag: ItemListItemTag {
|
|||||||
private enum ThemeSettingsControllerEntry: ItemListNodeEntry {
|
private enum ThemeSettingsControllerEntry: ItemListNodeEntry {
|
||||||
case themeListHeader(PresentationTheme, String)
|
case themeListHeader(PresentationTheme, String)
|
||||||
case chatPreview(PresentationTheme, TelegramWallpaper, PresentationFontSize, PresentationChatBubbleCorners, PresentationStrings, PresentationDateTimeFormat, PresentationPersonNameOrder, [ChatPreviewMessageItem])
|
case chatPreview(PresentationTheme, TelegramWallpaper, PresentationFontSize, PresentationChatBubbleCorners, PresentationStrings, PresentationDateTimeFormat, PresentationPersonNameOrder, [ChatPreviewMessageItem])
|
||||||
case themes(PresentationTheme, PresentationStrings, [PresentationThemeReference], PresentationThemeReference, Bool, [String: [StickerPackItem]])
|
case themes(PresentationTheme, PresentationStrings, [PresentationThemeReference], PresentationThemeReference, Bool, [String: [StickerPackItem]], [Int64: PresentationThemeAccentColor], [Int64: TelegramWallpaper])
|
||||||
case chatTheme(PresentationTheme, String)
|
case chatTheme(PresentationTheme, String)
|
||||||
case wallpaper(PresentationTheme, String)
|
case wallpaper(PresentationTheme, String)
|
||||||
case autoNight(PresentationTheme, String, Bool, Bool)
|
case autoNight(PresentationTheme, String, Bool, Bool)
|
||||||
@ -183,8 +183,8 @@ private enum ThemeSettingsControllerEntry: ItemListNodeEntry {
|
|||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
case let .themes(lhsTheme, lhsStrings, lhsThemes, lhsCurrentTheme, lhsNightMode, lhsAnimatedEmojiStickers):
|
case let .themes(lhsTheme, lhsStrings, lhsThemes, lhsCurrentTheme, lhsNightMode, lhsAnimatedEmojiStickers, lhsThemeAccentColors, lhsThemeSpecificChatWallpapers):
|
||||||
if case let .themes(rhsTheme, rhsStrings, rhsThemes, rhsCurrentTheme, rhsNightMode, rhsAnimatedEmojiStickers) = rhs, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsThemes == rhsThemes, lhsCurrentTheme == rhsCurrentTheme, lhsNightMode == rhsNightMode, lhsAnimatedEmojiStickers == rhsAnimatedEmojiStickers {
|
if case let .themes(rhsTheme, rhsStrings, rhsThemes, rhsCurrentTheme, rhsNightMode, rhsAnimatedEmojiStickers, rhsThemeAccentColors, rhsThemeSpecificChatWallpapers) = rhs, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsThemes == rhsThemes, lhsCurrentTheme == rhsCurrentTheme, lhsNightMode == rhsNightMode, lhsAnimatedEmojiStickers == rhsAnimatedEmojiStickers, lhsThemeAccentColors == rhsThemeAccentColors, lhsThemeSpecificChatWallpapers == rhsThemeSpecificChatWallpapers {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
@ -279,8 +279,8 @@ private enum ThemeSettingsControllerEntry: ItemListNodeEntry {
|
|||||||
switch self {
|
switch self {
|
||||||
case let .chatPreview(theme, wallpaper, fontSize, chatBubbleCorners, strings, dateTimeFormat, nameDisplayOrder, items):
|
case let .chatPreview(theme, wallpaper, fontSize, chatBubbleCorners, strings, dateTimeFormat, nameDisplayOrder, items):
|
||||||
return ThemeSettingsChatPreviewItem(context: arguments.context, theme: theme, componentTheme: theme, strings: strings, sectionId: self.section, fontSize: fontSize, chatBubbleCorners: chatBubbleCorners, wallpaper: wallpaper, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, messageItems: items)
|
return ThemeSettingsChatPreviewItem(context: arguments.context, theme: theme, componentTheme: theme, strings: strings, sectionId: self.section, fontSize: fontSize, chatBubbleCorners: chatBubbleCorners, wallpaper: wallpaper, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, messageItems: items)
|
||||||
case let .themes(theme, strings, chatThemes, currentTheme, nightMode, animatedEmojiStickers):
|
case let .themes(theme, strings, chatThemes, currentTheme, nightMode, animatedEmojiStickers, themeSpecificAccentColors, themeSpecificChatWallpapers):
|
||||||
return ThemeCarouselThemeItem(context: arguments.context, theme: theme, strings: strings, sectionId: self.section, themes: chatThemes, animatedEmojiStickers: animatedEmojiStickers, themeSpecificAccentColors: [:], themeSpecificChatWallpapers: [:], nightMode: nightMode, currentTheme: currentTheme, updatedTheme: { theme in
|
return ThemeCarouselThemeItem(context: arguments.context, theme: theme, strings: strings, sectionId: self.section, themes: chatThemes, animatedEmojiStickers: animatedEmojiStickers, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, nightMode: nightMode, currentTheme: currentTheme, updatedTheme: { theme in
|
||||||
arguments.selectTheme(theme)
|
arguments.selectTheme(theme)
|
||||||
}, contextAction: { theme, node, gesture in
|
}, contextAction: { theme, node, gesture in
|
||||||
arguments.themeContextAction(false, theme, node, gesture)
|
arguments.themeContextAction(false, theme, node, gesture)
|
||||||
@ -341,7 +341,7 @@ private func themeSettingsControllerEntries(presentationData: PresentationData,
|
|||||||
entries.append(.themeListHeader(presentationData.theme, title))
|
entries.append(.themeListHeader(presentationData.theme, title))
|
||||||
entries.append(.chatPreview(presentationData.theme, presentationData.chatWallpaper, presentationData.chatFontSize, presentationData.chatBubbleCorners, presentationData.strings, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, [ChatPreviewMessageItem(outgoing: false, reply: (presentationData.strings.Appearance_PreviewReplyAuthor, presentationData.strings.Appearance_PreviewReplyText), text: presentationData.strings.Appearance_PreviewIncomingText), ChatPreviewMessageItem(outgoing: true, reply: nil, text: presentationData.strings.Appearance_PreviewOutgoingText)]))
|
entries.append(.chatPreview(presentationData.theme, presentationData.chatWallpaper, presentationData.chatFontSize, presentationData.chatBubbleCorners, presentationData.strings, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, [ChatPreviewMessageItem(outgoing: false, reply: (presentationData.strings.Appearance_PreviewReplyAuthor, presentationData.strings.Appearance_PreviewReplyText), text: presentationData.strings.Appearance_PreviewIncomingText), ChatPreviewMessageItem(outgoing: true, reply: nil, text: presentationData.strings.Appearance_PreviewOutgoingText)]))
|
||||||
|
|
||||||
entries.append(.themes(presentationData.theme, presentationData.strings, chatThemes, themeReference, presentationThemeSettings.automaticThemeSwitchSetting.force || presentationData.autoNightModeTriggered, animatedEmojiStickers))
|
entries.append(.themes(presentationData.theme, presentationData.strings, chatThemes, themeReference, presentationThemeSettings.automaticThemeSwitchSetting.force || presentationData.autoNightModeTriggered, animatedEmojiStickers, presentationThemeSettings.themeSpecificAccentColors, presentationThemeSettings.themeSpecificChatWallpapers))
|
||||||
entries.append(.chatTheme(presentationData.theme, strings.Settings_ChatThemes))
|
entries.append(.chatTheme(presentationData.theme, strings.Settings_ChatThemes))
|
||||||
entries.append(.wallpaper(presentationData.theme, strings.Settings_ChatBackground))
|
entries.append(.wallpaper(presentationData.theme, strings.Settings_ChatBackground))
|
||||||
|
|
||||||
|
@ -595,9 +595,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
strongSelf.commitPurposefulAction()
|
strongSelf.commitPurposefulAction()
|
||||||
strongSelf.dismissAllTooltips()
|
strongSelf.dismissAllTooltips()
|
||||||
|
|
||||||
var openMessageByAction: Bool = false
|
var openMessageByAction = false
|
||||||
|
var isLocation = false
|
||||||
for media in message.media {
|
for media in message.media {
|
||||||
|
if media is TelegramMediaMap {
|
||||||
|
isLocation = true
|
||||||
|
}
|
||||||
if let file = media as? TelegramMediaFile, file.isInstantVideo {
|
if let file = media as? TelegramMediaFile, file.isInstantVideo {
|
||||||
if strongSelf.chatDisplayNode.isInputViewFocused {
|
if strongSelf.chatDisplayNode.isInputViewFocused {
|
||||||
strongSelf.returnInputViewFocus = true
|
strongSelf.returnInputViewFocus = true
|
||||||
@ -772,7 +775,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
strongSelf.chatDisplayNode.historyNode.view.superview?.insertSubview(view, aboveSubview: strongSelf.chatDisplayNode.historyNode.view)
|
strongSelf.chatDisplayNode.historyNode.view.superview?.insertSubview(view, aboveSubview: strongSelf.chatDisplayNode.historyNode.view)
|
||||||
}, openUrl: { url in
|
}, openUrl: { url in
|
||||||
self?.openUrl(url, concealed: false, message: nil)
|
self?.openUrl(url, concealed: false, skipConcealedAlert: isLocation, message: nil)
|
||||||
}, openPeer: { peer, navigation in
|
}, openPeer: { peer, navigation in
|
||||||
self?.openPeer(peerId: peer.id, navigation: navigation, fromMessage: nil)
|
self?.openPeer(peerId: peer.id, navigation: navigation, fromMessage: nil)
|
||||||
}, callPeer: { peerId, isVideo in
|
}, callPeer: { peerId, isVideo in
|
||||||
@ -12439,7 +12442,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}, contentContext: nil)
|
}, contentContext: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func openUrl(_ url: String, concealed: Bool, skipUrlAuth: Bool = false, message: Message? = nil) {
|
private func openUrl(_ url: String, concealed: Bool, skipUrlAuth: Bool = false, skipConcealedAlert: Bool = false, message: Message? = nil) {
|
||||||
self.commitPurposefulAction()
|
self.commitPurposefulAction()
|
||||||
|
|
||||||
let _ = self.presentVoiceMessageDiscardAlert(action: {
|
let _ = self.presentVoiceMessageDiscardAlert(action: {
|
||||||
@ -12495,7 +12498,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
openUserGeneratedUrl(context: self.context, peerId: self.peerView?.peerId, url: url, concealed: concealed, skipUrlAuth: skipUrlAuth, present: { [weak self] c in
|
openUserGeneratedUrl(context: self.context, peerId: self.peerView?.peerId, url: url, concealed: concealed, skipUrlAuth: skipUrlAuth, skipConcealedAlert: skipConcealedAlert, present: { [weak self] c in
|
||||||
self?.present(c, in: .window(.root))
|
self?.present(c, in: .window(.root))
|
||||||
}, openResolved: { [weak self] resolved in
|
}, openResolved: { [weak self] resolved in
|
||||||
self?.openResolved(result: resolved, sourceMessageId: message?.id)
|
self?.openResolved(result: resolved, sourceMessageId: message?.id)
|
||||||
|
@ -1314,7 +1314,11 @@ public func themeIconImage(account: Account, accountManager: AccountManager<Tele
|
|||||||
if case let .cloud(theme) = theme, theme.theme.settings != nil, let nightMode = nightMode {
|
if case let .cloud(theme) = theme, theme.theme.settings != nil, let nightMode = nightMode {
|
||||||
themeSignal = .single(makePresentationTheme(cloudTheme: theme.theme, dark: nightMode))
|
themeSignal = .single(makePresentationTheme(cloudTheme: theme.theme, dark: nightMode))
|
||||||
} else if case let .builtin(theme) = theme {
|
} else if case let .builtin(theme) = theme {
|
||||||
themeSignal = .single(makeDefaultPresentationTheme(reference: theme, serviceBackgroundColor: nil))
|
var defaultTheme = makeDefaultPresentationTheme(reference: theme, serviceBackgroundColor: nil)
|
||||||
|
if let color = color {
|
||||||
|
defaultTheme = customizePresentationTheme(defaultTheme, editing: false, accentColor: color.accentColor.flatMap { UIColor(rgb: $0) }, outgoingAccentColor: nil, backgroundColors: [], bubbleColors: color.bubbleColors, animateBubbleColors: nil, baseColor: color.baseColor)
|
||||||
|
}
|
||||||
|
themeSignal = .single(defaultTheme)
|
||||||
} else if case let .cloud(theme) = theme, let settings = theme.theme.settings?.first {
|
} else if case let .cloud(theme) = theme, let settings = theme.theme.settings?.first {
|
||||||
themeSignal = Signal { subscriber in
|
themeSignal = Signal { subscriber in
|
||||||
let theme = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: .builtin(PresentationBuiltinThemeReference(baseTheme: settings.baseTheme)), accentColor: UIColor(argb: settings.accentColor), backgroundColors: [], bubbleColors: settings.messageColors, wallpaper: settings.wallpaper, serviceBackgroundColor: nil, preview: false)
|
let theme = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: .builtin(PresentationBuiltinThemeReference(baseTheme: settings.baseTheme)), accentColor: UIColor(argb: settings.accentColor), backgroundColors: [], bubbleColors: settings.messageColors, wallpaper: settings.wallpaper, serviceBackgroundColor: nil, preview: false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user