Merge commit 'bff39b3f39d07cab7abc5dafe79a420afea70f9d' into beta

This commit is contained in:
Ilya Laktyushin 2025-10-04 20:39:53 +04:00
commit 04bf598060

View File

@ -1333,8 +1333,39 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
} }
if let user = data.peer as? TelegramUser { if let user = data.peer as? TelegramUser {
let ItemCallList = 1000
let ItemPersonalChannelHeader = 2000
let ItemPersonalChannel = 2001
let ItemPhoneNumber = 3000
let ItemUsername = 3001
let ItemBirthdate = 3002
let ItemAbout = 3003
let ItemNote = 3004
let ItemAppFooter = 3005
let ItemAffiliate = 4000
let ItemAffiliateInfo = 4001
let ItemBusinessHours = 5000
let ItemLocation = 5001
let ItemSendMessage = 5000
let ItemReport = 5001
let ItemAddToContacts = 5002
let ItemBlock = 5003
let ItemEncryptionKey = 5004
let ItemBalanceHeader = 6001
let ItemBalanceTon = 6001
let ItemBalanceStars = 6002
let ItemBotPermissionsHeader = 7000
let ItemBotPermissionsEmojiStatus = 7001
let ItemBotPermissionsLocation = 7002
let ItemBotPermissionsBiometry = 7003
let ItemBotSettings = 8000
let ItemBotReport = 8001
let ItemBotAddToChat = 8002
let ItemBotAddToChatInfo = 8003
let ItemVerification = 8004
if !callMessages.isEmpty { if !callMessages.isEmpty {
items[.calls]!.append(PeerInfoScreenCallListItem(id: 20, messages: callMessages)) items[.calls]!.append(PeerInfoScreenCallListItem(id: ItemCallList, messages: callMessages))
} }
if let personalChannel = data.personalChannel { if let personalChannel = data.personalChannel {
@ -1343,8 +1374,8 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
if let subscriberCount = personalChannel.subscriberCount { if let subscriberCount = personalChannel.subscriberCount {
label = presentationData.strings.Conversation_StatusSubscribers(Int32(subscriberCount)) label = presentationData.strings.Conversation_StatusSubscribers(Int32(subscriberCount))
} }
items[.personalChannel]?.append(PeerInfoScreenHeaderItem(id: 0, text: presentationData.strings.Profile_PersonalChannelSectionTitle, label: label)) items[.personalChannel]?.append(PeerInfoScreenHeaderItem(id: ItemPersonalChannelHeader, text: presentationData.strings.Profile_PersonalChannelSectionTitle, label: label))
items[.personalChannel]?.append(PeerInfoScreenPersonalChannelItem(id: 1, context: context, data: personalChannel, controller: { [weak interaction] in items[.personalChannel]?.append(PeerInfoScreenPersonalChannelItem(id: ItemPersonalChannel, context: context, data: personalChannel, controller: { [weak interaction] in
guard let interaction else { guard let interaction else {
return nil return nil
} }
@ -1365,7 +1396,7 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
} else { } else {
label = presentationData.strings.ContactInfo_PhoneLabelMobile label = presentationData.strings.ContactInfo_PhoneLabelMobile
} }
items[currentPeerInfoSection]!.append(PeerInfoScreenLabeledValueItem(id: 2, label: label, text: formattedPhone, textColor: .accent, action: { node, progress in items[currentPeerInfoSection]!.append(PeerInfoScreenLabeledValueItem(id: ItemPhoneNumber, label: label, text: formattedPhone, textColor: .accent, action: { node, progress in
interaction.openPhone(phone, node, nil, progress) interaction.openPhone(phone, node, nil, progress)
}, longTapAction: nil, contextAction: { node, gesture, _ in }, longTapAction: nil, contextAction: { node, gesture, _ in
interaction.openPhone(phone, node, gesture, nil) interaction.openPhone(phone, node, gesture, nil)
@ -1382,7 +1413,7 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
items[currentPeerInfoSection]!.append( items[currentPeerInfoSection]!.append(
PeerInfoScreenLabeledValueItem( PeerInfoScreenLabeledValueItem(
id: 1, id: ItemUsername,
label: presentationData.strings.Profile_Username, label: presentationData.strings.Profile_Username,
text: "@\(mainUsername)", text: "@\(mainUsername)",
additionalText: additionalUsernames, additionalText: additionalUsernames,
@ -1426,7 +1457,7 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
} }
} }
items[currentPeerInfoSection]!.append(PeerInfoScreenLabeledValueItem(id: 400, context: context, label: hasBirthdayToday ? presentationData.strings.UserInfo_BirthdayToday : presentationData.strings.UserInfo_Birthday, text: stringForCompactBirthday(birthday, strings: presentationData.strings, showAge: true), textColor: .primary, leftIcon: hasBirthdayToday ? .birthday : nil, icon: hasBirthdayToday ? .premiumGift : nil, action: birthdayAction, longTapAction: nil, iconAction: { items[currentPeerInfoSection]!.append(PeerInfoScreenLabeledValueItem(id: ItemBirthdate, context: context, label: hasBirthdayToday ? presentationData.strings.UserInfo_BirthdayToday : presentationData.strings.UserInfo_Birthday, text: stringForCompactBirthday(birthday, strings: presentationData.strings, showAge: true), textColor: .primary, leftIcon: hasBirthdayToday ? .birthday : nil, icon: hasBirthdayToday ? .premiumGift : nil, action: birthdayAction, longTapAction: nil, iconAction: {
interaction.openPremiumGift() interaction.openPremiumGift()
}, contextAction: birthdayContextAction, requestLayout: { _ in }, contextAction: birthdayContextAction, requestLayout: { _ in
})) }))
@ -1447,11 +1478,11 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
} }
if user.isFake { if user.isFake {
items[currentPeerInfoSection]!.append(PeerInfoScreenLabeledValueItem(id: 0, label: "", text: user.botInfo != nil ? presentationData.strings.UserInfo_FakeBotWarning : presentationData.strings.UserInfo_FakeUserWarning, textColor: .primary, textBehavior: .multiLine(maxLines: 100, enabledEntities: user.botInfo != nil ? enabledPrivateBioEntities : []), action: nil, requestLayout: { animated in items[currentPeerInfoSection]!.append(PeerInfoScreenLabeledValueItem(id: ItemAbout, label: "", text: user.botInfo != nil ? presentationData.strings.UserInfo_FakeBotWarning : presentationData.strings.UserInfo_FakeUserWarning, textColor: .primary, textBehavior: .multiLine(maxLines: 100, enabledEntities: user.botInfo != nil ? enabledPrivateBioEntities : []), action: nil, requestLayout: { animated in
interaction.requestLayout(animated) interaction.requestLayout(animated)
})) }))
} else if user.isScam { } else if user.isScam {
items[currentPeerInfoSection]!.append(PeerInfoScreenLabeledValueItem(id: 0, label: user.botInfo == nil ? presentationData.strings.Profile_About : presentationData.strings.Profile_BotInfo, text: user.botInfo != nil ? presentationData.strings.UserInfo_ScamBotWarning : presentationData.strings.UserInfo_ScamUserWarning, textColor: .primary, textBehavior: .multiLine(maxLines: 100, enabledEntities: user.botInfo != nil ? enabledPrivateBioEntities : []), action: nil, requestLayout: { animated in items[currentPeerInfoSection]!.append(PeerInfoScreenLabeledValueItem(id: ItemAbout, label: user.botInfo == nil ? presentationData.strings.Profile_About : presentationData.strings.Profile_BotInfo, text: user.botInfo != nil ? presentationData.strings.UserInfo_ScamBotWarning : presentationData.strings.UserInfo_ScamUserWarning, textColor: .primary, textBehavior: .multiLine(maxLines: 100, enabledEntities: user.botInfo != nil ? enabledPrivateBioEntities : []), action: nil, requestLayout: { animated in
interaction.requestLayout(animated) interaction.requestLayout(animated)
})) }))
} else if hasAbout || hasNote || hasWebApp { } else if hasAbout || hasNote || hasWebApp {
@ -1494,7 +1525,7 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
if let about = cachedData.about, !about.isEmpty { if let about = cachedData.about, !about.isEmpty {
label = user.botInfo == nil ? presentationData.strings.Profile_About : presentationData.strings.Profile_BotInfo label = user.botInfo == nil ? presentationData.strings.Profile_About : presentationData.strings.Profile_BotInfo
} }
items[currentPeerInfoSection]!.append(PeerInfoScreenLabeledValueItem(id: 0, label: label, text: cachedData.about ?? "", textColor: .primary, textBehavior: .multiLine(maxLines: 100, enabledEntities: user.isPremium ? enabledPublicBioEntities : enabledPrivateBioEntities), action: isMyProfile ? { node, _ in items[currentPeerInfoSection]!.append(PeerInfoScreenLabeledValueItem(id: ItemAbout, label: label, text: cachedData.about ?? "", textColor: .primary, textBehavior: .multiLine(maxLines: 100, enabledEntities: user.isPremium ? enabledPublicBioEntities : enabledPrivateBioEntities), action: isMyProfile ? { node, _ in
bioContextAction(node, nil, nil) bioContextAction(node, nil, nil)
} : nil, linkItemAction: bioLinkAction, button: actionButton, contextAction: bioContextAction, requestLayout: { animated in } : nil, linkItemAction: bioLinkAction, button: actionButton, contextAction: bioContextAction, requestLayout: { animated in
interaction.requestLayout(animated) interaction.requestLayout(animated)
@ -1506,13 +1537,13 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
if context.isPremium { if context.isPremium {
entities = generateTextEntities(note.text, enabledTypes: [.mention, .hashtag, .allUrl], currentEntities: entities) entities = generateTextEntities(note.text, enabledTypes: [.mention, .hashtag, .allUrl], currentEntities: entities)
} }
items[currentPeerInfoSection]!.append(PeerInfoScreenLabeledValueItem(id: 1, label: presentationData.strings.PeerInfo_Notes, rightLabel: presentationData.strings.PeerInfo_NotesInfo, text: note.text, entities: entities, handleSpoilers: true, textColor: .primary, textBehavior: .multiLine(maxLines: 100, enabledEntities: []), action: nil, linkItemAction: bioLinkAction, button: nil, contextAction: noteContextAction, requestLayout: { animated in items[currentPeerInfoSection]!.append(PeerInfoScreenLabeledValueItem(id: ItemNote, label: presentationData.strings.PeerInfo_Notes, rightLabel: presentationData.strings.PeerInfo_NotesInfo, text: note.text, entities: entities, handleSpoilers: true, textColor: .primary, textBehavior: .multiLine(maxLines: 100, enabledEntities: []), action: nil, linkItemAction: bioLinkAction, button: nil, contextAction: noteContextAction, requestLayout: { animated in
interaction.requestLayout(animated) interaction.requestLayout(animated)
})) }))
} }
if let botInfo = user.botInfo, botInfo.flags.contains(.canEdit) { if let botInfo = user.botInfo, botInfo.flags.contains(.canEdit) {
items[currentPeerInfoSection]!.append(PeerInfoScreenCommentItem(id: 800, text: presentationData.strings.PeerInfo_AppFooterAdmin, linkAction: { action in items[currentPeerInfoSection]!.append(PeerInfoScreenCommentItem(id: ItemAppFooter, text: presentationData.strings.PeerInfo_AppFooterAdmin, linkAction: { action in
if case let .tap(url) = action { if case let .tap(url) = action {
context.sharedContext.applicationBindings.openUrl(url) context.sharedContext.applicationBindings.openUrl(url)
} }
@ -1520,7 +1551,7 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
currentPeerInfoSection = .peerInfoTrailing currentPeerInfoSection = .peerInfoTrailing
} else if actionButton != nil { } else if actionButton != nil {
items[currentPeerInfoSection]!.append(PeerInfoScreenCommentItem(id: 800, text: presentationData.strings.PeerInfo_AppFooter, linkAction: { action in items[currentPeerInfoSection]!.append(PeerInfoScreenCommentItem(id: ItemAppFooter, text: presentationData.strings.PeerInfo_AppFooter, linkAction: { action in
if case let .tap(url) = action { if case let .tap(url) = action {
context.sharedContext.applicationBindings.openUrl(url) context.sharedContext.applicationBindings.openUrl(url)
} }
@ -1547,17 +1578,17 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
} }
let programTitleValue: String let programTitleValue: String
programTitleValue = "\(formatPermille(starRefProgram.commissionPermille))%" programTitleValue = "\(formatPermille(starRefProgram.commissionPermille))%"
items[.botAffiliateProgram]!.append(PeerInfoScreenDisclosureItem(id: 0, label: .labelBadge(programTitleValue), additionalBadgeLabel: nil, text: presentationData.strings.PeerInfo_ItemAffiliateProgram_Title, icon: PresentationResourcesSettings.affiliateProgram, action: { items[.botAffiliateProgram]!.append(PeerInfoScreenDisclosureItem(id: ItemAffiliate, label: .labelBadge(programTitleValue), additionalBadgeLabel: nil, text: presentationData.strings.PeerInfo_ItemAffiliateProgram_Title, icon: PresentationResourcesSettings.affiliateProgram, action: {
interaction.editingOpenAffiliateProgram() interaction.editingOpenAffiliateProgram()
})) }))
items[.botAffiliateProgram]!.append(PeerInfoScreenCommentItem(id: 1, text: presentationData.strings.PeerInfo_ItemAffiliateProgram_Footer(EnginePeer.user(user).compactDisplayTitle, formatPermille(starRefProgram.commissionPermille)).string)) items[.botAffiliateProgram]!.append(PeerInfoScreenCommentItem(id: ItemAffiliateInfo, text: presentationData.strings.PeerInfo_ItemAffiliateProgram_Footer(EnginePeer.user(user).compactDisplayTitle, formatPermille(starRefProgram.commissionPermille)).string))
} }
} }
} }
} }
if let businessHours = cachedData.businessHours { if let businessHours = cachedData.businessHours {
items[currentPeerInfoSection]!.append(PeerInfoScreenBusinessHoursItem(id: 300, label: presentationData.strings.PeerInfo_BusinessHours_Label, businessHours: businessHours, requestLayout: { animated in items[currentPeerInfoSection]!.append(PeerInfoScreenBusinessHoursItem(id: ItemBusinessHours, label: presentationData.strings.PeerInfo_BusinessHours_Label, businessHours: businessHours, requestLayout: { animated in
interaction.requestLayout(animated) interaction.requestLayout(animated)
}, longTapAction: nil, contextAction: workingHoursContextAction)) }, longTapAction: nil, contextAction: workingHoursContextAction))
} }
@ -1566,7 +1597,7 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
if let coordinates = businessLocation.coordinates { if let coordinates = businessLocation.coordinates {
let imageSignal = chatMapSnapshotImage(engine: context.engine, resource: MapSnapshotMediaResource(latitude: coordinates.latitude, longitude: coordinates.longitude, width: 90, height: 90)) let imageSignal = chatMapSnapshotImage(engine: context.engine, resource: MapSnapshotMediaResource(latitude: coordinates.latitude, longitude: coordinates.longitude, width: 90, height: 90))
items[currentPeerInfoSection]!.append(PeerInfoScreenAddressItem( items[currentPeerInfoSection]!.append(PeerInfoScreenAddressItem(
id: 301, id: ItemLocation,
label: presentationData.strings.PeerInfo_Location_Label, label: presentationData.strings.PeerInfo_Location_Label,
text: businessLocation.address, text: businessLocation.address,
imageSignal: imageSignal, imageSignal: imageSignal,
@ -1577,7 +1608,7 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
)) ))
} else { } else {
items[currentPeerInfoSection]!.append(PeerInfoScreenAddressItem( items[currentPeerInfoSection]!.append(PeerInfoScreenAddressItem(
id: 301, id: ItemLocation,
label: presentationData.strings.PeerInfo_Location_Label, label: presentationData.strings.PeerInfo_Location_Label,
text: businessLocation.address, text: businessLocation.address,
imageSignal: nil, imageSignal: nil,
@ -1590,25 +1621,25 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
if !isMyProfile { if !isMyProfile {
if let reactionSourceMessageId = reactionSourceMessageId, !data.isContact { if let reactionSourceMessageId = reactionSourceMessageId, !data.isContact {
items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: 3, text: presentationData.strings.UserInfo_SendMessage, action: { items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: ItemSendMessage, text: presentationData.strings.UserInfo_SendMessage, action: {
interaction.openChat(nil) interaction.openChat(nil)
})) }))
items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: 4, text: presentationData.strings.ReportPeer_BanAndReport, color: .destructive, action: { items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: ItemReport, text: presentationData.strings.ReportPeer_BanAndReport, color: .destructive, action: {
interaction.openReport(.reaction(reactionSourceMessageId)) interaction.openReport(.reaction(reactionSourceMessageId))
})) }))
} else if let _ = nearbyPeerDistance { } else if let _ = nearbyPeerDistance {
items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: 3, text: presentationData.strings.UserInfo_SendMessage, action: { items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: ItemSendMessage, text: presentationData.strings.UserInfo_SendMessage, action: {
interaction.openChat(nil) interaction.openChat(nil)
})) }))
items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: 4, text: presentationData.strings.ReportPeer_Report, color: .destructive, action: { items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: ItemReport, text: presentationData.strings.ReportPeer_Report, color: .destructive, action: {
interaction.openReport(.user) interaction.openReport(.user)
})) }))
} else { } else {
if !data.isContact { if !data.isContact {
if user.botInfo == nil { if user.botInfo == nil {
items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: 3, text: presentationData.strings.PeerInfo_AddToContacts, action: { items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: ItemAddToContacts, text: presentationData.strings.PeerInfo_AddToContacts, action: {
interaction.openAddContact() interaction.openAddContact()
})) }))
} }
@ -1620,14 +1651,14 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
} }
if isBlocked { if isBlocked {
items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: 4, text: user.botInfo != nil ? presentationData.strings.Bot_Unblock : presentationData.strings.Conversation_Unblock, action: { items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: ItemBlock, text: user.botInfo != nil ? presentationData.strings.Bot_Unblock : presentationData.strings.Conversation_Unblock, action: {
interaction.updateBlocked(false) interaction.updateBlocked(false)
})) }))
} else { } else {
if user.flags.contains(.isSupport) || data.isContact { if user.flags.contains(.isSupport) || data.isContact {
} else { } else {
if user.botInfo == nil { if user.botInfo == nil {
items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: 4, text: presentationData.strings.Conversation_BlockUser, color: .destructive, action: { items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: ItemBlock, text: presentationData.strings.Conversation_BlockUser, color: .destructive, action: {
interaction.updateBlocked(true) interaction.updateBlocked(true)
})) }))
} }
@ -1635,7 +1666,7 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
} }
if let encryptionKeyFingerprint = data.encryptionKeyFingerprint { if let encryptionKeyFingerprint = data.encryptionKeyFingerprint {
items[currentPeerInfoSection]!.append(PeerInfoScreenDisclosureEncryptionKeyItem(id: 5, text: presentationData.strings.Profile_EncryptionKey, fingerprint: encryptionKeyFingerprint, action: { items[currentPeerInfoSection]!.append(PeerInfoScreenDisclosureEncryptionKeyItem(id: ItemEncryptionKey, text: presentationData.strings.Profile_EncryptionKey, fingerprint: encryptionKeyFingerprint, action: {
interaction.openEncryptionKey() interaction.openEncryptionKey()
})) }))
} }
@ -1647,7 +1678,7 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
let overallStarsBalance = data.starsRevenueStatsState?.balances.overallRevenue.amount ?? StarsAmount.zero let overallStarsBalance = data.starsRevenueStatsState?.balances.overallRevenue.amount ?? StarsAmount.zero
if overallRevenueBalance > 0 || overallStarsBalance > StarsAmount.zero { if overallRevenueBalance > 0 || overallStarsBalance > StarsAmount.zero {
items[.balances]!.append(PeerInfoScreenHeaderItem(id: 20, text: presentationData.strings.PeerInfo_BotBalance_Title)) items[.balances]!.append(PeerInfoScreenHeaderItem(id: ItemBalanceHeader, text: presentationData.strings.PeerInfo_BotBalance_Title))
if overallRevenueBalance > 0 { if overallRevenueBalance > 0 {
let string = "*\(formatTonAmountText(revenueBalance, dateTimeFormat: presentationData.dateTimeFormat))" let string = "*\(formatTonAmountText(revenueBalance, dateTimeFormat: presentationData.dateTimeFormat))"
let attributedString = NSMutableAttributedString(string: string, font: Font.regular(presentationData.listsFontSize.itemListBaseFontSize), textColor: presentationData.theme.list.itemSecondaryTextColor) let attributedString = NSMutableAttributedString(string: string, font: Font.regular(presentationData.listsFontSize.itemListBaseFontSize), textColor: presentationData.theme.list.itemSecondaryTextColor)
@ -1655,7 +1686,7 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
attributedString.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: 0, file: nil, custom: .ton(tinted: false)), range: NSRange(range, in: attributedString.string)) attributedString.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: 0, file: nil, custom: .ton(tinted: false)), range: NSRange(range, in: attributedString.string))
attributedString.addAttribute(.baselineOffset, value: 1.5, range: NSRange(range, in: attributedString.string)) attributedString.addAttribute(.baselineOffset, value: 1.5, range: NSRange(range, in: attributedString.string))
} }
items[.balances]!.append(PeerInfoScreenDisclosureItem(id: 21, label: .attributedText(attributedString), text: presentationData.strings.PeerInfo_BotBalance_Ton, icon: PresentationResourcesSettings.ton, action: { items[.balances]!.append(PeerInfoScreenDisclosureItem(id: ItemBalanceTon, label: .attributedText(attributedString), text: presentationData.strings.PeerInfo_BotBalance_Ton, icon: PresentationResourcesSettings.ton, action: {
interaction.editingOpenRevenue() interaction.editingOpenRevenue()
})) }))
} }
@ -1672,12 +1703,10 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
attributedString.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: 0, file: nil, custom: .stars(tinted: false)), range: NSRange(range, in: attributedString.string)) attributedString.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: 0, file: nil, custom: .stars(tinted: false)), range: NSRange(range, in: attributedString.string))
attributedString.addAttribute(.baselineOffset, value: 1.5, range: NSRange(range, in: attributedString.string)) attributedString.addAttribute(.baselineOffset, value: 1.5, range: NSRange(range, in: attributedString.string))
} }
items[.balances]!.append(PeerInfoScreenDisclosureItem(id: 22, label: .attributedText(attributedString), text: presentationData.strings.PeerInfo_BotBalance_Stars, icon: PresentationResourcesSettings.stars, action: { items[.balances]!.append(PeerInfoScreenDisclosureItem(id: ItemBalanceStars, label: .attributedText(attributedString), text: presentationData.strings.PeerInfo_BotBalance_Stars, icon: PresentationResourcesSettings.stars, action: {
interaction.editingOpenStars() interaction.editingOpenStars()
})) }))
} }
} else {
print()
} }
if let _ = user.botInfo { if let _ = user.botInfo {
@ -1686,7 +1715,7 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
canManageEmojiStatus = true canManageEmojiStatus = true
} }
if canManageEmojiStatus || data.webAppPermissions?.emojiStatus?.isRequested == true { if canManageEmojiStatus || data.webAppPermissions?.emojiStatus?.isRequested == true {
items[.permissions]!.append(PeerInfoScreenSwitchItem(id: 31, text: presentationData.strings.PeerInfo_Permissions_EmojiStatus, value: canManageEmojiStatus, icon: UIImage(bundleImageName: "Chat/Info/Status"), isLocked: false, toggled: { value in items[.permissions]!.append(PeerInfoScreenSwitchItem(id: ItemBotPermissionsEmojiStatus, text: presentationData.strings.PeerInfo_Permissions_EmojiStatus, value: canManageEmojiStatus, icon: UIImage(bundleImageName: "Chat/Info/Status"), isLocked: false, toggled: { value in
let _ = (context.engine.peers.toggleBotEmojiStatusAccess(peerId: user.id, enabled: value) let _ = (context.engine.peers.toggleBotEmojiStatusAccess(peerId: user.id, enabled: value)
|> deliverOnMainQueue).startStandalone() |> deliverOnMainQueue).startStandalone()
@ -1696,31 +1725,31 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
})) }))
} }
if data.webAppPermissions?.location?.isRequested == true || data.webAppPermissions?.location?.isAllowed == true { if data.webAppPermissions?.location?.isRequested == true || data.webAppPermissions?.location?.isAllowed == true {
items[.permissions]!.append(PeerInfoScreenSwitchItem(id: 32, text: presentationData.strings.PeerInfo_Permissions_Geolocation, value: data.webAppPermissions?.location?.isAllowed ?? false, icon: UIImage(bundleImageName: "Chat/Info/Location"), isLocked: false, toggled: { value in items[.permissions]!.append(PeerInfoScreenSwitchItem(id: ItemBotPermissionsLocation, text: presentationData.strings.PeerInfo_Permissions_Geolocation, value: data.webAppPermissions?.location?.isAllowed ?? false, icon: UIImage(bundleImageName: "Chat/Info/Location"), isLocked: false, toggled: { value in
let _ = updateWebAppPermissionsStateInteractively(context: context, peerId: user.id) { current in let _ = updateWebAppPermissionsStateInteractively(context: context, peerId: user.id) { current in
return WebAppPermissionsState(location: WebAppPermissionsState.Location(isRequested: true, isAllowed: value), emojiStatus: current?.emojiStatus) return WebAppPermissionsState(location: WebAppPermissionsState.Location(isRequested: true, isAllowed: value), emojiStatus: current?.emojiStatus)
}.startStandalone() }.startStandalone()
})) }))
} }
if !"".isEmpty { if !"".isEmpty {
items[.permissions]!.append(PeerInfoScreenSwitchItem(id: 33, text: presentationData.strings.PeerInfo_Permissions_Biometry, value: true, icon: UIImage(bundleImageName: "Settings/Menu/TouchId"), isLocked: false, toggled: { value in items[.permissions]!.append(PeerInfoScreenSwitchItem(id: ItemBotPermissionsBiometry, text: presentationData.strings.PeerInfo_Permissions_Biometry, value: true, icon: UIImage(bundleImageName: "Settings/Menu/TouchId"), isLocked: false, toggled: { value in
})) }))
} }
if !items[.permissions]!.isEmpty { if !items[.permissions]!.isEmpty {
items[.permissions]!.insert(PeerInfoScreenHeaderItem(id: 30, text: presentationData.strings.PeerInfo_Permissions_Title), at: 0) items[.permissions]!.insert(PeerInfoScreenHeaderItem(id: ItemBotPermissionsHeader, text: presentationData.strings.PeerInfo_Permissions_Title), at: 0)
} }
} }
if let botInfo = user.botInfo, botInfo.flags.contains(.canEdit) { if let botInfo = user.botInfo, botInfo.flags.contains(.canEdit) {
items[currentPeerInfoSection]!.append(PeerInfoScreenDisclosureItem(id: 10, label: .none, text: presentationData.strings.Bot_Settings, icon: UIImage(bundleImageName: "Chat/Info/SettingsIcon"), action: { items[currentPeerInfoSection]!.append(PeerInfoScreenDisclosureItem(id: ItemBotSettings, label: .none, text: presentationData.strings.Bot_Settings, icon: UIImage(bundleImageName: "Chat/Info/SettingsIcon"), action: {
interaction.openEditing() interaction.openEditing()
})) }))
} }
if let botInfo = user.botInfo, !botInfo.flags.contains(.canEdit) { if let botInfo = user.botInfo, !botInfo.flags.contains(.canEdit) {
items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: 6, text: presentationData.strings.ReportPeer_Report, action: { items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: ItemBotReport, text: presentationData.strings.ReportPeer_Report, action: {
interaction.openReport(.default) interaction.openReport(.default)
})) }))
} }
@ -1739,16 +1768,16 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
let attributedPrefix = NSMutableAttributedString(string: " ") let attributedPrefix = NSMutableAttributedString(string: " ")
attributedPrefix.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: verification.iconFileId, file: nil), range: NSMakeRange(0, 1)) attributedPrefix.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: verification.iconFileId, file: nil), range: NSMakeRange(0, 1))
items[currentPeerInfoSection]!.append(PeerInfoScreenCommentItem(id: 800, text: description, attributedPrefix: attributedPrefix, useAccentLinkColor: false, linkAction: { action in items[currentPeerInfoSection]!.append(PeerInfoScreenCommentItem(id: ItemVerification, text: description, attributedPrefix: attributedPrefix, useAccentLinkColor: false, linkAction: { action in
if case let .tap(url) = action, let navigationController = interaction.getController()?.navigationController as? NavigationController { if case let .tap(url) = action, let navigationController = interaction.getController()?.navigationController as? NavigationController {
context.sharedContext.openExternalUrl(context: context, urlContext: .generic, url: url, forceExternal: false, presentationData: presentationData, navigationController: navigationController, dismissInput: {}) context.sharedContext.openExternalUrl(context: context, urlContext: .generic, url: url, forceExternal: false, presentationData: presentationData, navigationController: navigationController, dismissInput: {})
} }
})) }))
} else if let botInfo = user.botInfo, botInfo.flags.contains(.worksWithGroups) { } else if let botInfo = user.botInfo, botInfo.flags.contains(.worksWithGroups) {
items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: 7, text: presentationData.strings.Bot_AddToChat, color: .accent, action: { items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: ItemBotAddToChat, text: presentationData.strings.Bot_AddToChat, color: .accent, action: {
interaction.openAddBotToGroup() interaction.openAddBotToGroup()
})) }))
items[currentPeerInfoSection]!.append(PeerInfoScreenCommentItem(id: 8, text: presentationData.strings.Bot_AddToChatInfo)) items[currentPeerInfoSection]!.append(PeerInfoScreenCommentItem(id: ItemBotAddToChatInfo, text: presentationData.strings.Bot_AddToChatInfo))
} }
} }
} }