mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Various improvements
This commit is contained in:
@@ -129,7 +129,11 @@ private enum GlobalAutoremoveEntry: ItemListNodeEntry {
|
||||
isChecked = true
|
||||
}
|
||||
return ItemListCheckboxItem(presentationData: presentationData, icon: isEnabled ? nil : generateTintedImage(image: UIImage(bundleImageName: "Chat/Stickers/Lock"), color: presentationData.theme.list.itemSecondaryTextColor), iconPlacement: .check, title: presentationData.strings.Privacy_Messages_ChargeForMessages, style: .left, checked: isChecked, zeroSeparatorInsets: false, sectionId: self.section, action: {
|
||||
arguments.updateValue(.paidMessages(StarsAmount(value: 400, nanos: 0)))
|
||||
if isEnabled {
|
||||
arguments.updateValue(.paidMessages(StarsAmount(value: 400, nanos: 0)))
|
||||
} else {
|
||||
arguments.disabledValuePressed()
|
||||
}
|
||||
})
|
||||
case let .footer(value):
|
||||
let text: String
|
||||
@@ -146,7 +150,7 @@ private enum GlobalAutoremoveEntry: ItemListNodeEntry {
|
||||
case .priceHeader:
|
||||
return ItemListSectionHeaderItem(presentationData: presentationData, text: presentationData.strings.Privacy_Messages_MessagePrice, sectionId: self.section)
|
||||
case let .price(value, price):
|
||||
return MessagePriceItem(theme: presentationData.theme, strings: presentationData.strings, minValue: 10, maxValue: 9000, value: value, price: price, sectionId: self.section, updated: { value in
|
||||
return MessagePriceItem(theme: presentationData.theme, strings: presentationData.strings, minValue: 1, maxValue: 10000, value: value, price: price, sectionId: self.section, updated: { value in
|
||||
arguments.updateValue(.paidMessages(StarsAmount(value: value, nanos: 0)))
|
||||
})
|
||||
case let .priceInfo(value):
|
||||
@@ -168,12 +172,12 @@ private struct IncomingMessagePrivacyScreenState: Equatable {
|
||||
var disableFor: [EnginePeer.Id: SelectivePrivacyPeer]
|
||||
}
|
||||
|
||||
private func incomingMessagePrivacyScreenEntries(presentationData: PresentationData, state: IncomingMessagePrivacyScreenState, isPremium: Bool, configuration: StarsSubscriptionConfiguration) -> [GlobalAutoremoveEntry] {
|
||||
private func incomingMessagePrivacyScreenEntries(presentationData: PresentationData, state: IncomingMessagePrivacyScreenState, enableSetting: Bool, isPremium: Bool, configuration: StarsSubscriptionConfiguration) -> [GlobalAutoremoveEntry] {
|
||||
var entries: [GlobalAutoremoveEntry] = []
|
||||
|
||||
entries.append(.header)
|
||||
entries.append(.optionEverybody(value: state.updatedValue))
|
||||
entries.append(.optionPremium(value: state.updatedValue, isEnabled: isPremium))
|
||||
entries.append(.optionPremium(value: state.updatedValue, isEnabled: enableSetting))
|
||||
entries.append(.optionChargeForMessages(value: state.updatedValue, isEnabled: isPremium))
|
||||
|
||||
if case let .paidMessages(amount) = state.updatedValue {
|
||||
@@ -375,7 +379,7 @@ public func incomingMessagePrivacyScreen(context: AccountContext, value: GlobalP
|
||||
|
||||
let title: ItemListControllerTitle = .text(presentationData.strings.Privacy_Messages_Title)
|
||||
|
||||
let entries: [GlobalAutoremoveEntry] = incomingMessagePrivacyScreenEntries(presentationData: presentationData, state: state, isPremium: enableSetting, configuration: configuration)
|
||||
let entries: [GlobalAutoremoveEntry] = incomingMessagePrivacyScreenEntries(presentationData: presentationData, state: state, enableSetting: enableSetting, isPremium: context.isPremium, configuration: configuration)
|
||||
|
||||
let animateChanges = false
|
||||
|
||||
|
||||
@@ -437,9 +437,8 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
label = presentationData.strings.Settings_Privacy_Messages_ValueEveryone
|
||||
case .requirePremium:
|
||||
label = presentationData.strings.Settings_Privacy_Messages_ValueContactsAndPremium
|
||||
case let .paidMessages(amount):
|
||||
//TODO:localize
|
||||
label = "\(amount.value) Stars"
|
||||
case .paidMessages:
|
||||
label = presentationData.strings.Settings_Privacy_Messages_ValuePaid
|
||||
}
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: presentationData.strings.Settings_Privacy_Messages, titleIcon: hasPremium ? PresentationResourcesItemList.premiumIcon(theme) : nil, label: label, sectionId: self.section, style: .blocks, action: {
|
||||
arguments.openMessagePrivacy()
|
||||
@@ -862,7 +861,11 @@ public func privacyAndSecurityController(
|
||||
updateHasTwoStepAuth()
|
||||
|
||||
var setupEmailImpl: ((String?) -> Void)?
|
||||
|
||||
|
||||
var reviewCallPrivacySuggestion = false
|
||||
var reviewInvitePrivacySuggestion = false
|
||||
var showPrivacySuggestionImpl: (() -> Void)?
|
||||
|
||||
let arguments = PrivacyAndSecurityControllerArguments(account: context.account, openBlockedUsers: {
|
||||
pushControllerImpl?(blockedPeersController(context: context, blockedPeersContext: blockedPeersContext), true)
|
||||
}, openLastSeenPrivacy: {
|
||||
@@ -907,6 +910,10 @@ public func privacyAndSecurityController(
|
||||
return .complete()
|
||||
}
|
||||
currentInfoDisposable.set(applySetting.start())
|
||||
|
||||
Queue.mainQueue().after(0.3) {
|
||||
showPrivacySuggestionImpl?()
|
||||
}
|
||||
}
|
||||
}), true)
|
||||
}
|
||||
@@ -944,6 +951,10 @@ public func privacyAndSecurityController(
|
||||
return .complete()
|
||||
}
|
||||
currentInfoDisposable.set(applySetting.start())
|
||||
|
||||
Queue.mainQueue().after(0.3) {
|
||||
showPrivacySuggestionImpl?()
|
||||
}
|
||||
}
|
||||
}), true)
|
||||
}
|
||||
@@ -1319,6 +1330,22 @@ public func privacyAndSecurityController(
|
||||
return state
|
||||
}
|
||||
}))
|
||||
|
||||
if case .everybody = privacySettings.globalSettings.nonContactChatsPrivacy {
|
||||
if case .everybody = settingValue {
|
||||
|
||||
} else {
|
||||
if case .enableEveryone = privacySettings.voiceCalls {
|
||||
reviewCallPrivacySuggestion = true
|
||||
}
|
||||
if case .enableEveryone = privacySettings.groupInvitations {
|
||||
reviewInvitePrivacySuggestion = true
|
||||
}
|
||||
Queue.mainQueue().after(0.3) {
|
||||
showPrivacySuggestionImpl?()
|
||||
}
|
||||
}
|
||||
}
|
||||
}), true)
|
||||
})
|
||||
}, openGiftsPrivacy: {
|
||||
@@ -1442,6 +1469,50 @@ public func privacyAndSecurityController(
|
||||
}
|
||||
}
|
||||
|
||||
showPrivacySuggestionImpl = {
|
||||
//TODO:localize
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
if reviewCallPrivacySuggestion {
|
||||
reviewCallPrivacySuggestion = false
|
||||
let alertController = textAlertController(
|
||||
context: context,
|
||||
title: "Call Settings",
|
||||
text: "You've restricted who can message you, but anyone can still call you. Would you like to review these settings?",
|
||||
actions: [
|
||||
TextAlertAction(type: .defaultAction, title: "Review", action: {
|
||||
arguments.openVoiceCallPrivacy()
|
||||
}),
|
||||
TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {
|
||||
Queue.mainQueue().after(0.3) {
|
||||
showPrivacySuggestionImpl?()
|
||||
}
|
||||
})
|
||||
],
|
||||
actionLayout: .vertical
|
||||
)
|
||||
presentControllerImpl?(alertController)
|
||||
} else if reviewInvitePrivacySuggestion {
|
||||
reviewInvitePrivacySuggestion = false
|
||||
let alertController = textAlertController(
|
||||
context: context,
|
||||
title: "Invitation Settings",
|
||||
text: "You've restricted who can message you, but anyone can still invite you to groups and channels. Would you like to review these settings?",
|
||||
actions: [
|
||||
TextAlertAction(type: .defaultAction, title: "Review", action: {
|
||||
arguments.openGroupsPrivacy()
|
||||
}),
|
||||
TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {
|
||||
Queue.mainQueue().after(0.3) {
|
||||
showPrivacySuggestionImpl?()
|
||||
}
|
||||
})
|
||||
],
|
||||
actionLayout: .vertical
|
||||
)
|
||||
presentControllerImpl?(alertController)
|
||||
}
|
||||
}
|
||||
|
||||
setupEmailImpl = { emailPattern in
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
var dismissEmailControllerImpl: (() -> Void)?
|
||||
|
||||
Reference in New Issue
Block a user