mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
UI Fixes
This commit is contained in:
parent
62730b9c0b
commit
afc97ff44c
@ -112,6 +112,7 @@
|
||||
D005808B21CAB8F000CB7CD3 /* VoipDerivedState.swift in Sources */ = {isa = PBXBuildFile; fileRef = D005808A21CAB8F000CB7CD3 /* VoipDerivedState.swift */; };
|
||||
D00580A021DCF0A200CB7CD3 /* WallpaperListPreviewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D005809F21DCF0A200CB7CD3 /* WallpaperListPreviewController.swift */; };
|
||||
D00580A221DCF0B700CB7CD3 /* WallpaperListPreviewControllerNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00580A121DCF0B700CB7CD3 /* WallpaperListPreviewControllerNode.swift */; };
|
||||
D00580B121E3DEF200CB7CD3 /* MergedItemListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00580B021E3DEF200CB7CD3 /* MergedItemListItem.swift */; };
|
||||
D0068FA821760FA300D1B315 /* StoreDownloadedMedia.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0068FA721760FA300D1B315 /* StoreDownloadedMedia.swift */; };
|
||||
D007019C2029E8F2006B9E34 /* LegqacyICloudFileController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D007019B2029E8F2006B9E34 /* LegqacyICloudFileController.swift */; };
|
||||
D007019E2029EFDD006B9E34 /* ICloudResources.swift in Sources */ = {isa = PBXBuildFile; fileRef = D007019D2029EFDD006B9E34 /* ICloudResources.swift */; };
|
||||
@ -1232,6 +1233,7 @@
|
||||
D005808A21CAB8F000CB7CD3 /* VoipDerivedState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoipDerivedState.swift; sourceTree = "<group>"; };
|
||||
D005809F21DCF0A200CB7CD3 /* WallpaperListPreviewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WallpaperListPreviewController.swift; sourceTree = "<group>"; };
|
||||
D00580A121DCF0B700CB7CD3 /* WallpaperListPreviewControllerNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WallpaperListPreviewControllerNode.swift; sourceTree = "<group>"; };
|
||||
D00580B021E3DEF200CB7CD3 /* MergedItemListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MergedItemListItem.swift; sourceTree = "<group>"; };
|
||||
D0068FA721760FA300D1B315 /* StoreDownloadedMedia.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreDownloadedMedia.swift; sourceTree = "<group>"; };
|
||||
D007019B2029E8F2006B9E34 /* LegqacyICloudFileController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegqacyICloudFileController.swift; sourceTree = "<group>"; };
|
||||
D007019D2029EFDD006B9E34 /* ICloudResources.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ICloudResources.swift; sourceTree = "<group>"; };
|
||||
@ -3924,6 +3926,7 @@
|
||||
D0E305AE1E5BA8E000D7A3A2 /* ItemListLoadingIndicatorEmptyStateItem.swift */,
|
||||
D09AEFD31E5BAF67005C1A8B /* ItemListTextEmptyStateItem.swift */,
|
||||
D0BFAE5A20AB35D200793CF2 /* IconSwitchNode.swift */,
|
||||
D00580B021E3DEF200CB7CD3 /* MergedItemListItem.swift */,
|
||||
);
|
||||
name = Items;
|
||||
sourceTree = "<group>";
|
||||
@ -5484,6 +5487,7 @@
|
||||
9F06830B21A404C4001D8EDB /* NotificationExcetionSettingsController.swift in Sources */,
|
||||
D0EC6D891EB9F58800EBF1C3 /* ChatSecretAutoremoveTimerActionSheet.swift in Sources */,
|
||||
D05D8B782195E0050064586F /* SetupTwoStepVerificationContentNode.swift in Sources */,
|
||||
D00580B121E3DEF200CB7CD3 /* MergedItemListItem.swift in Sources */,
|
||||
D0EC6D8A1EB9F58800EBF1C3 /* ChatInfo.swift in Sources */,
|
||||
D0EC6D8B1EB9F58800EBF1C3 /* ChatHistoryNavigationStack.swift in Sources */,
|
||||
D0EC6D8C1EB9F58800EBF1C3 /* NavigateToChatController.swift in Sources */,
|
||||
|
@ -66,6 +66,8 @@ final class BotPaymentSwitchItemNode: BotPaymentItemNode {
|
||||
self.switchNode.frameColor = theme.list.itemSwitchColors.frameColor
|
||||
self.switchNode.contentColor = theme.list.itemSwitchColors.contentColor
|
||||
self.switchNode.handleColor = theme.list.itemSwitchColors.handleColor
|
||||
self.switchNode.positiveContentColor = theme.list.itemSwitchColors.positiveColor
|
||||
self.switchNode.negativeContentColor = theme.list.itemSwitchColors.negativeColor
|
||||
}
|
||||
|
||||
let leftInset: CGFloat = 16.0
|
||||
|
@ -510,7 +510,7 @@ public func channelBannedMemberController(account: Account, peerId: PeerId, memb
|
||||
if state.updating {
|
||||
rightNavigationButton = ItemListNavigationButton(content: .none, style: .activity, enabled: true, action: {})
|
||||
} else {
|
||||
rightNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.Common_Done), style: .bold, enabled: true, action: {
|
||||
rightNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.GroupPermission_ApplyAlertAction), style: .bold, enabled: true, action: {
|
||||
let _ = (peerView.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { view in
|
||||
|
@ -301,15 +301,15 @@ private enum ChannelInfoEntry: ItemListNodeEntry {
|
||||
|
||||
})
|
||||
case let .admins(theme, text, value):
|
||||
return ItemListDisclosureItem(theme: theme, icon: PresentationResourcesChat.groupInfoAdminsIcon(theme), title: text, label: value, sectionId: self.section, style: .plain, action: {
|
||||
return ItemListDisclosureItem(theme: theme, title: text, label: value, sectionId: self.section, style: .plain, action: {
|
||||
arguments.openAdmins()
|
||||
})
|
||||
case let .members(theme, text, value):
|
||||
return ItemListDisclosureItem(theme: theme, icon: PresentationResourcesChat.groupInfoMembersIcon(theme), title: text, label: value, sectionId: self.section, style: .plain, action: {
|
||||
return ItemListDisclosureItem(theme: theme, title: text, label: value, sectionId: self.section, style: .plain, action: {
|
||||
arguments.openMembers()
|
||||
})
|
||||
case let .banned(theme, text, value):
|
||||
return ItemListDisclosureItem(theme: theme, icon: PresentationResourcesChat.groupInfoBannedIcon(theme), title: text, label: value, sectionId: self.section, style: .plain, action: {
|
||||
return ItemListDisclosureItem(theme: theme, title: text, label: value, sectionId: self.section, style: .plain, action: {
|
||||
arguments.openBanned()
|
||||
})
|
||||
case let .signMessages(theme, text, value):
|
||||
@ -473,6 +473,8 @@ private func channelInfoEntries(account: Account, presentationData: Presentation
|
||||
} else {
|
||||
notificationsText = presentationData.strings.UserInfo_NotificationsDisabled
|
||||
}
|
||||
} else if case .default = notificationSettings.messageSound {
|
||||
notificationsText = presentationData.strings.UserInfo_NotificationsEnabled
|
||||
} else {
|
||||
notificationsText = localizedPeerNotificationSoundString(strings: presentationData.strings, sound: notificationSettings.messageSound, default: globalNotificationSettings.effective.channels.sound)
|
||||
}
|
||||
@ -794,6 +796,11 @@ public func channelInfoController(account: Account, peerId: PeerId) -> ViewContr
|
||||
}
|
||||
}
|
||||
|
||||
var canEditChannel = false
|
||||
if let peer = view.peers[view.peerId] as? TelegramChannel {
|
||||
canEditChannel = peer.hasPermission(.changeInfo)
|
||||
}
|
||||
|
||||
var leftNavigationButton: ItemListNavigationButton?
|
||||
var rightNavigationButton: ItemListNavigationButton?
|
||||
if let editingState = state.editingState {
|
||||
@ -856,7 +863,7 @@ public func channelInfoController(account: Account, peerId: PeerId) -> ViewContr
|
||||
}))
|
||||
})
|
||||
}
|
||||
} else {
|
||||
} else if canEditChannel {
|
||||
rightNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.Common_Edit), style: .regular, enabled: true, action: {
|
||||
if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
|
||||
var text = ""
|
||||
|
@ -113,7 +113,7 @@ func chatHistoryEntriesForView(location: ChatLocation, view: MessageHistoryView,
|
||||
entries.insert(.ChatInfoEntry(botInfo.description, presentationData), at: 0)
|
||||
}
|
||||
var isEmpty = true
|
||||
if entries.count <= 2 {
|
||||
if entries.count <= 3 {
|
||||
loop: for entry in view.entries {
|
||||
switch entry {
|
||||
case let .MessageEntry(entry):
|
||||
@ -121,7 +121,7 @@ func chatHistoryEntriesForView(location: ChatLocation, view: MessageHistoryView,
|
||||
for media in entry.0.media {
|
||||
if let action = media as? TelegramMediaAction {
|
||||
switch action.action {
|
||||
case .groupCreated, .photoUpdated:
|
||||
case .groupCreated, .photoUpdated, .channelMigratedFromGroup, .groupMigratedToChannel:
|
||||
isEmptyMedia = true
|
||||
default:
|
||||
break
|
||||
|
@ -121,27 +121,48 @@ struct ChatHistoryListViewTransition {
|
||||
let animateIn: Bool
|
||||
}
|
||||
|
||||
private func maxMessageIndexForEntries(_ entries: [ChatHistoryEntry], indexRange: (Int, Int)) -> (incoming: MessageIndex?, overall: MessageIndex?) {
|
||||
private func maxMessageIndexForEntries(_ view: ChatHistoryView, indexRange: (Int, Int)) -> (incoming: MessageIndex?, overall: MessageIndex?) {
|
||||
var incoming: MessageIndex?
|
||||
var overall: MessageIndex?
|
||||
for i in (indexRange.0 ... indexRange.1).reversed() {
|
||||
if case let .MessageEntry(message, _, _, _, _, _) = entries[i] {
|
||||
if overall == nil {
|
||||
overall = MessageIndex(message)
|
||||
var nextLowestIndex: MessageIndex?
|
||||
if indexRange.0 >= 0 && indexRange.0 < view.filteredEntries.count {
|
||||
if indexRange.0 > 0 {
|
||||
nextLowestIndex = view.filteredEntries[indexRange.0 - 1].index
|
||||
}
|
||||
}
|
||||
var nextHighestIndex: MessageIndex?
|
||||
if indexRange.1 >= 0 && indexRange.1 < view.filteredEntries.count {
|
||||
if indexRange.1 < view.filteredEntries.count - 1 {
|
||||
nextHighestIndex = view.filteredEntries[indexRange.1 + 1].index
|
||||
}
|
||||
}
|
||||
for i in (0 ..< view.originalView.entries.count).reversed() {
|
||||
let index = view.originalView.entries[i].index
|
||||
if let nextLowestIndex = nextLowestIndex {
|
||||
if index <= nextLowestIndex {
|
||||
continue
|
||||
}
|
||||
if message.flags.contains(.Incoming) {
|
||||
return (MessageIndex(message), overall)
|
||||
}
|
||||
if let nextHighestIndex = nextHighestIndex {
|
||||
if index >= nextHighestIndex {
|
||||
continue
|
||||
}
|
||||
} else if case let .MessageGroupEntry(_, messages, _) = entries[i] {
|
||||
let index = MessageIndex(messages[messages.count - 1].0)
|
||||
if overall == nil {
|
||||
}
|
||||
if case let .MessageEntry(messageEntry) = view.originalView.entries[i] {
|
||||
if overall == nil || overall! < index {
|
||||
overall = index
|
||||
}
|
||||
if messages[messages.count - 1].0.flags.contains(.Incoming) {
|
||||
return (index, overall)
|
||||
if messageEntry.0.flags.contains(.Incoming) {
|
||||
if incoming == nil || incoming! < index {
|
||||
incoming = index
|
||||
}
|
||||
}
|
||||
if incoming != nil {
|
||||
return (incoming, overall)
|
||||
}
|
||||
}
|
||||
}
|
||||
return (nil, overall)
|
||||
return (incoming, overall)
|
||||
}
|
||||
|
||||
private func mappedInsertEntries(account: Account, chatLocation: ChatLocation, associatedData: ChatMessageItemAssociatedData, controllerInteraction: ChatControllerInteraction, mode: ChatHistoryListMode, entries: [ChatHistoryViewTransitionInsertEntry]) -> [ListViewInsertItem] {
|
||||
@ -654,7 +675,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
|
||||
}
|
||||
|
||||
if readIndexRange.0 <= readIndexRange.1 {
|
||||
let (maxIncomingIndex, maxOverallIndex) = maxMessageIndexForEntries(historyView.filteredEntries, indexRange: readIndexRange)
|
||||
let (maxIncomingIndex, maxOverallIndex) = maxMessageIndexForEntries(historyView, indexRange: readIndexRange)
|
||||
|
||||
if let maxIncomingIndex = maxIncomingIndex {
|
||||
strongSelf.updateMaxVisibleReadIncomingMessageIndex(maxIncomingIndex)
|
||||
@ -980,7 +1001,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
|
||||
visibleFirstIndex += 1
|
||||
}*/
|
||||
if visibleFirstIndex <= visible.lastIndex {
|
||||
let (messageIndex, _) = maxMessageIndexForEntries(transition.historyView.filteredEntries, indexRange: (transition.historyView.filteredEntries.count - 1 - visible.lastIndex, transition.historyView.filteredEntries.count - 1 - visibleFirstIndex))
|
||||
let (messageIndex, _) = maxMessageIndexForEntries(transition.historyView, indexRange: (transition.historyView.filteredEntries.count - 1 - visible.lastIndex, transition.historyView.filteredEntries.count - 1 - visibleFirstIndex))
|
||||
if let messageIndex = messageIndex {
|
||||
strongSelf.updateMaxVisibleReadIncomingMessageIndex(messageIndex)
|
||||
}
|
||||
|
@ -436,10 +436,11 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
|
||||
|
||||
self.chatListDisplayNode.requestOpenMessageFromSearch = { [weak self] peer, messageId in
|
||||
if let strongSelf = self {
|
||||
strongSelf.openMessageFromSearchDisposable.set((storedMessageFromSearchPeer(account: strongSelf.account, peer: peer) |> deliverOnMainQueue).start(completed: { [weak strongSelf] in
|
||||
strongSelf.openMessageFromSearchDisposable.set((storedMessageFromSearchPeer(account: strongSelf.account, peer: peer)
|
||||
|> deliverOnMainQueue).start(next: { [weak strongSelf] actualPeerId in
|
||||
if let strongSelf = strongSelf {
|
||||
if let navigationController = strongSelf.navigationController as? NavigationController {
|
||||
navigateToChatController(navigationController: navigationController, account: strongSelf.account, chatLocation: .peer(messageId.peerId), messageId: messageId, purposefulAction: {
|
||||
navigateToChatController(navigationController: navigationController, account: strongSelf.account, chatLocation: .peer(actualPeerId), messageId: messageId, purposefulAction: {
|
||||
self?.deactivateSearch(animated: false)
|
||||
})
|
||||
strongSelf.chatListDisplayNode.chatListNode.clearHighlightAnimated(true)
|
||||
|
@ -100,8 +100,10 @@ class ChatListItem: ListViewItem {
|
||||
func selected(listView: ListView) {
|
||||
switch self.content {
|
||||
case let .peer(message, peer, _, _, _, _, _, isAd, _):
|
||||
if let message = message {
|
||||
self.interaction.messageSelected(message, isAd)
|
||||
if let message = message, let peer = peer.peer {
|
||||
self.interaction.messageSelected(peer, message, isAd)
|
||||
} else if let peer = peer.peer {
|
||||
self.interaction.peerSelected(peer)
|
||||
} else if let peer = peer.peers[peer.peerId] {
|
||||
self.interaction.peerSelected(peer)
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ final class ChatListNodeInteraction {
|
||||
let activateSearch: () -> Void
|
||||
let peerSelected: (Peer) -> Void
|
||||
let togglePeerSelected: (PeerId) -> Void
|
||||
let messageSelected: (Message, Bool) -> Void
|
||||
let messageSelected: (Peer, Message, Bool) -> Void
|
||||
let groupSelected: (PeerGroupId) -> Void
|
||||
let addContact: (String) -> Void
|
||||
let setPeerIdWithRevealedOptions: (PeerId?, PeerId?) -> Void
|
||||
@ -72,7 +72,7 @@ final class ChatListNodeInteraction {
|
||||
|
||||
var highlightedChatLocation: ChatListHighlightedLocation?
|
||||
|
||||
init(activateSearch: @escaping () -> Void, peerSelected: @escaping (Peer) -> Void, togglePeerSelected: @escaping (PeerId) -> Void, messageSelected: @escaping (Message, Bool) -> Void, groupSelected: @escaping (PeerGroupId) -> Void, addContact: @escaping (String) -> Void, setPeerIdWithRevealedOptions: @escaping (PeerId?, PeerId?) -> Void, setItemPinned: @escaping (PinnedItemId, Bool) -> Void, setPeerMuted: @escaping (PeerId, Bool) -> Void, deletePeer: @escaping (PeerId) -> Void, updatePeerGrouping: @escaping (PeerId, Bool) -> Void, togglePeerMarkedUnread: @escaping (PeerId, Bool) -> Void) {
|
||||
init(activateSearch: @escaping () -> Void, peerSelected: @escaping (Peer) -> Void, togglePeerSelected: @escaping (PeerId) -> Void, messageSelected: @escaping (Peer, Message, Bool) -> Void, groupSelected: @escaping (PeerGroupId) -> Void, addContact: @escaping (String) -> Void, setPeerIdWithRevealedOptions: @escaping (PeerId?, PeerId?) -> Void, setItemPinned: @escaping (PinnedItemId, Bool) -> Void, setPeerMuted: @escaping (PeerId, Bool) -> Void, deletePeer: @escaping (PeerId) -> Void, updatePeerGrouping: @escaping (PeerId, Bool) -> Void, togglePeerMarkedUnread: @escaping (PeerId, Bool) -> Void) {
|
||||
self.activateSearch = activateSearch
|
||||
self.peerSelected = peerSelected
|
||||
self.togglePeerSelected = togglePeerSelected
|
||||
@ -386,9 +386,9 @@ final class ChatListNode: ListView {
|
||||
}
|
||||
return state
|
||||
}
|
||||
}, messageSelected: { [weak self] message, isAd in
|
||||
}, messageSelected: { [weak self] peer, message, isAd in
|
||||
if let strongSelf = self, let peerSelected = strongSelf.peerSelected {
|
||||
peerSelected(message.id.peerId, true, isAd)
|
||||
peerSelected(peer.id, true, isAd)
|
||||
}
|
||||
}, groupSelected: { [weak self] groupId in
|
||||
if let strongSelf = self, let groupSelected = strongSelf.groupSelected {
|
||||
|
@ -842,7 +842,7 @@ final class ChatListSearchContainerNode: SearchDisplayControllerContentNode {
|
||||
let _ = addRecentlySearchedPeer(postbox: account.postbox, peerId: peer.id).start()
|
||||
self?.listNode.clearHighlightAnimated(true)
|
||||
}, togglePeerSelected: { _ in
|
||||
}, messageSelected: { [weak self] message, _ in
|
||||
}, messageSelected: { [weak self] peer, message, _ in
|
||||
if let peer = message.peers[message.id.peerId] {
|
||||
openMessage(peer, message.id)
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ private func universalServiceMessageString(theme: ChatPresentationThemeData?, st
|
||||
case .joinedByLink:
|
||||
attributedString = addAttributesToStringWithRanges(strings.Notification_JoinedGroupByLink(authorName), body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: [(0, message.author?.id)]))
|
||||
case .channelMigratedFromGroup, .groupMigratedToChannel:
|
||||
attributedString = NSAttributedString(string: strings.Notification_ChannelMigratedFrom, font: titleFont, textColor: primaryTextColor)
|
||||
attributedString = NSAttributedString(string: "", font: titleFont, textColor: primaryTextColor)
|
||||
case let .messageAutoremoveTimeoutUpdated(timeout):
|
||||
if timeout > 0 {
|
||||
let timeValue = timeIntervalString(strings: strings, value: timeout)
|
||||
|
@ -136,7 +136,7 @@ class ContactMultiselectionController: ViewController {
|
||||
let rightNavigationButton = UIBarButtonItem(title: self.presentationData.strings.Common_Next, style: .done, target: self, action: #selector(self.rightNavigationButtonPressed))
|
||||
self.rightNavigationButton = rightNavigationButton
|
||||
self.navigationItem.rightBarButtonItem = self.rightNavigationButton
|
||||
rightNavigationButton.isEnabled = false
|
||||
rightNavigationButton.isEnabled = count != 0
|
||||
case .channelCreation:
|
||||
self.titleView.title = CounterContollerTitle(title: self.presentationData.strings.GroupInfo_AddParticipantTitle, counter: "")
|
||||
let rightNavigationButton = UIBarButtonItem(title: self.presentationData.strings.Common_Next, style: .done, target: self, action: #selector(self.rightNavigationButtonPressed))
|
||||
|
@ -57,7 +57,9 @@ private let rootController = PresentationThemeRootController(
|
||||
private let switchColors = PresentationThemeSwitch(
|
||||
frameColor: UIColor(rgb: 0xDBF5FF, alpha: 0.5),
|
||||
handleColor: UIColor(rgb: 0x121212),
|
||||
contentColor: accentColor
|
||||
contentColor: accentColor,
|
||||
positiveColor: accentColor,
|
||||
negativeColor: destructiveColor
|
||||
)
|
||||
|
||||
private let list = PresentationThemeList(
|
||||
|
@ -57,7 +57,9 @@ private let rootController = PresentationThemeRootController(
|
||||
private let switchColors = PresentationThemeSwitch(
|
||||
frameColor: UIColor(rgb: 0x545454),
|
||||
handleColor: UIColor(rgb: 0x121212),
|
||||
contentColor: UIColor(rgb: 0xb2b2b2)
|
||||
contentColor: UIColor(rgb: 0xb2b2b2),
|
||||
positiveColor: UIColor(rgb: 0x000000),
|
||||
negativeColor: destructiveColor
|
||||
)
|
||||
|
||||
private let list = PresentationThemeList(
|
||||
|
@ -57,7 +57,9 @@ private func makeDefaultPresentationTheme(accentColor: UIColor, serviceBackgroun
|
||||
let switchColors = PresentationThemeSwitch(
|
||||
frameColor: UIColor(rgb: 0xe0e0e0),
|
||||
handleColor: UIColor(rgb: 0xffffff),
|
||||
contentColor: UIColor(rgb: 0x42d451)
|
||||
contentColor: UIColor(rgb: 0x42d451),
|
||||
positiveColor: UIColor(rgb: 0x00B12C),
|
||||
negativeColor: destructiveColor
|
||||
)
|
||||
|
||||
let list = PresentationThemeList(
|
||||
|
@ -28,7 +28,6 @@ private final class GroupInfoArguments {
|
||||
let promotePeer: (RenderedChannelParticipant) -> Void
|
||||
let restrictPeer: (RenderedChannelParticipant) -> Void
|
||||
let removePeer: (PeerId) -> Void
|
||||
let convertToSupergroup: () -> Void
|
||||
let leave: () -> Void
|
||||
let displayUsernameShareMenu: (String) -> Void
|
||||
let displayUsernameContextMenu: (String) -> Void
|
||||
@ -37,7 +36,7 @@ private final class GroupInfoArguments {
|
||||
let openStickerPackSetup: () -> Void
|
||||
let openGroupTypeSetup: () -> Void
|
||||
|
||||
init(account: Account, peerId: PeerId, avatarAndNameInfoContext: ItemListAvatarAndNameInfoItemContext, tapAvatarAction: @escaping () -> Void, changeProfilePhoto: @escaping () -> Void, pushController: @escaping (ViewController) -> Void, presentController: @escaping (ViewController, ViewControllerPresentationArguments) -> Void, changeNotificationMuteSettings: @escaping () -> Void, openPreHistory: @escaping () -> Void, openSharedMedia: @escaping () -> Void, openAdministrators: @escaping () -> Void, openPermissions: @escaping () -> Void, updateEditingName: @escaping (ItemListAvatarAndNameInfoItemName) -> Void, updateEditingDescriptionText: @escaping (String) -> Void, setPeerIdWithRevealedOptions: @escaping (PeerId?, PeerId?) -> Void, addMember: @escaping () -> Void, promotePeer: @escaping (RenderedChannelParticipant) -> Void, restrictPeer: @escaping (RenderedChannelParticipant) -> Void, removePeer: @escaping (PeerId) -> Void, convertToSupergroup: @escaping () -> Void, leave: @escaping () -> Void, displayUsernameShareMenu: @escaping (String) -> Void, displayUsernameContextMenu: @escaping (String) -> Void, displayAboutContextMenu: @escaping (String) -> Void, aboutLinkAction: @escaping (TextLinkItemActionType, TextLinkItem) -> Void, openStickerPackSetup: @escaping () -> Void, openGroupTypeSetup: @escaping () -> Void) {
|
||||
init(account: Account, peerId: PeerId, avatarAndNameInfoContext: ItemListAvatarAndNameInfoItemContext, tapAvatarAction: @escaping () -> Void, changeProfilePhoto: @escaping () -> Void, pushController: @escaping (ViewController) -> Void, presentController: @escaping (ViewController, ViewControllerPresentationArguments) -> Void, changeNotificationMuteSettings: @escaping () -> Void, openPreHistory: @escaping () -> Void, openSharedMedia: @escaping () -> Void, openAdministrators: @escaping () -> Void, openPermissions: @escaping () -> Void, updateEditingName: @escaping (ItemListAvatarAndNameInfoItemName) -> Void, updateEditingDescriptionText: @escaping (String) -> Void, setPeerIdWithRevealedOptions: @escaping (PeerId?, PeerId?) -> Void, addMember: @escaping () -> Void, promotePeer: @escaping (RenderedChannelParticipant) -> Void, restrictPeer: @escaping (RenderedChannelParticipant) -> Void, removePeer: @escaping (PeerId) -> Void, leave: @escaping () -> Void, displayUsernameShareMenu: @escaping (String) -> Void, displayUsernameContextMenu: @escaping (String) -> Void, displayAboutContextMenu: @escaping (String) -> Void, aboutLinkAction: @escaping (TextLinkItemActionType, TextLinkItem) -> Void, openStickerPackSetup: @escaping () -> Void, openGroupTypeSetup: @escaping () -> Void) {
|
||||
self.account = account
|
||||
self.peerId = peerId
|
||||
self.avatarAndNameInfoContext = avatarAndNameInfoContext
|
||||
@ -57,7 +56,6 @@ private final class GroupInfoArguments {
|
||||
self.promotePeer = promotePeer
|
||||
self.restrictPeer = restrictPeer
|
||||
self.removePeer = removePeer
|
||||
self.convertToSupergroup = convertToSupergroup
|
||||
self.leave = leave
|
||||
self.displayUsernameShareMenu = displayUsernameShareMenu
|
||||
self.displayUsernameContextMenu = displayUsernameContextMenu
|
||||
@ -147,7 +145,6 @@ private enum GroupInfoEntry: ItemListNodeEntry {
|
||||
case permissions(PresentationTheme, String, String)
|
||||
case addMember(PresentationTheme, String, editing: Bool)
|
||||
case member(PresentationTheme, PresentationStrings, PresentationDateTimeFormat, PresentationPersonNameOrder, index: Int, peerId: PeerId, peer: Peer, participant: RenderedChannelParticipant?, presence: PeerPresence?, memberStatus: GroupInfoMemberStatus, editing: ItemListPeerItemEditing, revealActions: [ParticipantRevealAction], enabled: Bool)
|
||||
case convertToSupergroup(PresentationTheme, String)
|
||||
case leave(PresentationTheme, String)
|
||||
|
||||
var section: ItemListSectionId {
|
||||
@ -164,7 +161,7 @@ private enum GroupInfoEntry: ItemListNodeEntry {
|
||||
return GroupInfoSection.memberManagement.rawValue
|
||||
case .addMember, .member:
|
||||
return GroupInfoSection.members.rawValue
|
||||
case .convertToSupergroup, .leave:
|
||||
case .leave:
|
||||
return GroupInfoSection.leave.rawValue
|
||||
}
|
||||
}
|
||||
@ -230,12 +227,6 @@ private enum GroupInfoEntry: ItemListNodeEntry {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .convertToSupergroup(lhsTheme, lhsText):
|
||||
if case let .convertToSupergroup(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .aboutHeader(lhsTheme, lhsText):
|
||||
if case let .aboutHeader(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
|
||||
return true
|
||||
@ -407,8 +398,6 @@ private enum GroupInfoEntry: ItemListNodeEntry {
|
||||
return 17
|
||||
case let .member(_, _, _, _, index, _, _, _, _, _, _, _, _):
|
||||
return 20 + index
|
||||
case .convertToSupergroup:
|
||||
return 100000
|
||||
case .leave:
|
||||
return 100000 + 1
|
||||
}
|
||||
@ -516,10 +505,6 @@ private enum GroupInfoEntry: ItemListNodeEntry {
|
||||
}, removePeer: { peerId in
|
||||
arguments.removePeer(peerId)
|
||||
})
|
||||
case let .convertToSupergroup(theme, title):
|
||||
return ItemListActionItem(theme: theme, title: title, kind: .generic, alignment: .center, sectionId: self.section, style: .blocks, action: {
|
||||
arguments.convertToSupergroup()
|
||||
})
|
||||
case let .leave(theme, title):
|
||||
return ItemListActionItem(theme: theme, title: title, kind: .destructive, alignment: .center, sectionId: self.section, style: .blocks, action: {
|
||||
arguments.leave()
|
||||
@ -746,6 +731,8 @@ private func groupInfoEntries(account: Account, presentationData: PresentationDa
|
||||
} else {
|
||||
notificationsText = presentationData.strings.UserInfo_NotificationsDisabled
|
||||
}
|
||||
} else if case .default = peerNotificationSettings.messageSound {
|
||||
notificationsText = presentationData.strings.UserInfo_NotificationsEnabled
|
||||
} else {
|
||||
notificationsText = localizedPeerNotificationSoundString(strings: presentationData.strings, sound: peerNotificationSettings.messageSound, default: globalNotificationSettings.effective.channels.sound)
|
||||
}
|
||||
@ -1023,35 +1010,40 @@ private func groupInfoEntries(account: Account, presentationData: PresentationDa
|
||||
|
||||
var canPromote: Bool
|
||||
var canRestrict: Bool
|
||||
switch participant.participant {
|
||||
case .creator:
|
||||
canPromote = false
|
||||
canRestrict = false
|
||||
case let .member(_, _, adminRights, bannedRights):
|
||||
if channel.hasPermission(.addAdmins) {
|
||||
canPromote = true
|
||||
} else {
|
||||
if participant.peer.id == account.peerId {
|
||||
canPromote = false
|
||||
canRestrict = false
|
||||
} else {
|
||||
switch participant.participant {
|
||||
case .creator:
|
||||
canPromote = false
|
||||
}
|
||||
if channel.hasPermission(.banMembers) {
|
||||
canRestrict = true
|
||||
} else {
|
||||
canRestrict = false
|
||||
}
|
||||
if canPromote {
|
||||
if let bannedRights = bannedRights {
|
||||
if bannedRights.restrictedBy != account.peerId && !channel.flags.contains(.isCreator) {
|
||||
canPromote = false
|
||||
case let .member(_, _, adminRights, bannedRights):
|
||||
if channel.hasPermission(.addAdmins) {
|
||||
canPromote = true
|
||||
} else {
|
||||
canPromote = false
|
||||
}
|
||||
if channel.hasPermission(.banMembers) {
|
||||
canRestrict = true
|
||||
} else {
|
||||
canRestrict = false
|
||||
}
|
||||
if canPromote {
|
||||
if let bannedRights = bannedRights {
|
||||
if bannedRights.restrictedBy != account.peerId && !channel.flags.contains(.isCreator) {
|
||||
canPromote = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if canRestrict {
|
||||
if let adminRights = adminRights {
|
||||
if adminRights.promotedBy != account.peerId && !channel.flags.contains(.isCreator) {
|
||||
canRestrict = false
|
||||
if canRestrict {
|
||||
if let adminRights = adminRights {
|
||||
if adminRights.promotedBy != account.peerId && !channel.flags.contains(.isCreator) {
|
||||
canRestrict = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var peerActions: [ParticipantRevealAction] = []
|
||||
@ -1069,9 +1061,6 @@ private func groupInfoEntries(account: Account, presentationData: PresentationDa
|
||||
|
||||
if let group = view.peers[view.peerId] as? TelegramGroup {
|
||||
if case .Member = group.membership {
|
||||
if case .creator = group.role, state.editingState != nil {
|
||||
entries.append(.convertToSupergroup(presentationData.theme, presentationData.strings.GroupInfo_ConvertToSupergroup))
|
||||
}
|
||||
entries.append(.leave(presentationData.theme, presentationData.strings.Group_LeaveGroup))
|
||||
}
|
||||
} else if let channel = view.peers[view.peerId] as? TelegramChannel {
|
||||
@ -1659,8 +1648,6 @@ public func groupInfoController(account: Account, peerId: PeerId) -> ViewControl
|
||||
}
|
||||
}
|
||||
removeMemberDisposable.set(signal.start())
|
||||
}, convertToSupergroup: {
|
||||
pushControllerImpl?(convertToSupergroupController(account: account, peerId: peerId))
|
||||
}, leave: {
|
||||
let _ = (peerView.get()
|
||||
|> take(1)
|
||||
@ -1761,7 +1748,24 @@ public func groupInfoController(account: Account, peerId: PeerId) -> ViewControl
|
||||
}
|
||||
}
|
||||
|
||||
let rightNavigationButton: ItemListNavigationButton
|
||||
var canEditGroupInfo = false
|
||||
if let group = view.peers[view.peerId] as? TelegramGroup {
|
||||
switch group.role {
|
||||
case .admin, .creator:
|
||||
canEditGroupInfo = true
|
||||
case .member:
|
||||
break
|
||||
}
|
||||
if !group.hasBannedPermission(.banChangeInfo) {
|
||||
canEditGroupInfo = true
|
||||
}
|
||||
} else if let channel = view.peers[view.peerId] as? TelegramChannel {
|
||||
if channel.hasPermission(.changeInfo) {
|
||||
canEditGroupInfo = true
|
||||
}
|
||||
}
|
||||
|
||||
var rightNavigationButton: ItemListNavigationButton?
|
||||
var secondaryRightNavigationButton: ItemListNavigationButton?
|
||||
if let editingState = state.editingState {
|
||||
var doneEnabled = true
|
||||
@ -1820,7 +1824,7 @@ public func groupInfoController(account: Account, peerId: PeerId) -> ViewControl
|
||||
}))
|
||||
})
|
||||
}
|
||||
} else {
|
||||
} else if canEditGroupInfo {
|
||||
rightNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.Common_Edit), style: .regular, enabled: true, action: {
|
||||
if let peer = peer as? TelegramGroup {
|
||||
var text = ""
|
||||
@ -1847,7 +1851,14 @@ public func groupInfoController(account: Account, peerId: PeerId) -> ViewControl
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
} else {
|
||||
if peer is TelegramChannel {
|
||||
rightNavigationButton = ItemListNavigationButton(content: .icon(.search), style: .regular, enabled: true, action: {
|
||||
updateState { state in
|
||||
return state.withUpdatedSearchingMembers(true)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var searchItem: ItemListControllerSearch?
|
||||
|
@ -44,15 +44,13 @@ final class HashtagSearchController: TelegramController {
|
||||
let interaction = ChatListNodeInteraction(activateSearch: {
|
||||
}, peerSelected: { peer in
|
||||
}, togglePeerSelected: { _ in
|
||||
}, messageSelected: { [weak self] message, _ in
|
||||
}, messageSelected: { [weak self] peer, message, _ in
|
||||
if let strongSelf = self {
|
||||
if let peer = message.peers[message.id.peerId] {
|
||||
strongSelf.openMessageFromSearchDisposable.set((storedMessageFromSearchPeer(account: strongSelf.account, peer: peer) |> deliverOnMainQueue).start(completed: {
|
||||
if let strongSelf = self {
|
||||
(strongSelf.navigationController as? NavigationController)?.pushViewController(ChatController(account: strongSelf.account, chatLocation: .peer(message.id.peerId), messageId: message.id))
|
||||
}
|
||||
}))
|
||||
}
|
||||
strongSelf.openMessageFromSearchDisposable.set((storedMessageFromSearchPeer(account: strongSelf.account, peer: peer) |> deliverOnMainQueue).start(next: { actualPeerId in
|
||||
if let strongSelf = self {
|
||||
(strongSelf.navigationController as? NavigationController)?.pushViewController(ChatController(account: strongSelf.account, chatLocation: .peer(actualPeerId), messageId: message.id.peerId == actualPeerId ? message.id : nil))
|
||||
}
|
||||
}))
|
||||
strongSelf.controllerNode.listNode.clearHighlightAnimated(true)
|
||||
}
|
||||
}, groupSelected: { _ in
|
||||
|
@ -38,6 +38,20 @@ class IconSwitchNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
}
|
||||
public var positiveContentColor = UIColor(rgb: 0x00ff00) {
|
||||
didSet {
|
||||
if self.isNodeLoaded {
|
||||
(self.view as! IconSwitchNodeView).setPositiveContentColor(self.positiveContentColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
public var negativeContentColor = UIColor(rgb: 0xff0000) {
|
||||
didSet {
|
||||
if self.isNodeLoaded {
|
||||
(self.view as! IconSwitchNodeView).setNegativeContentColor(self.negativeContentColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var _isOn: Bool = false
|
||||
public var isOn: Bool {
|
||||
@ -68,6 +82,8 @@ class IconSwitchNode: ASDisplayNode {
|
||||
(self.view as! UISwitch).tintColor = self.frameColor
|
||||
//(self.view as! UISwitch).thumbTintColor = self.handleColor
|
||||
(self.view as! UISwitch).onTintColor = self.contentColor
|
||||
(self.view as! IconSwitchNodeView).setNegativeContentColor(self.negativeContentColor)
|
||||
(self.view as! IconSwitchNodeView).setPositiveContentColor(self.positiveContentColor)
|
||||
|
||||
(self.view as! UISwitch).setOn(self._isOn, animated: false)
|
||||
|
||||
|
@ -75,10 +75,25 @@ private protocol ItemListSwitchNodeImpl {
|
||||
var frameColor: UIColor { get set }
|
||||
var contentColor: UIColor { get set }
|
||||
var handleColor: UIColor { get set }
|
||||
var positiveContentColor: UIColor { get set }
|
||||
var negativeContentColor: UIColor { get set }
|
||||
}
|
||||
|
||||
extension SwitchNode: ItemListSwitchNodeImpl {
|
||||
|
||||
var positiveContentColor: UIColor {
|
||||
get {
|
||||
return .white
|
||||
} set(value) {
|
||||
|
||||
}
|
||||
}
|
||||
var negativeContentColor: UIColor {
|
||||
get {
|
||||
return .white
|
||||
} set(value) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension IconSwitchNode: ItemListSwitchNodeImpl {
|
||||
@ -214,6 +229,8 @@ class ItemListSwitchItemNode: ListViewItemNode {
|
||||
strongSelf.switchNode.frameColor = item.theme.list.itemSwitchColors.frameColor
|
||||
strongSelf.switchNode.contentColor = item.theme.list.itemSwitchColors.contentColor
|
||||
strongSelf.switchNode.handleColor = item.theme.list.itemSwitchColors.handleColor
|
||||
strongSelf.switchNode.positiveContentColor = item.theme.list.itemSwitchColors.positiveColor
|
||||
strongSelf.switchNode.negativeContentColor = item.theme.list.itemSwitchColors.negativeColor
|
||||
}
|
||||
|
||||
let _ = titleApply()
|
||||
|
3
TelegramUI/MergedItemListItem.swift
Normal file
3
TelegramUI/MergedItemListItem.swift
Normal file
@ -0,0 +1,3 @@
|
||||
import Foundation
|
||||
|
||||
|
@ -219,7 +219,6 @@ enum PresentationResourceKey: Int32 {
|
||||
case groupInfoAdminsIcon
|
||||
case groupInfoPermissionsIcon
|
||||
case groupInfoMembersIcon
|
||||
case groupInfoBannedIcon
|
||||
|
||||
case emptyChatListCheckIcon
|
||||
}
|
||||
|
@ -953,12 +953,6 @@ struct PresentationResourcesChat {
|
||||
})
|
||||
}
|
||||
|
||||
static func groupInfoBannedIcon(_ theme: PresentationTheme) -> UIImage? {
|
||||
return theme.image(PresentationResourceKey.groupInfoBannedIcon.rawValue, { _ in
|
||||
return UIImage(bundleImageName: "Chat/Info/GroupBannedIcon")?.precomposed()
|
||||
})
|
||||
}
|
||||
|
||||
static func emptyChatListCheckIcon(_ theme: PresentationTheme) -> UIImage? {
|
||||
return theme.image(PresentationResourceKey.emptyChatListCheckIcon.rawValue, { _ in
|
||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Empty Chat/ListCheckIcon"), color: theme.chat.serviceMessage.components.withDefaultWallpaper.primaryText)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -210,11 +210,15 @@ public final class PresentationThemeSwitch {
|
||||
public let frameColor: UIColor
|
||||
public let handleColor: UIColor
|
||||
public let contentColor: UIColor
|
||||
public let positiveColor: UIColor
|
||||
public let negativeColor: UIColor
|
||||
|
||||
public init(frameColor: UIColor, handleColor: UIColor, contentColor: UIColor) {
|
||||
public init(frameColor: UIColor, handleColor: UIColor, contentColor: UIColor, positiveColor: UIColor, negativeColor: UIColor) {
|
||||
self.frameColor = frameColor
|
||||
self.handleColor = handleColor
|
||||
self.contentColor = contentColor
|
||||
self.positiveColor = positiveColor
|
||||
self.negativeColor = negativeColor
|
||||
}
|
||||
}
|
||||
|
||||
|
Binary file not shown.
@ -3,13 +3,17 @@ import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
|
||||
func storedMessageFromSearchPeer(account: Account, peer: Peer) -> Signal<Void, NoError> {
|
||||
return account.postbox.transaction { transaction -> Void in
|
||||
func storedMessageFromSearchPeer(account: Account, peer: Peer) -> Signal<PeerId, NoError> {
|
||||
return account.postbox.transaction { transaction -> PeerId in
|
||||
if transaction.getPeer(peer.id) == nil {
|
||||
updatePeers(transaction: transaction, peers: [peer], update: { previousPeer, updatedPeer in
|
||||
return updatedPeer
|
||||
})
|
||||
}
|
||||
if let group = transaction.getPeer(peer.id) as? TelegramGroup, let migrationReference = group.migrationReference {
|
||||
return migrationReference.peerId
|
||||
}
|
||||
return peer.id
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -665,6 +665,8 @@ private func userInfoEntries(account: Account, presentationData: PresentationDat
|
||||
} else {
|
||||
notificationsLabel = presentationData.strings.UserInfo_NotificationsDisabled
|
||||
}
|
||||
} else if case .default = notificationSettings.messageSound {
|
||||
notificationsLabel = presentationData.strings.UserInfo_NotificationsEnabled
|
||||
} else {
|
||||
notificationsLabel = localizedPeerNotificationSoundString(strings: presentationData.strings, sound: notificationSettings.messageSound, default: globalNotificationSettings.effective.channels.sound)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user