Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions Sources/ExyteChat/Theme/ChatTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
// Define keys only for older versions
#if swift(<6.0)
@preconcurrency public struct ChatThemeKey: EnvironmentKey {
public static let defaultValue = ChatTheme()

Check warning on line 30 in Sources/ExyteChat/Theme/ChatTheme.swift

View workflow job for this annotation

GitHub Actions / Build and Test

static property 'defaultValue' is not concurrency-safe because non-'Sendable' type 'ChatTheme' may have shared mutable state; this is an error in the Swift 6 language mode
}

public struct GiphyConfigurationKey: EnvironmentKey {
public static let defaultValue = GiphyConfiguration()

Check warning on line 34 in Sources/ExyteChat/Theme/ChatTheme.swift

View workflow job for this annotation

GitHub Actions / Build and Test

static property 'defaultValue' is not concurrency-safe because non-'Sendable' type 'GiphyConfiguration' may have shared mutable state; this is an error in the Swift 6 language mode
}
#endif

Expand All @@ -58,20 +58,18 @@
public let images: ChatTheme.Images
public let style: ChatTheme.Style

public var contentBG: Color {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this allows the .clear to be used instead of mainBG where needed, the InputView and UIList

images.background != nil ? .clear : colors.mainBG
}

public init(
colors: ChatTheme.Colors = .init(),
images: ChatTheme.Images = .init(),
style: ChatTheme.Style = .init()
) {
self.style = style
self.images = images

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was initially included so that the image background correctly was the background for input view, it worked but had the side effect that other components (recording button) that used mainBg also had there color set to clear

// if background images have been set then override the mainBG color to be clear
self.colors = if images.background != nil {
ChatTheme.Colors(copy: colors, mainBG: .clear)
} else {
colors
}
self.colors = colors
}

internal init(accentColor: Color, images: ChatTheme.Images) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/ExyteChat/Views/InputView/InputView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ struct InputView: View {
var backgroundColor: Color {
switch style {
case .message:
return theme.colors.mainBG
return theme.contentBG
case .signature:
return pickerTheme.main.pickerBackground
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/ExyteChat/Views/UIList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct UIList<MessageContent: View>: UIViewRepresentable {
tableView.showsVerticalScrollIndicator = false
tableView.estimatedSectionHeaderHeight = 1
tableView.estimatedSectionFooterHeight = UITableView.automaticDimension
tableView.backgroundColor = UIColor(theme.colors.mainBG)
tableView.backgroundColor = UIColor(theme.contentBG)
tableView.scrollsToTop = false
tableView.isScrollEnabled = chatParams.isScrollEnabled
tableView.keyboardDismissMode = chatParams.keyboardDismissMode
Expand Down Expand Up @@ -417,7 +417,7 @@ struct UIList<MessageContent: View>: UIViewRepresentable {

chatParams: chatParams,
messageParams: messageParams,
mainBackgroundColor: theme.colors.mainBG
mainBackgroundColor: theme.contentBG
)
}

Expand Down
Loading