mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 23:18:27 +02:00
Feature/4393 poll with visible participant p1
This commit is contained in:
committed by
JanNiklas Grabowski
parent
b76b4e0803
commit
902b529245
@@ -124,6 +124,7 @@ class BWIBuildSettings: NSObject {
|
||||
var bwiUserLabelParticipantSorting = true
|
||||
|
||||
var bwiShowClosedPolls = true
|
||||
var bwiPollShowParticipantsToggle = true
|
||||
var bwiShowThreads = false
|
||||
|
||||
var bwiShowRoomCreationSectionFooter = false
|
||||
|
||||
2
Podfile
2
Podfile
@@ -43,7 +43,7 @@ when String # specific MatrixSDK released version
|
||||
$matrixSDKVersionSpec = $matrixSDKVersion
|
||||
end
|
||||
|
||||
$matrixSDKVersionSpec = { :git => 'https://dl-gitlab.example.com/bwmessenger/bundesmessenger/bundesmessenger-ios-sdk', :tag => 'v0.26.9_bwi_beta' }
|
||||
$matrixSDKVersionSpec = { :git => 'https://dl-gitlab.example.com/bwmessenger/bundesmessenger/bundesmessenger-ios-sdk', :tag => 'v0.26.9_bwi_beta_2' }
|
||||
|
||||
# Method to import the MatrixSDK
|
||||
def import_MatrixSDK
|
||||
|
||||
@@ -540,6 +540,7 @@
|
||||
"poll_edit_form_poll_type" = "Umfragetyp";
|
||||
"poll_edit_form_poll_type_closed" = "Versteckte Umfrage";
|
||||
"poll_edit_form_poll_type_open" = "Offene Umfrage";
|
||||
"poll_edit_form_participant_toggle" = "Anzeigen, wer für welche Option gestimmt hat.";
|
||||
|
||||
// MARK: - Welcome Experience
|
||||
"welcome_experience_title1" = "Willkommen beim BundesMessenger";
|
||||
|
||||
@@ -445,6 +445,7 @@
|
||||
"poll_edit_form_poll_type" = "Poll type";
|
||||
"poll_edit_form_poll_type_closed" = "Hidden Poll";
|
||||
"poll_edit_form_poll_type_open" = "Open poll";
|
||||
"poll_edit_form_participant_toggle" = "Show who voted for which option";
|
||||
|
||||
// MARK: - Welcome Experience
|
||||
"welcome_experience_title1" = "Welcome to BundesMessenger";
|
||||
|
||||
@@ -967,6 +967,10 @@ public class BWIL10n: NSObject {
|
||||
public static var pollEditFormCreatePoll: String {
|
||||
return BWIL10n.tr("Bwi", "poll_edit_form_create_poll")
|
||||
}
|
||||
/// Anzeigen, wer für welche Option gestimmt hat.
|
||||
public static var pollEditFormParticipantToggle: String {
|
||||
return BWIL10n.tr("Bwi", "poll_edit_form_participant_toggle")
|
||||
}
|
||||
/// Umfragetyp
|
||||
public static var pollEditFormPollType: String {
|
||||
return BWIL10n.tr("Bwi", "poll_edit_form_poll_type")
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ enum MockPollHistoryDetailScreenState: MockScreenState, CaseIterable {
|
||||
startDate: .init(timeIntervalSinceReferenceDate: 0),
|
||||
totalAnswerCount: 20,
|
||||
type: self == .closedDisclosed || self == .openDisclosed ? .disclosed : .undisclosed,
|
||||
showParticipants: false,
|
||||
eventType: self == .closedPollEnded ? .ended : .started,
|
||||
maxAllowedSelections: 1,
|
||||
hasBeenEdited: false,
|
||||
|
||||
@@ -57,6 +57,7 @@ private extension MockPollHistoryService {
|
||||
startDate: .init().addingTimeInterval(TimeInterval(-index) * 3600 * 24),
|
||||
totalAnswerCount: 30,
|
||||
type: .disclosed,
|
||||
showParticipants: false,
|
||||
eventType: .started,
|
||||
maxAllowedSelections: 1,
|
||||
hasBeenEdited: false,
|
||||
@@ -74,6 +75,7 @@ private extension MockPollHistoryService {
|
||||
startDate: .init().addingTimeInterval(TimeInterval(-index) * 3600 * 24),
|
||||
totalAnswerCount: 30,
|
||||
type: .disclosed,
|
||||
showParticipants: false,
|
||||
eventType: .started,
|
||||
maxAllowedSelections: 1,
|
||||
hasBeenEdited: false,
|
||||
|
||||
@@ -90,6 +90,7 @@ struct PollListItem_Previews: PreviewProvider {
|
||||
startDate: .init(),
|
||||
totalAnswerCount: 30,
|
||||
type: .disclosed,
|
||||
showParticipants: false,
|
||||
eventType: .started,
|
||||
maxAllowedSelections: 1,
|
||||
hasBeenEdited: false,
|
||||
@@ -102,6 +103,7 @@ struct PollListItem_Previews: PreviewProvider {
|
||||
startDate: .init(),
|
||||
totalAnswerCount: 30,
|
||||
type: .disclosed,
|
||||
showParticipants: false,
|
||||
eventType: .started,
|
||||
maxAllowedSelections: 1,
|
||||
hasBeenEdited: false,
|
||||
@@ -117,6 +119,7 @@ struct PollListItem_Previews: PreviewProvider {
|
||||
startDate: .init(),
|
||||
totalAnswerCount: 30,
|
||||
type: .disclosed,
|
||||
showParticipants: false,
|
||||
eventType: .started,
|
||||
maxAllowedSelections: 1,
|
||||
hasBeenEdited: false,
|
||||
|
||||
@@ -144,6 +144,7 @@ extension TimelinePollDetails {
|
||||
startDate: poll.startDate,
|
||||
totalAnswerCount: poll.totalAnswerCount,
|
||||
type: poll.kind.timelinePollType,
|
||||
showParticipants: poll.showParticipants,
|
||||
eventType: eventType,
|
||||
maxAllowedSelections: poll.maxAllowedSelections,
|
||||
hasBeenEdited: poll.hasBeenEdited,
|
||||
|
||||
@@ -21,6 +21,7 @@ typealias TimelinePollViewModelCallback = (TimelinePollViewModelResult) -> Void
|
||||
|
||||
enum TimelinePollViewAction {
|
||||
case selectAnswerOptionWithIdentifier(String)
|
||||
case showParticipants
|
||||
}
|
||||
|
||||
enum TimelinePollViewModelResult {
|
||||
@@ -69,6 +70,7 @@ struct TimelinePollDetails {
|
||||
var startDate: Date
|
||||
var totalAnswerCount: UInt
|
||||
var type: TimelinePollType
|
||||
var showParticipants: Bool
|
||||
var eventType: TimelinePollEventType
|
||||
var maxAllowedSelections: UInt
|
||||
var hasBeenEdited: Bool
|
||||
|
||||
@@ -40,6 +40,7 @@ enum MockTimelinePollScreenState: MockScreenState, CaseIterable {
|
||||
startDate: .init(),
|
||||
totalAnswerCount: 20,
|
||||
type: self == .closedDisclosed || self == .openDisclosed ? .disclosed : .undisclosed,
|
||||
showParticipants: false,
|
||||
eventType: self == .closedPollEnded ? .ended : .started,
|
||||
maxAllowedSelections: 1,
|
||||
hasBeenEdited: false,
|
||||
|
||||
@@ -49,6 +49,8 @@ class TimelinePollViewModel: TimelinePollViewModelType, TimelinePollViewModelPro
|
||||
} else {
|
||||
updateMultiSelectPollLocalState(&state, selectedAnswerIdentifier: identifier, callback: completion)
|
||||
}
|
||||
case .showParticipants:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -161,6 +161,7 @@ struct TimelinePollAnswerOptionButton_Previews: PreviewProvider {
|
||||
startDate: .init(),
|
||||
totalAnswerCount: 100,
|
||||
type: type,
|
||||
showParticipants: false,
|
||||
eventType: .started,
|
||||
maxAllowedSelections: 1,
|
||||
hasBeenEdited: false,
|
||||
|
||||
Reference in New Issue
Block a user