mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-26 03:20:50 +02:00
d07184c687
* commit 'ee6e5de4358a2c0a2705194cd954f9207ff772cf': finish version++ version++ Fix a bug where QR codes aren't detected if the camera is too close. (#7762) element-hq/element-meta/issues/2201 - Disable mark as unread - relates to element-hq/element-meta/issues/891 - relates to element-hq/element-ios/issues/7253 Fix dictation when using the Rich Text Editor. (#7752) Prepare for new sprint finish version++ version++ changelog.d: Upgrade MatrixSDK version ([v0.27.6](https://github.com/matrix-org/matrix-ios-sdk/releases/tag/v0.27.6)). corrected translations Added translation using Weblate (Persian (Old)) Translated using Weblate (Albanian) Translated using Weblate (Chinese (Simplified)) Translated using Weblate (Chinese (Simplified)) Translated using Weblate (Albanian) changelog fix Prepare for new sprint GH actions: remove triaging process and old GH projects # Conflicts: # Config/AppVersion.xcconfig # Riot/Modules/ContextMenu/ActionProviders/RoomActionProvider.swift
186 lines
6.9 KiB
Swift
186 lines
6.9 KiB
Swift
//
|
|
// Copyright 2022 New Vector Ltd
|
|
//
|
|
// 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 UIKit
|
|
|
|
/// `RoomActionProvider` provides the menu for `MXRoom` instances
|
|
@available(iOS 13.0, *)
|
|
class RoomActionProvider: RoomActionProviderProtocol {
|
|
|
|
// MARK: - Properties
|
|
|
|
private let service: RoomContextActionService
|
|
|
|
// MARK: - Setup
|
|
|
|
init(service: RoomContextActionService) {
|
|
self.service = service
|
|
}
|
|
|
|
// MARK: - RoomActionProviderProtocol
|
|
|
|
var menu: UIMenu {
|
|
if service.isRoomJoined {
|
|
// bwi use our set of actions
|
|
if BWIBuildSettings.shared.bwiFilteredContextMenu {
|
|
if service.roomId == PersonalNotesDefaultService(mxSession: service.session).personalNotesRoomId() {
|
|
return UIMenu(children: [
|
|
self.hidePersonalNotesAction
|
|
])
|
|
} else {
|
|
return UIMenu(children: [
|
|
self.notificationsAction,
|
|
self.favouriteAction,
|
|
self.leaveAction
|
|
])
|
|
}
|
|
} else {
|
|
var children = service.hasUnread ? [self.markAsReadAction] : []
|
|
children.append(contentsOf: [
|
|
self.directChatAction,
|
|
self.notificationsAction,
|
|
self.favouriteAction,
|
|
self.lowPriorityAction,
|
|
self.leaveAction
|
|
])
|
|
return UIMenu(children: children)
|
|
}
|
|
} else {
|
|
if service.roomMembership == .invite {
|
|
return UIMenu(children: [
|
|
self.acceptInviteAction,
|
|
self.declineInviteAction
|
|
])
|
|
} else {
|
|
return UIMenu(children: [
|
|
self.joinAction
|
|
])
|
|
}
|
|
}
|
|
}
|
|
|
|
// MARK: - Private
|
|
|
|
private var directChatAction: UIAction {
|
|
return UIAction(
|
|
title: service.isRoomDirect ? VectorL10n.homeContextMenuMakeRoom : VectorL10n.homeContextMenuMakeDm,
|
|
image: UIImage(systemName: service.isRoomDirect ? "person.crop.circle.badge.xmark" : "person.circle")) { [weak self] action in
|
|
guard let self = self else { return }
|
|
self.service.isRoomDirect = !self.service.isRoomDirect
|
|
}
|
|
}
|
|
|
|
private var notificationsAction: UIAction {
|
|
let notificationsImage: UIImage?
|
|
let notificationsTitle: String
|
|
if BuildSettings.showNotificationsV2 {
|
|
notificationsTitle = VectorL10n.homeContextMenuNotifications
|
|
notificationsImage = UIImage(systemName: "bell")
|
|
} else {
|
|
notificationsTitle = service.isRoomMuted ? VectorL10n.homeContextMenuUnmute : VectorL10n.homeContextMenuMute
|
|
notificationsImage = UIImage(systemName: service.isRoomMuted ? "bell.slash": "bell")
|
|
}
|
|
|
|
return UIAction(
|
|
title: notificationsTitle,
|
|
image: notificationsImage) { [weak self] action in
|
|
guard let self = self else { return }
|
|
self.service.isRoomMuted = !self.service.isRoomMuted
|
|
}
|
|
}
|
|
|
|
private var favouriteAction: UIAction {
|
|
return UIAction(
|
|
title: self.service.isRoomFavourite ? VectorL10n.homeContextMenuUnfavourite : VectorL10n.homeContextMenuFavourite,
|
|
image: UIImage(systemName: self.service.isRoomFavourite ? "star.slash" : "star")) { [weak self] action in
|
|
guard let self = self else { return }
|
|
self.service.isRoomFavourite = !self.service.isRoomFavourite
|
|
}
|
|
}
|
|
|
|
// bwi #4802
|
|
private var hidePersonalNotesAction: UIAction {
|
|
return UIAction(
|
|
title: BWIL10n.homeContextMenuPersonalNotes,
|
|
image: UIImage(systemName: "star.slash")) { _ in
|
|
PersonalNotesSettings().personalNotesVisible = false
|
|
NotificationCenter.default.post(name: AllChatsLayoutSettingsManager.didUpdateSettings, object: self)
|
|
}
|
|
}
|
|
|
|
private var lowPriorityAction: UIAction {
|
|
return UIAction(
|
|
title: self.service.isRoomLowPriority ? VectorL10n.homeContextMenuNormalPriority : VectorL10n.homeContextMenuLowPriority,
|
|
image: UIImage(systemName: self.service.isRoomLowPriority ? "arrow.up" : "arrow.down")) { [weak self] action in
|
|
guard let self = self else { return }
|
|
self.service.isRoomLowPriority = !self.service.isRoomLowPriority
|
|
}
|
|
}
|
|
|
|
private var markAsReadAction: UIAction {
|
|
return UIAction(
|
|
title: VectorL10n.homeContextMenuMarkAsRead,
|
|
image: UIImage(systemName: "envelope.open")) { [weak self] action in
|
|
guard let self = self else { return }
|
|
self.service.markAsRead()
|
|
}
|
|
}
|
|
private var markAsUnreadAction: UIAction {
|
|
return UIAction(
|
|
title: VectorL10n.homeContextMenuMarkAsUnread,
|
|
image: UIImage(systemName: "envelope.badge")) { [weak self] action in
|
|
guard let self = self else { return }
|
|
self.service.markAsUnread()
|
|
}
|
|
}
|
|
|
|
private var leaveAction: UIAction {
|
|
let image = UIImage(systemName: "rectangle.righthalf.inset.fill.arrow.right")
|
|
let action = UIAction(title: VectorL10n.homeContextMenuLeave, image: image) { [weak self] action in
|
|
guard let self = self else { return }
|
|
self.service.leaveRoom(promptUser: true)
|
|
}
|
|
action.attributes = .destructive
|
|
return action
|
|
}
|
|
|
|
private var acceptInviteAction: UIAction {
|
|
return UIAction(
|
|
title: VectorL10n.accept) { [weak self] action in
|
|
guard let self = self else { return }
|
|
self.service.joinRoom()
|
|
}
|
|
}
|
|
|
|
private var declineInviteAction: UIAction {
|
|
let action = UIAction(
|
|
title: VectorL10n.decline) { [weak self] action in
|
|
guard let self = self else { return }
|
|
self.service.leaveRoom(promptUser: false)
|
|
}
|
|
action.attributes = .destructive
|
|
return action
|
|
}
|
|
|
|
private var joinAction: UIAction {
|
|
return UIAction(
|
|
title: BWIL10n.join) { [weak self] action in
|
|
guard let self = self else { return }
|
|
self.service.joinRoom()
|
|
}
|
|
}
|
|
}
|