Skip to content

Commit 268d6ba

Browse files
committed
Various improvements
1 parent 53dc1e6 commit 268d6ba

13 files changed

Lines changed: 268 additions & 42 deletions

File tree

‎Telegram/Telegram-iOS/en.lproj/Localizable.strings‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5303,6 +5303,8 @@ Sorry for the inconvenience.";
53035303

53045304
"PeerInfo.BioExpand" = "more";
53055305
"PeerInfo.HiddenCommunityStatus" = "Hidden • %@";
5306+
"PeerInfo.Community_1" = "Community with %@ chat";
5307+
"PeerInfo.Community_any" = "Community with %@ chats";
53065308
"PeerInfo.Community.RemoveBot" = "Remove Bot from Community";
53075309
"PeerInfo.Community.AddBot" = "Add Bot to a Community";
53085310
"PeerInfo.Community.BotInfo" = "Make your bot part of a community with multiple related chats";
@@ -16430,6 +16432,7 @@ Error: %8$@";
1643016432
"Community.View.SectionVisible" = "CHATS YOU CAN VIEW";
1643116433
"Community.View.SectionRequestable" = "CHATS YOU CAN REQUEST TO JOIN";
1643216434
"Community.View.SectionHidden" = "HIDDEN CHATS";
16435+
"Community.View.HiddenChatToast" = "You can't join or view this chat until an admin invites you.";
1643316436
"Community.View.PendingRequests" = "Pending Requests";
1643416437
"Community.View.PendingRequestHeader" = "PENDING REQUEST";
1643516438
"Community.View.ShowAsOneChat" = "Show as One Chat";
@@ -16514,9 +16517,13 @@ Error: %8$@";
1651416517
"Community.Add.VisibilityHiddenInfo" = "Only invited members and community admins will see this chat.";
1651516518
"Community.Add.ActionAddToCommunity" = "Add to Community";
1651616519

16520+
"Community.AddChat.Title" = "Add a Chat";
16521+
"Community.AddChat.Description" = "Select a chat to add to this community";
16522+
1651716523
"Community.Chat.JoinToView" = "You need to join this group to view its messages.";
1651816524
"Community.PrivateChat.Info" = "This group is invite-only.\nOnly its members can view it.";
1651916525
"Community.PrivateChat.MessageOwner" = "Message Group Owner";
16526+
"Community.CommunityAdded.View" = "View";
1652016527

1652116528
"Privacy.GroupsAndChannels.InviteToCommunityError" = "Sorry, you cannot add %@ to the community because of %@'s privacy settings.";
1652216529

@@ -16543,6 +16550,15 @@ Error: %8$@";
1654316550

1654416551
"Attachment.Article" = "Article";
1654516552
"RichText.AddMediaTitle" = "Add Media";
16553+
"RichText.RemoveFormattingTitle" = "Remove Formatting?";
16554+
"RichText.RemoveFormattingText" = "This message includes rich formatting, which requires Telegram Premium.";
16555+
"RichText.SubscribeToPremium" = "Subscribe to Premium";
16556+
"RichText.SendWithoutFormatting" = "Send Without Formatting";
16557+
"RichText.LinkTitle" = "Link";
16558+
"RichText.LinkText" = "Set a URL for the selected text";
16559+
"RichText.LinkSet" = "Set";
16560+
"RichText.LinkRemove" = "Remove";
16561+
"RichText.PremiumToastText" = "Sending a message with this formatting will require [Telegram Premium]().";
1654616562
"RichText.TableMenu.Alignment" = "Alignment";
1654716563
"RichText.FormulaAdd" = "Add Formula";
1654816564
"RichText.FormulaEdit" = "Edit Formula";

