mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-07 08:01:10 +00:00
Support poll options count configuration
This commit is contained in:
parent
e6f4910254
commit
40780242fe
@ -477,7 +477,7 @@ final class ComposePollScreenComponent: Component {
|
|||||||
defer {
|
defer {
|
||||||
self.isUpdating = false
|
self.isUpdating = false
|
||||||
}
|
}
|
||||||
|
|
||||||
var alphaTransition = transition
|
var alphaTransition = transition
|
||||||
if !transition.animation.isImmediate {
|
if !transition.animation.isImmediate {
|
||||||
alphaTransition = alphaTransition.withAnimation(.curve(duration: 0.25, curve: .easeInOut))
|
alphaTransition = alphaTransition.withAnimation(.curve(duration: 0.25, curve: .easeInOut))
|
||||||
@ -850,7 +850,7 @@ final class ComposePollScreenComponent: Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.pollOptions.count < 10, let lastOption = self.pollOptions.last {
|
if self.pollOptions.count < component.initialData.maxPollAnswersCount, let lastOption = self.pollOptions.last {
|
||||||
if lastOption.textInputState.text.length != 0 {
|
if lastOption.textInputState.text.length != 0 {
|
||||||
self.pollOptions.append(PollOption(id: self.nextPollOptionId))
|
self.pollOptions.append(PollOption(id: self.nextPollOptionId))
|
||||||
self.nextPollOptionId += 1
|
self.nextPollOptionId += 1
|
||||||
@ -921,7 +921,7 @@ final class ComposePollScreenComponent: Component {
|
|||||||
|
|
||||||
contentHeight += 7.0
|
contentHeight += 7.0
|
||||||
|
|
||||||
let pollOptionsLimitReached = self.pollOptions.count >= 10
|
let pollOptionsLimitReached = self.pollOptions.count >= component.initialData.maxPollAnswersCount
|
||||||
var animatePollOptionsFooterIn = false
|
var animatePollOptionsFooterIn = false
|
||||||
var pollOptionsFooterTransition = transition
|
var pollOptionsFooterTransition = transition
|
||||||
if self.currentPollOptionsLimitReached != pollOptionsLimitReached {
|
if self.currentPollOptionsLimitReached != pollOptionsLimitReached {
|
||||||
@ -944,7 +944,7 @@ final class ComposePollScreenComponent: Component {
|
|||||||
maximumNumberOfLines: 0
|
maximumNumberOfLines: 0
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
let remainingCount = 10 - self.pollOptions.count
|
let remainingCount = component.initialData.maxPollAnswersCount - self.pollOptions.count
|
||||||
let rawString = environment.strings.CreatePoll_OptionCountFooterFormat(Int32(remainingCount))
|
let rawString = environment.strings.CreatePoll_OptionCountFooterFormat(Int32(remainingCount))
|
||||||
|
|
||||||
var pollOptionsFooterItems: [AnimatedTextComponent.Item] = []
|
var pollOptionsFooterItems: [AnimatedTextComponent.Item] = []
|
||||||
@ -1476,13 +1476,16 @@ public class ComposePollScreen: ViewControllerComponentContainer, AttachmentCont
|
|||||||
public final class InitialData {
|
public final class InitialData {
|
||||||
fileprivate let maxPollTextLength: Int
|
fileprivate let maxPollTextLength: Int
|
||||||
fileprivate let maxPollOptionLength: Int
|
fileprivate let maxPollOptionLength: Int
|
||||||
|
fileprivate let maxPollAnswersCount: Int
|
||||||
|
|
||||||
fileprivate init(
|
fileprivate init(
|
||||||
maxPollTextLength: Int,
|
maxPollTextLength: Int,
|
||||||
maxPollOptionLength: Int
|
maxPollOptionLength: Int,
|
||||||
|
maxPollAnwsersCount: Int
|
||||||
) {
|
) {
|
||||||
self.maxPollTextLength = maxPollTextLength
|
self.maxPollTextLength = maxPollTextLength
|
||||||
self.maxPollOptionLength = maxPollOptionLength
|
self.maxPollOptionLength = maxPollOptionLength
|
||||||
|
self.maxPollAnswersCount = maxPollAnwsersCount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1577,9 +1580,14 @@ public class ComposePollScreen: ViewControllerComponentContainer, AttachmentCont
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static func initialData(context: AccountContext) -> InitialData {
|
public static func initialData(context: AccountContext) -> InitialData {
|
||||||
|
var maxPollAnwsersCount: Int = 10
|
||||||
|
if let data = context.currentAppConfiguration.with({ $0 }).data, let value = data["poll_answers_max"] as? Double {
|
||||||
|
maxPollAnwsersCount = Int(value)
|
||||||
|
}
|
||||||
return InitialData(
|
return InitialData(
|
||||||
maxPollTextLength: Int(200),
|
maxPollTextLength: Int(200),
|
||||||
maxPollOptionLength: 100
|
maxPollOptionLength: 100,
|
||||||
|
maxPollAnwsersCount: maxPollAnwsersCount
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,7 +426,9 @@ private func contactListNodeEntries(accountPeer: EnginePeer?, peers: [ContactLis
|
|||||||
let text = strings.Contacts_PermissionsText
|
let text = strings.Contacts_PermissionsText
|
||||||
switch authorizationStatus {
|
switch authorizationStatus {
|
||||||
case .limited:
|
case .limited:
|
||||||
entries.append(.permissionLimited(theme, strings))
|
if displaySortOptions {
|
||||||
|
entries.append(.permissionLimited(theme, strings))
|
||||||
|
}
|
||||||
case .denied:
|
case .denied:
|
||||||
entries.append(.permissionInfo(theme, title, text, suppressed))
|
entries.append(.permissionInfo(theme, title, text, suppressed))
|
||||||
entries.append(.permissionEnable(theme, strings.Permissions_ContactsAllowInSettings_v0))
|
entries.append(.permissionEnable(theme, strings.Permissions_ContactsAllowInSettings_v0))
|
||||||
|
@ -61,8 +61,10 @@ extension ChatControllerImpl {
|
|||||||
|
|
||||||
var canSendPolls = true
|
var canSendPolls = true
|
||||||
if let peer = self.presentationInterfaceState.renderedPeer?.peer {
|
if let peer = self.presentationInterfaceState.renderedPeer?.peer {
|
||||||
if let peer = peer as? TelegramUser, peer.botInfo == nil {
|
if let peer = peer as? TelegramUser {
|
||||||
canSendPolls = false
|
if peer.botInfo == nil && peer.id != self.context.account.peerId {
|
||||||
|
canSendPolls = false
|
||||||
|
}
|
||||||
} else if peer is TelegramSecretChat {
|
} else if peer is TelegramSecretChat {
|
||||||
canSendPolls = false
|
canSendPolls = false
|
||||||
} else if let channel = peer as? TelegramChannel {
|
} else if let channel = peer as? TelegramChannel {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user