mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-25 11:02:48 +02:00
Cleanup, documentation and ui tests.
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// 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 { }
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// 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
|
||||
}
|
||||
+1
-20
@@ -16,15 +16,7 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
|
||||
struct TemplateRoomChatBubble {
|
||||
let id: String
|
||||
let sender: TemplateRoomChatMember
|
||||
var items: [TemplateRoomChatBubbleItem]
|
||||
}
|
||||
|
||||
extension TemplateRoomChatBubble: Identifiable { }
|
||||
|
||||
/// 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
|
||||
@@ -33,15 +25,4 @@ struct TemplateRoomChatBubbleItem {
|
||||
|
||||
extension TemplateRoomChatBubbleItem: Identifiable { }
|
||||
|
||||
enum TemplateRoomChatBubbleItemContent {
|
||||
case message(TemplateRoomChatBubbleMessageContent)
|
||||
case image(TemplateRoomChatBubbleImageContent)
|
||||
}
|
||||
|
||||
struct TemplateRoomChatBubbleMessageContent {
|
||||
var body: String
|
||||
}
|
||||
|
||||
struct TemplateRoomChatBubbleImageContent {
|
||||
var image: UIImage
|
||||
}
|
||||
|
||||
+2
-2
@@ -16,6 +16,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
enum TemplateRoomChatViewModelResult {
|
||||
case done
|
||||
enum TemplateRoomChatBubbleItemContent {
|
||||
case message(TemplateRoomChatMessageContent)
|
||||
}
|
||||
+1
-9
@@ -16,15 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct TemplateRoomChatMessage {
|
||||
let id: String
|
||||
let body: String
|
||||
let sender: TemplateRoomChatMember
|
||||
let timestamp: Date
|
||||
}
|
||||
|
||||
extension TemplateRoomChatMessage: Identifiable {}
|
||||
|
||||
/// A user who is a member of the room.
|
||||
struct TemplateRoomChatMember {
|
||||
let id: String
|
||||
let avatarUrl: String?
|
||||
+27
@@ -0,0 +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.
|
||||
//
|
||||
|
||||
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 {}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// 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)
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// 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
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// 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
|
||||
}
|
||||
+3
-1
@@ -16,7 +16,9 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Actions to be performed on the `ViewModel` State
|
||||
enum TemplateRoomChatStateAction {
|
||||
case clearMessageInput
|
||||
case updateRoomInitializationStatus(TemplateRoomChatRoomInitializationStatus)
|
||||
case updateBubbles([TemplateRoomChatBubble])
|
||||
case clearMessageInput
|
||||
}
|
||||
|
||||
+1
@@ -16,6 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Actions send from the `View` to the `ViewModel`.
|
||||
enum TemplateRoomChatViewAction {
|
||||
case sendMessage
|
||||
case done
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// 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
@@ -16,6 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/// State bound directly to SwiftUI elements.
|
||||
struct TemplateRoomChatViewModelBindings {
|
||||
var messageInput: String
|
||||
}
|
||||
|
||||
+2
@@ -16,7 +16,9 @@
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user