‎submodules/AccountContext/Sources/AccountContext.swift‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,7 @@ public protocol SharedAccountContext: AnyObject {
14401440
func makeProxySettingsController(context: AccountContext) -> ViewController
14411441
func makeLocalizationListController(context: AccountContext) -> ViewController
14421442
func makeCreateGroupController(context: AccountContext, peerIds: [EnginePeer.Id], initialTitle: String?, mode: CreateGroupMode, completion: ((EnginePeer.Id, @escaping () -> Void) -> Void)?) -> ViewController
1443+
func makeCreateChannelController(context: AccountContext, completion: @escaping (EnginePeer.Id, @escaping () -> Void) -> Void) -> ViewController
14431444
func makeChatRecentActionsController(context: AccountContext, peer: EnginePeer, adminPeerId: EnginePeer.Id?, starsState: StarsRevenueStats?) -> ViewController
14441445
func makePrivacyAndSecurityController(context: AccountContext) -> ViewController
14451446
func makeBioPrivacyController(context: AccountContext, settings: Promise<AccountPrivacySettings?>, present: @escaping (ViewController) -> Void)

‎submodules/ItemListAvatarAndNameInfoItem/Sources/ItemListAvatarAndNameItem.swift‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,8 +938,13 @@ public class ItemListAvatarAndNameInfoItemNode: ListViewItemNode, ItemListItemNo
938938
strongSelf.addSubnode(strongSelf.inputFirstClearButton!)
939939
}
940940

941-
strongSelf.inputSeparator?.frame = CGRect(origin: CGPoint(x: params.leftInset + 100.0, y: 64.0), size: CGSize(width: params.width - params.leftInset - 100.0 - separatorRightInset, height: separatorHeight))
942-
strongSelf.inputFirstField?.frame = CGRect(origin: CGPoint(x: params.leftInset + 111.0, y: 28.0), size: CGSize(width: params.width - params.leftInset - params.rightInset - 111.0 - 36.0, height: 35.0))
941+
let inputFieldHeight: CGFloat = 35.0
942+
let inputFieldFrame = CGRect(
943+
origin: CGPoint(x: params.leftInset + 111.0, y: floorToScreenPixels((contentSize.height - inputFieldHeight) * 0.5)),
944+
size: CGSize(width: params.width - params.leftInset - params.rightInset - 111.0 - 36.0, height: inputFieldHeight)
945+
)
946+
strongSelf.inputSeparator?.frame = CGRect(origin: CGPoint(x: params.leftInset + 100.0, y: floor(inputFieldFrame.maxY + 1.0)), size: CGSize(width: params.width - params.leftInset - 100.0 - separatorRightInset, height: separatorHeight))
947+
strongSelf.inputFirstField?.frame = inputFieldFrame
943948

944949
if let image = strongSelf.inputFirstClearButton?.image(for: []), let inputFieldFrame = strongSelf.inputFirstField?.frame {
945950
strongSelf.inputFirstClearButton?.frame = CGRect(origin: CGPoint(x: inputFieldFrame.maxX, y: inputFieldFrame.minY + floor((inputFieldFrame.size.height - image.size.height) / 2.0) - 1.0 + UIScreenPixel), size: image.size)

‎submodules/TelegramCore/Sources/TelegramEngine/Peers/AddressNames.swift‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,8 @@ func _internal_adminedPublicChannels(account: Account, scope: AdminedPublicChann
591591
if case let .channel(channelData) = chat {
592592
let participantsCount = channelData.participantsCount
593593
subscriberCounts[chat.peerId] = participantsCount.flatMap(Int.init)
594+
} else if case let .chat(chatData) = chat {
595+
subscriberCounts[chat.peerId] = Int(chatData.participantsCount)
594596
}
595597
}
596598
case let .chatsSlice(chatsSliceData):

‎submodules/TelegramUI/Components/Chat/ChatMessageCommunityChangedBubbleContentNode/Sources/ChatMessageCommunityChangedBubbleContentNode.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public class ChatMessageCommunityChangedBubbleContentNode: ChatMessageBubbleCont
158158

159159
let (subtitleLayout, subtitleApply) = makeSubtitleLayout(TextNodeLayoutArguments(attributedString: attributedText, backgroundColor: nil, maximumNumberOfLines: 0, truncationType: .end, constrainedSize: CGSize(width: width - 32.0, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets()))
160160

161-
let (buttonTitleLayout, buttonTitleApply) = makeButtonTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: "View", font: Font.semibold(15.0), textColor: primaryTextColor, paragraphAlignment: .center), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: width - 32.0, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets()))
161+
let (buttonTitleLayout, buttonTitleApply) = makeButtonTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.presentationData.strings.Community_CommunityAdded_View, font: Font.semibold(15.0), textColor: primaryTextColor, paragraphAlignment: .center), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: width - 32.0, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets()))
162162

