Skip to content

Commit a8e6433

Browse files
authored
Merge pull request #8 from jaesung-0o0/feature/jaesung/100-beta-1
[Release/1.0.0-Beta.1] Merge to main
2 parents aeb840d + 68d9327 commit a8e6433

File tree

9 files changed

+71
-24
lines changed

9 files changed

+71
-24
lines changed

Documentation/Chat_in_Channel/MessageList.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
## Lists messages in row contents
44

5-
In the constructor, you can list message objects that conform to `MessageProtocol` to display messages using the `rowContent` parameter.
5+
In the intializer, you can list message objects that conform to `MessageProtocol` to display messages using the `rowContent` parameter.
66

77
All the body and row contents are flipped vertically so that new messages can be listed from the bottom.
88

99
The messages are listed in the following order, depending on the `readReceipt` value of the `MessageProtocol`. For more details, please refer to `MessageProtocol/readReceipt` or `ReadReceipt`.
1010

11-
sending → failed → sent → delivered → seen
11+
> **NOTE:** The order of the messages is like below:
12+
>
13+
> sending → failed → sent → delivered → seen
1214
1315
## Scrolls to bottom
1416

Sources/ChatUI/ChatInChannel/ChannelInfoView.swift

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77

88
import SwiftUI
99

10+
/**
11+
The view that displays the following channel information:
12+
13+
- The image of the channel
14+
- The title of the channel
15+
- The subtitle of the channel
16+
*/
1017
public struct ChannelInfoView: View {
1118
@Environment(\.appearance) var appearance
1219

Sources/ChatUI/ChatInChannel/ChannelStack.swift

+3-15
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@
77

88
import SwiftUI
99

10-
// TODO: VStack 감싸기
11-
/**
12-
```swift
13-
ChannelStack(channel, spacing: 0) {
14-
MessageList() { ... }
15-
16-
MessageField { ... }
17-
}
18-
.channelInfoBar { ... }
19-
```
20-
*/
21-
2210
/**
2311
The *vertical* stack view that provides ``ChannelInfoView`` as a `ToolbarItem`.
2412

@@ -34,10 +22,10 @@ import SwiftUI
3422
}
3523
```
3624
*/
37-
public struct ChannelStack<C: ChannelProtocol, Content: View>: View {
25+
public struct ChannelStack<ChannelType: ChannelProtocol, Content: View>: View {
3826
@EnvironmentObject private var configuration: ChatConfiguration
3927

40-
let channel: C
28+
let channel: ChannelType
4129
let content: () -> Content
4230

4331
public var body: some View {
@@ -56,7 +44,7 @@ public struct ChannelStack<C: ChannelProtocol, Content: View>: View {
5644
}
5745

5846
public init(
59-
_ channel: C,
47+
_ channel: ChannelType,
6048
@ViewBuilder content: @escaping () -> Content
6149
) {
6250
self.channel = channel

Sources/ChatUI/ChatInChannel/MessageField/Location/DataModel/LocationModel.swift

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class LocationModel: NSObject, ObservableObject {
1919
case tracked
2020
}
2121

22-
// TODO: change to `false`
2322
@Published var locationTrackingStatus: TrackStatus = .none
2423
@Published var coordinateRegion: MKCoordinateRegion = .init(
2524
center: .init(latitude: 37.57827, longitude: 126.97695),

Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift

+44
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,50 @@ import Combine
99
import SwiftUI
1010
import PhotosUI
1111

12+
/**
13+
The view for sending messages.
14+
15+
When creating a `MessageField`, you can provide an action for how to handle a new `MessageStyle` information in the `onSend` parameter. `MessageStyle` can contain different types of messages, such as text, media (photo, video, document, contact), and voice.
16+
17+
```swift
18+
MessageField { messageStyle in
19+
viewModel.sendMessage($0)
20+
}
21+
```
22+
23+
To handle menu items, assign state property to `isMenuItemPresented` parameter.
24+
25+
```swift
26+
MessageField(isMenuItemPresented: $isMenuItemPresented) { ... }
27+
28+
if isMenuItemPresented {
29+
MyMenuItemList()
30+
}
31+
```
32+
33+
To publish a new message, you can create a new `MessageStyle` object and send it using `send(_:)`.
34+
35+
```swift
36+
let _ = Empty<Void, Never>()
37+
.sink(
38+
receiveCompletion: { _ in
39+
// Create `MessageStyle` object
40+
let style = MessageStyle.text("{TEXT}")
41+
// Publish the created style object via `send(_:)`
42+
sendMessagePublisher.send(style)
43+
},
44+
receiveValue: { _ in }
45+
)
46+
```
47+
48+
You can subscribe to `sendMessagePublisher` to handle new messages.
49+
50+
```swift
51+
.onReceive(sendMessagePublisher) { messageStyle in
52+
// Handle `messageStyle` here (e.g., sending message with the style)
53+
}
54+
```
55+
*/
1256
public struct MessageField: View {
1357
@EnvironmentObject private var configuration: ChatConfiguration
1458

Sources/ChatUI/ChatInChannel/MessageList.swift

+11-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@
77

88
import SwiftUI
99

10+
/**
11+
The view that lists message objects.
12+
13+
In the intializer, you can list message objects that conform to ``MessageProtocol`` to display messages using the `rowContent` parameter.
1014

15+
All the body and row contents are flipped vertically so that new messages can be listed from the bottom.
16+
17+
The messages are listed in the following order, depending on the ``ReadReceipt`` value of the ``MessageProtocol``. For more details, please refer to ``MessageProtocol/readReceipt`` or ``ReadReceipt``.
18+
19+
- **NOTE:** The order of the messages: sending → failed → sent → delivered → seen
20+
*/
1121
public struct MessageList<MessageType: MessageProtocol & Identifiable, RowContent: View>: View {
1222

1323
@EnvironmentObject var configuration: ChatConfiguration
@@ -104,7 +114,6 @@ public struct MessageList<MessageType: MessageProtocol & Identifiable, RowConten
104114
showsScrollButton = isScrollButtonShown
105115
}
106116

107-
print(diff)
108117
if isKeyboardShown && diff < -20 {
109118
isKeyboardShown = false
110119
}
@@ -114,7 +123,6 @@ public struct MessageList<MessageType: MessageProtocol & Identifiable, RowConten
114123
/// When tapped sending button. Called after `onSent` in ``MessageField``
115124
.onChange(of: sendingMessages) { newValue in
116125
if let id = sendingMessages.first?.id {
117-
print("☺️ \(id)")
118126
withAnimation {
119127
scrollView.scrollTo(id, anchor: .bottom)
120128
}
@@ -145,7 +153,7 @@ public struct MessageList<MessageType: MessageProtocol & Identifiable, RowConten
145153

146154
public init(
147155
_ messageData: [MessageType],
148-
showsDate: Bool = false,
156+
showsDate: Bool = false, // TODO: Not Supported yet
149157
@ViewBuilder rowContent: @escaping (_ message: MessageType) -> RowContent
150158
) {
151159
var sendingMessages: [MessageType] = []

Sources/ChatUI/ChatInChannel/MessageSearchBar.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import SwiftUI
99

10-
// TODO: Not current scope
10+
// TODO: Not Supported yet
1111
struct MessageSearchBar: View {
1212
@State private var searchText: String = ""
1313

Sources/ChatUI/ChatInChannel/ScrollButton.swift

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public struct ScrollButton: View {
2828
let _ = Empty<Void, Never>()
2929
.sink(
3030
receiveCompletion: { _ in
31-
print("☺️ scrollsToBottom send")
3231
scrollDownPublisher.send(())
3332
},
3433
receiveValue: { _ in }

Sources/ChatUI/Previews/ChatInChannel/MessageSearch.Previews.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import SwiftUI
99

10-
// TODO: Not current scope
10+
// TODO: Not Supported yet
1111
struct MessageSearch_Previews: PreviewProvider {
1212
static var previews: some View {
1313
MessageSearchBar()

0 commit comments

Comments
 (0)