-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move mock related files to newly created SwiftyChatMock pac…
…kage (#63) * refactor: move mock related files into SwiftyChatMock target * Update README.md * Update Lorem.swift * Update MessageMocker.swift * Update AdvancedExampleView.swift
- Loading branch information
1 parent
c5b3abc
commit f9fced1
Showing
8 changed files
with
184 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,11 @@ | |
|
||
import SwiftUI | ||
import SwiftyChat | ||
import SwiftyChatMock | ||
|
||
struct AdvancedExampleView: View { | ||
|
||
@State var messages: [MockMessages.ChatMessageItem] = [] | ||
@State var messages: [MessageMocker.ChatMessageItem] = [] | ||
@State private var scrollToBottom = false | ||
|
||
@State private var message = "" | ||
|
@@ -20,13 +21,13 @@ struct AdvancedExampleView: View { | |
} | ||
|
||
private var chatView: some View { | ||
ChatView<MockMessages.ChatMessageItem, MockMessages.ChatUserItem>(messages: $messages) { | ||
ChatView<MessageMocker.ChatMessageItem, MessageMocker.ChatUserItem>(messages: $messages, scrollToBottom: $scrollToBottom) { | ||
BasicInputView( | ||
message: $message, | ||
placeholder: "Type something", | ||
onCommit: { messageKind in | ||
self.messages.append( | ||
.init(user: MockMessages.sender, messageKind: messageKind, isSender: true) | ||
.init(user: MessageMocker.sender, messageKind: messageKind, isSender: true) | ||
) | ||
} | ||
) | ||
|
@@ -59,8 +60,8 @@ struct AdvancedExampleView: View { | |
// ▼ Implement in case ChatMessageKind.quickReply | ||
.onQuickReplyItemSelected { (quickReply) in | ||
self.messages.append( | ||
MockMessages.ChatMessageItem( | ||
user: MockMessages.sender, | ||
MessageMocker.ChatMessageItem( | ||
user: MessageMocker.sender, | ||
messageKind: .text(quickReply.title), | ||
isSender: true | ||
) | ||
|
@@ -83,20 +84,19 @@ struct AdvancedExampleView: View { | |
#if os(iOS) | ||
.navigationBarTitle("Advanced") | ||
#endif | ||
.listStyle(PlainListStyle()) | ||
.task { | ||
if let portraitUrl = URL(string: "https://picsum.photos/id/\(Int.random(in: 1...100))/400/600") { | ||
self.messages.append(.init(user: MockMessages.chatbot, messageKind: .image(.remote(portraitUrl)))) | ||
self.messages.append(.init(user: MessageMocker.chatbot, messageKind: .image(.remote(portraitUrl)))) | ||
} | ||
|
||
self.messages.append( | ||
.init( | ||
user: MockMessages.chatbot, | ||
user: MessageMocker.chatbot, | ||
messageKind: .text("https://github.com/EnesKaraosman/SwiftyChat and here is his phone +90 537 844 11-41, & mail: [email protected] Today is 27 May 2020") | ||
) | ||
) | ||
|
||
self.messages.append(contentsOf: MockMessages.generatedMessages(count: 53)) | ||
self.messages.append(contentsOf: MessageMocker.generate(count: 53)) | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.