mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 00:52:43 +02:00
MESSENGER-3671 Merge FOSS 1.9.8
Conflicts: - CommonConfiguration.swift - BuildSettings.swift - Generated/images.Swift - RoomMemberDetailsViewController.m - LiveLocationSharingViewModell - PinCodeEnterViewController.m
This commit is contained in:
@@ -15,8 +15,8 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
struct PollEditFormCoordinatorParameters {
|
||||
let room: MXRoom
|
||||
@@ -24,7 +24,6 @@ struct PollEditFormCoordinatorParameters {
|
||||
}
|
||||
|
||||
final class PollEditFormCoordinator: Coordinator, Presentable {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
@@ -50,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 { $0.text })))
|
||||
answerOptions: pollContent.answerOptions.map(\.text))))
|
||||
|
||||
} else {
|
||||
viewModel = PollEditFormViewModel(parameters: PollEditFormViewModelParameters(mode: .creation, pollDetails: .default))
|
||||
@@ -63,6 +62,7 @@ final class PollEditFormCoordinator: Coordinator, Presentable {
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
func start() {
|
||||
pollEditFormViewModel.completion = { [weak self] result in
|
||||
guard let self = self else { return }
|
||||
@@ -75,7 +75,7 @@ final class PollEditFormCoordinator: Coordinator, Presentable {
|
||||
|
||||
self.pollEditFormViewModel.startLoading()
|
||||
|
||||
self.parameters.room.sendPollStart(withContent: pollStartContent, threadId: nil, localEcho: nil) { [weak self] result in
|
||||
self.parameters.room.sendPollStart(withContent: pollStartContent, threadId: nil, localEcho: nil) { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
|
||||
self.pollEditFormViewModel.stopLoading()
|
||||
@@ -103,7 +103,7 @@ final class PollEditFormCoordinator: Coordinator, Presentable {
|
||||
|
||||
self.parameters.room.sendPollUpdate(for: pollStartEvent,
|
||||
oldContent: oldPollContent,
|
||||
newContent: newPollContent, localEcho: nil) { [weak self] result in
|
||||
newContent: newPollContent, localEcho: nil) { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
|
||||
self.pollEditFormViewModel.stopLoading()
|
||||
@@ -113,7 +113,7 @@ final class PollEditFormCoordinator: Coordinator, Presentable {
|
||||
|
||||
MXLog.error("Failed updating poll", context: error)
|
||||
self.pollEditFormViewModel.stopLoading(errorAlertType: .failedUpdatingPoll)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ final class PollEditFormCoordinator: Coordinator, Presentable {
|
||||
// MARK: - Presentable
|
||||
|
||||
func toPresentable() -> UIViewController {
|
||||
return pollEditFormHostingController
|
||||
pollEditFormHostingController
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
@@ -136,21 +136,20 @@ final class PollEditFormCoordinator: Coordinator, Presentable {
|
||||
kind: Self.pollDetailsTypeToKindKey(details.type),
|
||||
maxSelections: NSNumber(value: details.maxSelections),
|
||||
answerOptions: options)
|
||||
|
||||
}
|
||||
|
||||
private static func pollDetailsTypeToKindKey(_ type: EditFormPollType) -> String {
|
||||
let mapping = [EditFormPollType.disclosed : kMXMessageContentKeyExtensiblePollKindDisclosedMSC3381,
|
||||
EditFormPollType.undisclosed : kMXMessageContentKeyExtensiblePollKindUndisclosedMSC3381]
|
||||
let mapping = [EditFormPollType.disclosed: kMXMessageContentKeyExtensiblePollKindDisclosedMSC3381,
|
||||
EditFormPollType.undisclosed: kMXMessageContentKeyExtensiblePollKindUndisclosedMSC3381]
|
||||
|
||||
return mapping[type] ?? kMXMessageContentKeyExtensiblePollKindDisclosedMSC3381
|
||||
}
|
||||
|
||||
private static func pollKindKeyToDetailsType(_ key: String) -> EditFormPollType {
|
||||
let mapping = [kMXMessageContentKeyExtensiblePollKindDisclosed : EditFormPollType.disclosed,
|
||||
kMXMessageContentKeyExtensiblePollKindDisclosedMSC3381 : EditFormPollType.disclosed,
|
||||
kMXMessageContentKeyExtensiblePollKindUndisclosed : EditFormPollType.undisclosed,
|
||||
kMXMessageContentKeyExtensiblePollKindUndisclosedMSC3381 : EditFormPollType.undisclosed]
|
||||
let mapping = [kMXMessageContentKeyExtensiblePollKindDisclosed: EditFormPollType.disclosed,
|
||||
kMXMessageContentKeyExtensiblePollKindDisclosedMSC3381: EditFormPollType.disclosed,
|
||||
kMXMessageContentKeyExtensiblePollKindUndisclosed: EditFormPollType.undisclosed,
|
||||
kMXMessageContentKeyExtensiblePollKindUndisclosedMSC3381: EditFormPollType.undisclosed]
|
||||
|
||||
return mapping[key] ?? EditFormPollType.disclosed
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -82,14 +82,14 @@ struct PollEditFormViewState: BindableState {
|
||||
|
||||
var confirmationButtonEnabled: Bool {
|
||||
!bindings.question.text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty &&
|
||||
bindings.answerOptions.filter({ !$0.text.isEmpty }).count >= minAnswerOptionsCount
|
||||
bindings.answerOptions.filter { !$0.text.isEmpty }.count >= minAnswerOptionsCount
|
||||
}
|
||||
|
||||
var addAnswerOptionButtonEnabled: Bool {
|
||||
bindings.answerOptions.count < maxAnswerOptionsCount
|
||||
}
|
||||
|
||||
var showLoadingIndicator: Bool = false
|
||||
var showLoadingIndicator = false
|
||||
}
|
||||
|
||||
struct PollEditFormViewStateBindings {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -24,7 +24,7 @@ enum MockPollEditFormScreenState: MockScreenState, CaseIterable {
|
||||
PollEditForm.self
|
||||
}
|
||||
|
||||
var screenView: ([Any], AnyView) {
|
||||
var screenView: ([Any], AnyView) {
|
||||
let viewModel = PollEditFormViewModel(parameters: PollEditFormViewModelParameters(mode: .creation, pollDetails: .default))
|
||||
return ([viewModel], AnyView(PollEditForm(viewModel: viewModel.context)))
|
||||
}
|
||||
|
||||
@@ -14,20 +14,18 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Combine
|
||||
import SwiftUI
|
||||
|
||||
struct PollEditFormViewModelParameters {
|
||||
let mode: PollEditFormMode
|
||||
let pollDetails: EditFormPollDetails
|
||||
}
|
||||
|
||||
typealias PollEditFormViewModelType = StateStoreViewModel <PollEditFormViewState,
|
||||
Never,
|
||||
PollEditFormViewAction>
|
||||
typealias PollEditFormViewModelType = StateStoreViewModel<PollEditFormViewState, PollEditFormViewAction>
|
||||
|
||||
class PollEditFormViewModel: PollEditFormViewModelType, PollEditFormViewModelProtocol {
|
||||
|
||||
private struct Constants {
|
||||
private enum Constants {
|
||||
static let minAnswerOptionsCount = 2
|
||||
static let maxAnswerOptionsCount = 20
|
||||
static let maxQuestionLength = 340
|
||||
@@ -102,11 +100,11 @@ class PollEditFormViewModel: PollEditFormViewModelType, PollEditFormViewModelPro
|
||||
// MARK: - Private
|
||||
|
||||
private func buildPollDetails() -> EditFormPollDetails {
|
||||
return 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
|
||||
}))
|
||||
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
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import RiotSwiftUI
|
||||
import XCTest
|
||||
|
||||
class PollEditFormUITests: MockScreenTestCase {
|
||||
func testInitialStateComponents() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import Combine
|
||||
import XCTest
|
||||
|
||||
@testable import RiotSwiftUI
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -17,7 +17,6 @@
|
||||
import SwiftUI
|
||||
|
||||
struct PollEditForm: View {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
@@ -33,7 +32,6 @@ struct PollEditForm: View {
|
||||
GeometryReader { proxy in
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 32.0) {
|
||||
|
||||
PollEditFormTypePicker(selectedType: $viewModel.type)
|
||||
|
||||
VStack(alignment: .leading, spacing: 16.0) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -17,7 +17,6 @@
|
||||
import SwiftUI
|
||||
|
||||
struct PollEditFormAnswerOptionView: View {
|
||||
|
||||
@Environment(\.theme) private var theme: ThemeSwiftUI
|
||||
|
||||
@State private var focused = false
|
||||
@@ -39,7 +38,7 @@ struct PollEditFormAnswerOptionView: View {
|
||||
})
|
||||
.textFieldStyle(BorderedInputFieldStyle(isEditing: focused))
|
||||
Button(action: onDelete) {
|
||||
Image(uiImage:Asset.Images.pollDeleteOptionIcon.image)
|
||||
Image(uiImage: Asset.Images.pollDeleteOptionIcon.image)
|
||||
}
|
||||
.accessibilityIdentifier("Delete answer option")
|
||||
}
|
||||
@@ -50,12 +49,8 @@ struct PollEditFormAnswerOptionView: View {
|
||||
struct PollEditFormAnswerOptionView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VStack(spacing: 32.0) {
|
||||
PollEditFormAnswerOptionView(text: Binding.constant(""), index: 0) {
|
||||
|
||||
}
|
||||
PollEditFormAnswerOptionView(text: Binding.constant("Test"), index: 5) {
|
||||
|
||||
}
|
||||
PollEditFormAnswerOptionView(text: Binding.constant(""), index: 0) { }
|
||||
PollEditFormAnswerOptionView(text: Binding.constant("Test"), index: 5) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -45,7 +45,6 @@ private struct PollEditFormTypeButton: View {
|
||||
selectedType = type
|
||||
} label: {
|
||||
HStack(alignment: .top, spacing: 8.0) {
|
||||
|
||||
Image(uiImage: selectionImage)
|
||||
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
|
||||
Reference in New Issue
Block a user