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:
@@ -19,19 +19,22 @@ private final class IncomingMessagePrivacyScreenArguments {
|
||||
let disabledValuePressed: () -> Void
|
||||
let infoLinkAction: () -> Void
|
||||
let openExceptions: () -> Void
|
||||
let openPremiumInfo: () -> Void
|
||||
|
||||
init(
|
||||
context: AccountContext,
|
||||
updateValue: @escaping (GlobalPrivacySettings.NonContactChatsPrivacy) -> Void,
|
||||
disabledValuePressed: @escaping () -> Void,
|
||||
infoLinkAction: @escaping () -> Void,
|
||||
openExceptions: @escaping () -> Void
|
||||
openExceptions: @escaping () -> Void,
|
||||
openPremiumInfo: @escaping () -> Void
|
||||
) {
|
||||
self.context = context
|
||||
self.updateValue = updateValue
|
||||
self.disabledValuePressed = disabledValuePressed
|
||||
self.infoLinkAction = infoLinkAction
|
||||
self.openExceptions = openExceptions
|
||||
self.openPremiumInfo = openPremiumInfo
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +52,7 @@ private enum GlobalAutoremoveEntry: ItemListNodeEntry {
|
||||
case optionChargeForMessages(value: GlobalPrivacySettings.NonContactChatsPrivacy, isEnabled: Bool)
|
||||
case footer(value: GlobalPrivacySettings.NonContactChatsPrivacy)
|
||||
case priceHeader
|
||||
case price(value: Int64, price: String)
|
||||
case price(value: Int64, maxValue: Int64, price: String, isEnabled: Bool)
|
||||
case priceInfo(commission: Int32, value: String)
|
||||
case exceptionsHeader
|
||||
case exceptions(count: Int)
|
||||
@@ -128,12 +131,8 @@ private enum GlobalAutoremoveEntry: ItemListNodeEntry {
|
||||
if case .paidMessages = value {
|
||||
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: {
|
||||
if isEnabled {
|
||||
arguments.updateValue(.paidMessages(StarsAmount(value: 400, nanos: 0)))
|
||||
} else {
|
||||
arguments.disabledValuePressed()
|
||||
}
|
||||
return ItemListCheckboxItem(presentationData: presentationData, icon: isEnabled || isChecked ? 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)))
|
||||
})
|
||||
case let .footer(value):
|
||||
let text: String
|
||||
@@ -149,9 +148,11 @@ 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: 1, maxValue: 10000, value: value, price: price, sectionId: self.section, updated: { value in
|
||||
case let .price(value, maxValue, price, isEnabled):
|
||||
return MessagePriceItem(theme: presentationData.theme, strings: presentationData.strings, isEnabled: isEnabled, minValue: 1, maxValue: maxValue, value: value, price: price, sectionId: self.section, updated: { value in
|
||||
arguments.updateValue(.paidMessages(StarsAmount(value: value, nanos: 0)))
|
||||
}, openPremiumInfo: {
|
||||
arguments.openPremiumInfo()
|
||||
})
|
||||
case let .priceInfo(commission, value):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .markdown(presentationData.strings.Privacy_Messages_MessagePriceInfo("\(commission)", value).string), sectionId: self.section)
|
||||
@@ -178,7 +179,9 @@ private func incomingMessagePrivacyScreenEntries(presentationData: PresentationD
|
||||
entries.append(.header)
|
||||
entries.append(.optionEverybody(value: state.updatedValue))
|
||||
entries.append(.optionPremium(value: state.updatedValue, isEnabled: enableSetting))
|
||||
entries.append(.optionChargeForMessages(value: state.updatedValue, isEnabled: isPremium))
|
||||
if configuration.paidMessagesAvailable {
|
||||
entries.append(.optionChargeForMessages(value: state.updatedValue, isEnabled: isPremium))
|
||||
}
|
||||
|
||||
if case let .paidMessages(amount) = state.updatedValue {
|
||||
entries.append(.footer(value: state.updatedValue))
|
||||
@@ -188,11 +191,14 @@ private func incomingMessagePrivacyScreenEntries(presentationData: PresentationD
|
||||
|
||||
let price = "≈\(formatTonUsdValue(amount.value, divide: false, rate: usdRate, dateTimeFormat: presentationData.dateTimeFormat))"
|
||||
|
||||
entries.append(.price(value: amount.value, price: price))
|
||||
entries.append(.price(value: amount.value, maxValue: configuration.paidMessageMaxAmount, price: price, isEnabled: isPremium))
|
||||
entries.append(.priceInfo(commission: configuration.paidMessageCommissionPermille / 10, value: price))
|
||||
entries.append(.exceptionsHeader)
|
||||
entries.append(.exceptions(count: state.disableFor.count))
|
||||
entries.append(.exceptionsInfo)
|
||||
|
||||
if isPremium {
|
||||
entries.append(.exceptionsHeader)
|
||||
entries.append(.exceptions(count: state.disableFor.count))
|
||||
entries.append(.exceptionsInfo)
|
||||
}
|
||||
} else {
|
||||
entries.append(.footer(value: state.updatedValue))
|
||||
entries.append(.info)
|
||||
@@ -347,6 +353,17 @@ public func incomingMessagePrivacyScreen(context: AccountContext, value: GlobalP
|
||||
})
|
||||
pushControllerImpl?(controller)
|
||||
}
|
||||
},
|
||||
openPremiumInfo: {
|
||||
var replaceImpl: ((ViewController) -> Void)?
|
||||
let controller = context.sharedContext.makePremiumDemoController(context: context, subject: .paidMessages, forceDark: false, action: {
|
||||
let controller = context.sharedContext.makePremiumIntroController(context: context, source: .paidMessages, forceDark: false, dismissed: nil)
|
||||
replaceImpl?(controller)
|
||||
}, dismissed: nil)
|
||||
replaceImpl = { [weak controller] c in
|
||||
controller?.replace(with: c)
|
||||
}
|
||||
pushControllerImpl?(controller)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -414,7 +431,12 @@ public func incomingMessagePrivacyScreen(context: AccountContext, value: GlobalP
|
||||
controller?.push(c)
|
||||
}
|
||||
controller.attemptNavigation = { _ in
|
||||
update(stateValue.with({ $0 }).updatedValue)
|
||||
let updatedValue = stateValue.with({ $0 }).updatedValue
|
||||
if !context.isPremium, case .paidMessages = updatedValue {
|
||||
|
||||
} else {
|
||||
update(updatedValue)
|
||||
}
|
||||
return true
|
||||
}
|
||||
dismissImpl = { [weak controller] in
|
||||
|
||||
Reference in New Issue
Block a user