163163
let backgroundSize = CGSize(width: width, height: subtitleLayout.size.height + 165.0)
164164

‎submodules/TelegramUI/Components/Communities/CommunityViewScreen/Sources/CommunityViewScreen.swift‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,21 @@ private final class CommunityViewContentComponent: Component {
10501050
), in: .window(.root))
10511051
}
10521052

1053+
private func presentHiddenChatToast() {
1054+
guard let component = self.component, let environment = self.environment, let controller = environment.controller() else {
1055+
return
1056+
}
1057+
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }
1058+
controller.present(UndoOverlayController(
1059+
presentationData: presentationData,
1060+
content: .banned(text: presentationData.strings.Community_View_HiddenChatToast),
1061+
elevatedLayout: true,
1062+
position: .bottom,
1063+
animateInAsReplacement: false,
1064+
action: { _ in return true }
1065+
), in: .current)
1066+
}
1067+
10531068
private func activateChatPreview(item: ChatListItem, sourceNode: ASDisplayNode, gesture: ContextGesture?) {
10541069
guard let component = self.component, let environment = self.environment, let controller = environment.controller() else {
10551070
gesture?.cancel()
@@ -1467,8 +1482,15 @@ private final class CommunityViewContentComponent: Component {
14671482
background: component.mode.usesPlainStyle ? theme.chatList.itemBackgroundColor : theme.list.itemBlocksBackgroundColor
14681483
),
14691484
insets: UIEdgeInsets(top: 2.0, left: 0.0, bottom: 2.0, right: 0.0),
1470-
action: { peer, _, _ in
1471-
component.openPeer(peer)
1485+
action: { [weak self] peer, _, _ in
1486+
switch section {
1487+
case .requestable:
1488+
component.openPeer(peer)
1489+
case .hidden:
1490+
self?.presentHiddenChatToast()
1491+
default:
1492+
break
1493+
}
14721494
}
14731495
))))
14741496
}

‎submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/ListItems/PeerInfoScreenCommunityItem.swift‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ private final class PeerInfoScreenCommunityItemNode: PeerInfoScreenItemNode {
110110

111111
let subtitle: String?
112112
if let chatCount = item.chatCount {
113-
let formattedCount = presentationStringsFormattedNumber(Int32(clamping: chatCount), presentationData.dateTimeFormat.groupingSeparator)
114-
subtitle = chatCount == 1 ? "Community with \(formattedCount) chat" : "Community with \(formattedCount) chats"
113+
subtitle = presentationData.strings.PeerInfo_Community(Int32(clamping: chatCount))
115114
} else {
116115
subtitle = nil
117116
}

‎submodules/TelegramUI/Components/RichTextAttachmentScreen/Sources/RichTextAttachmentScreen.swift‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,9 @@ public class RichTextAttachmentScreen: ViewControllerComponentContainer, Attachm
327327
return
328328
}
329329

