Skip to content

Commit 79a9494

Browse files
committed
add second preview
1 parent f1b8d69 commit 79a9494

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

WireUI/Sources/WireConversationUI/Views/MessageCell.swift

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public final class MessageCell: UITableViewCell { // TODO: this probably has to
2929
}
3030
}
3131

32-
public var messageLayout = MessageLayout.oneOnOneConversation {
32+
public var messageLayout = MessageLayout.oneOnOneConversationStyle {
3333
didSet {
3434
if oldValue != messageLayout {
3535
updateContent()
@@ -77,7 +77,7 @@ public final class MessageCell: UITableViewCell { // TODO: this probably has to
7777
var dataSourceX: AnyObject?
7878

7979
@MainActor
80-
public func MessageCellPreview() -> UIViewController {
80+
public func MessageCellPreview(_ messageLayout: MessageLayout) -> UIViewController {
8181

8282
let tableViewController = UITableViewController()
8383
tableViewController.tableView.register(MessageCell.self, forCellReuseIdentifier: "MessageCell")
@@ -86,7 +86,7 @@ public func MessageCellPreview() -> UIViewController {
8686
) { tableView, indexPath, itemID in
8787
let cell = tableView.dequeueReusableCell(withIdentifier: "MessageCell", for: indexPath)
8888
if let cell = cell as? MessageCell {
89-
cell.messageLayout = .groupConversation
89+
cell.messageLayout = messageLayout
9090
cell.message = Message(
9191
id: .init(itemID),
9292
attributedText: AttributedString("Hello,\nWorld!")
@@ -112,16 +112,25 @@ public func MessageCellPreview() -> UIViewController {
112112
}
113113

114114
@available(iOS 17, *)
115-
#Preview {
116-
MessageCellPreview()
115+
#Preview("oneOnOne") {
116+
MessageCellPreview(.oneOnOneConversationStyle)
117+
}
118+
119+
@available(iOS 17, *)
120+
#Preview("group") {
121+
MessageCellPreview(.groupConversationStyle)
117122
}
118123

119124
public struct MessageCellPreviewRepresentable: UIViewControllerRepresentable {
120125

121-
public init() {}
126+
private let messageLayout: MessageLayout
127+
128+
public init(messageLayout: MessageLayout) {
129+
self.messageLayout = messageLayout
130+
}
122131

123132
public func makeUIViewController(context: Context) -> UIViewController {
124-
MessageCellPreview()
133+
MessageCellPreview(messageLayout)
125134
}
126135

127136
public func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}

WireUI/Sources/WireConversationUI/Views/MessageContentView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ struct MessageContentView<
3030

3131
var body: some View {
3232
switch layout {
33-
case .oneOnOneConversation:
33+
case .oneOnOneConversationStyle:
3434
oneOnOneConversationContent()
35-
case .groupConversation:
35+
case .groupConversationStyle:
3636
groupConversationContent()
3737
}
3838
}

WireUI/Sources/WireConversationUI/Views/MessageLayout.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
//
1818

1919
public enum MessageLayout {
20-
case oneOnOneConversation
21-
case groupConversation
20+
case oneOnOneConversationStyle
21+
case groupConversationStyle
2222
}

0 commit comments

Comments
 (0)