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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### ✅ Added
- Add factory method to customize the channel avatar [#734](https://github.com/GetStream/stream-chat-swiftui/pull/734)
- Add possibility to replace the no content icons [#740](https://github.com/GetStream/stream-chat-swiftui/pull/740)

# [4.71.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.71.0)
_January 28, 2025_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public struct FileAttachmentsView: View {

@Injected(\.colors) private var colors
@Injected(\.fonts) private var fonts
@Injected(\.images) private var images

public init(channel: ChatChannel) {
_viewModel = StateObject(
Expand All @@ -29,7 +30,7 @@ public struct FileAttachmentsView: View {
LoadingView()
} else if viewModel.attachmentsDataSource.isEmpty {
NoContentView(
imageName: "folder",
image: images.noMedia,
title: L10n.ChatInfo.Files.emptyTitle,
description: L10n.ChatInfo.Files.emptyDesc
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import SwiftUI

/// View displaying media attachments.
public struct MediaAttachmentsView: View {

@Injected(\.images) private var images

@StateObject private var viewModel: MediaAttachmentsViewModel

Expand Down Expand Up @@ -40,7 +42,7 @@ public struct MediaAttachmentsView: View {
LoadingView()
} else if viewModel.mediaItems.isEmpty {
NoContentView(
imageName: "folder",
image: images.noMedia,
title: L10n.ChatInfo.Media.emptyTitle,
description: L10n.ChatInfo.Media.emptyDesc
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import SwiftUI

/// View displaying pinned messages in the chat info screen.
public struct PinnedMessagesView: View {

@Injected(\.images) private var images

@StateObject private var viewModel: PinnedMessagesViewModel

Expand All @@ -32,7 +34,7 @@ public struct PinnedMessagesView: View {
}
} else {
NoContentView(
imageName: "message",
image: images.noContent,
title: L10n.ChatInfo.PinnedMessages.emptyTitle,
description: L10n.ChatInfo.PinnedMessages.emptyDesc,
shouldRotateImage: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import SwiftUI
///
/// Different view can be injected in its place.
public struct NoChannelsView: View {

@Injected(\.images) private var images

public var body: some View {
NoContentView(
imageName: "message",
image: images.noContent,
title: L10n.Channel.NoContent.title,
description: L10n.Channel.NoContent.message,
shouldRotateImage: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import SwiftUI

/// Default SDK implementation for the view displayed when there are no threads available.
public struct NoThreadsView: View {

@Injected(\.images) private var images

public init() {}

public var body: some View {
NoContentView(
imageName: "text.bubble",
image: images.noThreads,
title: nil,
description: L10n.Thread.NoContent.message,
shouldRotateImage: false
Expand Down
11 changes: 7 additions & 4 deletions Sources/StreamChatSwiftUI/CommonViews/NoContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,25 @@ struct NoContentView: View {
@Injected(\.fonts) private var fonts
@Injected(\.colors) private var colors

var imageName: String
var image: UIImage
var title: String?
var description: String
var shouldRotateImage: Bool = false
var size: CGSize = CGSize(width: 100, height: 100)

public var body: some View {
VStack(spacing: 8) {
Spacer()

VStack(spacing: 8) {
Image(systemName: imageName)
Image(uiImage: image)
.resizable()
.renderingMode(.template)
.aspectRatio(contentMode: .fit)
.frame(width: size.width, height: size.height)
.rotation3DEffect(
shouldRotateImage ? .degrees(180) : .zero, axis: (x: 0, y: 1, z: 0)
)
.aspectRatio(contentMode: .fit)
.font(.system(size: 100))
.foregroundColor(Color(colors.textLowEmphasis))
title.map { Text($0) }
.font(fonts.bodyBold)
Expand Down
15 changes: 15 additions & 0 deletions Sources/StreamChatSwiftUI/Images.swift
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,19 @@ public class Images {
// MARK: - Threads

public var threadIcon: UIImage = UIImage(systemName: "text.bubble")!

// MARK: - No Content Icons

public var noContent: UIImage = UIImage(
systemName: "message",
withConfiguration: UIImage.SymbolConfiguration(pointSize: 100, weight: .regular)
) ?? UIImage.circleImage
public var noMedia: UIImage = UIImage(
systemName: "folder",
withConfiguration: UIImage.SymbolConfiguration(pointSize: 100, weight: .regular)
) ?? UIImage.circleImage
public var noThreads: UIImage = UIImage(
systemName: "text.bubble",
withConfiguration: UIImage.SymbolConfiguration(pointSize: 100, weight: .regular)
) ?? UIImage.circleImage
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class FileAttachmentsView_Tests: StreamChatTestCase {
.applyDefaultSize()

// Then
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
AssertSnapshot(view, size: defaultScreenSize)
}

func test_fileAttachmentsView_loadingSnapshot() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MediaAttachmentsView_Tests: StreamChatTestCase {
.applyDefaultSize()

// Then
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
AssertSnapshot(view, size: .defaultAvatarSize)
}

func test_mediaAttachmentsView_loading() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class PinnedMessagesView_Tests: StreamChatTestCase {
.applyDefaultSize()

// Then
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
AssertSnapshot(view, size: defaultScreenSize)
}
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class NoChannelsView_Tests: StreamChatTestCase {
.frame(width: 375, height: 600)

// Then
assertSnapshot(matching: view, as: .image)
AssertSnapshot(view, size: CGSize(width: 375, height: 600))
}
}
Loading