diff --git a/iosApp/Survey.xcodeproj/project.pbxproj b/iosApp/Survey.xcodeproj/project.pbxproj index 9a393103..0d8a51ec 100644 --- a/iosApp/Survey.xcodeproj/project.pbxproj +++ b/iosApp/Survey.xcodeproj/project.pbxproj @@ -131,6 +131,7 @@ 09E08C5A2990EB4B00CC765C /* CollectionSafeSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09E08C582990EB3800CC765C /* CollectionSafeSpec.swift */; }; 09E08C5C2990F8B600CC765C /* QuestionRangePickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09E08C5B2990F8B600CC765C /* QuestionRangePickerView.swift */; }; 09E08C45298B7DD500CC765C /* QuestionMultiChoiceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09E08C44298B7DD500CC765C /* QuestionMultiChoiceView.swift */; }; + 09E08C47298B89F400CC765C /* QuestionMultiFormView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09E08C46298B89F400CC765C /* QuestionMultiFormView.swift */; }; 09E6ABF32951D105007F1EE3 /* KIF+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09E6ABF12951D103007F1EE3 /* KIF+Swift.swift */; }; 09E6ABFD2951D32F007F1EE3 /* ViewId.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09636B1428D8148C00A5CB97 /* ViewId.swift */; }; 09E6ABFE2951D333007F1EE3 /* ViewId+General.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09636B2F28D8267D00A5CB97 /* ViewId+General.swift */; }; @@ -329,6 +330,7 @@ 09E08C582990EB3800CC765C /* CollectionSafeSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionSafeSpec.swift; sourceTree = ""; }; 09E08C5B2990F8B600CC765C /* QuestionRangePickerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QuestionRangePickerView.swift; sourceTree = ""; }; 09E08C44298B7DD500CC765C /* QuestionMultiChoiceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuestionMultiChoiceView.swift; sourceTree = ""; }; + 09E08C46298B89F400CC765C /* QuestionMultiFormView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuestionMultiFormView.swift; sourceTree = ""; }; 09E6ABE42951CF3E007F1EE3 /* SurveyKIFUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SurveyKIFUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 09E6ABF12951D103007F1EE3 /* KIF+Swift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "KIF+Swift.swift"; sourceTree = ""; }; 09E6AC0B2951D5DD007F1EE3 /* AccountSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSpec.swift; sourceTree = ""; }; @@ -916,6 +918,7 @@ 09E08C4A298CB0BD00CC765C /* QuestionEmojiView.swift */, 09E08C5B2990F8B600CC765C /* QuestionRangePickerView.swift */, 09E08C44298B7DD500CC765C /* QuestionMultiChoiceView.swift */, + 09E08C46298B89F400CC765C /* QuestionMultiFormView.swift */, ); path = SurveyQuestion; sourceTree = ""; @@ -1921,6 +1924,7 @@ 09CE771328E1A94600EAA9EE /* ResetPasswordView.swift in Sources */, 09FE26CD294B1EE3005A7F85 /* SurveySelectionView+DataSource.swift in Sources */, 09D09DCA29682810009F88AF /* Constants+Animation.swift in Sources */, + 09E08C47298B89F400CC765C /* QuestionMultiFormView.swift in Sources */, 09636B3028D8267D00A5CB97 /* ViewId+General.swift in Sources */, 09636B0228D4876100A5CB97 /* PrimaryButton.swift in Sources */, 09CE770C28E191B400EAA9EE /* AppCoordinator.swift in Sources */, diff --git a/iosApp/Survey/Sources/Presentation/Modules/SurveyDetail/SurveyQuestion/QuestionMultiFormView.swift b/iosApp/Survey/Sources/Presentation/Modules/SurveyDetail/SurveyQuestion/QuestionMultiFormView.swift new file mode 100644 index 00000000..04afbf5f --- /dev/null +++ b/iosApp/Survey/Sources/Presentation/Modules/SurveyDetail/SurveyQuestion/QuestionMultiFormView.swift @@ -0,0 +1,43 @@ +// +// QuestionMultiFormView.swift +// Survey +// +// Created by Bliss on 2/2/23. +// Copyright © 2023 Nimble. All rights reserved. +// + +import SwiftUI + +struct QuestionMultiFormView: View { + + struct MultiFormAnswer { + + let question: Answer + var input: String = "" + } + + @State var multiFormAnswers = [MultiFormAnswer]() + + var body: some View { + VStack(spacing: .lineSpacing) { + ForEach( + Array(multiFormAnswers.enumerated()), + id: \.element.question.id + ) { index, answer in + TextField( + answer.question.text, + text: $multiFormAnswers[index].input + ) + .primaryTextField() + } + } + } + + init(answers: [Answer]) { + _multiFormAnswers = .init( + initialValue: answers.map { + MultiFormAnswer(question: $0) + } + ) + } +} diff --git a/iosApp/Survey/Sources/Presentation/Modules/SurveyDetail/SurveyQuestion/SurveyQuestionView.swift b/iosApp/Survey/Sources/Presentation/Modules/SurveyDetail/SurveyQuestion/SurveyQuestionView.swift index 8ebfac53..a6d4dd43 100644 --- a/iosApp/Survey/Sources/Presentation/Modules/SurveyDetail/SurveyQuestion/SurveyQuestionView.swift +++ b/iosApp/Survey/Sources/Presentation/Modules/SurveyDetail/SurveyQuestion/SurveyQuestionView.swift @@ -58,6 +58,8 @@ struct SurveyQuestionView: View { ) case .choice: QuestionMultiChoiceView(options: question.answers) + case .textfield: + QuestionMultiFormView(answers: question.answers) default: QuestionPickerView(options: []) }