Reaction list setup

This commit is contained in:
Ali
2021-12-17 00:20:30 +04:00
parent 321fe4e052
commit 1ac4c70dec
12 changed files with 1473 additions and 59 deletions

View File

@@ -464,6 +464,7 @@ private final class PeerInfoInteraction {
let openFaq: (String?) -> Void
let openAddMember: () -> Void
let openQrCode: () -> Void
let editingOpenReactionsSetup: () -> Void
init(
openUsername: @escaping (String) -> Void,
@@ -504,7 +505,8 @@ private final class PeerInfoInteraction {
openDeletePeer: @escaping () -> Void,
openFaq: @escaping (String?) -> Void,
openAddMember: @escaping () -> Void,
openQrCode: @escaping () -> Void
openQrCode: @escaping () -> Void,
editingOpenReactionsSetup: @escaping () -> Void
) {
self.openUsername = openUsername
self.openPhone = openPhone
@@ -545,6 +547,7 @@ private final class PeerInfoInteraction {
self.openFaq = openFaq
self.openAddMember = openAddMember
self.openQrCode = openQrCode
self.editingOpenReactionsSetup = editingOpenReactionsSetup
}
}
@@ -1127,7 +1130,8 @@ private func editingItems(data: PeerInfoScreenData?, context: AccountContext, pr
let ItemDiscussionGroup = 3
let ItemSignMessages = 4
let ItemSignMessagesHelp = 5
let ItemDeleteChannel = 5
let ItemDeleteChannel = 6
let ItemReactions = 7
let isCreator = channel.flags.contains(.isCreator)
@@ -1176,6 +1180,13 @@ private func editingItems(data: PeerInfoScreenData?, context: AccountContext, pr
}))
}
if isCreator || (channel.adminRights?.rights.contains(.canChangeInfo) == true) {
//TODO:localize
items[.peerSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemReactions, label: .none, text: "Reactions", icon: UIImage(bundleImageName: "Chat/Info/GroupDiscussionIcon"), action: {
interaction.editingOpenReactionsSetup()
}))
}
if isCreator || (channel.adminRights != nil && channel.hasPermission(.sendMessages)) {
let messagesShouldHaveSignatures: Bool
switch channel.info {
@@ -1210,6 +1221,7 @@ private func editingItems(data: PeerInfoScreenData?, context: AccountContext, pr
let ItemLocation = 112
let ItemLocationSetup = 113
let ItemDeleteGroup = 114
let ItemReactions = 115
let isCreator = channel.flags.contains(.isCreator)
let isPublic = channel.username != nil
@@ -1283,11 +1295,25 @@ private func editingItems(data: PeerInfoScreenData?, context: AccountContext, pr
}))
}
if isCreator || (channel.adminRights?.rights.contains(.canChangeInfo) == true) {
//TODO:localize
items[.peerPublicSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemReactions, label: .none, text: "Reactions", icon: UIImage(bundleImageName: "Chat/Info/GroupDiscussionIcon"), action: {
interaction.editingOpenReactionsSetup()
}))
}
if !isPublic, case .known(nil) = cachedData.linkedDiscussionPeerId {
items[.peerPublicSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemPreHistory, label: .text(cachedData.flags.contains(.preHistoryEnabled) ? presentationData.strings.GroupInfo_GroupHistoryVisible : presentationData.strings.GroupInfo_GroupHistoryHidden), text: presentationData.strings.GroupInfo_GroupHistoryShort, icon: UIImage(bundleImageName: "Chat/Info/GroupDiscussionIcon"), action: {
interaction.editingOpenPreHistorySetup()
}))
}
} else {
if isCreator || (channel.adminRights?.rights.contains(.canChangeInfo) == true) {
//TODO:localize
items[.peerPublicSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemReactions, label: .none, text: "Reactions", icon: UIImage(bundleImageName: "Chat/Info/GroupDiscussionIcon"), action: {
interaction.editingOpenReactionsSetup()
}))
}
}
if cachedData.flags.contains(.canSetStickerSet) && canEditPeerInfo(context: context, peer: channel) {
@@ -1353,6 +1379,7 @@ private func editingItems(data: PeerInfoScreenData?, context: AccountContext, pr
let ItemPermissions = 104
let ItemAdmins = 105
let ItemMemberRequests = 106
let ItemReactions = 107
var canViewAdminsAndBanned = false
@@ -1382,6 +1409,11 @@ private func editingItems(data: PeerInfoScreenData?, context: AccountContext, pr
interaction.editingOpenPreHistorySetup()
}))
//TODO:localize
items[.peerSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemReactions, label: .none, text: "Reactions", icon: UIImage(bundleImageName: "Chat/Info/GroupDiscussionIcon"), action: {
interaction.editingOpenReactionsSetup()
}))
canViewAdminsAndBanned = true
} else if case let .admin(rights, _) = group.role {
if rights.rights.contains(.canInviteUsers) {
@@ -1677,6 +1709,9 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
},
openQrCode: { [weak self] in
self?.openQrCode()
},
editingOpenReactionsSetup: { [weak self] in
self?.editingOpenReactionsSetup()
}
)
@@ -4698,6 +4733,13 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
self.controller?.push(channelDiscussionGroupSetupController(context: self.context, updatedPresentationData: self.controller?.updatedPresentationData, peerId: peer.id))
}
private func editingOpenReactionsSetup() {
guard let data = self.data, let peer = data.peer else {
return
}
self.controller?.push(peerAllowedReactionListController(context: self.context, updatedPresentationData: self.controller?.updatedPresentationData, peerId: peer.id))
}
private func editingToggleMessageSignatures(value: Bool) {
self.toggleShouldChannelMessagesSignaturesDisposable.set(self.context.engine.peers.toggleShouldChannelMessagesSignatures(peerId: self.peerId, enabled: value).start())
}