diff --git a/submodules/ContactListUI/Sources/ContactListNode.swift b/submodules/ContactListUI/Sources/ContactListNode.swift index 6e1ec74269..a953165789 100644 --- a/submodules/ContactListUI/Sources/ContactListNode.swift +++ b/submodules/ContactListUI/Sources/ContactListNode.swift @@ -874,7 +874,7 @@ public final class ContactListNode: ASDisplayNode { private var authorizationNode: PermissionContentNode private let displayPermissionPlaceholder: Bool - public init(context: AccountContext, presentation: Signal, filters: [ContactListFilter] = [.excludeSelf], selectionState: ContactListNodeGroupSelectionState? = nil, displayPermissionPlaceholder: Bool = true, displaySortOptions: Bool = false, displayCallIcons: Bool = false, contextAction: ((Peer, ASDisplayNode, ContextGesture?) -> Void)? = nil, isSearch: Bool = false) { + public init(context: AccountContext, presentation: Signal, filters: [ContactListFilter] = [.excludeSelf], selectionState: ContactListNodeGroupSelectionState? = nil, displayPermissionPlaceholder: Bool = true, displaySortOptions: Bool = false, displayCallIcons: Bool = false, contextAction: ((Peer, ASDisplayNode, ContextGesture?) -> Void)? = nil, isSearch: Bool = false, multipleSelection: Bool = false) { self.context = context self.filters = filters self.displayPermissionPlaceholder = displayPermissionPlaceholder @@ -951,7 +951,7 @@ public final class ContactListNode: ASDisplayNode { self?.suppressPermissionWarning?() }, openPeer: { [weak self] peer, action in if let strongSelf = self { - if let _ = strongSelf.selectionStateValue { + if multipleSelection { strongSelf.updateSelectionState({ state in if let state = state { var selectedPeerMap = state.selectedPeerMap diff --git a/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift b/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift index 46a894e8a8..e7852ee034 100644 --- a/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift +++ b/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift @@ -892,7 +892,11 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll if messages.count == 1 { strongSelf.commitDeleteMessages(messages, ask: true) } else { - let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 } + var presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 } + if !presentationData.theme.overallDarkAppearance { + presentationData = presentationData.withUpdated(theme: defaultDarkColorPresentationTheme) + } + var generalMessageContentKind: MessageContentKind? for message in messages { let currentKind = messageContentKind(contentSettings: strongSelf.context.currentContentSettings.with { $0 }, message: message, strings: presentationData.strings, nameDisplayOrder: presentationData.nameDisplayOrder, accountPeerId: strongSelf.context.account.peerId) @@ -926,7 +930,8 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll } } - let actionSheet = ActionSheetController(presentationData: presentationData.withUpdated(theme: defaultDarkColorPresentationTheme)) + + let actionSheet = ActionSheetController(presentationData: presentationData) let items: [ActionSheetItem] = [ ActionSheetButtonItem(title: singleText, color: .destructive, action: { [weak actionSheet] in actionSheet?.dismissAnimated() @@ -956,7 +961,11 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll private func commitDeleteMessages(_ messages: [Message], ask: Bool) { self.messageContextDisposable.set((self.context.sharedContext.chatAvailableMessageActions(postbox: self.context.account.postbox, accountPeerId: self.context.account.peerId, messageIds: Set(messages.map { $0.id })) |> deliverOnMainQueue).start(next: { [weak self] actions in if let strongSelf = self, let controllerInteration = strongSelf.controllerInteraction, !actions.options.isEmpty { - let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData.withUpdated(theme: defaultDarkColorPresentationTheme)) + var presentationData = strongSelf.presentationData + if !presentationData.theme.overallDarkAppearance { + presentationData = presentationData.withUpdated(theme: defaultDarkColorPresentationTheme) + } + let actionSheet = ActionSheetController(presentationData: presentationData) var items: [ActionSheetItem] = [] var personalPeerName: String? var isChannel = false @@ -1020,7 +1029,10 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll return transaction.getMessageGroup(currentMessage.id) ?? [] } |> deliverOnMainQueue).start(next: { [weak self] messages in if let strongSelf = self, !messages.isEmpty { - let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 } + var presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 } + if !presentationData.theme.overallDarkAppearance { + presentationData = presentationData.withUpdated(theme: defaultDarkColorPresentationTheme) + } var generalMessageContentKind: MessageContentKind? var beganContentKindScanning = false var messageContentKinds = Set() @@ -1097,7 +1109,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll } } } - let shareController = ShareController(context: strongSelf.context, subject: subject, preferredAction: preferredAction, forcedTheme: defaultDarkColorPresentationTheme) + let shareController = ShareController(context: strongSelf.context, subject: subject, preferredAction: preferredAction, forcedTheme: presentationData.theme.overallDarkAppearance ? nil : defaultDarkColorPresentationTheme) shareController.completed = { [weak self] peerIds in if let strongSelf = self { let _ = (strongSelf.context.account.postbox.transaction { transaction -> [Peer] in @@ -1158,7 +1170,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll let shareAction: ([Message]) -> Void = { messages in if let strongSelf = self { - let shareController = ShareController(context: strongSelf.context, subject: .messages(messages), preferredAction: preferredAction, forcedTheme: defaultDarkColorPresentationTheme) + let shareController = ShareController(context: strongSelf.context, subject: .messages(messages), preferredAction: preferredAction, forcedTheme: presentationData.theme.overallDarkAppearance ? nil : defaultDarkColorPresentationTheme) shareController.completed = { [weak self] peerIds in if let strongSelf = self { let _ = (strongSelf.context.account.postbox.transaction { transaction -> [Peer] in @@ -1203,7 +1215,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll } } - let actionSheet = ActionSheetController(presentationData: presentationData.withUpdated(theme: defaultDarkColorPresentationTheme)) + let actionSheet = ActionSheetController(presentationData: presentationData) let items: [ActionSheetItem] = [ ActionSheetButtonItem(title: singleText, color: .accent, action: { [weak actionSheet] in actionSheet?.dismissAnimated() @@ -1227,7 +1239,10 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll } }) } else if let (webPage, media) = self.currentWebPageAndMedia { - let presentationData = self.context.sharedContext.currentPresentationData.with { $0 } + var presentationData = self.context.sharedContext.currentPresentationData.with { $0 } + if !presentationData.theme.overallDarkAppearance { + presentationData = presentationData.withUpdated(theme: defaultDarkColorPresentationTheme) + } var preferredAction = ShareControllerPreferredAction.default var subject = ShareControllerSubject.media(.webPage(webPage: WebpageReference(webPage), media: media)) @@ -1250,7 +1265,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll if availableOpenInOptions(context: self.context, item: item).count > 1 { preferredAction = .custom(action: ShareControllerAction(title: presentationData.strings.Conversation_FileOpenIn, action: { [weak self] in if let strongSelf = self { - let openInController = OpenInActionSheetController(context: strongSelf.context, forceTheme: defaultDarkColorPresentationTheme, item: item, additionalAction: nil, openUrl: { [weak self] url in + let openInController = OpenInActionSheetController(context: strongSelf.context, forceTheme: presentationData.theme.overallDarkAppearance ? nil : defaultDarkColorPresentationTheme, item: item, additionalAction: nil, openUrl: { [weak self] url in if let strongSelf = self { strongSelf.context.sharedContext.openExternalUrl(context: strongSelf.context, urlContext: .generic, url: url, forceExternal: true, presentationData: presentationData, navigationController: nil, dismissInput: {}) } @@ -1275,7 +1290,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll } } } - let shareController = ShareController(context: self.context, subject: subject, preferredAction: preferredAction, forcedTheme: defaultDarkColorPresentationTheme) + let shareController = ShareController(context: self.context, subject: subject, preferredAction: preferredAction, forcedTheme: presentationData.theme.overallDarkAppearance ? nil : defaultDarkColorPresentationTheme) shareController.completed = { [weak self] peerIds in if let strongSelf = self { let _ = (strongSelf.context.account.postbox.transaction { transaction -> [Peer] in diff --git a/submodules/GalleryUI/Sources/GalleryController.swift b/submodules/GalleryUI/Sources/GalleryController.swift index a35425a0fe..2f4fa9c6ac 100644 --- a/submodules/GalleryUI/Sources/GalleryController.swift +++ b/submodules/GalleryUI/Sources/GalleryController.swift @@ -665,7 +665,10 @@ public class GalleryController: ViewController, StandalonePresentableController openActionOptionsImpl = { [weak self] action in if let strongSelf = self { - let presentationData = strongSelf.presentationData + var presentationData = strongSelf.presentationData + if !presentationData.theme.overallDarkAppearance { + presentationData = presentationData.withUpdated(theme: defaultDarkColorPresentationTheme) + } switch action { case let .url(url, _): var cleanUrl = url @@ -673,7 +676,7 @@ public class GalleryController: ViewController, StandalonePresentableController let canOpenIn = availableOpenInOptions(context: strongSelf.context, item: .url(url: url)).count > 1 let mailtoString = "mailto:" let telString = "tel:" - var openText = strongSelf.presentationData.strings.Conversation_LinkDialogOpen + var openText = presentationData.strings.Conversation_LinkDialogOpen var phoneNumber: String? var isEmail = false @@ -686,12 +689,12 @@ public class GalleryController: ViewController, StandalonePresentableController canAddToReadingList = false phoneNumber = String(cleanUrl[cleanUrl.index(cleanUrl.startIndex, offsetBy: telString.distance(from: telString.startIndex, to: telString.endIndex))...]) cleanUrl = phoneNumber! - openText = strongSelf.presentationData.strings.UserInfo_PhoneCall + openText = presentationData.strings.UserInfo_PhoneCall isPhoneNumber = true } else if canOpenIn { - openText = strongSelf.presentationData.strings.Conversation_FileOpenIn + openText = presentationData.strings.Conversation_FileOpenIn } - let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData.withUpdated(theme: defaultDarkColorPresentationTheme)) + let actionSheet = ActionSheetController(presentationData: presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetTextItem(title: cleanUrl)) @@ -707,7 +710,7 @@ public class GalleryController: ViewController, StandalonePresentableController } })) if let phoneNumber = phoneNumber { - items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_AddContact, color: .accent, action: { [weak actionSheet] in + items.append(ActionSheetButtonItem(title: presentationData.strings.Conversation_AddContact, color: .accent, action: { [weak actionSheet] in actionSheet?.dismissAnimated() if let strongSelf = self { strongSelf.dismiss(forceAway: false) @@ -715,7 +718,7 @@ public class GalleryController: ViewController, StandalonePresentableController } })) } - items.append(ActionSheetButtonItem(title: canAddToReadingList ? strongSelf.presentationData.strings.ShareMenu_CopyShareLink : strongSelf.presentationData.strings.Conversation_ContextMenuCopy, color: .accent, action: { [weak actionSheet, weak self] in + items.append(ActionSheetButtonItem(title: canAddToReadingList ? presentationData.strings.ShareMenu_CopyShareLink : presentationData.strings.Conversation_ContextMenuCopy, color: .accent, action: { [weak actionSheet, weak self] in actionSheet?.dismissAnimated() UIPasteboard.general.string = cleanUrl @@ -732,7 +735,7 @@ public class GalleryController: ViewController, StandalonePresentableController self?.present(UndoOverlayController(presentationData: presentationData, content: content, elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), in: .window(.root)) })) if canAddToReadingList { - items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_AddToReadingList, color: .accent, action: { [weak actionSheet] in + items.append(ActionSheetButtonItem(title: presentationData.strings.Conversation_AddToReadingList, color: .accent, action: { [weak actionSheet] in actionSheet?.dismissAnimated() if let link = URL(string: url) { let _ = try? SSReadingList.default()?.addItem(with: link, title: nil, previewText: nil) @@ -740,13 +743,13 @@ public class GalleryController: ViewController, StandalonePresentableController })) } actionSheet.setItemGroups([ActionSheetItemGroup(items: items), ActionSheetItemGroup(items: [ - ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in + ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in actionSheet?.dismissAnimated() }) ])]) strongSelf.present(actionSheet, in: .window(.root)) case let .peerMention(peerId, mention): - let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData.withUpdated(theme: defaultDarkColorPresentationTheme)) + let actionSheet = ActionSheetController(presentationData: presentationData) var items: [ActionSheetItem] = [] if !mention.isEmpty { items.append(ActionSheetTextItem(title: mention)) @@ -774,7 +777,7 @@ public class GalleryController: ViewController, StandalonePresentableController ])]) strongSelf.present(actionSheet, in: .window(.root)) case let .textMention(mention): - let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData.withUpdated(theme: defaultDarkColorPresentationTheme)) + let actionSheet = ActionSheetController(presentationData: presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: mention), ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_LinkDialogOpen, color: .accent, action: { [weak actionSheet] in @@ -798,7 +801,7 @@ public class GalleryController: ViewController, StandalonePresentableController ])]) strongSelf.present(actionSheet, in: .window(.root)) case let .botCommand(command): - let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData.withUpdated(theme: defaultDarkColorPresentationTheme)) + let actionSheet = ActionSheetController(presentationData: presentationData) var items: [ActionSheetItem] = [] items.append(ActionSheetTextItem(title: command)) items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_LinkDialogCopy, color: .accent, action: { [weak actionSheet, weak self] in @@ -815,7 +818,7 @@ public class GalleryController: ViewController, StandalonePresentableController ])]) strongSelf.present(actionSheet, in: .window(.root)) case let .hashtag(peerName, hashtag): - let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData.withUpdated(theme: defaultDarkColorPresentationTheme)) + let actionSheet = ActionSheetController(presentationData: presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: hashtag), ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_LinkDialogOpen, color: .accent, action: { [weak actionSheet] in @@ -840,7 +843,7 @@ public class GalleryController: ViewController, StandalonePresentableController ]) strongSelf.present(actionSheet, in: .window(.root)) case let .timecode(timecode, text): - let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData.withUpdated(theme: defaultDarkColorPresentationTheme)) + let actionSheet = ActionSheetController(presentationData: presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: text), ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_LinkDialogOpen, color: .accent, action: { [weak actionSheet] in diff --git a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift index 75fe8b3561..25c46bf8ff 100644 --- a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift @@ -504,14 +504,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { if item.hideControls { self.statusButtonNode.isHidden = true } - - let dimensions = item.content.dimensions - if dimensions.height > 0.0 { - if dimensions.width / dimensions.height < 1.33 { - self.overlayContentNode.isHidden = true - } - } - + self.dismissOnOrientationChange = item.landscape var hasLinkedStickers = false @@ -546,6 +539,13 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { forceEnablePiP = true } + let dimensions = item.content.dimensions + if dimensions.height > 0.0 { + if dimensions.width / dimensions.height < 1.33 || isAnimated { + self.overlayContentNode.isHidden = true + } + } + if let videoNode = self.videoNode { videoNode.canAttachContent = false videoNode.removeFromSupernode() diff --git a/submodules/InstantPageUI/Sources/InstantPageGalleryController.swift b/submodules/InstantPageUI/Sources/InstantPageGalleryController.swift index 8c4754b2f1..3132ae4f80 100644 --- a/submodules/InstantPageUI/Sources/InstantPageGalleryController.swift +++ b/submodules/InstantPageUI/Sources/InstantPageGalleryController.swift @@ -282,9 +282,14 @@ public class InstantPageGalleryController: ViewController, StandalonePresentable openLinkOptionsImpl = { [weak self] url in if let strongSelf = self { + var presentationData = strongSelf.presentationData + if !presentationData.theme.overallDarkAppearance { + presentationData = presentationData.withUpdated(theme: defaultDarkColorPresentationTheme) + } + let canOpenIn = availableOpenInOptions(context: context, item: .url(url: url.url)).count > 1 let openText = canOpenIn ? strongSelf.presentationData.strings.Conversation_FileOpenIn : strongSelf.presentationData.strings.Conversation_LinkDialogOpen - let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData.withUpdated(theme: defaultDarkColorPresentationTheme)) + let actionSheet = ActionSheetController(presentationData: presentationData) actionSheet.setItemGroups([ActionSheetItemGroup(items: [ ActionSheetTextItem(title: url.url), ActionSheetButtonItem(title: openText, color: .accent, action: { [weak actionSheet] in diff --git a/submodules/JoinLinkPreviewUI/BUILD b/submodules/JoinLinkPreviewUI/BUILD index cb02124a89..a7fb398ee0 100644 --- a/submodules/JoinLinkPreviewUI/BUILD +++ b/submodules/JoinLinkPreviewUI/BUILD @@ -20,6 +20,7 @@ swift_library( "//submodules/ShareController:ShareController", "//submodules/SelectablePeerNode:SelectablePeerNode", "//submodules/PeerInfoUI:PeerInfoUI", + "//submodules/UndoUI:UndoUI", ], visibility = [ "//visibility:public", diff --git a/submodules/JoinLinkPreviewUI/Sources/JoinLinkPreviewController.swift b/submodules/JoinLinkPreviewUI/Sources/JoinLinkPreviewController.swift index 4701e24a22..ea5de677db 100644 --- a/submodules/JoinLinkPreviewUI/Sources/JoinLinkPreviewController.swift +++ b/submodules/JoinLinkPreviewUI/Sources/JoinLinkPreviewController.swift @@ -11,6 +11,7 @@ import AccountContext import AlertUI import PresentationDataUtils import PeerInfoUI +import UndoUI public final class JoinLinkPreviewController: ViewController { private var controllerNode: JoinLinkPreviewControllerNode { @@ -87,7 +88,8 @@ public final class JoinLinkPreviewController: ViewController { strongSelf.navigateToPeer(peerId, ChatPeekTimeout(deadline: deadline, linkData: strongSelf.link)) strongSelf.dismiss() case .invalidHash: - strongSelf.present(textAlertController(context: strongSelf.context, title: nil, text: strongSelf.presentationData.strings.InviteLinks_InviteLinkExpired, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root)) + let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 } + strongSelf.present(UndoOverlayController(presentationData: presentationData, content: .linkRevoked(text: presentationData.strings.InviteLinks_InviteLinkExpired), elevatedLayout: true, animateInAsReplacement: true, action: { _ in return false }), in: .window(.root)) strongSelf.dismiss() } } diff --git a/submodules/TelegramBaseController/Sources/TelegramBaseController.swift b/submodules/TelegramBaseController/Sources/TelegramBaseController.swift index 9bdaf8d5e4..534023efba 100644 --- a/submodules/TelegramBaseController/Sources/TelegramBaseController.swift +++ b/submodules/TelegramBaseController/Sources/TelegramBaseController.swift @@ -856,6 +856,8 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder { let context = self.context let presentationData = self.context.sharedContext.currentPresentationData.with { $0 } + self.view.endEditing(true) + self.context.joinGroupCall(peerId: peerId, invite: invite, requestJoinAsPeerId: { completion in let currentAccountPeer = context.account.postbox.loadedPeerWithId(context.account.peerId) |> map { peer in @@ -898,7 +900,10 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder { var items: [ActionSheetItem] = [] var isGroup = false for peer in peers { - if let peer = peer.peer as? TelegramChannel, case .group = peer.info { + if peer.peer is TelegramGroup { + isGroup = true + break + } else if let peer = peer.peer as? TelegramChannel, case .group = peer.info { isGroup = true break } diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift index dba9aa2e02..0b592a6ee1 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift @@ -1265,8 +1265,8 @@ public final class VoiceChatController: ViewController { openTitle = strongSelf.presentationData.strings.VoiceChat_OpenChannel openIcon = UIImage(bundleImageName: "Chat/Context Menu/Channels") } else { - openTitle = strongSelf.presentationData.strings.VoiceChat_OpenChat - openIcon = UIImage(bundleImageName: "Chat/Context Menu/Message") + openTitle = strongSelf.presentationData.strings.Conversation_ContextMenuOpenProfile + openIcon = UIImage(bundleImageName: "Chat/Context Menu/Info") } items.append(.action(ContextMenuActionItem(text: openTitle, icon: { theme in return generateTintedImage(image: openIcon, color: theme.actionSheet.primaryTextColor) @@ -1277,7 +1277,7 @@ public final class VoiceChatController: ViewController { let context = strongSelf.context strongSelf.controller?.dismiss(completion: { - Queue.mainQueue().justDispatch { + Queue.mainQueue().after(0.3) { if peer.id.namespace == Namespaces.Peer.CloudUser { let _ = (strongSelf.context.account.postbox.loadedPeerWithId(peer.id) |> take(1) @@ -1299,7 +1299,7 @@ public final class VoiceChatController: ViewController { } }) - f(.dismissWithoutContent) + f(.default) }))) if let callState = strongSelf.callState, (callState.canManageCall && !callState.adminIds.contains(peer.id)) { @@ -1959,7 +1959,10 @@ public final class VoiceChatController: ViewController { var isGroup = false for peer in peers { - if let peer = peer.peer as? TelegramChannel, case .group = peer.info { + if peer.peer is TelegramGroup { + isGroup = true + break + } else if let peer = peer.peer as? TelegramChannel, case .group = peer.info { isGroup = true break } diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatJoinScreen.swift b/submodules/TelegramCallsUI/Sources/VoiceChatJoinScreen.swift index e4c8d97308..b6086120ad 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatJoinScreen.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatJoinScreen.swift @@ -14,6 +14,7 @@ import PresentationDataUtils import PeerInfoUI import ShareController import AvatarNode +import UndoUI public final class VoiceChatJoinScreen: ViewController { private var controllerNode: Node { @@ -152,7 +153,8 @@ public final class VoiceChatJoinScreen: ViewController { strongSelf.controllerNode.setPeer(call: activeCall, peer: peer, title: call.info.title, memberCount: call.info.participantCount) } } else { - strongSelf.present(textAlertController(context: strongSelf.context, title: nil, text: strongSelf.presentationData.strings.InviteLinks_InviteLinkExpired, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root)) + let presentationData = context.sharedContext.currentPresentationData.with { $0 } + strongSelf.present(UndoOverlayController(presentationData: presentationData, content: .linkRevoked(text: presentationData.strings.InviteLinks_InviteLinkExpired), elevatedLayout: true, animateInAsReplacement: true, action: { _ in return false }), in: .window(.root)) strongSelf.dismiss() } } diff --git a/submodules/TelegramPresentationData/Sources/PresentationData.swift b/submodules/TelegramPresentationData/Sources/PresentationData.swift index b8eee86679..75e1d1a4bc 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationData.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationData.swift @@ -16,6 +16,7 @@ public struct PresentationDateTimeFormat: Equatable { public let dateFormat: PresentationDateFormat public let dateSeparator: String public let dateSuffix: String + public let requiresFullYear: Bool public let decimalSeparator: String public let groupingSeparator: String @@ -24,15 +25,17 @@ public struct PresentationDateTimeFormat: Equatable { self.dateFormat = .monthFirst self.dateSeparator = "." self.dateSuffix = "" + self.requiresFullYear = false self.decimalSeparator = "." self.groupingSeparator = "." } - public init(timeFormat: PresentationTimeFormat, dateFormat: PresentationDateFormat, dateSeparator: String, dateSuffix: String, decimalSeparator: String, groupingSeparator: String) { + public init(timeFormat: PresentationTimeFormat, dateFormat: PresentationDateFormat, dateSeparator: String, dateSuffix: String, requiresFullYear: Bool, decimalSeparator: String, groupingSeparator: String) { self.timeFormat = timeFormat self.dateFormat = dateFormat self.dateSeparator = dateSeparator self.dateSuffix = dateSuffix + self.requiresFullYear = requiresFullYear self.decimalSeparator = decimalSeparator self.groupingSeparator = groupingSeparator } @@ -157,12 +160,14 @@ private func currentDateTimeFormat() -> PresentationDateTimeFormat { let dateFormat: PresentationDateFormat var dateSeparator = "/" var dateSuffix = "" + var requiresFullYear = false if let dateString = DateFormatter.dateFormat(fromTemplate: "MdY", options: 0, locale: locale) { for separator in [". ", ".", "/", "-", "/"] { if dateString.contains(separator) { if separator == ". " { dateSuffix = "." dateSeparator = "." + requiresFullYear = true } else { dateSeparator = separator } @@ -180,7 +185,7 @@ private func currentDateTimeFormat() -> PresentationDateTimeFormat { let decimalSeparator = locale.decimalSeparator ?? "." let groupingSeparator = locale.groupingSeparator ?? "" - return PresentationDateTimeFormat(timeFormat: timeFormat, dateFormat: dateFormat, dateSeparator: dateSeparator, dateSuffix: dateSuffix, decimalSeparator: decimalSeparator, groupingSeparator: groupingSeparator) + return PresentationDateTimeFormat(timeFormat: timeFormat, dateFormat: dateFormat, dateSeparator: dateSeparator, dateSuffix: dateSuffix, requiresFullYear: requiresFullYear, decimalSeparator: decimalSeparator, groupingSeparator: groupingSeparator) } private func currentPersonNameSortOrder() -> PresentationPersonNameOrder { diff --git a/submodules/TelegramStringFormatting/Sources/DateFormat.swift b/submodules/TelegramStringFormatting/Sources/DateFormat.swift index fedb29e4d1..ebf1f1c351 100644 --- a/submodules/TelegramStringFormatting/Sources/DateFormat.swift +++ b/submodules/TelegramStringFormatting/Sources/DateFormat.swift @@ -54,11 +54,12 @@ public func stringForMediumDate(timestamp: Int32, strings: PresentationStrings, let dateString: String let separator = dateTimeFormat.dateSeparator let suffix = dateTimeFormat.dateSuffix + let displayYear = dateTimeFormat.requiresFullYear ? year - 100 + 2000 : year - 100 switch dateTimeFormat.dateFormat { case .monthFirst: - dateString = String(format: "%02d%@%02d%@%02d%@", month, separator, day, separator, year - 100, suffix) + dateString = String(format: "%02d%@%02d%@%02d%@", month, separator, day, separator, displayYear, suffix) case .dayFirst: - dateString = String(format: "%02d%@%02d%@%02d%@", day, separator, month, separator, year - 100, suffix) + dateString = String(format: "%02d%@%02d%@%02d%@", day, separator, month, separator, displayYear, suffix) } let timeString = stringForShortTimestamp(hours: Int32(timeinfo.tm_hour), minutes: Int32(timeinfo.tm_min), dateTimeFormat: dateTimeFormat) diff --git a/submodules/TelegramStringFormatting/Sources/PresenceStrings.swift b/submodules/TelegramStringFormatting/Sources/PresenceStrings.swift index 5a30f40144..f0ab9f7838 100644 --- a/submodules/TelegramStringFormatting/Sources/PresenceStrings.swift +++ b/submodules/TelegramStringFormatting/Sources/PresenceStrings.swift @@ -7,11 +7,12 @@ import TelegramPresentationData public func stringForTimestamp(day: Int32, month: Int32, year: Int32, dateTimeFormat: PresentationDateTimeFormat) -> String { let separator = dateTimeFormat.dateSeparator let suffix = dateTimeFormat.dateSuffix + let displayYear = dateTimeFormat.requiresFullYear ? year - 100 + 2000 : year - 100 switch dateTimeFormat.dateFormat { case .monthFirst: - return String(format: "%02d%@%02d%@%02d%@", month, separator, day, separator, year - 100, suffix) + return String(format: "%02d%@%02d%@%02d%@", month, separator, day, separator, displayYear, suffix) case .dayFirst: - return String(format: "%02d%@%02d%@%02d%@", day, separator, month, separator, year - 100, suffix) + return String(format: "%02d%@%02d%@%02d%@", day, separator, month, separator, displayYear, suffix) } } diff --git a/submodules/TelegramUI/Sources/ContactSelectionController.swift b/submodules/TelegramUI/Sources/ContactSelectionController.swift index f5a0659e84..e8988a0757 100644 --- a/submodules/TelegramUI/Sources/ContactSelectionController.swift +++ b/submodules/TelegramUI/Sources/ContactSelectionController.swift @@ -35,6 +35,7 @@ class ContactSelectionControllerImpl: ViewController, ContactSelectionController private let options: [ContactListAdditionalOption] private let displayDeviceContacts: Bool private let displayCallIcons: Bool + private let multipleSelection: Bool private var _ready = Promise() override var ready: Promise { @@ -77,6 +78,7 @@ class ContactSelectionControllerImpl: ViewController, ContactSelectionController self.displayDeviceContacts = params.displayDeviceContacts self.displayCallIcons = params.displayCallIcons self.confirmation = params.confirmation + self.multipleSelection = params.multipleSelection self.presentationData = context.sharedContext.currentPresentationData.with { $0 } @@ -154,7 +156,7 @@ class ContactSelectionControllerImpl: ViewController, ContactSelectionController } override func loadDisplayNode() { - self.displayNode = ContactSelectionControllerNode(context: self.context, options: self.options, displayDeviceContacts: self.displayDeviceContacts, displayCallIcons: self.displayCallIcons) + self.displayNode = ContactSelectionControllerNode(context: self.context, options: self.options, displayDeviceContacts: self.displayDeviceContacts, displayCallIcons: self.displayCallIcons, multipleSelection: self.multipleSelection) self._ready.set(self.contactsNode.contactListNode.ready) self.contactsNode.navigationBar = self.navigationBar diff --git a/submodules/TelegramUI/Sources/ContactSelectionControllerNode.swift b/submodules/TelegramUI/Sources/ContactSelectionControllerNode.swift index dd204ee413..f53326a268 100644 --- a/submodules/TelegramUI/Sources/ContactSelectionControllerNode.swift +++ b/submodules/TelegramUI/Sources/ContactSelectionControllerNode.swift @@ -47,13 +47,13 @@ final class ContactSelectionControllerNode: ASDisplayNode { private var selectionState: ContactListNodeGroupSelectionState? - init(context: AccountContext, options: [ContactListAdditionalOption], displayDeviceContacts: Bool, displayCallIcons: Bool) { + init(context: AccountContext, options: [ContactListAdditionalOption], displayDeviceContacts: Bool, displayCallIcons: Bool, multipleSelection: Bool) { self.context = context self.presentationData = context.sharedContext.currentPresentationData.with { $0 } self.displayDeviceContacts = displayDeviceContacts self.displayCallIcons = displayCallIcons - self.contactListNode = ContactListNode(context: context, presentation: .single(.natural(options: options, includeChatList: false)), displayCallIcons: displayCallIcons) + self.contactListNode = ContactListNode(context: context, presentation: .single(.natural(options: options, includeChatList: false)), displayCallIcons: displayCallIcons, multipleSelection: multipleSelection) self.dimNode = ASDisplayNode() diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index 4146876fd4..41f8b93d79 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -1284,7 +1284,7 @@ private func editingItems(data: PeerInfoScreenData?, context: AccountContext, pr } } else { if cachedData.flags.contains(.canChangeUsername) { - items[.peerPublicSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemUsername, label: .text(isPublic ? presentationData.strings.Channel_Setup_TypePublic : presentationData.strings.Channel_Setup_TypePrivate), text: presentationData.strings.GroupInfo_GroupType, icon: UIImage(bundleImageName: "Chat/Info/GroupTypeIcon"), action: { + items[.peerPublicSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemUsername, label: .text(isPublic ? presentationData.strings.Group_Setup_TypePublic : presentationData.strings.Group_Setup_TypePrivate), text: presentationData.strings.GroupInfo_GroupType, icon: UIImage(bundleImageName: "Chat/Info/GroupTypeIcon"), action: { interaction.editingOpenPublicLinkSetup() })) } @@ -4365,7 +4365,10 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD var isGroup = false for peer in peers { - if let peer = peer.peer as? TelegramChannel, case .group = peer.info { + if peer.peer is TelegramGroup { + isGroup = true + break + } else if let peer = peer.peer as? TelegramChannel, case .group = peer.info { isGroup = true break }