mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-03 21:16:35 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
aa2f80183f
@ -3948,6 +3948,7 @@ Unused sets are archived when you add more.";
|
||||
"WallpaperPreview.Title" = "Background Preview";
|
||||
"WallpaperPreview.PreviewTopText" = "Press Set to apply the background";
|
||||
"WallpaperPreview.PreviewBottomText" = "Enjoy the view";
|
||||
|
||||
"WallpaperPreview.SwipeTopText" = "Swipe left or right to preview more backgrounds";
|
||||
"WallpaperPreview.SwipeBottomText" = "Backgrounds for the god of backgrounds!";
|
||||
"WallpaperPreview.SwipeColorsTopText" = "Swipe left or right to see more colors";
|
||||
@ -6507,3 +6508,5 @@ Sorry for the inconvenience.";
|
||||
"ImportStickerPack.ChooseName" = "Choose Name";
|
||||
"ImportStickerPack.ChooseNameDescription" = "Please choose a name for your set.";
|
||||
"ImportStickerPack.ImportingStickers" = "Importing Stickers";
|
||||
|
||||
"WallpaperPreview.PreviewBottomTextAnimatable" = "Tap the play button to view the background animation.";
|
||||
|
||||
@ -1853,7 +1853,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
||||
strongSelf.highlightedBackgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: layoutOffset - separatorHeight - topNegativeInset), size: CGSize(width: layout.contentSize.width, height: layout.contentSize.height + separatorHeight + topNegativeInset))
|
||||
|
||||
if let peerPresence = peerPresence as? TelegramUserPresence {
|
||||
strongSelf.peerPresenceManager?.reset(presence: TelegramUserPresence(status: peerPresence.status, lastActivity: 0))
|
||||
strongSelf.peerPresenceManager?.reset(presence: TelegramUserPresence(status: peerPresence.status, lastActivity: 0), isOnline: online)
|
||||
}
|
||||
|
||||
strongSelf.updateLayout(size: layout.contentSize, leftInset: params.leftInset, rightInset: params.rightInset)
|
||||
|
||||
@ -4,19 +4,23 @@ import TelegramCore
|
||||
import SyncCore
|
||||
import SyncCore
|
||||
|
||||
private func suggestedUserPresenceStringRefreshTimeout(_ presence: TelegramUserPresence, relativeTo timestamp: Int32) -> Double {
|
||||
private func suggestedUserPresenceStringRefreshTimeout(_ presence: TelegramUserPresence, relativeTo timestamp: Int32, isOnline: Bool?) -> Double {
|
||||
switch presence.status {
|
||||
case let .present(statusTimestamp):
|
||||
if statusTimestamp >= timestamp {
|
||||
return Double(statusTimestamp - timestamp)
|
||||
} else {
|
||||
let difference = timestamp - statusTimestamp
|
||||
if difference < 30 {
|
||||
return Double((30 - difference) + 1)
|
||||
} else if difference < 60 * 60 {
|
||||
return Double((difference % 60) + 1)
|
||||
if let isOnline = isOnline, isOnline {
|
||||
return 1.0
|
||||
} else {
|
||||
return Double.infinity
|
||||
let difference = timestamp - statusTimestamp
|
||||
if difference < 30 {
|
||||
return Double((30 - difference) + 1)
|
||||
} else if difference < 60 * 60 {
|
||||
return Double((difference % 60) + 1)
|
||||
} else {
|
||||
return Double.infinity
|
||||
}
|
||||
}
|
||||
}
|
||||
case .recently:
|
||||
@ -43,12 +47,12 @@ public final class PeerPresenceStatusManager {
|
||||
self.timer?.invalidate()
|
||||
}
|
||||
|
||||
public func reset(presence: TelegramUserPresence) {
|
||||
public func reset(presence: TelegramUserPresence, isOnline: Bool? = nil) {
|
||||
self.timer?.invalidate()
|
||||
self.timer = nil
|
||||
|
||||
let timestamp = CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970
|
||||
let timeout = suggestedUserPresenceStringRefreshTimeout(presence, relativeTo: Int32(timestamp))
|
||||
let timeout = suggestedUserPresenceStringRefreshTimeout(presence, relativeTo: Int32(timestamp), isOnline: isOnline)
|
||||
if timeout.isFinite {
|
||||
self.timer = SwiftSignalKit.Timer(timeout: timeout, repeat: false, completion: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
|
||||
@ -1289,7 +1289,7 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
|
||||
updatedTheme = generalThemeReference
|
||||
}
|
||||
|
||||
guard let theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: generalThemeReference, accentColor: accentColor?.color, wallpaper: presetWallpaper) else {
|
||||
guard let theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: generalThemeReference, accentColor: accentColor?.color, wallpaper: presetWallpaper, wallpaperGradientColors: accentColor?.baseColor.wallpaperGradientColors) else {
|
||||
return current
|
||||
}
|
||||
|
||||
|
||||
@ -171,6 +171,7 @@ public class WallpaperGalleryController: ViewController {
|
||||
return self._ready
|
||||
}
|
||||
private var didSetReady = false
|
||||
private var didBeginSettingReady = false
|
||||
|
||||
private let disposable = MetaDisposable()
|
||||
|
||||
@ -581,11 +582,6 @@ public class WallpaperGalleryController: ViewController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let ready = self.galleryNode.pager.ready() |> timeout(2.0, queue: Queue.mainQueue(), alternate: .single(Void())) |> afterNext { [weak self] _ in
|
||||
self?.didSetReady = true
|
||||
}
|
||||
self._ready.set(ready |> map { true })
|
||||
}
|
||||
|
||||
private func currentEntry() -> WallpaperGalleryEntry? {
|
||||
@ -723,6 +719,14 @@ public class WallpaperGalleryController: ViewController {
|
||||
}
|
||||
}
|
||||
}
|
||||
if !self.didBeginSettingReady {
|
||||
self.didBeginSettingReady = true
|
||||
|
||||
let ready = self.galleryNode.pager.ready() |> timeout(2.0, queue: Queue.mainQueue(), alternate: .single(Void())) |> afterNext { [weak self] _ in
|
||||
self?.didSetReady = true
|
||||
}
|
||||
self._ready.set(ready |> map { true })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -855,10 +855,6 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
||||
}
|
||||
|
||||
func setMotionEnabled(_ enabled: Bool, animated: Bool) {
|
||||
if let entry = self.entry, case let .wallpaper(wallpaper, _) = entry, case .builtin = wallpaper {
|
||||
return
|
||||
}
|
||||
|
||||
if enabled {
|
||||
let horizontal = UIInterpolatingMotionEffect(keyPath: "center.x", type: .tiltAlongHorizontalAxis)
|
||||
horizontal.minimumRelativeValue = motionAmount
|
||||
@ -1069,14 +1065,48 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
||||
|
||||
if let source = self.source {
|
||||
switch source {
|
||||
case .wallpaper, .slug:
|
||||
case .slug, .wallpaper:
|
||||
topMessageText = presentationData.strings.WallpaperPreview_PreviewTopText
|
||||
bottomMessageText = presentationData.strings.WallpaperPreview_PreviewBottomText
|
||||
|
||||
var hasAnimatableGradient = false
|
||||
switch currentWallpaper {
|
||||
case let .file(file) where file.isPattern:
|
||||
if file.settings.colors.count >= 3 {
|
||||
hasAnimatableGradient = true
|
||||
}
|
||||
case let .gradient(colors, _):
|
||||
if colors.count >= 3 {
|
||||
hasAnimatableGradient = true
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
if hasAnimatableGradient {
|
||||
bottomMessageText = presentationData.strings.WallpaperPreview_PreviewBottomTextAnimatable
|
||||
}
|
||||
case let .list(_, _, type):
|
||||
switch type {
|
||||
case .wallpapers:
|
||||
topMessageText = presentationData.strings.WallpaperPreview_SwipeTopText
|
||||
bottomMessageText = presentationData.strings.WallpaperPreview_SwipeBottomText
|
||||
|
||||
var hasAnimatableGradient = false
|
||||
switch currentWallpaper {
|
||||
case let .file(file) where file.isPattern:
|
||||
if file.settings.colors.count >= 3 {
|
||||
hasAnimatableGradient = true
|
||||
}
|
||||
case let .gradient(colors, _):
|
||||
if colors.count >= 3 {
|
||||
hasAnimatableGradient = true
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
if hasAnimatableGradient {
|
||||
bottomMessageText = presentationData.strings.WallpaperPreview_PreviewBottomTextAnimatable
|
||||
}
|
||||
case .colors:
|
||||
topMessageText = presentationData.strings.WallpaperPreview_SwipeColorsTopText
|
||||
bottomMessageText = presentationData.strings.WallpaperPreview_SwipeColorsBottomText
|
||||
@ -1099,7 +1129,18 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
||||
items.append(self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, messages: [message2], theme: theme, strings: self.presentationData.strings, wallpaper: currentWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: self.nativeNode))
|
||||
|
||||
let params = ListViewItemLayoutParams(width: layout.size.width, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, availableHeight: layout.size.height)
|
||||
if let _ = self.messageNodes {
|
||||
if let messageNodes = self.messageNodes {
|
||||
for i in 0 ..< items.count {
|
||||
items[i].updateNode(async: { f in f() }, node: { return messageNodes[i] }, params: params, previousItem: i == 0 ? nil : items[i - 1], nextItem: i == (items.count - 1) ? nil : items[i + 1], animation: .None) { layout, apply in
|
||||
let nodeFrame = CGRect(origin: messageNodes[i].frame.origin, size: CGSize(width: layout.size.width, height: layout.size.height))
|
||||
|
||||
messageNodes[i].contentSize = layout.contentSize
|
||||
messageNodes[i].insets = layout.insets
|
||||
messageNodes[i].frame = nodeFrame
|
||||
|
||||
apply(ListViewItemApply(isOnScreen: true))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var messageNodes: [ListViewItemNode] = []
|
||||
for i in 0 ..< items.count {
|
||||
|
||||
@ -2457,6 +2457,8 @@ extension GroupCallParticipantsContext.Participant {
|
||||
} else if mutedByYou {
|
||||
muteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: false, mutedByYou: mutedByYou)
|
||||
}
|
||||
|
||||
|
||||
var videoDescription = video.flatMap(GroupCallParticipantsContext.Participant.VideoDescription.init)
|
||||
var presentationDescription = presentation.flatMap(GroupCallParticipantsContext.Participant.VideoDescription.init)
|
||||
if muteState?.canUnmute == false {
|
||||
|
||||
@ -7,7 +7,7 @@ import SyncCore
|
||||
|
||||
public func telegramWallpapers(postbox: Postbox, network: Network, forceUpdate: Bool = false) -> Signal<[TelegramWallpaper], NoError> {
|
||||
let fetch: ([TelegramWallpaper]?, Int32?) -> Signal<[TelegramWallpaper], NoError> = { current, hash in
|
||||
network.request(Api.functions.account.getWallPapers(hash: hash ?? 0))
|
||||
network.request(Api.functions.account.getWallPapers(hash: 0))//hash ?? 0))
|
||||
|> retryRequest
|
||||
|> mapToSignal { result -> Signal<([TelegramWallpaper], Int32), NoError> in
|
||||
switch result {
|
||||
|
||||
@ -3,11 +3,12 @@ import UIKit
|
||||
import TelegramCore
|
||||
import SyncCore
|
||||
import TelegramUIPreferences
|
||||
import Postbox
|
||||
|
||||
private let defaultDarkTintedAccentColor = UIColor(rgb: 0x2ea6ff)
|
||||
public let defaultDarkTintedPresentationTheme = makeDefaultDarkTintedPresentationTheme(preview: false)
|
||||
|
||||
public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme, editing: Bool, title: String?, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: (UIColor, UIColor?)?, wallpaper forcedWallpaper: TelegramWallpaper? = nil) -> PresentationTheme {
|
||||
public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme, editing: Bool, title: String?, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: (UIColor, UIColor?)?, wallpaper forcedWallpaper: TelegramWallpaper? = nil, wallpaperGradientColors: [UInt32]? = nil) -> PresentationTheme {
|
||||
if (theme.referenceTheme != .nightAccent) {
|
||||
return theme
|
||||
}
|
||||
@ -46,8 +47,12 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme
|
||||
var bubbleColors = bubbleColors
|
||||
if bubbleColors == nil, editing {
|
||||
if let accentColor = accentColor {
|
||||
let color = accentColor.withMultiplied(hue: 1.024, saturation: 0.573, brightness: 0.18)
|
||||
suggestedWallpaper = .color(color.argb)
|
||||
if let wallpaperGradientColors = wallpaperGradientColors, !wallpaperGradientColors.isEmpty {
|
||||
suggestedWallpaper = .file(id: 0, accessHash: 0, isCreator: false, isDefault: true, isPattern: true, isDark: false, slug: "fqv01SQemVIBAAAApND8LDRUhRU", file: TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: 36542425), partialReference: nil, resource: WallpaperDataResource(slug: "fqv01SQemVIBAAAApND8LDRUhRU"), previewRepresentations: [TelegramMediaImageRepresentation(dimensions: PixelDimensions(width: 600, height: 800), resource: WallpaperDataResource(slug: "fqv01SQemVIBAAAApND8LDRUhRU"), progressiveSizes: [], immediateThumbnailData: nil)], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "image/tgv", size: nil, attributes: []), settings: WallpaperSettings(colors: wallpaperGradientColors, intensity: 50))
|
||||
} else {
|
||||
let color = accentColor.withMultiplied(hue: 1.024, saturation: 0.573, brightness: 0.18)
|
||||
suggestedWallpaper = .color(color.argb)
|
||||
}
|
||||
}
|
||||
|
||||
let accentColor = accentColor ?? defaultDarkTintedAccentColor
|
||||
|
||||
@ -19,7 +19,7 @@ public func makeDefaultPresentationTheme(reference: PresentationBuiltinThemeRefe
|
||||
return theme
|
||||
}
|
||||
|
||||
public func customizePresentationTheme(_ theme: PresentationTheme, editing: Bool, title: String? = nil, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: (UIColor, UIColor?)?, wallpaper: TelegramWallpaper? = nil) -> PresentationTheme {
|
||||
public func customizePresentationTheme(_ theme: PresentationTheme, editing: Bool, title: String? = nil, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: (UIColor, UIColor?)?, wallpaper: TelegramWallpaper? = nil, wallpaperGradientColors: [UInt32]? = nil) -> PresentationTheme {
|
||||
if accentColor == nil && bubbleColors == nil && backgroundColors.isEmpty && wallpaper == nil {
|
||||
return theme
|
||||
}
|
||||
@ -29,7 +29,7 @@ public func customizePresentationTheme(_ theme: PresentationTheme, editing: Bool
|
||||
case .night:
|
||||
return customizeDefaultDarkPresentationTheme(theme: theme, editing: editing, title: title, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, wallpaper: wallpaper)
|
||||
case .nightAccent:
|
||||
return customizeDefaultDarkTintedPresentationTheme(theme: theme, editing: editing, title: title, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, wallpaper: wallpaper)
|
||||
return customizeDefaultDarkTintedPresentationTheme(theme: theme, editing: editing, title: title, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, wallpaper: wallpaper, wallpaperGradientColors: wallpaperGradientColors)
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,12 +38,12 @@ public func makePresentationTheme(settings: TelegramThemeSettings, title: String
|
||||
return customizePresentationTheme(defaultTheme, editing: true, title: title, accentColor: UIColor(argb: settings.accentColor), backgroundColors: [], bubbleColors: settings.messageColors.flatMap { (UIColor(argb: $0.top), UIColor(argb: $0.bottom)) }, wallpaper: settings.wallpaper)
|
||||
}
|
||||
|
||||
public func makePresentationTheme(mediaBox: MediaBox, themeReference: PresentationThemeReference, extendingThemeReference: PresentationThemeReference? = nil, accentColor: UIColor? = nil, backgroundColors: [UInt32] = [], bubbleColors: (UIColor, UIColor?)? = nil, wallpaper: TelegramWallpaper? = nil, serviceBackgroundColor: UIColor? = nil, preview: Bool = false) -> PresentationTheme? {
|
||||
public func makePresentationTheme(mediaBox: MediaBox, themeReference: PresentationThemeReference, extendingThemeReference: PresentationThemeReference? = nil, accentColor: UIColor? = nil, backgroundColors: [UInt32] = [], bubbleColors: (UIColor, UIColor?)? = nil, wallpaper: TelegramWallpaper? = nil, wallpaperGradientColors: [UInt32]? = nil, serviceBackgroundColor: UIColor? = nil, preview: Bool = false) -> PresentationTheme? {
|
||||
let theme: PresentationTheme
|
||||
switch themeReference {
|
||||
case let .builtin(reference):
|
||||
let defaultTheme = makeDefaultPresentationTheme(reference: reference, extendingThemeReference: extendingThemeReference, serviceBackgroundColor: serviceBackgroundColor, preview: preview)
|
||||
theme = customizePresentationTheme(defaultTheme, editing: true, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, wallpaper: wallpaper)
|
||||
theme = customizePresentationTheme(defaultTheme, editing: true, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, wallpaper: wallpaper, wallpaperGradientColors: wallpaperGradientColors)
|
||||
case let .local(info):
|
||||
if let path = mediaBox.completedResourcePath(info.resource), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead), let loadedTheme = makePresentationTheme(data: data, themeReference: themeReference, resolvedWallpaper: info.resolvedWallpaper) {
|
||||
theme = customizePresentationTheme(loadedTheme, editing: false, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, wallpaper: wallpaper)
|
||||
|
||||
@ -292,7 +292,7 @@ public func currentPresentationDataAndSettings(accountManager: AccountManager, s
|
||||
}
|
||||
|
||||
let effectiveColors = themeSettings.themeSpecificAccentColors[effectiveTheme.index]
|
||||
let theme = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: effectiveTheme, accentColor: effectiveColors?.color, bubbleColors: effectiveColors?.customBubbleColors) ?? defaultPresentationTheme
|
||||
let theme = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: effectiveTheme, accentColor: effectiveColors?.color, bubbleColors: effectiveColors?.customBubbleColors, wallpaperGradientColors: effectiveColors?.baseColor.wallpaperGradientColors) ?? defaultPresentationTheme
|
||||
|
||||
|
||||
let effectiveChatWallpaper: TelegramWallpaper = (themeSettings.themeSpecificChatWallpapers[coloredThemeIndex(reference: effectiveTheme, accentColor: effectiveColors)] ?? themeSettings.themeSpecificChatWallpapers[effectiveTheme.index]) ?? theme.chat.defaultWallpaper
|
||||
@ -583,7 +583,7 @@ public func updatedPresentationData(accountManager: AccountManager, applicationI
|
||||
if let themeSpecificWallpaper = themeSpecificWallpaper {
|
||||
currentWallpaper = themeSpecificWallpaper
|
||||
} else {
|
||||
let theme = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: themeSettings.theme, accentColor: currentColors?.color, bubbleColors: currentColors?.customBubbleColors, wallpaper: currentColors?.wallpaper) ?? defaultPresentationTheme
|
||||
let theme = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: themeSettings.theme, accentColor: currentColors?.color, bubbleColors: currentColors?.customBubbleColors, wallpaper: currentColors?.wallpaper, wallpaperGradientColors: currentColors?.baseColor.wallpaperGradientColors) ?? defaultPresentationTheme
|
||||
currentWallpaper = theme.chat.defaultWallpaper
|
||||
}
|
||||
|
||||
@ -619,7 +619,7 @@ public func updatedPresentationData(accountManager: AccountManager, applicationI
|
||||
effectiveColors = nil
|
||||
}
|
||||
|
||||
let themeValue = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: effectiveTheme, accentColor: effectiveColors?.color, bubbleColors: effectiveColors?.customBubbleColors, wallpaper: effectiveColors?.wallpaper, serviceBackgroundColor: serviceBackgroundColor) ?? defaultPresentationTheme
|
||||
let themeValue = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: effectiveTheme, accentColor: effectiveColors?.color, bubbleColors: effectiveColors?.customBubbleColors, wallpaper: effectiveColors?.wallpaper, wallpaperGradientColors: effectiveColors?.baseColor.wallpaperGradientColors, serviceBackgroundColor: serviceBackgroundColor) ?? defaultPresentationTheme
|
||||
|
||||
if autoNightModeTriggered && !switchedToNightModeWallpaper {
|
||||
switch effectiveChatWallpaper {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -88,6 +88,8 @@ final class ForwardAccessoryPanelNode: AccessoryPanelNode {
|
||||
let context: AccountContext
|
||||
var theme: PresentationTheme
|
||||
var strings: PresentationStrings
|
||||
|
||||
private var validLayout: (size: CGSize, interfaceState: ChatPresentationInterfaceState)?
|
||||
|
||||
init(context: AccountContext, messageIds: [MessageId], theme: PresentationTheme, strings: PresentationStrings) {
|
||||
self.context = context
|
||||
@ -158,12 +160,9 @@ final class ForwardAccessoryPanelNode: AccessoryPanelNode {
|
||||
headerString = "Forward messages"
|
||||
}
|
||||
strongSelf.actionArea.accessibilityLabel = "\(headerString). From: \(authors).\n\(text)"
|
||||
|
||||
strongSelf.setNeedsLayout()
|
||||
if let subnodes = strongSelf.subnodes {
|
||||
for subnode in subnodes {
|
||||
subnode.setNeedsDisplay()
|
||||
}
|
||||
|
||||
if let (size, interfaceState) = strongSelf.validLayout {
|
||||
strongSelf.updateState(size: size, interfaceState: interfaceState)
|
||||
}
|
||||
}
|
||||
}))
|
||||
@ -196,37 +195,36 @@ final class ForwardAccessoryPanelNode: AccessoryPanelNode {
|
||||
self.textNode.attributedText = NSAttributedString(string: text, font: Font.regular(15.0), textColor: self.theme.chat.inputPanel.primaryTextColor)
|
||||
}
|
||||
|
||||
self.setNeedsLayout()
|
||||
if let (size, interfaceState) = self.validLayout {
|
||||
self.updateState(size: size, interfaceState: interfaceState)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override func calculateSizeThatFits(_ constrainedSize: CGSize) -> CGSize {
|
||||
return CGSize(width: constrainedSize.width, height: 45.0)
|
||||
}
|
||||
|
||||
override func updateState(size: CGSize, interfaceState: ChatPresentationInterfaceState) {
|
||||
}
|
||||
|
||||
override func layout() {
|
||||
super.layout()
|
||||
|
||||
let bounds = self.bounds
|
||||
self.validLayout = (size, interfaceState)
|
||||
|
||||
let bounds = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: 45.0))
|
||||
let leftInset: CGFloat = 55.0
|
||||
let textLineInset: CGFloat = 10.0
|
||||
let rightInset: CGFloat = 55.0
|
||||
let textRightInset: CGFloat = 20.0
|
||||
|
||||
|
||||
let closeButtonSize = CGSize(width: 44.0, height: bounds.height)
|
||||
let closeButtonFrame = CGRect(origin: CGPoint(x: bounds.width - rightInset - closeButtonSize.width + 12.0, y: 2.0), size: closeButtonSize)
|
||||
self.closeButton.frame = closeButtonFrame
|
||||
|
||||
|
||||
self.actionArea.frame = CGRect(origin: CGPoint(x: leftInset, y: 2.0), size: CGSize(width: closeButtonFrame.minX - leftInset, height: bounds.height))
|
||||
|
||||
|
||||
self.lineNode.frame = CGRect(origin: CGPoint(x: leftInset, y: 8.0), size: CGSize(width: 2.0, height: bounds.size.height - 10.0))
|
||||
|
||||
|
||||
let titleSize = self.titleNode.updateLayout(CGSize(width: bounds.size.width - leftInset - textLineInset - rightInset - textRightInset, height: bounds.size.height))
|
||||
self.titleNode.frame = CGRect(origin: CGPoint(x: leftInset + textLineInset, y: 7.0), size: titleSize)
|
||||
|
||||
|
||||
let textSize = self.textNode.updateLayout(CGSize(width: bounds.size.width - leftInset - textLineInset - rightInset - textRightInset, height: bounds.size.height))
|
||||
self.textNode.frame = CGRect(origin: CGPoint(x: leftInset + textLineInset, y: 25.0), size: textSize)
|
||||
}
|
||||
|
||||
@ -404,6 +404,36 @@ public enum PresentationThemeBaseColor: Int32, CaseIterable {
|
||||
}
|
||||
return UIColor(rgb: value)
|
||||
}
|
||||
|
||||
|
||||
public var wallpaperGradientColors: [UInt32]? {
|
||||
switch self {
|
||||
case .blue:
|
||||
return [0x1b2836, 0x121a22, 0x1b2836, 0x121a22]
|
||||
case .cyan:
|
||||
return [0x152b32, 0x0c181c, 0x152b32, 0x0c181c]
|
||||
case .green:
|
||||
return [0x142615, 0x0b160c, 0x142615, 0x0b160c]
|
||||
case .pink:
|
||||
return [0x2d1f23, 0x22171a, 0x2d1f23, 0x22171a]
|
||||
case .orange:
|
||||
return [0x2e2213, 0x221b0f, 0x2e2213, 0x221b0f]
|
||||
case .purple:
|
||||
return [0x25212e, 0x1b1822, 0x25212e, 0x1b1822]
|
||||
case .red:
|
||||
return [0x281613, 0x1e110e, 0x281613, 0x1e110e]
|
||||
case .yellow:
|
||||
return [0x2d2813, 0x221d0e, 0x2d2813, 0x221d0e]
|
||||
case .gray:
|
||||
return [0x1b1d21, 0x111315, 0x1b1d21, 0x111315]
|
||||
case .black:
|
||||
return nil
|
||||
case .white:
|
||||
return nil
|
||||
case .custom, .preset, .theme:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct PresentationThemeAccentColor: PostboxCoding, Equatable {
|
||||
|
||||
@ -1117,6 +1117,9 @@ private:
|
||||
|
||||
tgcalls::GroupConfig config;
|
||||
config.need_log = false;
|
||||
#if DEBUG
|
||||
config.need_log = true;
|
||||
#endif
|
||||
|
||||
__weak GroupCallThreadLocalContext *weakSelf = self;
|
||||
_instance.reset(new tgcalls::GroupInstanceCustomImpl((tgcalls::GroupInstanceDescriptor){
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 4de3323f05c77a4e3d2ae414c002ab419aba3bf5
|
||||
Subproject commit 10e208f6f35eaa4a8ef6bb95e58b704178e8affd
|
||||
@ -380,9 +380,11 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
||||
|
||||
if case let .color(color) = wallpaper {
|
||||
gradientColors = [color]
|
||||
self._isReady.set(true)
|
||||
} else if case let .gradient(colors, settings) = wallpaper {
|
||||
gradientColors = colors
|
||||
gradientAngle = settings.rotation ?? 0
|
||||
self._isReady.set(true)
|
||||
} else if case let .file(_, _, _, _, isPattern, _, _, _, settings) = wallpaper, isPattern {
|
||||
gradientColors = settings.colors
|
||||
gradientAngle = settings.rotation ?? 0
|
||||
@ -437,9 +439,15 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
||||
if let image = chatControllerBackgroundImage(theme: nil, wallpaper: wallpaper, mediaBox: self.context.sharedContext.accountManager.mediaBox, knockoutMode: false) {
|
||||
self.contentNode.contents = image.cgImage
|
||||
self.wallpaperDisposable.set(nil)
|
||||
Queue.mainQueue().justDispatch {
|
||||
self._isReady.set(true)
|
||||
}
|
||||
} else if let image = chatControllerBackgroundImage(theme: nil, wallpaper: wallpaper, mediaBox: self.context.account.postbox.mediaBox, knockoutMode: false) {
|
||||
self.contentNode.contents = image.cgImage
|
||||
self.wallpaperDisposable.set(nil)
|
||||
Queue.mainQueue().justDispatch {
|
||||
self._isReady.set(true)
|
||||
}
|
||||
} else {
|
||||
self.wallpaperDisposable.set((chatControllerBackgroundImageSignal(wallpaper: wallpaper, mediaBox: self.context.sharedContext.accountManager.mediaBox, accountMediaBox: self.context.account.postbox.mediaBox)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] image in
|
||||
@ -447,6 +455,7 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
||||
return
|
||||
}
|
||||
strongSelf.contentNode.contents = image?.0?.cgImage
|
||||
strongSelf._isReady.set(true)
|
||||
}))
|
||||
}
|
||||
self.contentNode.isHidden = false
|
||||
@ -466,11 +475,14 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
||||
|
||||
var invertPattern: Bool = false
|
||||
var patternIsLight: Bool = false
|
||||
var patternIsBlack: Bool = false
|
||||
|
||||
switch wallpaper {
|
||||
case let .file(_, _, _, _, isPattern, _, _, file, settings) where isPattern:
|
||||
var updated = true
|
||||
let isLight = UIColor.average(of: settings.colors.map(UIColor.init(rgb:))).hsb.b > 0.3
|
||||
let brightness = UIColor.average(of: settings.colors.map(UIColor.init(rgb:))).hsb.b
|
||||
let isLight = brightness > 0.3
|
||||
patternIsBlack = brightness <= 0.01
|
||||
if let previousWallpaper = self.validPatternImage?.wallpaper {
|
||||
switch previousWallpaper {
|
||||
case let .file(_, _, _, _, _, _, _, previousFile, _):
|
||||
@ -528,10 +540,10 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
||||
self.patternImageNode.layer.compositingFilter = nil
|
||||
} else {
|
||||
self.patternImageNode.alpha = intensity
|
||||
if patternIsLight {
|
||||
self.patternImageNode.layer.compositingFilter = "softLightBlendMode"
|
||||
} else {
|
||||
if patternIsBlack {
|
||||
self.patternImageNode.layer.compositingFilter = nil
|
||||
} else {
|
||||
self.patternImageNode.layer.compositingFilter = "softLightBlendMode"
|
||||
}
|
||||
}
|
||||
self.patternImageNode.isHidden = false
|
||||
@ -553,7 +565,6 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
||||
self.backgroundColor = nil
|
||||
self.gradientBackgroundNode?.contentView.alpha = 1.0
|
||||
self.contentNode.alpha = 1.0
|
||||
self._isReady.set(true)
|
||||
}
|
||||
|
||||
if let validPatternImage = self.validPatternImage {
|
||||
|
||||
@ -87,7 +87,7 @@ public func wallpaperDatas(account: Account, accountManager: AccountManager, fil
|
||||
}
|
||||
} else {
|
||||
let fetchedThumbnail: Signal<FetchResourceSourceType, FetchResourceError>
|
||||
if let _ = decodedThumbnailData {
|
||||
if let _ = decodedThumbnailData, false {
|
||||
fetchedThumbnail = .complete()
|
||||
} else {
|
||||
fetchedThumbnail = fetchedMediaResource(mediaBox: account.postbox.mediaBox, reference: representations[smallestIndex].reference)
|
||||
@ -96,7 +96,7 @@ public func wallpaperDatas(account: Account, accountManager: AccountManager, fil
|
||||
let fetchedFullSize = fetchedMediaResource(mediaBox: account.postbox.mediaBox, reference: representations[largestIndex].reference)
|
||||
|
||||
let thumbnailData: Signal<Data?, NoError>
|
||||
if let decodedThumbnailData = decodedThumbnailData {
|
||||
if let decodedThumbnailData = decodedThumbnailData, false {
|
||||
thumbnailData = .single(decodedThumbnailData)
|
||||
} else {
|
||||
thumbnailData = Signal<Data?, NoError> { subscriber in
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user