MESSENGER-4484 poi participants in history

This commit is contained in:
Frank Rotermund
2023-07-18 11:44:35 +00:00
parent b386e7c812
commit dc5198f5d9
11 changed files with 55 additions and 17 deletions

View File

@@ -126,6 +126,9 @@ class BWIBuildSettings: NSObject {
var bwiShowClosedPolls = true
var bwiPollShowParticipantsToggle = true
var bwiPollVisibleVotes = 5
var bwiPollParticipantsInHistory = true
var bwiShowThreads = false
var bwiShowRoomCreationSectionFooter = false

View File

@@ -21,7 +21,8 @@ import SwiftUI
/// Dark theme colors.
public class DarkColors {
private static let values = ColorValues(
accent: UIColor(rgb:0x0DBD8B),
// bwi: BUM accent color 108194
accent: UIColor(rgb:0x108194),
alert: UIColor(rgb:0xFF4B55),
primaryContent: UIColor(rgb:0xFFFFFF),
secondaryContent: UIColor(rgb:0xA9B2BC),

View File

@@ -22,7 +22,8 @@ import SwiftUI
/// Light theme colors.
public class LightColors {
private static let values = ColorValues(
accent: UIColor(rgb:0x0DBD8B),
// bwi: BUM accent color 108194
accent: UIColor(rgb:0x108194),
alert: UIColor(rgb:0xFF4B55),
primaryContent: UIColor(rgb:0x17191C),
secondaryContent: UIColor(rgb:0x737D8C),

View File

@@ -57,7 +57,7 @@ final class PollHistoryCoordinator: NSObject, Coordinator, Presentable {
func showPollDetail(_ poll: TimelinePollDetails) {
guard let event = parameters.room.mxSession.store.event(withEventId: poll.id, inRoom: parameters.room.roomId),
let detailCoordinator: PollHistoryDetailCoordinator = try? .init(parameters: .init(event: event, poll: poll, room: parameters.room)) else {
let detailCoordinator: PollHistoryDetailCoordinator = try? .init(parameters: .init(event: event, poll: poll, room: parameters.room, navigationRouter: navigationRouter)) else {
pollHistoryViewModel.context.alertInfo = .init(id: true, title: VectorL10n.settingsDiscoveryErrorMessage)
return
}
@@ -68,8 +68,20 @@ final class PollHistoryCoordinator: NSObject, Coordinator, Presentable {
}
add(childCoordinator: detailCoordinator)
detailCoordinator.start()
toPresentable().present(detailCoordinator.toPresentable(), animated: true)
// bwi #4484: Participant details need a navigation controller not a presented VC
if BWIBuildSettings.shared.bwiPollParticipantsInHistory {
if navigationRouter.modules.isEmpty == false {
navigationRouter.push(detailCoordinator, animated: true, popCompletion: nil)
} else {
navigationRouter.setRootModule(detailCoordinator, popCompletion: nil)
}
detailCoordinator.start()
} else {
detailCoordinator.start()
toPresentable().present(detailCoordinator.toPresentable(), animated: true)
}
}
func toPresentable() -> UIViewController {

View File

@@ -19,10 +19,12 @@ import CommonKit
import MatrixSDK
import SwiftUI
// bwi #4484: Poi history needs to pass a navigation router to show participants
struct PollHistoryDetailCoordinatorParameters {
let event: MXEvent
let poll: TimelinePollDetails
let room: MXRoom
let navigationRouter: NavigationRouterType
}
final class PollHistoryDetailCoordinator: Coordinator, Presentable {
@@ -36,7 +38,7 @@ final class PollHistoryDetailCoordinator: Coordinator, Presentable {
init(parameters: PollHistoryDetailCoordinatorParameters) throws {
self.parameters = parameters
let timelinePollCoordinator = try TimelinePollCoordinator(parameters: .init(session: parameters.room.mxSession, room: parameters.room, pollEvent: parameters.event))
let timelinePollCoordinator = try TimelinePollCoordinator(parameters: .init(session: parameters.room.mxSession, room: parameters.room, pollEvent: parameters.event, showParticipantButton: BWIBuildSettings.shared.bwiPollParticipantsInHistory), navigationRouter: parameters.navigationRouter)
let viewModel = PollHistoryDetailViewModel(poll: parameters.poll)
let view = PollHistoryDetail(viewModel: viewModel.context, contentPoll: timelinePollCoordinator.toView())

View File

@@ -26,8 +26,19 @@ struct PollHistoryDetail: View {
@ObservedObject var viewModel: PollHistoryDetailViewModel.Context
var contentPoll: any View
// bwi #4484: poi participants in history needs a pushed not presented view: Navigation title looks better this way in that case
var body: some View {
navigation
if BWIBuildSettings.shared.bwiPollParticipantsInHistory {
navigation
.accentColor(theme.colors.accent)
.navigationViewStyle(StackNavigationViewStyle())
.navigationTitle(navigationTitle)
.navigationBarTitleDisplayMode(.inline)
} else {
navigation
.accentColor(theme.colors.accent)
}
}
private var navigation: some View {
@@ -50,11 +61,17 @@ struct PollHistoryDetail: View {
.font(theme.fonts.caption1)
.padding([.top])
.accessibilityIdentifier("PollHistoryDetail.date")
AnyView(contentPoll)
.navigationTitle(navigationTitle)
.navigationBarTitleDisplayMode(.inline)
.navigationBarBackButtonHidden(true)
.navigationBarItems(leading: backButton, trailing: doneButton)
if BWIBuildSettings.shared.bwiPollParticipantsInHistory {
AnyView(contentPoll)
} else {
AnyView(contentPoll)
.navigationTitle(navigationTitle)
.navigationBarTitleDisplayMode(.inline)
.navigationBarBackButtonHidden(true)
.navigationBarItems(leading: backButton, trailing: doneButton)
}
viewInTimeline
}
}

View File

@@ -22,6 +22,7 @@ struct TimelinePollCoordinatorParameters {
let session: MXSession
let room: MXRoom
let pollEvent: MXEvent
let showParticipantButton: Bool
}
final class TimelinePollCoordinator: Coordinator, Presentable, PollAggregatorDelegate {
@@ -48,7 +49,7 @@ final class TimelinePollCoordinator: Coordinator, Presentable, PollAggregatorDel
self.parameters = parameters
self.navigationRouter = navigationRouter
viewModel = TimelinePollViewModel(timelinePollDetailsState: .loading)
viewModel = TimelinePollViewModel(timelinePollDetailsState: .loading, showParticipantsButton: parameters.showParticipantButton)
try pollAggregator = PollAggregator(session: parameters.session, room: parameters.room, pollEvent: parameters.pollEvent, delegate: self)
viewModel.completion = { [weak self] result in

View File

@@ -48,7 +48,7 @@ class TimelinePollProvider: NSObject {
return coordinator.toPresentable()
}
let parameters = TimelinePollCoordinatorParameters(session: session, room: room, pollEvent: event)
let parameters = TimelinePollCoordinatorParameters(session: session, room: room, pollEvent: event, showParticipantButton: true)
guard let coordinator = try? TimelinePollCoordinator(parameters: parameters, navigationRouter: navigationRouter ) else {
return messageViewController(for: event)
}

View File

@@ -115,6 +115,7 @@ struct TimelinePollViewState: BindableState {
struct TimelinePollViewStateBindings {
var alertInfo: AlertInfo<TimelinePollAlertType>?
var showParticipantButton: Bool
}
enum TimelinePollAlertType {

View File

@@ -30,8 +30,8 @@ class TimelinePollViewModel: TimelinePollViewModelType, TimelinePollViewModelPro
// MARK: - Setup
init(timelinePollDetailsState: TimelinePollDetailsState) {
super.init(initialViewState: TimelinePollViewState(pollState: timelinePollDetailsState, bindings: TimelinePollViewStateBindings()))
init(timelinePollDetailsState: TimelinePollDetailsState, showParticipantsButton: Bool = true) {
super.init(initialViewState: TimelinePollViewState(pollState: timelinePollDetailsState, bindings: TimelinePollViewStateBindings( showParticipantButton: showParticipantsButton)))
}
// MARK: - Public

View File

@@ -74,7 +74,7 @@ struct TimelinePollView: View {
.font(theme.fonts.footnote)
.foregroundColor(theme.colors.tertiaryContent)
if poll.shouldShowShowParticipantsButton {
if poll.shouldShowShowParticipantsButton && viewModel.viewState.bindings.showParticipantButton {
Button(action: {
viewModel.send(viewAction:.showParticipants)
})