330-
let controller = textAlertController(context: self.context, title: "Remove Formatting?", text: "This message includes rich formatting, which requires Telegram Premium.", actions: [
331-
TextAlertAction(type: .defaultAction, title: "Subscribe to Premium", action: { [weak self] in
330+
let strings = self.context.sharedContext.currentPresentationData.with { $0 }.strings
331+
let controller = textAlertController(context: self.context, title: strings.RichText_RemoveFormattingTitle, text: strings.RichText_RemoveFormattingText, actions: [
332+
TextAlertAction(type: .defaultAction, title: strings.RichText_SubscribeToPremium, action: { [weak self] in
332333
guard let self else {
333334
return
334335
}
@@ -339,10 +340,10 @@ public class RichTextAttachmentScreen: ViewControllerComponentContainer, Attachm
339340
self.push(premiumController)
340341
}
341342
}),
342-
TextAlertAction(type: .genericAction, title: "Send Without Formatting", action: { [weak self] in
343+
TextAlertAction(type: .genericAction, title: strings.RichText_SendWithoutFormatting, action: { [weak self] in
343344
self?.complete(withoutFormatting: true)
344345
}),
345-
TextAlertAction(type: .genericAction, title: "Cancel", action: {
346+
TextAlertAction(type: .genericAction, title: strings.Common_Cancel, action: {
346347
})
347348
], actionLayout: .vertical)
348349
self.present(controller, in: .window(.root))
@@ -533,26 +534,27 @@ final class RichTextAttachmentScreenComponent: Component {
533534
}
534535

535536
let existing = editor.currentLink()
536-
let alert = UIAlertController(title: "Link", message: "Set a URL for the selected text", preferredStyle: .alert)
537+
let strings = component.context.sharedContext.currentPresentationData.with { $0 }.strings
538+
let alert = UIAlertController(title: strings.RichText_LinkTitle, message: strings.RichText_LinkText, preferredStyle: .alert)
537539
alert.addTextField { tf in
538540
tf.placeholder = "https://example.com"
539541
tf.text = existing
540542
tf.keyboardType = .URL
541543
tf.autocapitalizationType = .none
542544
tf.autocorrectionType = .no
543545
}
544-
alert.addAction(UIAlertAction(title: "Set", style: .default) { [weak self, weak alert] _ in
546+
alert.addAction(UIAlertAction(title: strings.RichText_LinkSet, style: .default) { [weak self, weak alert] _ in
545547
guard let url = alert?.textFields?.first?.text, !url.isEmpty else { return }
546548
self?.editor.becomeFirstResponder()
547549
self?.editor.setLink(url)
548550
})
549551
if existing != nil {
550-
alert.addAction(UIAlertAction(title: "Remove", style: .destructive) { [weak self] _ in
552+
alert.addAction(UIAlertAction(title: strings.RichText_LinkRemove, style: .destructive) { [weak self] _ in
551553
self?.editor.becomeFirstResponder()
552554
self?.editor.removeLink()
553555
})
554556
}
555-
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel))
557+
alert.addAction(UIAlertAction(title: strings.Common_Cancel, style: .cancel))
556558
component.context.sharedContext.mainWindow?.presentNative(alert)
557559
}
558560

@@ -609,7 +611,7 @@ final class RichTextAttachmentScreenComponent: Component {
609611

610612
let overlayController = UndoOverlayController(
611613
presentationData: presentationData,
612-
content: .premiumPaywall(title: nil, text: "Sending a message with this formatting will require [Telegram Premium]().", customUndoText: nil, timeout: nil, linkAction: nil),
614+
content: .premiumPaywall(title: nil, text: presentationData.strings.RichText_PremiumToastText, customUndoText: nil, timeout: nil, linkAction: nil),
613615
elevatedLayout: true,
614616
action: { action in
615617
if case .info = action {
@@ -709,7 +711,7 @@ final class RichTextAttachmentScreenComponent: Component {
709711
action: { _, f in f(.default); request.toggleSpoiler() }
710712
)))
711713
items.append(.action(ContextMenuActionItem(
712-
text: "Delete",
714+
text: presentationData.strings.Common_Delete,
713715
textColor: .destructive,
714716
icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Delete"), color: theme.contextMenu.destructiveColor) },
715717
action: { _, f in f(.default); request.delete() }

‎submodules/TelegramUI/Components/Settings/PeerSelectionScreen/BUILD‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ swift_library(
1212
deps = [
1313
"//submodules/Display",
1414
"//submodules/AsyncDisplayKit",
15+
"//submodules/AppBundle",
1516
"//submodules/SSignalKit/SwiftSignalKit",
1617
"//submodules/TelegramCore",
1718
"//submodules/TelegramPresentationData",

0 commit comments

Comments
 (0)