-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...rvey/Sources/Presentation/Modules/SurveyDetail/SurveyQuestion/QuestionMultiFormView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters