diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 9b424bf106..af885d6c05 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -7137,3 +7137,5 @@ Sorry for the inconvenience."; "UserInfo.QRCode.InfoYou" = "Everyone on Telegram can scan this code to message you."; "UserInfo.QRCode.InfoBot" = "Everyone on Telegram can scan this code to use this bot."; "UserInfo.QRCode.InfoOther" = "Everyone on Telegram can scan this code to message %@."; + +"PeerInfo.QRCode.Title" = "QR Code"; diff --git a/submodules/QrCodeUI/Sources/QrCodeScreen.swift b/submodules/QrCodeUI/Sources/QrCodeScreen.swift index 7a89f95658..1ff524792d 100644 --- a/submodules/QrCodeUI/Sources/QrCodeScreen.swift +++ b/submodules/QrCodeUI/Sources/QrCodeScreen.swift @@ -218,8 +218,31 @@ public final class QrCodeScreen: ViewController { self.contentBackgroundNode = ASDisplayNode() self.contentBackgroundNode.backgroundColor = backgroundColor + let title: String + let text: String + switch subject { + case let .peer(peer): + title = self.presentationData.strings.PeerInfo_QRCode_Title + if case let .user(user) = peer { + if user.id == context.account.peerId { + text = self.presentationData.strings.UserInfo_QRCode_InfoYou + } else if user.botInfo != nil { + text = self.presentationData.strings.UserInfo_QRCode_InfoBot + } else { + text = self.presentationData.strings.UserInfo_QRCode_InfoOther(peer.compactDisplayTitle).string + } + } else if case let .channel(channel) = peer, case .broadcast = channel.info { + text = self.presentationData.strings.GroupInfo_QRCode_Info + } else { + text = self.presentationData.strings.ChannelInfo_QRCode_Info + } + case let .invite(_, isGroup): + title = self.presentationData.strings.InviteLink_QRCode_Title + text = isGroup ? self.presentationData.strings.InviteLink_QRCode_Info : self.presentationData.strings.InviteLink_QRCode_InfoChannel + } + self.titleNode = ASTextNode() - self.titleNode.attributedText = NSAttributedString(string: self.presentationData.strings.InviteLink_QRCode_Title, font: Font.bold(17.0), textColor: textColor) + self.titleNode.attributedText = NSAttributedString(string: title, font: Font.bold(17.0), textColor: textColor) self.cancelButton = HighlightableButtonNode() self.cancelButton.setTitle(self.presentationData.strings.Common_Done, with: Font.bold(17.0), with: accentColor, for: .normal) @@ -264,27 +287,7 @@ public final class QrCodeScreen: ViewController { self.contentContainerNode.addSubnode(self.qrIconNode) self.contentContainerNode.addSubnode(self.qrButtonNode) - let text: String - switch subject { - case let .peer(peer): - if case let .user(user) = peer { - if user.id == context.account.peerId { - text = self.presentationData.strings.UserInfo_QRCode_InfoYou - } else if user.botInfo != nil { - text = self.presentationData.strings.UserInfo_QRCode_InfoBot - } else { - text = self.presentationData.strings.UserInfo_QRCode_InfoOther(peer.compactDisplayTitle).string - } - } else if case let .channel(channel) = peer, case .broadcast = channel.info { - text = self.presentationData.strings.GroupInfo_QRCode_Info - } else { - text = self.presentationData.strings.ChannelInfo_QRCode_Info - } - case let .invite(_, isGroup): - text = isGroup ? self.presentationData.strings.InviteLink_QRCode_Info : self.presentationData.strings.InviteLink_QRCode_InfoChannel - } - - self.textNode.attributedText = NSAttributedString(string: text, font: Font.regular(13.0), textColor: secondaryTextColor) + self.textNode.attributedText = NSAttributedString(string: text, font: Font.regular(14.0), textColor: secondaryTextColor) self.buttonNode.title = self.presentationData.strings.InviteLink_QRCode_Share self.cancelButton.addTarget(self, action: #selector(self.cancelButtonPressed), forControlEvents: .touchUpInside) @@ -439,7 +442,7 @@ public final class QrCodeScreen: ViewController { } let inset: CGFloat = 32.0 - var textSize = self.textNode.updateLayout(CGSize(width: width - inset * 2.0, height: CGFloat.greatestFiniteMagnitude)) + var textSize = self.textNode.updateLayout(CGSize(width: width - inset * 3.0, height: CGFloat.greatestFiniteMagnitude)) let textFrame = CGRect(origin: CGPoint(x: floor((width - textSize.width) / 2.0), y: imageFrame.maxY + 20.0), size: textSize) transition.updateFrame(node: self.textNode, frame: textFrame) @@ -482,7 +485,7 @@ public final class QrCodeScreen: ViewController { transition.updateFrame(node: self.titleNode, frame: titleFrame) let cancelSize = self.cancelButton.measure(CGSize(width: width, height: titleHeight)) - let cancelFrame = CGRect(origin: CGPoint(x: width - cancelSize.width - 16.0, y: 18.0), size: cancelSize) + let cancelFrame = CGRect(origin: CGPoint(x: width - cancelSize.width - 16.0, y: 16.0), size: cancelSize) transition.updateFrame(node: self.cancelButton, frame: cancelFrame) let buttonInset: CGFloat = 16.0 diff --git a/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesRootController.swift b/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesRootController.swift index 15a7e6b44c..b9b1061675 100644 --- a/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesRootController.swift +++ b/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesRootController.swift @@ -100,7 +100,7 @@ public struct PresentationResourcesRootController { } public static func navigationQrCodeIcon(_ theme: PresentationTheme) -> UIImage? { - return theme.image(PresentationResourceKey.navigationMoreCircledIcon.rawValue, { theme in + return theme.image(PresentationResourceKey.navigationQrCodeIcon.rawValue, { theme in generateTintedImage(image: UIImage(bundleImageName: "Settings/QrIcon"), color: theme.rootController.navigationBar.accentTextColor) }) } diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift index ef25e82d2d..712a3c61b5 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift @@ -935,6 +935,10 @@ final class PeerInfoHeaderNavigationButton: HighlightableButtonNode { var isWhite: Bool = false { didSet { if self.isWhite != oldValue { + if case .qrCode = self.key, let theme = self.theme { + self.iconNode.image = self.isWhite ? generateTintedImage(image: PresentationResourcesRootController.navigationQrCodeIcon(theme), color: .white) : PresentationResourcesRootController.navigationQrCodeIcon(theme) + } + self.regularTextNode.isHidden = self.isWhite self.whiteTextNode.isHidden = !self.isWhite } @@ -1141,7 +1145,7 @@ final class PeerInfoHeaderNavigationButtonContainerNode: ASDisplayNode { } var removeKeys: [PeerInfoHeaderNavigationButtonKey] = [] for (key, _) in self.leftButtonNodes { - if !rightButtons.contains(where: { $0.key == key }) { + if !leftButtons.contains(where: { $0.key == key }) { removeKeys.append(key) } } @@ -1153,7 +1157,7 @@ final class PeerInfoHeaderNavigationButtonContainerNode: ASDisplayNode { } else { var nextRegularButtonOrigin = 16.0 var nextExpandedButtonOrigin = 16.0 - for spec in rightButtons.reversed() { + for spec in leftButtons.reversed() { if let buttonNode = self.leftButtonNodes[spec.key] { let buttonSize = buttonNode.bounds.size var nextButtonOrigin = spec.isForExpandedView ? nextExpandedButtonOrigin : nextRegularButtonOrigin diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index 6f8ed8dd81..f0f857e5a3 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -6640,7 +6640,6 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate } else { if self.isSettings { leftNavigationButtons.append(PeerInfoHeaderNavigationButtonSpec(key: .qrCode, isForExpandedView: false)) - leftNavigationButtons.append(PeerInfoHeaderNavigationButtonSpec(key: .qrCode, isForExpandedView: true)) rightNavigationButtons.append(PeerInfoHeaderNavigationButtonSpec(key: .edit, isForExpandedView: false)) rightNavigationButtons.append(PeerInfoHeaderNavigationButtonSpec(key: .search, isForExpandedView: true))