mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 00:52:43 +02:00
Feature/4393 poll with visible participant p1
This commit is contained in:
committed by
JanNiklas Grabowski
parent
b76b4e0803
commit
902b529245
@@ -49,7 +49,7 @@ final class PollEditFormCoordinator: Coordinator, Presentable {
|
||||
viewModel = PollEditFormViewModel(parameters: PollEditFormViewModelParameters(mode: .editing,
|
||||
pollDetails: EditFormPollDetails(type: Self.pollKindKeyToDetailsType(pollContent.kind),
|
||||
question: pollContent.question,
|
||||
answerOptions: pollContent.answerOptions.map(\.text))))
|
||||
answerOptions: pollContent.answerOptions.map(\.text), showParticipants: pollContent.showParticipants)))
|
||||
|
||||
} else {
|
||||
viewModel = PollEditFormViewModel(parameters: PollEditFormViewModelParameters(mode: .creation, pollDetails: .default))
|
||||
@@ -134,6 +134,7 @@ final class PollEditFormCoordinator: Coordinator, Presentable {
|
||||
|
||||
return MXEventContentPollStart(question: details.question,
|
||||
kind: Self.pollDetailsTypeToKindKey(details.type),
|
||||
showParticipants: details.showParticipants,
|
||||
maxSelections: NSNumber(value: details.maxSelections),
|
||||
answerOptions: options)
|
||||
}
|
||||
|
||||
@@ -27,9 +27,10 @@ struct EditFormPollDetails {
|
||||
let question: String
|
||||
let answerOptions: [String]
|
||||
let maxSelections: UInt = 1
|
||||
let showParticipants: Bool
|
||||
|
||||
static var `default`: EditFormPollDetails {
|
||||
EditFormPollDetails(type: .disclosed, question: "", answerOptions: ["", ""])
|
||||
EditFormPollDetails(type: .disclosed, question: "", answerOptions: ["", ""], showParticipants: false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +97,7 @@ struct PollEditFormViewStateBindings {
|
||||
var question: PollEditFormQuestion
|
||||
var answerOptions: [PollEditFormAnswerOption]
|
||||
var type: EditFormPollType
|
||||
var showParticipants: Bool
|
||||
|
||||
var alertInfo: PollEditFormErrorAlertInfo?
|
||||
}
|
||||
|
||||
@@ -50,7 +50,8 @@ class PollEditFormViewModel: PollEditFormViewModelType, PollEditFormViewModelPro
|
||||
bindings: PollEditFormViewStateBindings(
|
||||
question: PollEditFormQuestion(text: parameters.pollDetails.question, maxLength: Constants.maxQuestionLength),
|
||||
answerOptions: parameters.pollDetails.answerOptions.map { PollEditFormAnswerOption(text: $0, maxLength: Constants.maxAnswerOptionLength) },
|
||||
type: parameters.pollDetails.type
|
||||
type: parameters.pollDetails.type,
|
||||
showParticipants: parameters.pollDetails.showParticipants
|
||||
)
|
||||
)
|
||||
|
||||
@@ -100,11 +101,13 @@ class PollEditFormViewModel: PollEditFormViewModelType, PollEditFormViewModelPro
|
||||
// MARK: - Private
|
||||
|
||||
private func buildPollDetails() -> EditFormPollDetails {
|
||||
|
||||
EditFormPollDetails(type: state.bindings.type,
|
||||
question: state.bindings.question.text.trimmingCharacters(in: .whitespacesAndNewlines),
|
||||
answerOptions: state.bindings.answerOptions.compactMap { answerOption in
|
||||
let text = answerOption.text.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
return text.isEmpty ? nil : text
|
||||
})
|
||||
},
|
||||
showParticipants: state.bindings.showParticipants)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,11 @@ struct PollEditForm: View {
|
||||
VStack(alignment: .leading, spacing: 32.0) {
|
||||
PollEditFormTypePicker(selectedType: $viewModel.type)
|
||||
|
||||
// bwi (#4483) Adds a boolean shoparticpants to the view models, the event and the view
|
||||
if BWIBuildSettings.shared.bwiPollShowParticipantsToggle {
|
||||
PollEditFormParticipationToggle(showParticipants: $viewModel.showParticipants)
|
||||
}
|
||||
|
||||
VStack(alignment: .leading, spacing: 16.0) {
|
||||
Text(VectorL10n.pollEditFormPollQuestionOrTopic)
|
||||
.font(theme.fonts.title3SB)
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
/*
|
||||
* Copyright (c) 2022 BWI GmbH
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct PollEditFormParticipationToggle: View {
|
||||
@Environment(\.theme) private var theme: ThemeSwiftUI
|
||||
|
||||
@Binding var showParticipants: Bool
|
||||
|
||||
var body: some View {
|
||||
Toggle(BWIL10n.pollEditFormParticipantToggle, isOn: $showParticipants)
|
||||
.accessibilityIdentifier("PollEditFormParticipationToggle")
|
||||
}
|
||||
}
|
||||
|
||||
struct PollEditFormParticipationToggle_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
PollEditFormParticipationToggle(showParticipants: .constant(true))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user