Various fixes

This commit is contained in:
Ilya Laktyushin
2024-09-26 15:18:34 +04:00
parent a30ab38ce4
commit 072c6bc3c4
11 changed files with 170 additions and 59 deletions

View File

@@ -438,6 +438,8 @@ final class GiftSetupScreenComponent: Component {
contentHeight += environment.navigationHeight
contentHeight += 26.0
let giftConfiguration = GiftConfiguration.with(appConfiguration: component.context.currentAppConfiguration.with { $0 })
var introSectionItems: [AnyComponentWithIdentity<Empty>] = []
introSectionItems.append(AnyComponentWithIdentity(id: introSectionItems.count, component: AnyComponent(Rectangle(color: .clear, height: 346.0, tag: self.introPlaceholderTag))))
@@ -451,10 +453,10 @@ final class GiftSetupScreenComponent: Component {
return ListMultilineTextFieldItemComponent.ResetText(value: $0)
},
placeholder: "Enter Message",
autocapitalizationType: .none,
autocorrectionType: .no,
autocapitalizationType: .sentences,
autocorrectionType: .yes,
returnKeyType: .done,
characterLimit: 255,
characterLimit: Int(giftConfiguration.maxCaptionLength),
displayCharacterLimit: true,
emptyLineHandling: .notAllowed,
formatMenuAvailability: .available([.bold, .italic, .underline, .strikethrough, .spoiler]),
@@ -1062,3 +1064,27 @@ public final class GiftSetupScreen: ViewControllerComponentContainer {
super.containerLayoutUpdated(layout, transition: transition)
}
}
private struct GiftConfiguration {
static var defaultValue: GiftConfiguration {
return GiftConfiguration(maxCaptionLength: 255)
}
let maxCaptionLength: Int32
fileprivate init(maxCaptionLength: Int32) {
self.maxCaptionLength = maxCaptionLength
}
static func with(appConfiguration: AppConfiguration) -> GiftConfiguration {
if let data = appConfiguration.data {
var maxCaptionLength: Int32?
if let value = data["stargifts_message_length_max"] as? Double {
maxCaptionLength = Int32(value)
}
return GiftConfiguration(maxCaptionLength: maxCaptionLength ?? GiftConfiguration.defaultValue.maxCaptionLength)
} else {
return .defaultValue
}
}
}