Skip to content
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions DemoAppSwiftUI/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ class AppDelegate: NSObject, UIApplicationDelegate {

let utils = Utils(
channelListConfig: ChannelListConfig(
channelItemMutedStyle: .afterChannelName,
messageRelativeDateFormatEnabled: true
channelItemMutedStyle: .afterChannelName
),
messageListConfig: MessageListConfig(
messageDisplayOptions: .init(showOriginalTranslatedButton: true),
Expand Down
2 changes: 1 addition & 1 deletion DemoAppSwiftUI/ChannelHeader/CustomChannelHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public struct CustomChannelHeader: ToolbarContent {
.frame(width: 24, height: 24)
.foregroundColor(Color(colors.navigationBarGlyph))
.padding(.all, 8)
.background(colors.navigationBarTintColor)
.background(Color(colors.navigationBarTintColor))
.clipShape(Circle())
}
.accessibilityLabel(Text("New Channel"))
Expand Down
4 changes: 2 additions & 2 deletions DemoAppSwiftUI/ChannelHeader/NewChatView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ struct CreateGroupButton: View {
HStack {
Image(systemName: "person.3")
.renderingMode(.template)
.foregroundColor(colors.tintColor)
.foregroundColor(Color(colors.accentPrimary))

Text("Create a group")
.font(fonts.bodyBold)
Expand Down Expand Up @@ -227,7 +227,7 @@ struct ChatUserView: View {
if isSelected {
Image(systemName: "checkmark")
.renderingMode(.template)
.foregroundColor(colors.tintColor)
.foregroundColor(Color(colors.accentPrimary))
}
}
}
Expand Down
1 change: 1 addition & 0 deletions DemoAppSwiftUI/ChannelHeader/NewChatViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

import StreamChat
import StreamChatCommonUI
import StreamChatSwiftUI
import SwiftUI

Expand Down
1 change: 1 addition & 0 deletions DemoAppSwiftUI/CreateGroupViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

import StreamChat
import StreamChatCommonUI
import StreamChatSwiftUI
import SwiftUI

Expand Down
2 changes: 1 addition & 1 deletion DemoAppSwiftUI/GroupNameView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct GroupControlsView: View {
Image(systemName: "checkmark")
.renderingMode(.template)
.foregroundColor(
viewModel.canCreateGroup ? colors.tintColor : Color(colors.textLowEmphasis)
viewModel.canCreateGroup ? Color(colors.accentPrimary) : Color(colors.textLowEmphasis)
)
}
.disabled(!viewModel.canCreateGroup)
Expand Down
4 changes: 2 additions & 2 deletions DemoAppSwiftUI/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct DemoUserView: View {
if user.isGuest {
Image(systemName: "person.fill")
.resizable()
.foregroundColor(colors.tintColor)
.foregroundColor(Color(colors.accentPrimary))
.frame(width: imageSize, height: imageSize)
.aspectRatio(contentMode: .fit)
.background(Color(colors.background6))
Expand All @@ -88,7 +88,7 @@ struct DemoUserView: View {

Image(systemName: "arrow.forward")
.renderingMode(.template)
.foregroundColor(colors.tintColor)
.foregroundColor(Color(colors.accentPrimary))
}
}
}
2 changes: 1 addition & 1 deletion DemoAppSwiftUI/PinChannelHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct DemoAppChatChannelListItem: View {
}
.foregroundColor(.black)
.disabled(disabled)
.background(channel.isPinned ? Color(colors.pinnedBackground) : .clear)
.background(channel.isPinned ? Color(colors.pinnedMessageBackground) : .clear)
}

private var subtitleView: some View {
Expand Down
13 changes: 8 additions & 5 deletions DemoAppSwiftUI/WhatsAppChannelHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ struct WhatsAppChannelHeader: ToolbarContent {
chatClient.currentUserId ?? ""
}

private var channelNamer: ChatChannelNamer {
utils.channelNamer
}

private var channelSubtitle: String {
if channel.memberCount <= 2 {
channel.onlineInfoText(currentUserId: currentUserId)
Expand All @@ -54,7 +50,7 @@ struct WhatsAppChannelHeader: ToolbarContent {
size: CGSize(width: 36, height: 36)
)
VStack(alignment: .leading) {
Text(channelNamer(channel, currentUserId) ?? "")
Text(name(for: channel))
.font(fonts.bodyBold)
Text(channelSubtitle)
.font(fonts.caption1)
Expand All @@ -77,4 +73,11 @@ struct WhatsAppChannelHeader: ToolbarContent {
}
}
}

private func name(for channel: ChatChannel) -> String {
utils.channelNameFormatter.format(
channel: channel,
forCurrentUserId: chatClient.currentUserId
) ?? ""
}
}
3 changes: 1 addition & 2 deletions DemoAppSwiftUI/iMessagePocView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ struct iMessagePocView: View {
viewModel.selectedChannel = ChannelSelectionInfo(channel: channel, message: nil)
},
onItemAppear: viewModel.checkForChannels(index:),
channelNaming: viewModel.name(forChannel:),
channelDestination: factory.makeChannelDestination(options: ChannelDestinationOptions()),
trailingSwipeRightButtonTapped: viewModel.onDeleteTapped(channel:),
trailingSwipeLeftButtonTapped: viewModel.onMoreTapped(channel:),
Expand All @@ -78,7 +77,7 @@ struct iMessagePocView: View {
}
.blur(radius: (viewModel.customAlertShown || viewModel.alertShown) ? 6 : 0)
.overlay(viewModel.customAlertShown ? customViewOverlay() : nil)
.accentColor(colors.tintColor)
.accentColor(Color(colors.accentPrimary))
.navigationTitle("Messages")
}
}
Expand Down
23 changes: 1 addition & 22 deletions Sources/StreamChatSwiftUI/Appearance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,9 @@
// Copyright © 2025 Stream.io Inc. All rights reserved.
//

import StreamChatCommonUI
import SwiftUI

/// An object containing visual configuration for the whole application.
@MainActor public class Appearance {
public var colors: ColorPalette
public var images: Images
public var fonts: Fonts

public init(
colors: ColorPalette = ColorPalette(),
images: Images = Images(),
fonts: Fonts = Fonts()
) {
self.colors = colors
self.images = images
self.fonts = fonts
}

/// Provider for custom localization which is dependent on App Bundle.
public static var localizationProvider: @Sendable (_ key: String, _ table: String) -> String = { key, table in
Bundle.streamChatUI.localizedString(forKey: key, value: nil, table: table)
}
}

// MARK: - Appearance + Default

public extension Appearance {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,9 @@ public struct ChannelTitleView: View {
chatClient.currentUserId ?? ""
}

private var channelNamer: ChatChannelNamer {
utils.channelNamer
}

public var body: some View {
VStack(spacing: 2) {
Text(channelNamer(channel, currentUserId) ?? "")
Text(name(for: channel))
.font(fonts.bodyBold)
.foregroundColor(Color(colors.navigationBarTitle))
.accessibilityIdentifier("chatName")
Expand All @@ -179,4 +175,11 @@ public struct ChannelTitleView: View {
}
}
}

private func name(for channel: ChatChannel) -> String {
utils.channelNameFormatter.format(
channel: channel,
forCurrentUserId: chatClient.currentUserId
) ?? ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public struct ChannelNameUpdateView: View {
viewModel.confirmGroupRenaming()
} label: {
Image(systemName: "checkmark")
.foregroundColor(colors.tintColor)
.foregroundColor(Color(colors.accentPrimary))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ struct ChatChannelInfoViewHeaderViewModifier: ViewModifier {
.frame(width: glyphSize, height: glyphSize)
.foregroundColor(Color(colors.navigationBarGlyph))
.padding(.all, 8)
.background(colors.navigationBarTintColor)
.background(Color(colors.navigationBarTintColor))
.clipShape(Circle())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import Combine
import Foundation
import StreamChat
import StreamChatCommonUI
import SwiftUI

// View model for the `ChatChannelInfoView`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct PinnedMessageView<Factory: ViewFactory>: View {
Spacer()

SubtitleText(
text: utils.messageRelativeDateFormatter.string(from: message.createdAt)
text: utils.messageTimestampFormatter.format(message.createdAt)
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/StreamChatSwiftUI/ChatChannel/ChatChannelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public struct ChatChannelView<Factory: ViewFactory>: View, KeyboardReadable {
)
} else {
ZStack {
factory.makeEmptyMessagesView(options: EmptyMessagesViewOptions(channel: channel, colors: colors))
factory.makeEmptyMessagesView(options: EmptyMessagesViewOptions(channel: channel))
.dismissKeyboardOnTap(enabled: keyboardShown) {
hideComposerCommandsAndAttachmentsPicker()
}
Expand Down Expand Up @@ -225,7 +225,7 @@ public struct ChatChannelView<Factory: ViewFactory>: View, KeyboardReadable {
.accessibilityElement(children: .contain)
.accessibilityIdentifier("ChatChannelView")
.modifier(factory.styles.makeBouncedMessageActionsModifier(viewModel: viewModel))
.accentColor(colors.tintColor)
.accentColor(Color(colors.accentPrimary))
}

private var composerView: some View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ import SwiftUI
private var canMarkRead = false
private var hasSetInitialCanMarkRead = false
private var currentUserSentNewMessage = false

private let messageListDateOverlay: DateFormatter = DateFormatter.messageListDateOverlay

private lazy var messagesDateFormatter = utils.dateFormatter
private lazy var messageCachingUtils = utils.messageCachingUtils
Expand Down Expand Up @@ -762,7 +760,7 @@ import SwiftUI
return
}

let dateString = messageListDateOverlay.string(from: currentDate)
let dateString = utils.messageDateSeparatorFormatter.format(currentDate)
if currentDateString != dateString {
currentDateString = dateString
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public struct ComposerInputView<Factory: ViewFactory>: View, KeyboardReadable {
.padding(.horizontal, 8)
.font(fonts.footnoteBold)
.frame(height: 24)
.background(colors.tintColor)
.background(Color(colors.accentPrimary))
.foregroundColor(Color(colors.staticColorText))
.cornerRadius(16)
}
Expand Down Expand Up @@ -510,12 +510,10 @@ public struct ComposerInputView<Factory: ViewFactory>: View, KeyboardReadable {
}

private var composerInputBackground: Color {
var colors = colors
return Color(colors.composerInputBackground)
}

private var highlightedBorder: UIColor {
var colors = colors
return colors.composerInputHighlightedBorder
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

import Photos
import StreamChatCommonUI
import SwiftUI

/// View for the photo attachment picker.
Expand Down Expand Up @@ -222,3 +223,15 @@ public struct PhotoAttachmentCell: View {
return imageSelected(id)
}
}

extension UIImage {
func saveAsJpgToTemporaryUrl() throws -> URL? {
guard let imageData = jpegData(compressionQuality: 1.0) else { return nil }
let imageName = "\(UUID().uuidString).jpg"
let documentDirectory = NSTemporaryDirectory()
let localPath = documentDirectory.appending(imageName)
let photoURL = URL(fileURLWithPath: localPath)
try imageData.write(to: photoURL)
return photoURL
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct SendInChannelView: View {
sendInChannel.toggle()
} label: {
Image(systemName: sendInChannel ? "checkmark.square.fill" : "square")
.foregroundColor(sendInChannel ? colors.tintColor : Color(colors.background7))
.foregroundColor(sendInChannel ? Color(colors.accentPrimary) : Color(colors.background7))
}

Text(isDirectMessage ? L10n.Composer.Checkmark.directMessageReply : L10n.Composer.Checkmark.channelReply)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct InstantCommandsHeader: View {
.renderingMode(.template)
.resizable()
.frame(width: 24, height: 24)
.foregroundColor(colors.tintColor)
.foregroundColor(Color(colors.accentPrimary))
.accessibilityIdentifier("InstantCommandsImage")
Text(L10n.Composer.Suggestions.Commands.header)
.font(fonts.body)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public struct MentionUserView<Factory: ViewFactory>: View {
Spacer()
Text(utils.commandsConfig.mentionsSymbol)
.font(fonts.title)
.foregroundColor(colors.tintColor)
.foregroundColor(Color(colors.accentPrimary))
}
.standardPadding()
.highPriorityGesture(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public struct GalleryView<Factory: ViewFactory>: View {
options: GalleryHeaderViewOptions(
title: author.name ?? "",
subtitle: message.map {
utils.galleryHeaderViewDateFormatter.string(from: $0.createdAt)
utils.galleryHeaderViewDateFormatter.format($0.createdAt)
} ?? author.onlineText,
shown: $isShown
)
Expand Down

This file was deleted.

Loading
Loading