Various fixes

This commit is contained in:
Ilya Laktyushin
2024-09-03 15:48:15 +04:00
parent 32e6629538
commit d2deea0ea2
26 changed files with 528 additions and 268 deletions

View File

@@ -488,6 +488,8 @@ final class ComposePollScreenComponent: Component {
self.environment = environment
if self.component == nil {
self.isQuiz = component.isQuiz ?? false
self.pollOptions.append(ComposePollScreenComponent.PollOption(
id: self.nextPollOptionId
))
@@ -1002,28 +1004,35 @@ final class ComposePollScreenComponent: Component {
contentHeight += pollOptionsSectionFooterSize.height
contentHeight += sectionSpacing
var canBePublic = true
if case let .channel(channel) = component.peer, case .broadcast = channel.info {
canBePublic = false
}
var pollSettingsSectionItems: [AnyComponentWithIdentity<Empty>] = []
pollSettingsSectionItems.append(AnyComponentWithIdentity(id: "anonymous", component: AnyComponent(ListActionItemComponent(
theme: environment.theme,
title: AnyComponent(VStack([
AnyComponentWithIdentity(id: AnyHashable(0), component: AnyComponent(MultilineTextComponent(
text: .plain(NSAttributedString(
string: environment.strings.CreatePoll_Anonymous,
font: Font.regular(presentationData.listsFontSize.baseDisplaySize),
textColor: environment.theme.list.itemPrimaryTextColor
)),
maximumNumberOfLines: 1
))),
], alignment: .left, spacing: 2.0)),
accessory: .toggle(ListActionItemComponent.Toggle(style: .regular, isOn: self.isAnonymous, action: { [weak self] _ in
guard let self else {
return
}
self.isAnonymous = !self.isAnonymous
self.state?.updated(transition: .spring(duration: 0.4))
})),
action: nil
))))
if canBePublic {
pollSettingsSectionItems.append(AnyComponentWithIdentity(id: "anonymous", component: AnyComponent(ListActionItemComponent(
theme: environment.theme,
title: AnyComponent(VStack([
AnyComponentWithIdentity(id: AnyHashable(0), component: AnyComponent(MultilineTextComponent(
text: .plain(NSAttributedString(
string: environment.strings.CreatePoll_Anonymous,
font: Font.regular(presentationData.listsFontSize.baseDisplaySize),
textColor: environment.theme.list.itemPrimaryTextColor
)),
maximumNumberOfLines: 1
))),
], alignment: .left, spacing: 2.0)),
accessory: .toggle(ListActionItemComponent.Toggle(style: .regular, isOn: self.isAnonymous, action: { [weak self] _ in
guard let self else {
return
}
self.isAnonymous = !self.isAnonymous
self.state?.updated(transition: .spring(duration: 0.4))
})),
action: nil
))))
}
pollSettingsSectionItems.append(AnyComponentWithIdentity(id: "multiAnswer", component: AnyComponent(ListActionItemComponent(
theme: environment.theme,
title: AnyComponent(VStack([
@@ -1569,7 +1578,7 @@ public class ComposePollScreen: ViewControllerComponentContainer, AttachmentCont
public static func initialData(context: AccountContext) -> InitialData {
return InitialData(
maxPollTextLength: Int(255),
maxPollTextLength: Int(200),
maxPollOptionLength: 100
)
}

View File

@@ -134,7 +134,7 @@ private struct OrderedLinkedList<T: Equatable>: Sequence, Equatable {
}
}
private let maxTextLength = 255
private let maxTextLength = 200
private let maxOptionLength = 100
private let maxOptionCount = 10