Skip to content

Commit

Permalink
Add show network error setting
Browse files Browse the repository at this point in the history
  • Loading branch information
f3dm76 committed Jun 17, 2024
1 parent 4b3f976 commit c37ebe0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ExyteChat.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ExyteChat"
s.version = "1.3.7"
s.version = "1.3.8"
s.summary = "Chat with fully customizable message cells and built-in media picker written with SwiftUI"

s.homepage = 'https://github.com/exyte/Chat.git'
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ If you are not using your own `messageBuilder`:
`showDateHeaders` - show section headers with dates between days, default is `true`
`avatarSize` - the default avatar is a circle, you can specify its diameter here
`showMessageMenuOnLongPress` - turn menu on long tap on/off
`showNetworkConnectionProblem` - display network error on/off
`tapAvatarClosure` - closure to call on avatar tap
`messageUseMarkdown` - whether the default message cell uses markdown
`mediaPickerSelectionParameters` - a struct holding MediaPicker selection parameters (mediaType, selectionStyle, etc.)
Expand Down
9 changes: 8 additions & 1 deletion Sources/ExyteChat/ChatView/ChatView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public struct ChatView<MessageContent: View, InputViewContent: View>: View {
var avatarSize: CGFloat = 32
var messageUseMarkdown: Bool = false
var showMessageMenuOnLongPress: Bool = true
var showNetworkConnectionProblem: Bool = false
var tapAvatarClosure: TapAvatarClosure?
var mediaPickerSelectionParameters: MediaPickerParameters?
var orientationHandler: MediaPickerOrientationHandler = {_ in}
Expand Down Expand Up @@ -106,7 +107,7 @@ public struct ChatView<MessageContent: View, InputViewContent: View>: View {

public var body: some View {
VStack {
if !networkMonitor.isConnected {
if showNetworkConnectionProblem, !networkMonitor.isConnected {
waitingForNetwork
}

Expand Down Expand Up @@ -435,6 +436,12 @@ public extension ChatView {
return view
}

func showNetworkConnectionProblem(_ show: Bool) -> ChatView {
var view = self
view.showNetworkConnectionProblem = show
return view
}

func tapAvatarClosure(_ closure: @escaping TapAvatarClosure) -> ChatView {
var view = self
view.tapAvatarClosure = closure
Expand Down

0 comments on commit c37ebe0

Please sign in to comment.