Skip to content

Commit

Permalink
/issues/5114 - Small answer option count limit code tweak.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Jan 18, 2022
1 parent 469bf6d commit f1103d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ struct PollEditFormAnswerOption: Identifiable, Equatable {
}

struct PollEditFormViewState: BindableState {
var minAnswerOptionsCount: Int
var maxAnswerOptionsCount: Int
var mode: PollEditFormMode
var bindings: PollEditFormViewStateBindings

var confirmationButtonEnabled: Bool {
!bindings.question.text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty &&
bindings.answerOptions.filter({ !$0.text.isEmpty }).count >= 2
bindings.answerOptions.filter({ !$0.text.isEmpty }).count >= minAnswerOptionsCount
}

var addAnswerOptionButtonEnabled: Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ typealias PollEditFormViewModelType = StateStoreViewModel< PollEditFormViewState
class PollEditFormViewModel: PollEditFormViewModelType {

private struct Constants {
static let minAnswerOptionsCount = 2
static let maxAnswerOptionsCount = 20
static let maxQuestionLength = 340
static let maxAnswerOptionLength = 340
Expand All @@ -47,6 +48,7 @@ class PollEditFormViewModel: PollEditFormViewModelType {

init(parameters: PollEditFormViewModelParameters) {
let state = PollEditFormViewState(
minAnswerOptionsCount: Constants.minAnswerOptionsCount,
maxAnswerOptionsCount: Constants.maxAnswerOptionsCount,
mode: parameters.mode,
bindings: PollEditFormViewStateBindings(
Expand Down

0 comments on commit f1103d1

Please sign in to comment.