Merge branch 'develop' into ismail/5068_start_thread

This commit is contained in:
ismailgulek
2021-12-09 15:25:14 +03:00
765 changed files with 94930 additions and 1211 deletions
@@ -1,23 +1,27 @@
/*
Copyright 2021 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.
*/
//
// Copyright 2021 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 Foundation
import UIKit
import SwiftUI
struct TemplateRoomChatCoordinatorParameters {
let room: MXRoom
}
final class TemplateRoomChatCoordinator: Coordinator, Presentable {
// MARK: - Properties
@@ -1,21 +0,0 @@
//
// Copyright 2021 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 Foundation
struct TemplateRoomChatCoordinatorParameters {
let room: MXRoom
}
@@ -17,7 +17,6 @@
import Foundation
import SwiftUI
/// Using an enum for the screen allows you define the different state cases with
/// the relevant associated data for each case.
@available(iOS 14.0, *)
@@ -1,26 +0,0 @@
//
// Copyright 2021 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 Foundation
/// Represents a grouped bubble in the View(For example multiple message of different time sent close together).
struct TemplateRoomChatBubble {
let id: String
let sender: TemplateRoomChatMember
var items: [TemplateRoomChatBubbleItem]
}
extension TemplateRoomChatBubble: Identifiable, Equatable { }
@@ -1,24 +0,0 @@
//
// Copyright 2021 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
/// An image sent as a message.
struct TemplateRoomChatMessageImageContent {
var image: UIImage
}
extension TemplateRoomChatMessageImageContent: Equatable { }
@@ -1,28 +0,0 @@
//
// Copyright 2021 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
/// One of the items grouped within a bubble(could be message types like text, image or video, or could be other items like url previews).
struct TemplateRoomChatBubbleItem {
let id: String
var timestamp: Date
var content: TemplateRoomChatBubbleItemContent
}
extension TemplateRoomChatBubbleItem: Identifiable, Equatable { }
@@ -1,23 +0,0 @@
//
// Copyright 2021 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 Foundation
enum TemplateRoomChatBubbleItemContent {
case message(TemplateRoomChatMessageContent)
}
extension TemplateRoomChatBubbleItemContent: Equatable { }
@@ -1,36 +0,0 @@
//
// Copyright 2021 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 Foundation
/// A user who is a member of the room.
struct TemplateRoomChatMember {
let id: String
let avatarUrl: String?
let displayName: String?
}
extension TemplateRoomChatMember: Avatarable {
var mxContentUri: String? {
avatarUrl
}
var matrixItemId: String {
id
}
}
extension TemplateRoomChatMember: Identifiable, Equatable {}
@@ -1,27 +0,0 @@
//
// Copyright 2021 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 Foundation
/// A chat message send to the timeline within a room.
struct TemplateRoomChatMessage {
let id: String
let content: TemplateRoomChatMessageContent
let sender: TemplateRoomChatMember
let timestamp: Date
}
extension TemplateRoomChatMessage: Identifiable {}
@@ -1,25 +0,0 @@
//
// Copyright 2021 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 Foundation
/// The type of message a long with it's content.
enum TemplateRoomChatMessageContent {
case text(TemplateRoomChatMessageTextContent)
case image(TemplateRoomChatMessageImageContent)
}
extension TemplateRoomChatMessageContent: Equatable { }
@@ -1,25 +0,0 @@
//
// Copyright 2021 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 Foundation
/// The text content of a message sent by a user.
struct TemplateRoomChatMessageTextContent {
var body: String
}
extension TemplateRoomChatMessageTextContent: Equatable { }
@@ -1,23 +0,0 @@
//
// Copyright 2021 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 Foundation
enum TemplateRoomChatRoomInitializationStatus {
case notInitialized
case initialized
case failedToInitialize
}
@@ -1,24 +0,0 @@
//
// Copyright 2021 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 Foundation
/// Actions to be performed on the `ViewModel` State
enum TemplateRoomChatStateAction {
case updateRoomInitializationStatus(TemplateRoomChatRoomInitializationStatus)
case updateBubbles([TemplateRoomChatBubble])
case clearMessageInput
}
@@ -1,23 +0,0 @@
//
// Copyright 2021 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 Foundation
/// Actions send from the `View` to the `ViewModel`.
enum TemplateRoomChatViewAction {
case sendMessage
case done
}
@@ -1,22 +0,0 @@
//
// Copyright 2021 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 Foundation
/// Actions sent by the `ViewModel` to the `Coordinator`
enum TemplateRoomChatViewModelAction {
case done
}
@@ -1,22 +0,0 @@
//
// Copyright 2021 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 Foundation
/// State bound directly to SwiftUI elements.
struct TemplateRoomChatViewModelBindings {
var messageInput: String
}
@@ -1,32 +0,0 @@
//
// Copyright 2021 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 Foundation
/// State managed by the `ViewModel` delivered to the `View`.
struct TemplateRoomChatViewState: BindableState {
var roomInitializationStatus: TemplateRoomChatRoomInitializationStatus
let roomName: String?
var bubbles: [TemplateRoomChatBubble]
var bindings: TemplateRoomChatViewModelBindings
}
extension TemplateRoomChatViewState {
var sendButtonEnabled: Bool {
!bindings.messageInput.isEmpty
}
}
@@ -0,0 +1,122 @@
//
// Copyright 2021 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
// MARK: - Coordinator
/// An image sent as a message.
struct TemplateRoomChatMessageImageContent: Equatable {
var image: UIImage
}
/// The text content of a message sent by a user.
struct TemplateRoomChatMessageTextContent: Equatable {
var body: String
}
/// The type of message a long with it's content.
enum TemplateRoomChatMessageContent: Equatable {
case text(TemplateRoomChatMessageTextContent)
case image(TemplateRoomChatMessageImageContent)
}
enum TemplateRoomChatBubbleItemContent: Equatable {
case message(TemplateRoomChatMessageContent)
}
/// One of the items grouped within a bubble(could be message types like text, image or video, or could be other items like url previews).
struct TemplateRoomChatBubbleItem: Identifiable, Equatable {
let id: String
var timestamp: Date
var content: TemplateRoomChatBubbleItemContent
}
/// A user who is a member of the room.
struct TemplateRoomChatMember: Identifiable, Equatable, Avatarable {
let id: String
let avatarUrl: String?
let displayName: String?
var mxContentUri: String? {
avatarUrl
}
var matrixItemId: String {
id
}
}
/// Represents a grouped bubble in the View(For example multiple message of different time sent close together).
struct TemplateRoomChatBubble: Identifiable, Equatable {
let id: String
let sender: TemplateRoomChatMember
var items: [TemplateRoomChatBubbleItem]
}
/// A chat message send to the timeline within a room.
struct TemplateRoomChatMessage: Identifiable {
let id: String
let content: TemplateRoomChatMessageContent
let sender: TemplateRoomChatMember
let timestamp: Date
}
// MARK: - View model
enum TemplateRoomChatRoomInitializationStatus {
case notInitialized
case initialized
case failedToInitialize
}
/// Actions to be performed on the `ViewModel` State
enum TemplateRoomChatStateAction {
case updateRoomInitializationStatus(TemplateRoomChatRoomInitializationStatus)
case updateBubbles([TemplateRoomChatBubble])
case clearMessageInput
}
/// Actions sent by the `ViewModel` to the `Coordinator`
enum TemplateRoomChatViewModelAction {
case done
}
// MARK: - View
/// Actions send from the `View` to the `ViewModel`.
enum TemplateRoomChatViewAction {
case sendMessage
case done
}
/// State managed by the `ViewModel` delivered to the `View`.
struct TemplateRoomChatViewState: BindableState {
var roomInitializationStatus: TemplateRoomChatRoomInitializationStatus
let roomName: String?
var bubbles: [TemplateRoomChatBubble]
var bindings: TemplateRoomChatViewModelBindings
var sendButtonEnabled: Bool {
!bindings.messageInput.isEmpty
}
}
/// State bound directly to SwiftUI elements.
struct TemplateRoomChatViewModelBindings {
var messageInput: String
}
@@ -1,23 +1,27 @@
/*
Copyright 2021 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.
*/
//
// Copyright 2021 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 Foundation
import UIKit
import SwiftUI
struct TemplateRoomListCoordinatorParameters {
let session: MXSession
}
final class TemplateRoomListCoordinator: Coordinator, Presentable {
// MARK: - Properties
@@ -1,21 +0,0 @@
//
// Copyright 2021 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 Foundation
struct TemplateRoomListCoordinatorParameters {
let session: MXSession
}
@@ -1,23 +0,0 @@
//
// Copyright 2021 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 Foundation
/// Actions returned by the coordinator callback
enum TemplateRoomListCoordinatorAction {
case didSelectRoom(String)
case done
}
@@ -1,25 +0,0 @@
//
// Copyright 2021 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 Foundation
struct TemplateRoomListRoom {
let id: String
let avatar: AvatarInput
let displayName: String?
}
extension TemplateRoomListRoom: Identifiable, Equatable {}
@@ -1,22 +0,0 @@
//
// Copyright 2021 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 Foundation
/// Actions to be performed on the `ViewModel` State
enum TemplateRoomListStateAction {
case updateRooms([TemplateRoomListRoom])
}
@@ -1,23 +0,0 @@
//
// Copyright 2021 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 Foundation
/// Actions send from the `View` to the `ViewModel`.
enum TemplateRoomListViewAction {
case done
case didSelectRoom(String)
}
@@ -1,23 +0,0 @@
//
// Copyright 2021 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 Foundation
/// Actions sent by the`ViewModel` to the `Coordinator`.
enum TemplateRoomListViewModelAction {
case didSelectRoom(String)
case done
}
@@ -16,7 +16,42 @@
import Foundation
// MARK: - Coordinator
struct TemplateRoomListRoom: Identifiable, Equatable {
let id: String
let avatar: AvatarInput
let displayName: String?
}
/// Actions returned by the coordinator callback
enum TemplateRoomListCoordinatorAction {
case didSelectRoom(String)
case done
}
// MARK: - View model
/// Actions to be performed on the `ViewModel` State
enum TemplateRoomListStateAction {
case updateRooms([TemplateRoomListRoom])
}
/// Actions sent by the`ViewModel` to the `Coordinator`.
enum TemplateRoomListViewModelAction {
case didSelectRoom(String)
case done
}
// MARK: - View
/// State managed by the `ViewModel` delivered to the `View`.
struct TemplateRoomListViewState: BindableState {
var rooms: [TemplateRoomListRoom]
}
/// Actions send from the `View` to the `ViewModel`.
enum TemplateRoomListViewAction {
case done
case didSelectRoom(String)
}