Business improvements

This commit is contained in:
Isaac 2024-03-26 12:40:18 +04:00
parent cf323a57b8
commit 19719dc7d4
7 changed files with 83 additions and 32 deletions

View File

@ -47,6 +47,7 @@ public enum ContactMultiselectionControllerMode {
public var displayPresence: Bool
public var onlyUsers: Bool
public var disableChannels: Bool
public var disableBots: Bool
public init(
title: String,
@ -57,7 +58,8 @@ public enum ContactMultiselectionControllerMode {
displayAutoremoveTimeout: Bool = false,
displayPresence: Bool = false,
onlyUsers: Bool = false,
disableChannels: Bool = false
disableChannels: Bool = false,
disableBots: Bool = false
) {
self.title = title
self.searchPlaceholder = searchPlaceholder
@ -68,6 +70,7 @@ public enum ContactMultiselectionControllerMode {
self.displayPresence = displayPresence
self.onlyUsers = onlyUsers
self.disableChannels = disableChannels
self.disableBots = disableBots
}
}

View File

@ -1720,7 +1720,8 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
strongSelf.containerNode.view.addSubview(customAvatarIconView)
}
customAvatarIconView.image = customAvatarIcon
customAvatarIconView.frame = strongSelf.avatarNode.frame
transition.updateFrame(view: customAvatarIconView, frame: strongSelf.avatarNode.frame)
} else if let customAvatarIconView = strongSelf.customAvatarIconView {
strongSelf.customAvatarIconView = nil
customAvatarIconView.removeFromSuperview()
@ -1870,6 +1871,10 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
avatarButton.frame = avatarFrame
}
if let customAvatarIconView = self.customAvatarIconView {
transition.updateFrame(view: customAvatarIconView, frame: avatarFrame)
}
if let avatarIconComponentView = self.avatarIconView?.view {
let avatarFrame = self.avatarNode.frame
let threadIconSize = floor(avatarFrame.width * 0.9)

View File

@ -168,30 +168,30 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
return 15
case .voiceCallPrivacy:
return 16
case .groupPrivacy:
return 17
case .voiceMessagePrivacy:
return 18
case .messagePrivacy:
return 19
case .selectivePrivacyInfo:
case .groupPrivacy:
return 20
case .autoArchiveHeader:
return 21
case .autoArchive:
case .selectivePrivacyInfo:
return 22
case .autoArchiveInfo:
case .autoArchiveHeader:
return 23
case .accountHeader:
case .autoArchive:
return 24
case .accountTimeout:
case .autoArchiveInfo:
return 25
case .accountInfo:
case .accountHeader:
return 26
case .dataSettings:
case .accountTimeout:
return 27
case .dataSettingsInfo:
case .accountInfo:
return 28
case .dataSettings:
return 29
case .dataSettingsInfo:
return 30
}
}
@ -529,7 +529,8 @@ private func stringForSelectiveSettings(strings: PresentationStrings, settings:
}
case let .enableContacts(enableFor, disableFor, enableForPremium):
if enableForPremium {
if !enableFor.isEmpty && !disableFor.isEmpty {
return "Premium & Contacts"
/*if !enableFor.isEmpty && !disableFor.isEmpty {
return "Premium, " + strings.PrivacySettings_LastSeenContactsMinusPlus("\(countForSelectivePeers(disableFor))", "\(countForSelectivePeers(enableFor))").string
} else if !enableFor.isEmpty {
return "Premium, " + strings.PrivacySettings_LastSeenContactsPlus("\(countForSelectivePeers(enableFor))").string
@ -537,7 +538,7 @@ private func stringForSelectiveSettings(strings: PresentationStrings, settings:
return "Premium, " + strings.PrivacySettings_LastSeenContactsMinus("\(countForSelectivePeers(disableFor))").string
} else {
return "Premium, " + strings.PrivacySettings_LastSeenContacts
}
}*/
} else {
if !enableFor.isEmpty && !disableFor.isEmpty {
return strings.PrivacySettings_LastSeenContactsMinusPlus("\(countForSelectivePeers(disableFor))", "\(countForSelectivePeers(enableFor))").string
@ -630,11 +631,12 @@ private func privacyAndSecurityControllerEntries(
entries.append(.birthdayPrivacy(presentationData.theme, presentationData.strings.Privacy_Birthday, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.birthday)))
entries.append(.forwardPrivacy(presentationData.theme, presentationData.strings.Privacy_Forwards, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.forwards)))
entries.append(.voiceCallPrivacy(presentationData.theme, presentationData.strings.Privacy_Calls, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.voiceCalls)))
entries.append(.groupPrivacy(presentationData.theme, presentationData.strings.Privacy_GroupsAndChannels, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.groupInvitations)))
if !isPremiumDisabled {
entries.append(.voiceMessagePrivacy(presentationData.theme, presentationData.strings.Privacy_VoiceMessages, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.voiceMessages), isPremium))
entries.append(.messagePrivacy(presentationData.theme, privacySettings.globalSettings.nonContactChatsRequirePremium, isPremium))
}
//TODO:localize
entries.append(.groupPrivacy(presentationData.theme, "Invites", stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.groupInvitations)))
} else {
entries.append(.phoneNumberPrivacy(presentationData.theme, presentationData.strings.PrivacySettings_PhoneNumber, presentationData.strings.Channel_NotificationLoading))
entries.append(.lastSeenPrivacy(presentationData.theme, presentationData.strings.PrivacySettings_LastSeen, presentationData.strings.Channel_NotificationLoading))

View File

@ -1120,6 +1120,7 @@ public func selectivePrivacySettingsController(
//TODO:localize
var additionalCategories: [ChatListNodeAdditionalCategory] = []
var selectedCategories = Set<Int>()
if displayPremiumCategory && enable {
additionalCategories = [
ChatListNodeAdditionalCategory(
@ -1130,8 +1131,8 @@ public func selectivePrivacySettingsController(
appearance: .option(sectionTitle: "USER TYPES")
)
]
selectedCategories.insert(AdditionalCategoryId.premiumUsers.rawValue)
}
let selectedCategories = Set<Int>([AdditionalCategoryId.premiumUsers.rawValue])
let controller = context.sharedContext.makeContactMultiselectionController(ContactMultiselectionControllerParams(context: context, mode: .chatSelection(ContactMultiselectionControllerMode.ChatSelection(
title: "Add Users",
@ -1140,7 +1141,8 @@ public func selectivePrivacySettingsController(
additionalCategories: ContactMultiselectionControllerAdditionalCategories(categories: additionalCategories, selectedCategories: selectedCategories),
chatListFilters: nil,
onlyUsers: false,
disableChannels: true
disableChannels: true,
disableBots: true
)), options: [], filters: [.excludeSelf]))
addPeerDisposable.set((controller.result
|> take(1)

View File

@ -353,8 +353,9 @@ public func selectivePrivacyPeersController(context: AccountContext, title: Stri
additionalCategories: ContactMultiselectionControllerAdditionalCategories(categories: additionalCategories, selectedCategories: selectedCategories),
chatListFilters: nil,
onlyUsers: false,
disableChannels: true
)), options: []))
disableChannels: true,
disableBots: true
)), options: [], alwaysEnabled: true))
addPeerDisposable.set((controller.result
|> take(1)
|> deliverOnMainQueue).start(next: { [weak controller] result in

View File

@ -534,7 +534,7 @@ private enum TopicsLimitedReason {
private final class PeerInfoInteraction {
let openChat: (EnginePeer.Id?) -> Void
let openUsername: (String, Bool, Promise<Bool>?) -> Void
let openPhone: (String, ASDisplayNode, ContextGesture?) -> Void
let openPhone: (String, ASDisplayNode, ContextGesture?, Promise<Bool>?) -> Void
let editingOpenNotificationSettings: () -> Void
let editingOpenSoundSettings: () -> Void
let editingToggleShowMessageText: (Bool) -> Void
@ -595,7 +595,7 @@ private final class PeerInfoInteraction {
init(
openUsername: @escaping (String, Bool, Promise<Bool>?) -> Void,
openPhone: @escaping (String, ASDisplayNode, ContextGesture?) -> Void,
openPhone: @escaping (String, ASDisplayNode, ContextGesture?, Promise<Bool>?) -> Void,
editingOpenNotificationSettings: @escaping () -> Void,
editingOpenSoundSettings: @escaping () -> Void,
editingToggleShowMessageText: @escaping (Bool) -> Void,
@ -1208,10 +1208,10 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
} else {
label = presentationData.strings.ContactInfo_PhoneLabelMobile
}
items[.peerInfo]!.append(PeerInfoScreenLabeledValueItem(id: 2, label: label, text: formattedPhone, textColor: .accent, action: { node, _ in
interaction.openPhone(phone, node, nil)
items[.peerInfo]!.append(PeerInfoScreenLabeledValueItem(id: 2, label: label, text: formattedPhone, textColor: .accent, action: { node, progress in
interaction.openPhone(phone, node, nil, progress)
}, longTapAction: nil, contextAction: { node, gesture, _ in
interaction.openPhone(phone, node, gesture)
interaction.openPhone(phone, node, gesture, nil)
}, requestLayout: {
interaction.requestLayout(false)
}))
@ -2513,8 +2513,8 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
openUsername: { [weak self] value, isMainUsername, progress in
self?.openUsername(value: value, isMainUsername: isMainUsername, progress: progress)
},
openPhone: { [weak self] value, node, gesture in
self?.openPhone(value: value, node: node, gesture: gesture)
openPhone: { [weak self] value, node, gesture, progress in
self?.openPhone(value: value, node: node, gesture: gesture, progress: progress)
},
editingOpenNotificationSettings: { [weak self] in
self?.editingOpenNotificationSettings()
@ -6786,11 +6786,36 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
}
}
private func openPhone(value: String, node: ASDisplayNode, gesture: ContextGesture?) {
private func openPhone(value: String, node: ASDisplayNode, gesture: ContextGesture?, progress: Promise<Bool>?) {
guard let sourceNode = node as? ContextExtractedContentContainingNode else {
return
}
let formattedPhoneNumber = formatPhoneNumber(context: self.context, number: value)
if gesture == nil, formattedPhoneNumber.hasPrefix("+888") {
let collectibleInfo = Promise<CollectibleItemInfoScreenInitialData?>()
collectibleInfo.set(self.context.sharedContext.makeCollectibleItemInfoScreenInitialData(context: self.context, peerId: self.peerId, subject: .phoneNumber(value)))
progress?.set(.single(true))
let _ = (collectibleInfo.get()
|> take(1)
|> deliverOnMainQueue).start(next: { [weak self] initialData in
progress?.set(.single(false))
guard let self else {
return
}
if let initialData {
self.view.endEditing(true)
self.controller?.push(self.context.sharedContext.makeCollectibleItemInfoScreen(context: self.context, initialData: initialData))
} else {
self.context.sharedContext.openExternalUrl(context: self.context, urlContext: .generic, url: "https://fragment.com/numbers", forceExternal: true, presentationData: self.presentationData, navigationController: nil, dismissInput: {})
}
})
return
}
let _ = (combineLatest(
getUserPeer(engine: self.context.engine, peerId: self.peerId),
getUserPeer(engine: self.context.engine, peerId: self.context.account.peerId)
@ -6832,7 +6857,6 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
}
}
let formattedPhoneNumber = formatPhoneNumber(context: strongSelf.context, number: value)
var isAnonymousNumber = false
var items: [ContextMenuItem] = []
if case let .user(peer) = peer, let peerPhoneNumber = peer.phone, formattedPhoneNumber == formatPhoneNumber(context: strongSelf.context, number: peerPhoneNumber) {
@ -10384,7 +10408,10 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
contentHeight += sectionSpacing + 12.0
}
var isFirst = true
for (sectionId, sectionItems) in items {
let isFirstSection = isFirst
isFirst = false
validRegularSections.append(sectionId)
var wasAdded = false
@ -10404,6 +10431,9 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
}
let sectionWidth = layout.size.width - insets.left - insets.right
if isFirstSection && sectionItems.first is PeerInfoScreenHeaderItem {
contentHeight -= 16.0
}
let sectionHeight = sectionNode.update(width: sectionWidth, safeInsets: UIEdgeInsets(), hasCorners: !insets.left.isZero, presentationData: self.presentationData, items: sectionItems, transition: transition)
let sectionFrame = CGRect(origin: CGPoint(x: insets.left, y: contentHeight), size: CGSize(width: sectionWidth, height: sectionHeight))
if additive {

View File

@ -140,11 +140,19 @@ final class ContactMultiselectionControllerNode: ASDisplayNode {
excludePeers: [],
color: nil
))
} else if chatSelection.disableChannels {
} else if chatSelection.disableChannels || chatSelection.disableBots {
var categories: ChatListFilterPeerCategories = [.contacts, .nonContacts, .groups, .bots, .channels]
if chatSelection.disableChannels {
categories.remove(.channels)
}
if chatSelection.disableChannels {
categories.remove(.bots)
}
chatListFilter = .filter(id: Int32.max, title: "", emoticon: nil, data: ChatListFilterData(
isShared: false,
hasSharedLinks: false,
categories: [.contacts, .nonContacts, .groups, .bots],
categories: categories,
excludeMuted: false,
excludeRead: false,
excludeArchived: false,