MESSENGER-2762 Initial Merge

This commit is contained in:
Frank Rotermund
2022-03-17 15:51:23 +01:00
parent ecae8d618f
commit c2108a2178
384 changed files with 17708 additions and 1928 deletions

View File

@@ -2,6 +2,7 @@
// $ createScreen.sh Room2/RoomInfo RoomInfoList
/*
Copyright 2020 New Vector Ltd
Copyright (c) 2021 BWI GmbH
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -58,8 +59,9 @@ final class RoomInfoListViewController: UIViewController {
}()
private lazy var leaveAlertController: UIAlertController = {
let title = self.isRoomDirect ? VectorL10n.roomParticipantsLeavePromptTitleForDm : VectorL10n.roomParticipantsLeavePromptTitle
let message = self.isRoomDirect ? VectorL10n.roomParticipantsLeavePromptMsgForDm : VectorL10n.roomParticipantsLeavePromptMsg
var title = self.isRoomDirect ? VectorL10n.roomParticipantsLeavePromptTitleForDm : VectorL10n.roomParticipantsLeavePromptTitle
var message = self.isRoomDirect ? VectorL10n.roomParticipantsLeavePromptMsgForDm : VectorL10n.roomParticipantsLeavePromptMsg
let controller = UIAlertController(title: title, message: message, preferredStyle: .alert)
controller.addAction(UIAlertAction(title: VectorL10n.cancel, style: .cancel, handler: nil))
@@ -72,6 +74,26 @@ final class RoomInfoListViewController: UIViewController {
return controller
}()
private func getLeaveAlertController() -> UIAlertController {
if self.viewModel.canLeaveRoom() {
let title = self.isRoomDirect ? VectorL10n.roomParticipantsLeavePromptTitleForDm : VectorL10n.roomParticipantsLeavePromptTitle
let message = self.isRoomDirect ? VectorL10n.roomParticipantsLeavePromptMsgForDm : VectorL10n.roomParticipantsLeavePromptMsg
let controller = UIAlertController(title: title, message: message, preferredStyle: .alert)
controller.addAction(UIAlertAction(title: VectorL10n.cancel, style: .cancel, handler: nil))
controller.addAction(UIAlertAction(title: VectorL10n.leave, style: .default, handler: { [weak self] (action) in
guard let self = self else { return }
self.viewModel.process(viewAction: .leave)
}))
controller.mxk_setAccessibilityIdentifier("RoomSettingsVCLeaveAlert")
return controller
} else {
return self.doNotLeaveUIAlertController()
}
}
private enum RowType {
case `default`
case destructive
@@ -155,12 +177,20 @@ final class RoomInfoListViewController: UIViewController {
private func updateSections(with viewData: RoomInfoListViewData) {
basicInfoView.configure(withViewData: viewData.basicInfoViewData)
guard !viewModel.isPersonalNotesRoom() else {
self.updateSectionsAsPersonalNote(with: viewData)
return
}
var tmpSections: [Section] = []
let rowSettings = Row(type: .default, icon: Asset.Images.settingsIcon.image, text: VectorL10n.roomDetailsSettings, accessoryType: .disclosureIndicator) {
self.viewModel.process(viewAction: .navigate(target: .settings()))
}
let rowRollsAndRights = Row(type: .default, icon: Asset.Images.rollsAndRights.image, text: VectorL10n.bwiRollsAndRights, accessoryType: .disclosureIndicator) {
self.viewModel.process(viewAction: .navigate(target: .rollsAndRights))
}
let roomNotifications = Row(type: .default, icon: Asset.Images.notifications.image, text: VectorL10n.roomDetailsNotifs, accessoryType: .disclosureIndicator) {
self.viewModel.process(viewAction: .navigate(target: .notifications))
}
@@ -174,12 +204,16 @@ final class RoomInfoListViewController: UIViewController {
let rowSearch = Row(type: .default, icon: Asset.Images.searchIcon.image, text: VectorL10n.roomDetailsSearch, accessoryType: .disclosureIndicator) {
self.viewModel.process(viewAction: .navigate(target: .search))
}
let rowIntegrations = Row(type: .default, icon: Asset.Images.integrationsIcon.image, text: VectorL10n.roomDetailsIntegrations, accessoryType: .disclosureIndicator) {
self.viewModel.process(viewAction: .navigate(target: .integrations))
}
var rows = [rowSettings]
if BuildSettings.bwiRollsAndRights && !(viewModel.isPersonalNotesRoom() || viewModel.isDirectRoom()) {
rows.append(rowRollsAndRights)
}
if BuildSettings.showNotificationsV2 {
rows.append(roomNotifications)
}
@@ -198,7 +232,11 @@ final class RoomInfoListViewController: UIViewController {
VectorL10n.roomParticipantsLeavePromptTitleForDm :
VectorL10n.roomParticipantsLeavePromptTitle
let rowLeave = Row(type: .destructive, icon: Asset.Images.roomActionLeave.image, text: leaveTitle, accessoryType: .none) {
self.present(self.leaveAlertController, animated: true, completion: nil)
if BuildSettings.lastAdminIsNotAllowedToLeaveRoom {
self.present(self.getLeaveAlertController(), animated: true, completion: nil)
} else {
self.present(self.leaveAlertController, animated: true, completion: nil)
}
}
let sectionLeave = Section(header: nil,
rows: [rowLeave],
@@ -275,6 +313,18 @@ final class RoomInfoListViewController: UIViewController {
self.errorPresenter.presentError(from: self, forError: error, animated: true, handler: nil)
}
private func doNotLeaveUIAlertController() -> UIAlertController {
let title = VectorL10n.roomParticipantsLeavePromptTitle
let message = NSLocalizedString("room_participants_cant_leave_prompt_message", tableName: "Vector", comment: "")
let controller = UIAlertController(title: title, message: message, preferredStyle: .alert)
controller.addAction(UIAlertAction(title: VectorL10n.cancel, style: .cancel, handler: nil))
controller.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
controller.mxk_setAccessibilityIdentifier("RoomSettingsVCLeaveAlert")
return controller
}
// MARK: - Actions
@objc private func closeButtonTapped(_ sender: Any) {
@@ -363,7 +413,7 @@ extension RoomInfoListViewController: UITableViewDelegate {
let view: TextViewTableViewHeaderFooterView? = tableView.dequeueReusableHeaderFooterView()
view?.textView.text = header
view?.textView.font = .systemFont(ofSize: 13)
view?.textView.font = .boldSystemFont(ofSize: 15)
view?.textViewInsets = UIEdgeInsets(top: 16, left: 16, bottom: 8, right: 16)
view?.update(theme: theme)
@@ -416,3 +466,40 @@ extension RoomInfoListViewController: RoomInfoListViewModelViewDelegate {
}
}
// MARK: - Extention for Personal Notes room
extension RoomInfoListViewController {
func updateSectionsAsPersonalNote(with viewData: RoomInfoListViewData) {
var tmpSections: [Section] = []
let rowSettings = Row(type: .default, icon: Asset.Images.settingsIcon.image, text: VectorL10n.roomDetailsSettings, accessoryType: .disclosureIndicator) {
self.viewModel.process(viewAction: .navigate(target: .settings()))
}
let rowUploads = Row(type: .default, icon: Asset.Images.scrollup.image, text: VectorL10n.roomDetailsFiles, accessoryType: .disclosureIndicator) {
self.viewModel.process(viewAction: .navigate(target: .uploads))
}
var rows = [rowSettings]
rows.append(rowUploads)
if BuildSettings.bwiPersonalNotesRoomLeavable {
let leaveTitle = VectorL10n.roomParticipantsLeavePromptTitle
let rowLeave = Row(type: .destructive, icon: Asset.Images.roomActionLeave.image, text: leaveTitle, accessoryType: .none) {
self.present(self.leaveAlertController, animated: true, completion: nil)
}
rows.append(rowLeave)
}
let sectionSettings = Section(header: VectorL10n.roomInfoListSectionOther,
rows: rows,
footer: nil)
tmpSections.append(sectionSettings)
sections = tmpSections
}
}