From 9aff9e73127ad40a72d3a8eb2e89db58ee9e49f5 Mon Sep 17 00:00:00 2001 From: Fred Bowker Date: Sun, 6 Aug 2023 12:15:05 +0100 Subject: [PATCH 1/4] allow all images to be changed --- .../ChatUI/Appearance/Appearance.ChatUI.swift | 13 +- Sources/ChatUI/Appearance/Image.ChatUI.swift | 88 ----------- .../Appearance/ImageAppearance.ChatUI.swift | 131 ++++++++++++++++ .../ImageAppearanceScheme.ChatUI.swift | 148 ++++++++++++++++++ .../ChatInChannel/ChannelInfoView.swift | 6 +- .../Camera/View/CameraField.swift | 12 +- .../MessageField/Camera/View/CameraView.swift | 8 +- .../Camera/View/CapturedItemView.swift | 5 +- .../Location/View/LocationSelector.swift | 10 +- .../Location/View/SendLocationButton.swift | 6 +- .../MessageField/MessageField.swift | 17 +- .../MessageField/Mic/View/VoiceField.swift | 8 +- Sources/ChatUI/ChatInChannel/MessageRow.swift | 12 +- .../MessageViews/PhotoStyleView.swift | 9 +- .../MessageViews/VoiceStyleView.swift | 9 +- .../ChatUI/ChatInChannel/ScrollButton.swift | 6 +- .../ChatInChannel/MessageField.Previews.swift | 8 +- 17 files changed, 363 insertions(+), 133 deletions(-) delete mode 100644 Sources/ChatUI/Appearance/Image.ChatUI.swift create mode 100644 Sources/ChatUI/Appearance/ImageAppearance.ChatUI.swift create mode 100644 Sources/ChatUI/Appearance/ImageAppearanceScheme.ChatUI.swift diff --git a/Sources/ChatUI/Appearance/Appearance.ChatUI.swift b/Sources/ChatUI/Appearance/Appearance.ChatUI.swift index 4cc3409..893ee13 100644 --- a/Sources/ChatUI/Appearance/Appearance.ChatUI.swift +++ b/Sources/ChatUI/Appearance/Appearance.ChatUI.swift @@ -1,6 +1,6 @@ // // Color.ChatUI.swift -// +// // // Created by Jaesung Lee on 2023/02/08. // @@ -40,6 +40,7 @@ private struct AppearanceKey: EnvironmentKey { ``` */ public struct Appearance { + // MARK: Predefined Colors /// The main colors used in views provided by ``ChatUI``. The default is `Color(.systemBlue)` public let tint: Color @@ -83,6 +84,9 @@ public struct Appearance { /// Format of the time shown next to a message, default is 12 hour time hh:mm public let messageTimeFormat: String + /// Images used throughout, these are defaulted and can be overridden for both light and dark modes + public let images: ImageAppearanceScheme + public init( tint: Color = Color(.tintColor), primary: Color = Color.primary, @@ -103,6 +107,8 @@ public struct Appearance { footnote: Font = .footnote, title: Font = .headline, subtitle: Font = .footnote, + lightImages: ImageAppearance = ImageAppearance(), + darkImages: ImageAppearance = ImageAppearance(), messageTimeFormat: String = "hh:mm" ) { self.tint = tint @@ -127,5 +133,10 @@ public struct Appearance { self.footnote = footnote self.title = title self.subtitle = subtitle + + // Image + self.images = ImageAppearanceScheme(darkAppearance: darkImages, + lightAppearance: lightImages) } } + diff --git a/Sources/ChatUI/Appearance/Image.ChatUI.swift b/Sources/ChatUI/Appearance/Image.ChatUI.swift deleted file mode 100644 index f509e1e..0000000 --- a/Sources/ChatUI/Appearance/Image.ChatUI.swift +++ /dev/null @@ -1,88 +0,0 @@ -// -// Image.ChatUI.swift -// -// -// Created by Jaesung Lee on 2023/02/08. -// - -/// Defines images used in ``ChatUI``. -/// -/// Use these image names to display icons, avatars, and other images in the chat user interface. -/// -/// Example usage: -/// ``` -/// Image.send -/// .resizable() -/// .frame(width: 100, height: 100) -/// .clipShape(Circle()) -/// ``` - -import SwiftUI - -extension Image { - /// circle.grid.2x2.fill - public static var menu: Image = Image(systemName: "circle.grid.2x2.fill") - - /// camera.fill - public static var camera: Image = Image(systemName: "camera.fill") - - /// photo - public static var photoLibrary: Image = Image(systemName: "photo") - - /// mic.fill - public static var mic: Image = Image(systemName: "mic.fill") - - /// face.smiling.fill - public static var giphy: Image = Image(systemName: "face.smiling.fill") - - /// paperplane.fill - public static var send: Image = Image(systemName: "paperplane.fill") - - /// chevron.right - public static var buttonHidden: Image = Image(systemName: "chevron.right") - - /// chevron.down - public static var directionDown: Image = Image(systemName: "chevron.down") - - /// location.fill - public static var location: Image = Image(systemName: "location.fill") - - /// paperclip - public static var document: Image = Image(systemName: "paperclip") - - /// music.note - public static var music: Image = Image(systemName: "music.note") - - /// circle.dotted - public static var sending: Image = Image(systemName: "circle.dotted") - - /// checkmark.circle - public static var sent: Image = Image(systemName: "checkmark.circle") - - /// checkmark.circle.fill - public static var delivered: Image = Image(systemName: "checkmark.circle.fill") - - /// exclamationmark.circle - public static var failed: Image = Image(systemName: "exclamationmark.circle") - - /// icloud.slash - public static var downloadFailed: Image = Image(systemName: "icloud.slash") - - /// xmark.circle.fill - public static var close: Image = Image(systemName: "xmark.circle.fill") - - /// arrow.triangle.2.circlepath - public static var flip: Image = Image(systemName: "arrow.triangle.2.circlepath") - - /// trash - public static var delete: Image = Image(systemName: "trash") - - /// pause.circle.fill - public static var pause: Image = Image(systemName: "pause.circle.fill") - - /// play.circle.fill - public static var play: Image = Image(systemName: "play.circle.fill") - - /// person.crop.circle.fill - public static var person: Image = Image(systemName: "person.crop.circle.fill") -} diff --git a/Sources/ChatUI/Appearance/ImageAppearance.ChatUI.swift b/Sources/ChatUI/Appearance/ImageAppearance.ChatUI.swift new file mode 100644 index 0000000..21766a5 --- /dev/null +++ b/Sources/ChatUI/Appearance/ImageAppearance.ChatUI.swift @@ -0,0 +1,131 @@ +/// Defines images used in ``ChatUI``. +/// +/// Use these image names to display icons, avatars, and other images in the chat user interface. +/// +/// Example usage: +/// ``` +/// Image.send +/// .resizable() +/// .frame(width: 100, height: 100) +/// .clipShape(Circle()) +/// ``` + +import Foundation +import SwiftUI + +public struct ImageAppearance { + + /// circle.grid.2x2.fill + public let menu: Image + + /// camera.fill + public let camera: Image + + /// photo + public let photoLibrary: Image + + /// mic.fill + public let mic: Image + + /// face.smiling.fill + public let giphy: Image + + /// paperplane.fill + public let send: Image + + /// chevron.right + public let buttonHidden: Image + + /// chevron.down + public let directionDown: Image + + /// location.fill + public let location: Image + + /// paperclip + public let document: Image + + /// music.note + public let music: Image + + /// circle.dotted + public let sending: Image + + /// checkmark.circle + public let sent: Image + + /// checkmark.circle.fill + public let delivered: Image + + /// exclamationmark.circle + public let failed: Image + + /// icloud.slash + public let downloadFailed: Image + + /// xmark.circle.fill + public let close: Image + + /// arrow.triangle.2.circlepath + public let flip: Image + + /// trash + public let delete: Image + + /// pause.circle.fill + public let pause: Image + + /// play.circle.fill + public let play: Image + + /// person.crop.circle.fill + public let person: Image + + public init( + menu: Image = Image(systemName: "circle.grid.2x2.fill"), + camera: Image = Image(systemName: "camera.fill"), + photoLibrary: Image = Image(systemName: "photo"), + mic: Image = Image(systemName: "mic.fill"), + giphy: Image = Image(systemName: "face.smiling.fill"), + send: Image = Image(systemName: "paperplane.fill"), + buttonHidden: Image = Image(systemName: "chevron.right"), + directionDown: Image = Image(systemName: "chevron.down"), + location: Image = Image(systemName: "location.fill"), + document: Image = Image(systemName: "paperclip"), + music: Image = Image(systemName: "music.note"), + sending: Image = Image(systemName: "circle.dotted"), + sent: Image = Image(systemName: "checkmark.circle"), + delivered: Image = Image(systemName: "checkmark.circle.fill"), + failed: Image = Image(systemName: "exclamationmark.circle"), + downloadFailed: Image = Image(systemName: "icloud.slash"), + close: Image = Image(systemName: "xmark.circle.fill"), + flip: Image = Image(systemName: "arrow.triangle.2.circlepath"), + delete: Image = Image(systemName: "trash"), + pause: Image = Image(systemName: "pause.circle.fill"), + play: Image = Image(systemName: "play.circle.fill"), + person: Image = Image(systemName: "person.crop.circle.fill") + ) { + self.menu = menu + self.camera = camera + self.photoLibrary = photoLibrary + self.mic = mic + self.giphy = giphy + self.send = send + self.buttonHidden = buttonHidden + self.directionDown = directionDown + self.location = location + self.document = document + self.music = music + self.sending = sending + self.sent = sent + self.delivered = delivered + self.failed = failed + self.downloadFailed = downloadFailed + self.close = close + self.flip = flip + self.delete = delete + self.pause = pause + self.play = play + self.person = person + } +} diff --git a/Sources/ChatUI/Appearance/ImageAppearanceScheme.ChatUI.swift b/Sources/ChatUI/Appearance/ImageAppearanceScheme.ChatUI.swift new file mode 100644 index 0000000..cf23e2f --- /dev/null +++ b/Sources/ChatUI/Appearance/ImageAppearanceScheme.ChatUI.swift @@ -0,0 +1,148 @@ +import Foundation +import SwiftUI + +public struct ImageAppearanceScheme { + + private let darkAppearance: ImageAppearance + private let lightAppearance: ImageAppearance + + public func getMenu(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.menu + : lightAppearance.menu + } + + public func getCamera(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.camera + : lightAppearance.camera + } + + public func getPhotoLibrary(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.photoLibrary + : lightAppearance.photoLibrary + } + + public func getMic(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.mic + : lightAppearance.mic + } + + public func getGiphy(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.giphy + : lightAppearance.giphy + } + + public func getSend(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.send + : lightAppearance.send + } + + public func getButtonHidden(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.buttonHidden + : lightAppearance.buttonHidden + } + + public func getDirectionDown(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.directionDown + : lightAppearance.directionDown + } + + public func getLocation(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.location + : lightAppearance.location + } + + public func getDocument(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.document + : lightAppearance.document + } + + public func getMusic(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.music + : lightAppearance.music + } + + public func getSending(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.sending + : lightAppearance.sending + } + + public func getSent(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.sent + : lightAppearance.sent + } + + public func getDelivered(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.delivered + : lightAppearance.delivered + } + + public func getFailed(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.failed + : lightAppearance.failed + } + + public func getDownloadFailed(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.downloadFailed + : lightAppearance.downloadFailed + } + + public func getClose(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.close + : lightAppearance.close + } + + public func getFlip(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.flip + : lightAppearance.flip + } + + public func getDelete(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.delete + : lightAppearance.delete + } + + public func getPause(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.pause + : lightAppearance.pause + } + + public func getPlay(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.play + : lightAppearance.play + } + + public func getPerson(_ colorScheme: ColorScheme) -> Image { + return colorScheme == .dark + ? darkAppearance.person + : lightAppearance.person + } + + init(darkAppearance: ImageAppearance, + lightAppearance: ImageAppearance) { + self.darkAppearance = darkAppearance + self.lightAppearance = lightAppearance + } + +} + diff --git a/Sources/ChatUI/ChatInChannel/ChannelInfoView.swift b/Sources/ChatUI/ChatInChannel/ChannelInfoView.swift index fc75e82..7869fa7 100644 --- a/Sources/ChatUI/ChatInChannel/ChannelInfoView.swift +++ b/Sources/ChatUI/ChatInChannel/ChannelInfoView.swift @@ -1,6 +1,6 @@ // // ChannelInfoView.swift -// +// // // Created by Jaesung Lee on 2023/02/09. // @@ -15,6 +15,7 @@ import SwiftUI - The subtitle of the channel */ public struct ChannelInfoView: View { + @Environment(\.colorScheme) var colorScheme @Environment(\.appearance) var appearance let imageURL: URL? @@ -32,7 +33,7 @@ public struct ChannelInfoView: View { .clipShape(Circle()) } } placeholder: { - Image.person.large2 + appearance.images.getPerson(colorScheme).large2 .foregroundColor(appearance.secondary) .clipShape(Circle()) } @@ -55,3 +56,4 @@ public struct ChannelInfoView: View { self.subtitle = subtitle } } + diff --git a/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CameraField.swift b/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CameraField.swift index 397c442..7482253 100644 --- a/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CameraField.swift +++ b/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CameraField.swift @@ -1,6 +1,6 @@ // // CameraField.swift -// +// // // Created by Jaesung Lee on 2023/02/12. // @@ -9,6 +9,7 @@ import SwiftUI import Combine public struct CameraField: View { + @Environment(\.colorScheme) var colorScheme @Environment(\.appearance) var appearance @State private var isCameraViewPresented: Bool = true @@ -26,7 +27,7 @@ public struct CameraField: View { appearance.secondary .overlay { VStack { - Image.downloadFailed.xLarge + appearance.images.getDownloadFailed(colorScheme).xLarge .clipped() Text(String.Message.failedPhoto) @@ -42,7 +43,7 @@ public struct CameraField: View { HStack { Button(action: retake) { - Image.camera.medium + appearance.images.getCamera(colorScheme).medium } .tint(appearance.tint) .frame(width: 36, height: 36) @@ -51,7 +52,7 @@ public struct CameraField: View { Button(action: send) { HStack { - Image.send.xSmall + appearance.images.getSend(colorScheme).xSmall Text("Send") .font(appearance.footnote.bold()) @@ -98,7 +99,8 @@ public struct CameraField: View { sendMessagePublisher.send(style) } receiveValue: { _ in } withAnimation { - isPresented = false + isPresented = false } } } + diff --git a/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CameraView.swift b/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CameraView.swift index 390885c..bc19a01 100644 --- a/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CameraView.swift +++ b/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CameraView.swift @@ -1,6 +1,6 @@ // // CameraView.swift -// +// // // Created by Jaesung Lee on 2023/02/12. // @@ -10,6 +10,7 @@ import CoreImage import AVFoundation public struct CameraView: View { + @Environment(\.colorScheme) var colorScheme @Environment(\.appearance) var appearance @Environment(\.dismiss) private var dismiss @@ -24,14 +25,14 @@ public struct CameraView: View { dismiss() onDismiss() }) { - Image.close.medium + appearance.images.getClose(colorScheme).medium .foregroundColor(appearance.prominent) } Spacer() Button(action: dataModel.switchCaptureDevice) { - Image.flip.medium + appearance.images.getFlip(colorScheme).medium .foregroundColor(appearance.prominent) } } @@ -62,3 +63,4 @@ public struct CameraView: View { self.onDismiss = onDismiss } } + diff --git a/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CapturedItemView.swift b/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CapturedItemView.swift index e2cc5b1..eb276c0 100644 --- a/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CapturedItemView.swift +++ b/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CapturedItemView.swift @@ -1,6 +1,6 @@ // // CapturedItemView.swift -// +// // // Created by Jaesung Lee on 2023/02/12. // @@ -9,6 +9,7 @@ import SwiftUI import Combine public struct CapturedItemView: View { + @Environment(\.colorScheme) var colorScheme @Environment(\.appearance) var appearance let itemType: CaptureType @@ -37,7 +38,7 @@ public struct CapturedItemView: View { Color(uiColor: .secondarySystemBackground) .overlay { VStack { - Image.downloadFailed.xLarge + appearance.images.getDownloadFailed(colorScheme).xLarge Text(String.Message.failedPhoto) .font(appearance.footnote.bold()) diff --git a/Sources/ChatUI/ChatInChannel/MessageField/Location/View/LocationSelector.swift b/Sources/ChatUI/ChatInChannel/MessageField/Location/View/LocationSelector.swift index fad3c53..68eb4d4 100644 --- a/Sources/ChatUI/ChatInChannel/MessageField/Location/View/LocationSelector.swift +++ b/Sources/ChatUI/ChatInChannel/MessageField/Location/View/LocationSelector.swift @@ -1,6 +1,6 @@ // // LocationSelector.swift -// +// // // Created by Jaesung Lee on 2023/02/11. // @@ -11,6 +11,7 @@ import Combine import CoreLocationUI public struct LocationSelector: View { + @Environment(\.colorScheme) var colorScheme @Environment(\.appearance) var appearance @StateObject var dataModel = LocationModel() @@ -71,7 +72,7 @@ public struct LocationSelector: View { // Dimiss button & Search bar HStack { Button(action: dismiss) { - Image.close.medium + appearance.images.getClose(colorScheme).medium } .tint(appearance.tint) .frame(width: 36, height: 36) @@ -97,7 +98,7 @@ public struct LocationSelector: View { .disabled(true) .mask(LinearGradient(gradient: fade, startPoint: .top, endPoint: .bottom)) - Image.location.medium + appearance.images.getLocation(colorScheme).medium .foregroundColor(appearance.prominent) .padding() .background { @@ -176,7 +177,7 @@ public struct LocationSelector: View { func dismiss() { withAnimation { - isPresented = false + isPresented = false } } @@ -184,3 +185,4 @@ public struct LocationSelector: View { self._isPresented = isPresented } } + diff --git a/Sources/ChatUI/ChatInChannel/MessageField/Location/View/SendLocationButton.swift b/Sources/ChatUI/ChatInChannel/MessageField/Location/View/SendLocationButton.swift index fd4e70e..457802a 100644 --- a/Sources/ChatUI/ChatInChannel/MessageField/Location/View/SendLocationButton.swift +++ b/Sources/ChatUI/ChatInChannel/MessageField/Location/View/SendLocationButton.swift @@ -1,6 +1,6 @@ // // SendLocationButton.swift -// +// // // Created by Jaesung Lee on 2023/02/11. // @@ -8,6 +8,7 @@ import SwiftUI struct SendLocationButton: View { + @Environment(\.colorScheme) var colorScheme @Environment(\.appearance) var appearance let action: () -> Void @@ -19,7 +20,7 @@ struct SendLocationButton: View { .foregroundColor(appearance.tint) .frame(width: 48, height: 48) .overlay { - Image.send.medium + appearance.images.getSend(colorScheme).medium .foregroundColor(appearance.prominent) } @@ -37,3 +38,4 @@ struct SendLocationButton: View { self.action = action } } + diff --git a/Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift b/Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift index dc7fd14..3517bb5 100644 --- a/Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift +++ b/Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift @@ -1,6 +1,6 @@ // // MessageField.swift -// +// // // Created by Jaesung Lee on 2023/02/08. // @@ -50,6 +50,7 @@ import PhotosUI public struct MessageField: View { @EnvironmentObject private var configuration: ChatConfiguration + @Environment(\.colorScheme) var colorScheme @Environment(\.appearance) var appearance @FocusState private var isTextFieldFocused: Bool @@ -81,7 +82,7 @@ public struct MessageField: View { HStack(alignment: .bottom) { if isTextFieldFocused, leftSideOptions.count > 1 { Button(action: onTapHiddenButton) { - Image.buttonHidden.medium + appearance.images.getButtonHidden(colorScheme).medium .tint(appearance.tint) } .frame(width: 36, height: 36) @@ -89,7 +90,7 @@ public struct MessageField: View { if options.contains(.menu) { // More Button Button(action: onTapMore) { - Image.menu.medium + appearance.images.getMenu(colorScheme).medium } .tint(appearance.tint) .frame(width: 36, height: 36) @@ -98,7 +99,7 @@ public struct MessageField: View { // Camera Button if options.contains(.camera) { Button(action: onTapCamera) { - Image.camera.medium + appearance.images.getCamera(colorScheme).medium } .tint(appearance.tint) .disabled(isMenuItemPresented) @@ -112,7 +113,7 @@ public struct MessageField: View { matching: .images, photoLibrary: .shared() ) { - Image.photoLibrary.medium + appearance.images.getPhotoLibrary(colorScheme).medium } .tint(appearance.tint) .disabled(isMenuItemPresented) @@ -130,7 +131,7 @@ public struct MessageField: View { // Mic Button if options.contains(.mic) { Button(action: onTapMic) { - Image.mic.medium + appearance.images.getMic(colorScheme).medium } .tint(appearance.tint) .disabled(isMenuItemPresented) @@ -149,7 +150,7 @@ public struct MessageField: View { // Giphy Button if options.contains(.giphy) { Button(action: onTapGiphy) { - Image.giphy.medium + appearance.images.getGiphy(colorScheme).medium } .tint(appearance.tint) .disabled(isMenuItemPresented) @@ -164,7 +165,7 @@ public struct MessageField: View { // Send Button if showsSendButtonAlways || !text.isEmpty { Button(action: onTapSend) { - Image.send.medium + appearance.images.getSend(colorScheme).medium } .frame(width: 36, height: 36) .tint(appearance.tint) diff --git a/Sources/ChatUI/ChatInChannel/MessageField/Mic/View/VoiceField.swift b/Sources/ChatUI/ChatInChannel/MessageField/Mic/View/VoiceField.swift index c67782b..876905f 100644 --- a/Sources/ChatUI/ChatInChannel/MessageField/Mic/View/VoiceField.swift +++ b/Sources/ChatUI/ChatInChannel/MessageField/Mic/View/VoiceField.swift @@ -1,6 +1,6 @@ // // VoiceField.swift -// +// // // Created by Jaesung Lee on 2023/02/13. // @@ -9,6 +9,7 @@ import SwiftUI import Combine public struct VoiceField: View { + @Environment(\.colorScheme) var colorScheme @Environment(\.appearance) var appearance @StateObject private var dataModel = Recorder() @@ -17,7 +18,7 @@ public struct VoiceField: View { public var body: some View { HStack { Button(action: cancel) { - Image.delete.small + appearance.images.getDelete(colorScheme).small .foregroundColor(appearance.secondary) } .buttonStyle(.plain) @@ -40,7 +41,7 @@ public struct VoiceField: View { Spacer() Button(action: dataModel.stopRecording) { - Image.send.small + appearance.images.getSend(colorScheme).small .foregroundColor(appearance.prominent) } .buttonStyle(.plain) @@ -72,3 +73,4 @@ public struct VoiceField: View { isPresented = false } } + diff --git a/Sources/ChatUI/ChatInChannel/MessageRow.swift b/Sources/ChatUI/ChatInChannel/MessageRow.swift index a617e93..61b84a1 100644 --- a/Sources/ChatUI/ChatInChannel/MessageRow.swift +++ b/Sources/ChatUI/ChatInChannel/MessageRow.swift @@ -1,6 +1,6 @@ // // MessageRow.swift -// +// // // Created by Jaesung Lee on 2023/02/08. // @@ -11,6 +11,7 @@ import Combine public struct MessageRow: View { @EnvironmentObject var configuration: ChatConfiguration + @Environment(\.colorScheme) var colorScheme @Environment(\.appearance) var appearance let message: M @@ -113,22 +114,22 @@ public struct MessageRow: View { switch message.readReceipt { case .sending: - Image.sending.xSmall2 + appearance.images.getSending(colorScheme).xSmall2 .clipShape(Circle()) .foregroundColor(appearance.secondary) .padding(.top, 4) case .failed: - Image.failed.xSmall2 + appearance.images.getFailed(colorScheme).xSmall2 .clipShape(Circle()) .foregroundColor(appearance.error) .padding(.top, 4) case .sent: - Image.sent.xSmall2 + appearance.images.getSent(colorScheme).xSmall2 .clipShape(Circle()) .foregroundColor(appearance.tint) .padding(.top, 4) case .delivered: - Image.delivered.xSmall2 + appearance.images.getDelivered(colorScheme).xSmall2 .clipShape(Circle()) .foregroundColor(appearance.tint) .padding(.top, 4) @@ -166,3 +167,4 @@ public struct MessageRow: View { return formatter } } + diff --git a/Sources/ChatUI/ChatInChannel/MessageViews/PhotoStyleView.swift b/Sources/ChatUI/ChatInChannel/MessageViews/PhotoStyleView.swift index 4747dc6..af04200 100644 --- a/Sources/ChatUI/ChatInChannel/MessageViews/PhotoStyleView.swift +++ b/Sources/ChatUI/ChatInChannel/MessageViews/PhotoStyleView.swift @@ -1,6 +1,6 @@ // // PhotoStyleView.swift -// +// // // Created by Jaesung Lee on 2023/02/09. // @@ -8,6 +8,10 @@ import SwiftUI public struct PhotoStyleView: View { + + @Environment(\.colorScheme) var colorScheme + @Environment(\.appearance) var appearance + let data: Data var uiImage: UIImage? { UIImage(data: data) @@ -31,7 +35,7 @@ public struct PhotoStyleView: View { .frame(width: 220, height: 120) .overlay { VStack { - Image.downloadFailed.xLarge + appearance.images.getDownloadFailed(colorScheme).xLarge Text(String.Message.failedPhoto) .font(.footnote.bold()) @@ -44,3 +48,4 @@ public struct PhotoStyleView: View { self.data = data } } + diff --git a/Sources/ChatUI/ChatInChannel/MessageViews/VoiceStyleView.swift b/Sources/ChatUI/ChatInChannel/MessageViews/VoiceStyleView.swift index 1afdb93..052aecc 100644 --- a/Sources/ChatUI/ChatInChannel/MessageViews/VoiceStyleView.swift +++ b/Sources/ChatUI/ChatInChannel/MessageViews/VoiceStyleView.swift @@ -1,6 +1,6 @@ // // VoiceStyleView.swift -// +// // // Created by Jaesung Lee on 2023/02/10. // @@ -50,6 +50,8 @@ class VoicePlayer: NSObject, ObservableObject, AVAudioPlayerDelegate { } public struct VoiceStyleView: View { + @Environment(\.colorScheme) var colorScheme + @Environment(\.appearance) var appearance @StateObject private var dataModel = VoicePlayer() let data: Data @@ -59,9 +61,9 @@ public struct VoiceStyleView: View { Button(action: controlAudioPlayer) { Group { if dataModel.isPlaying { - Image.pause.medium + appearance.images.getPause(colorScheme).medium } else { - Image.play.medium + appearance.images.getPlay(colorScheme).medium } } .foregroundColor(.white) @@ -95,3 +97,4 @@ public struct VoiceStyleView: View { } } } + diff --git a/Sources/ChatUI/ChatInChannel/ScrollButton.swift b/Sources/ChatUI/ChatInChannel/ScrollButton.swift index 4cedf68..3e3ff5f 100644 --- a/Sources/ChatUI/ChatInChannel/ScrollButton.swift +++ b/Sources/ChatUI/ChatInChannel/ScrollButton.swift @@ -1,6 +1,6 @@ // // ScrollButton.swift -// +// // // Created by Jaesung Lee on 2023/02/09. // @@ -9,11 +9,12 @@ import SwiftUI import Combine public struct ScrollButton: View { + @Environment(\.colorScheme) var colorScheme @Environment(\.appearance) var appearance public var body: some View { Button(action: scrollToBotton) { - Image.directionDown.small + appearance.images.getDirectionDown(colorScheme).small .foregroundColor(appearance.tint) .padding(8) .background { @@ -34,3 +35,4 @@ public struct ScrollButton: View { ) } } + diff --git a/Sources/ChatUI/Previews/ChatInChannel/MessageField.Previews.swift b/Sources/ChatUI/Previews/ChatInChannel/MessageField.Previews.swift index 5641338..ae726ba 100644 --- a/Sources/ChatUI/Previews/ChatInChannel/MessageField.Previews.swift +++ b/Sources/ChatUI/Previews/ChatInChannel/MessageField.Previews.swift @@ -1,6 +1,6 @@ // // MessageField.Previews.swift -// +// // // Created by Jaesung Lee on 2023/02/08. // @@ -79,6 +79,7 @@ struct MessageField_Previews: PreviewProvider { } struct MenuItemPreview: View { + @Environment(\.colorScheme) var colorScheme @Environment(\.appearance) var appearance @State private var isMenuItemPresented: Bool = false @@ -112,7 +113,7 @@ struct MessageField_Previews: PreviewProvider { ScrollView(.horizontal, showsIndicators: false) { LazyHStack { Button(action: { }) { - Image.location.large + appearance.images.getLocation(colorScheme).large .foregroundColor(.white) .padding(14) .background { @@ -122,7 +123,7 @@ struct MessageField_Previews: PreviewProvider { } Button(action: { }) { - Image.music.large + appearance.images.getMusic(colorScheme).large .foregroundColor(.white) .padding(14) .background { @@ -155,3 +156,4 @@ struct MessageField_Previews: PreviewProvider { } } } + From dcbefd4e0f9c6324662af157015c3e724bf28268 Mon Sep 17 00:00:00 2001 From: Fred Bowker Date: Sun, 6 Aug 2023 12:16:35 +0100 Subject: [PATCH 2/4] Remove MessageField padding This should be set by the app developer in the view code --- Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift b/Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift index 3517bb5..29f271e 100644 --- a/Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift +++ b/Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift @@ -172,7 +172,6 @@ public struct MessageField: View { .disabled(text.isEmpty) } } - .padding(16) if isVoiceFieldPresented { VoiceField(isPresented: $isVoiceFieldPresented) From 76c856c11b1c97ee54c374e3073569c60cf80ef3 Mon Sep 17 00:00:00 2001 From: Fred Bowker Date: Sun, 6 Aug 2023 13:15:41 +0100 Subject: [PATCH 3/4] Fixed compile error in previous commit, otherwise no change --- .../ChatInChannel/NextMessageField.Previews.swift | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Sources/ChatUI/Previews/ChatInChannel/NextMessageField.Previews.swift b/Sources/ChatUI/Previews/ChatInChannel/NextMessageField.Previews.swift index 90cc8ee..73b9ae3 100644 --- a/Sources/ChatUI/Previews/ChatInChannel/NextMessageField.Previews.swift +++ b/Sources/ChatUI/Previews/ChatInChannel/NextMessageField.Previews.swift @@ -14,6 +14,10 @@ struct NextMessageField_Previews: PreviewProvider { } struct Preview: View { + + private let appearance = Appearance() + + @Environment(\.colorScheme) var colorScheme @State private var pendingMessage: Message? @State private var text: String = "" @@ -38,17 +42,17 @@ struct NextMessageField_Previews: PreviewProvider { } leftLabel: { HStack { Button(action: {}) { - Image.camera.medium + appearance.images.getCamera(colorScheme).medium } .frame(width: 36, height: 36) Button(action: {}) { - Image.photoLibrary.medium + appearance.images.getPhotoLibrary(colorScheme).medium } .frame(width: 36, height: 36) Button(action: {}) { - Image.mic.medium + appearance.images.getMic(colorScheme).medium } .frame(width: 36, height: 36) } @@ -56,11 +60,11 @@ struct NextMessageField_Previews: PreviewProvider { Button { sendMessagePublisher.send(.text(text)) } label: { - Image.send.medium + appearance.images.getSend(colorScheme).medium } .frame(width: 36, height: 36) } - .environment(\.appearance, Appearance()) + .environment(\.appearance, appearance) } } @@ -68,3 +72,4 @@ struct NextMessageField_Previews: PreviewProvider { } + From c3ed9dbff98bbd1cca8645f2f5bb281cabc301a9 Mon Sep 17 00:00:00 2001 From: Jaesung Date: Tue, 15 Aug 2023 01:58:28 +0900 Subject: [PATCH 4/4] [MOD] Renamed a new public interfaces for image assets --- .../ChatUI/Appearance/Appearance.ChatUI.swift | 11 +- .../Appearance/ImageAppearance.ChatUI.swift | 5 +- .../ImageAppearanceScheme.ChatUI.swift | 162 ++++++++++-------- .../ChatInChannel/ChannelInfoView.swift | 3 +- .../Camera/View/CameraField.swift | 7 +- .../MessageField/Camera/View/CameraView.swift | 5 +- .../Camera/View/CapturedItemView.swift | 2 +- .../Location/View/LocationSelector.swift | 5 +- .../Location/View/SendLocationButton.swift | 3 +- .../MessageField/MessageField.swift | 15 +- .../MessageField/Mic/View/VoiceField.swift | 5 +- Sources/ChatUI/ChatInChannel/MessageRow.swift | 9 +- .../MessageViews/PhotoStyleView.swift | 3 +- .../MessageViews/VoiceStyleView.swift | 5 +- .../ChatUI/ChatInChannel/ScrollButton.swift | 3 +- .../ChatInChannel/MessageField.Previews.swift | 5 +- .../NextMessageField.Previews.swift | 9 +- 17 files changed, 130 insertions(+), 127 deletions(-) diff --git a/Sources/ChatUI/Appearance/Appearance.ChatUI.swift b/Sources/ChatUI/Appearance/Appearance.ChatUI.swift index 893ee13..5e06e23 100644 --- a/Sources/ChatUI/Appearance/Appearance.ChatUI.swift +++ b/Sources/ChatUI/Appearance/Appearance.ChatUI.swift @@ -84,8 +84,8 @@ public struct Appearance { /// Format of the time shown next to a message, default is 12 hour time hh:mm public let messageTimeFormat: String - /// Images used throughout, these are defaulted and can be overridden for both light and dark modes - public let images: ImageAppearanceScheme + /// Images used throughout, these are default and can be overridden for both light and dark modes + public let images: ImageAsset public init( tint: Color = Color(.tintColor), @@ -107,8 +107,8 @@ public struct Appearance { footnote: Font = .footnote, title: Font = .headline, subtitle: Font = .footnote, - lightImages: ImageAppearance = ImageAppearance(), - darkImages: ImageAppearance = ImageAppearance(), + lightImages: ChatSymbols = ChatSymbols(), + darkImages: ChatSymbols = ChatSymbols(), messageTimeFormat: String = "hh:mm" ) { self.tint = tint @@ -135,8 +135,7 @@ public struct Appearance { self.subtitle = subtitle // Image - self.images = ImageAppearanceScheme(darkAppearance: darkImages, - lightAppearance: lightImages) + self.images = ImageAsset(lightSymbol: lightImages, darkSymbol: darkImages) } } diff --git a/Sources/ChatUI/Appearance/ImageAppearance.ChatUI.swift b/Sources/ChatUI/Appearance/ImageAppearance.ChatUI.swift index 21766a5..77c3d21 100644 --- a/Sources/ChatUI/Appearance/ImageAppearance.ChatUI.swift +++ b/Sources/ChatUI/Appearance/ImageAppearance.ChatUI.swift @@ -4,7 +4,7 @@ /// /// Example usage: /// ``` -/// Image.send +/// ChatSymbols.send /// .resizable() /// .frame(width: 100, height: 100) /// .clipShape(Circle()) @@ -13,7 +13,7 @@ import Foundation import SwiftUI -public struct ImageAppearance { +public struct ChatSymbols { /// circle.grid.2x2.fill public let menu: Image @@ -81,6 +81,7 @@ public struct ImageAppearance { /// person.crop.circle.fill public let person: Image + /// Creates a new ``ChatSymbols``. public init( menu: Image = Image(systemName: "circle.grid.2x2.fill"), camera: Image = Image(systemName: "camera.fill"), diff --git a/Sources/ChatUI/Appearance/ImageAppearanceScheme.ChatUI.swift b/Sources/ChatUI/Appearance/ImageAppearanceScheme.ChatUI.swift index cf23e2f..37cefb5 100644 --- a/Sources/ChatUI/Appearance/ImageAppearanceScheme.ChatUI.swift +++ b/Sources/ChatUI/Appearance/ImageAppearanceScheme.ChatUI.swift @@ -1,147 +1,163 @@ +/// Provides images from ``ChatSymbols`` with the specific color scheme. +/// +/// The initializer allows to set up the ``ChatSymbols`` for both light and dark mode. +/// +/// Example usage: +/// ``` +/// // To get ``ChatSymbols.send`` for dark mode +/// ImageAsset.send(.dark) +/// // To get ``ChatSybmols.camera`` for light mode +/// ImageAsset.camera(.light) +/// ``` + import Foundation import SwiftUI -public struct ImageAppearanceScheme { +public struct ImageAsset { - private let darkAppearance: ImageAppearance - private let lightAppearance: ImageAppearance + private let darkSymbol: ChatSymbols + private let lightSymbol: ChatSymbols - public func getMenu(_ colorScheme: ColorScheme) -> Image { + public func menu(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.menu - : lightAppearance.menu + ? darkSymbol.menu + : lightSymbol.menu } - public func getCamera(_ colorScheme: ColorScheme) -> Image { + public func camera(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.camera - : lightAppearance.camera + ? darkSymbol.camera + : lightSymbol.camera } - public func getPhotoLibrary(_ colorScheme: ColorScheme) -> Image { + public func photoLibrary(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.photoLibrary - : lightAppearance.photoLibrary + ? darkSymbol.photoLibrary + : lightSymbol.photoLibrary } - public func getMic(_ colorScheme: ColorScheme) -> Image { + public func mic(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.mic - : lightAppearance.mic + ? darkSymbol.mic + : lightSymbol.mic } - public func getGiphy(_ colorScheme: ColorScheme) -> Image { + public func giphy(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.giphy - : lightAppearance.giphy + ? darkSymbol.giphy + : lightSymbol.giphy } - public func getSend(_ colorScheme: ColorScheme) -> Image { + public func send(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.send - : lightAppearance.send + ? darkSymbol.send + : lightSymbol.send } - public func getButtonHidden(_ colorScheme: ColorScheme) -> Image { + public func buttonHidden(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.buttonHidden - : lightAppearance.buttonHidden + ? darkSymbol.buttonHidden + : lightSymbol.buttonHidden } - public func getDirectionDown(_ colorScheme: ColorScheme) -> Image { + public func directionDown(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.directionDown - : lightAppearance.directionDown + ? darkSymbol.directionDown + : lightSymbol.directionDown } - public func getLocation(_ colorScheme: ColorScheme) -> Image { + public func location(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.location - : lightAppearance.location + ? darkSymbol.location + : lightSymbol.location } - public func getDocument(_ colorScheme: ColorScheme) -> Image { + public func document(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.document - : lightAppearance.document + ? darkSymbol.document + : lightSymbol.document } - public func getMusic(_ colorScheme: ColorScheme) -> Image { + public func music(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.music - : lightAppearance.music + ? darkSymbol.music + : lightSymbol.music } - public func getSending(_ colorScheme: ColorScheme) -> Image { + public func sending(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.sending - : lightAppearance.sending + ? darkSymbol.sending + : lightSymbol.sending } - public func getSent(_ colorScheme: ColorScheme) -> Image { + public func sent(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.sent - : lightAppearance.sent + ? darkSymbol.sent + : lightSymbol.sent } - public func getDelivered(_ colorScheme: ColorScheme) -> Image { + public func delivered(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.delivered - : lightAppearance.delivered + ? darkSymbol.delivered + : lightSymbol.delivered } - public func getFailed(_ colorScheme: ColorScheme) -> Image { + public func failed(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.failed - : lightAppearance.failed + ? darkSymbol.failed + : lightSymbol.failed } - public func getDownloadFailed(_ colorScheme: ColorScheme) -> Image { + public func downloadFailed(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.downloadFailed - : lightAppearance.downloadFailed + ? darkSymbol.downloadFailed + : lightSymbol.downloadFailed } - public func getClose(_ colorScheme: ColorScheme) -> Image { + public func close(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.close - : lightAppearance.close + ? darkSymbol.close + : lightSymbol.close } - public func getFlip(_ colorScheme: ColorScheme) -> Image { + public func flip(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.flip - : lightAppearance.flip + ? darkSymbol.flip + : lightSymbol.flip } - public func getDelete(_ colorScheme: ColorScheme) -> Image { + public func delete(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.delete - : lightAppearance.delete + ? darkSymbol.delete + : lightSymbol.delete } - public func getPause(_ colorScheme: ColorScheme) -> Image { + public func pause(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.pause - : lightAppearance.pause + ? darkSymbol.pause + : lightSymbol.pause } - public func getPlay(_ colorScheme: ColorScheme) -> Image { + public func play(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.play - : lightAppearance.play + ? darkSymbol.play + : lightSymbol.play } - public func getPerson(_ colorScheme: ColorScheme) -> Image { + public func person(_ colorScheme: ColorScheme) -> Image { return colorScheme == .dark - ? darkAppearance.person - : lightAppearance.person + ? darkSymbol.person + : lightSymbol.person } - init(darkAppearance: ImageAppearance, - lightAppearance: ImageAppearance) { - self.darkAppearance = darkAppearance - self.lightAppearance = lightAppearance + /// Creates a new ``ImageAsset`` with ``ChatSymbols`` objects. + /// - Parameters: + /// - lightSybmol: ``ChatSymbols`` object that is used for the light mode. + /// - darkSymbol: ``ChatSymbols`` object that is used for the dark mode. + public init(lightSymbol: ChatSymbols, + darkSymbol: ChatSymbols) { + self.lightSymbol = lightSymbol + self.darkSymbol = darkSymbol } } diff --git a/Sources/ChatUI/ChatInChannel/ChannelInfoView.swift b/Sources/ChatUI/ChatInChannel/ChannelInfoView.swift index 7869fa7..5d40eda 100644 --- a/Sources/ChatUI/ChatInChannel/ChannelInfoView.swift +++ b/Sources/ChatUI/ChatInChannel/ChannelInfoView.swift @@ -33,7 +33,7 @@ public struct ChannelInfoView: View { .clipShape(Circle()) } } placeholder: { - appearance.images.getPerson(colorScheme).large2 + appearance.images.person(colorScheme).large2 .foregroundColor(appearance.secondary) .clipShape(Circle()) } @@ -56,4 +56,3 @@ public struct ChannelInfoView: View { self.subtitle = subtitle } } - diff --git a/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CameraField.swift b/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CameraField.swift index 7482253..178a548 100644 --- a/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CameraField.swift +++ b/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CameraField.swift @@ -27,7 +27,7 @@ public struct CameraField: View { appearance.secondary .overlay { VStack { - appearance.images.getDownloadFailed(colorScheme).xLarge + appearance.images.downloadFailed(colorScheme).xLarge .clipped() Text(String.Message.failedPhoto) @@ -43,7 +43,7 @@ public struct CameraField: View { HStack { Button(action: retake) { - appearance.images.getCamera(colorScheme).medium + appearance.images.camera(colorScheme).medium } .tint(appearance.tint) .frame(width: 36, height: 36) @@ -52,7 +52,7 @@ public struct CameraField: View { Button(action: send) { HStack { - appearance.images.getSend(colorScheme).xSmall + appearance.images.send(colorScheme).xSmall Text("Send") .font(appearance.footnote.bold()) @@ -103,4 +103,3 @@ public struct CameraField: View { } } } - diff --git a/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CameraView.swift b/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CameraView.swift index bc19a01..3b21a5b 100644 --- a/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CameraView.swift +++ b/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CameraView.swift @@ -25,14 +25,14 @@ public struct CameraView: View { dismiss() onDismiss() }) { - appearance.images.getClose(colorScheme).medium + appearance.images.close(colorScheme).medium .foregroundColor(appearance.prominent) } Spacer() Button(action: dataModel.switchCaptureDevice) { - appearance.images.getFlip(colorScheme).medium + appearance.images.flip(colorScheme).medium .foregroundColor(appearance.prominent) } } @@ -63,4 +63,3 @@ public struct CameraView: View { self.onDismiss = onDismiss } } - diff --git a/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CapturedItemView.swift b/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CapturedItemView.swift index eb276c0..81eb4a5 100644 --- a/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CapturedItemView.swift +++ b/Sources/ChatUI/ChatInChannel/MessageField/Camera/View/CapturedItemView.swift @@ -38,7 +38,7 @@ public struct CapturedItemView: View { Color(uiColor: .secondarySystemBackground) .overlay { VStack { - appearance.images.getDownloadFailed(colorScheme).xLarge + appearance.images.downloadFailed(colorScheme).xLarge Text(String.Message.failedPhoto) .font(appearance.footnote.bold()) diff --git a/Sources/ChatUI/ChatInChannel/MessageField/Location/View/LocationSelector.swift b/Sources/ChatUI/ChatInChannel/MessageField/Location/View/LocationSelector.swift index 68eb4d4..cb55d80 100644 --- a/Sources/ChatUI/ChatInChannel/MessageField/Location/View/LocationSelector.swift +++ b/Sources/ChatUI/ChatInChannel/MessageField/Location/View/LocationSelector.swift @@ -72,7 +72,7 @@ public struct LocationSelector: View { // Dimiss button & Search bar HStack { Button(action: dismiss) { - appearance.images.getClose(colorScheme).medium + appearance.images.close(colorScheme).medium } .tint(appearance.tint) .frame(width: 36, height: 36) @@ -98,7 +98,7 @@ public struct LocationSelector: View { .disabled(true) .mask(LinearGradient(gradient: fade, startPoint: .top, endPoint: .bottom)) - appearance.images.getLocation(colorScheme).medium + appearance.images.location(colorScheme).medium .foregroundColor(appearance.prominent) .padding() .background { @@ -185,4 +185,3 @@ public struct LocationSelector: View { self._isPresented = isPresented } } - diff --git a/Sources/ChatUI/ChatInChannel/MessageField/Location/View/SendLocationButton.swift b/Sources/ChatUI/ChatInChannel/MessageField/Location/View/SendLocationButton.swift index 457802a..2207f2d 100644 --- a/Sources/ChatUI/ChatInChannel/MessageField/Location/View/SendLocationButton.swift +++ b/Sources/ChatUI/ChatInChannel/MessageField/Location/View/SendLocationButton.swift @@ -20,7 +20,7 @@ struct SendLocationButton: View { .foregroundColor(appearance.tint) .frame(width: 48, height: 48) .overlay { - appearance.images.getSend(colorScheme).medium + appearance.images.send(colorScheme).medium .foregroundColor(appearance.prominent) } @@ -38,4 +38,3 @@ struct SendLocationButton: View { self.action = action } } - diff --git a/Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift b/Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift index 29f271e..a66917d 100644 --- a/Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift +++ b/Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift @@ -82,7 +82,7 @@ public struct MessageField: View { HStack(alignment: .bottom) { if isTextFieldFocused, leftSideOptions.count > 1 { Button(action: onTapHiddenButton) { - appearance.images.getButtonHidden(colorScheme).medium + appearance.images.buttonHidden(colorScheme).medium .tint(appearance.tint) } .frame(width: 36, height: 36) @@ -90,7 +90,7 @@ public struct MessageField: View { if options.contains(.menu) { // More Button Button(action: onTapMore) { - appearance.images.getMenu(colorScheme).medium + appearance.images.menu(colorScheme).medium } .tint(appearance.tint) .frame(width: 36, height: 36) @@ -99,7 +99,7 @@ public struct MessageField: View { // Camera Button if options.contains(.camera) { Button(action: onTapCamera) { - appearance.images.getCamera(colorScheme).medium + appearance.images.camera(colorScheme).medium } .tint(appearance.tint) .disabled(isMenuItemPresented) @@ -113,7 +113,7 @@ public struct MessageField: View { matching: .images, photoLibrary: .shared() ) { - appearance.images.getPhotoLibrary(colorScheme).medium + appearance.images.photoLibrary(colorScheme).medium } .tint(appearance.tint) .disabled(isMenuItemPresented) @@ -131,7 +131,7 @@ public struct MessageField: View { // Mic Button if options.contains(.mic) { Button(action: onTapMic) { - appearance.images.getMic(colorScheme).medium + appearance.images.mic(colorScheme).medium } .tint(appearance.tint) .disabled(isMenuItemPresented) @@ -150,7 +150,7 @@ public struct MessageField: View { // Giphy Button if options.contains(.giphy) { Button(action: onTapGiphy) { - appearance.images.getGiphy(colorScheme).medium + appearance.images.giphy(colorScheme).medium } .tint(appearance.tint) .disabled(isMenuItemPresented) @@ -165,7 +165,7 @@ public struct MessageField: View { // Send Button if showsSendButtonAlways || !text.isEmpty { Button(action: onTapSend) { - appearance.images.getSend(colorScheme).medium + appearance.images.send(colorScheme).medium } .frame(width: 36, height: 36) .tint(appearance.tint) @@ -342,4 +342,3 @@ extension MessageField { ) } } - diff --git a/Sources/ChatUI/ChatInChannel/MessageField/Mic/View/VoiceField.swift b/Sources/ChatUI/ChatInChannel/MessageField/Mic/View/VoiceField.swift index 876905f..668fab8 100644 --- a/Sources/ChatUI/ChatInChannel/MessageField/Mic/View/VoiceField.swift +++ b/Sources/ChatUI/ChatInChannel/MessageField/Mic/View/VoiceField.swift @@ -18,7 +18,7 @@ public struct VoiceField: View { public var body: some View { HStack { Button(action: cancel) { - appearance.images.getDelete(colorScheme).small + appearance.images.delete(colorScheme).small .foregroundColor(appearance.secondary) } .buttonStyle(.plain) @@ -41,7 +41,7 @@ public struct VoiceField: View { Spacer() Button(action: dataModel.stopRecording) { - appearance.images.getSend(colorScheme).small + appearance.images.send(colorScheme).small .foregroundColor(appearance.prominent) } .buttonStyle(.plain) @@ -73,4 +73,3 @@ public struct VoiceField: View { isPresented = false } } - diff --git a/Sources/ChatUI/ChatInChannel/MessageRow.swift b/Sources/ChatUI/ChatInChannel/MessageRow.swift index 61b84a1..c2d1e24 100644 --- a/Sources/ChatUI/ChatInChannel/MessageRow.swift +++ b/Sources/ChatUI/ChatInChannel/MessageRow.swift @@ -114,22 +114,22 @@ public struct MessageRow: View { switch message.readReceipt { case .sending: - appearance.images.getSending(colorScheme).xSmall2 + appearance.images.sending(colorScheme).xSmall2 .clipShape(Circle()) .foregroundColor(appearance.secondary) .padding(.top, 4) case .failed: - appearance.images.getFailed(colorScheme).xSmall2 + appearance.images.failed(colorScheme).xSmall2 .clipShape(Circle()) .foregroundColor(appearance.error) .padding(.top, 4) case .sent: - appearance.images.getSent(colorScheme).xSmall2 + appearance.images.sent(colorScheme).xSmall2 .clipShape(Circle()) .foregroundColor(appearance.tint) .padding(.top, 4) case .delivered: - appearance.images.getDelivered(colorScheme).xSmall2 + appearance.images.delivered(colorScheme).xSmall2 .clipShape(Circle()) .foregroundColor(appearance.tint) .padding(.top, 4) @@ -167,4 +167,3 @@ public struct MessageRow: View { return formatter } } - diff --git a/Sources/ChatUI/ChatInChannel/MessageViews/PhotoStyleView.swift b/Sources/ChatUI/ChatInChannel/MessageViews/PhotoStyleView.swift index af04200..04c33bd 100644 --- a/Sources/ChatUI/ChatInChannel/MessageViews/PhotoStyleView.swift +++ b/Sources/ChatUI/ChatInChannel/MessageViews/PhotoStyleView.swift @@ -35,7 +35,7 @@ public struct PhotoStyleView: View { .frame(width: 220, height: 120) .overlay { VStack { - appearance.images.getDownloadFailed(colorScheme).xLarge + appearance.images.downloadFailed(colorScheme).xLarge Text(String.Message.failedPhoto) .font(.footnote.bold()) @@ -48,4 +48,3 @@ public struct PhotoStyleView: View { self.data = data } } - diff --git a/Sources/ChatUI/ChatInChannel/MessageViews/VoiceStyleView.swift b/Sources/ChatUI/ChatInChannel/MessageViews/VoiceStyleView.swift index 052aecc..0d33c4b 100644 --- a/Sources/ChatUI/ChatInChannel/MessageViews/VoiceStyleView.swift +++ b/Sources/ChatUI/ChatInChannel/MessageViews/VoiceStyleView.swift @@ -61,9 +61,9 @@ public struct VoiceStyleView: View { Button(action: controlAudioPlayer) { Group { if dataModel.isPlaying { - appearance.images.getPause(colorScheme).medium + appearance.images.pause(colorScheme).medium } else { - appearance.images.getPlay(colorScheme).medium + appearance.images.play(colorScheme).medium } } .foregroundColor(.white) @@ -97,4 +97,3 @@ public struct VoiceStyleView: View { } } } - diff --git a/Sources/ChatUI/ChatInChannel/ScrollButton.swift b/Sources/ChatUI/ChatInChannel/ScrollButton.swift index 3e3ff5f..928bda7 100644 --- a/Sources/ChatUI/ChatInChannel/ScrollButton.swift +++ b/Sources/ChatUI/ChatInChannel/ScrollButton.swift @@ -14,7 +14,7 @@ public struct ScrollButton: View { public var body: some View { Button(action: scrollToBotton) { - appearance.images.getDirectionDown(colorScheme).small + appearance.images.directionDown(colorScheme).small .foregroundColor(appearance.tint) .padding(8) .background { @@ -35,4 +35,3 @@ public struct ScrollButton: View { ) } } - diff --git a/Sources/ChatUI/Previews/ChatInChannel/MessageField.Previews.swift b/Sources/ChatUI/Previews/ChatInChannel/MessageField.Previews.swift index ae726ba..0f4bd90 100644 --- a/Sources/ChatUI/Previews/ChatInChannel/MessageField.Previews.swift +++ b/Sources/ChatUI/Previews/ChatInChannel/MessageField.Previews.swift @@ -113,7 +113,7 @@ struct MessageField_Previews: PreviewProvider { ScrollView(.horizontal, showsIndicators: false) { LazyHStack { Button(action: { }) { - appearance.images.getLocation(colorScheme).large + appearance.images.location(colorScheme).large .foregroundColor(.white) .padding(14) .background { @@ -123,7 +123,7 @@ struct MessageField_Previews: PreviewProvider { } Button(action: { }) { - appearance.images.getMusic(colorScheme).large + appearance.images.music(colorScheme).large .foregroundColor(.white) .padding(14) .background { @@ -156,4 +156,3 @@ struct MessageField_Previews: PreviewProvider { } } } - diff --git a/Sources/ChatUI/Previews/ChatInChannel/NextMessageField.Previews.swift b/Sources/ChatUI/Previews/ChatInChannel/NextMessageField.Previews.swift index 73b9ae3..be48d61 100644 --- a/Sources/ChatUI/Previews/ChatInChannel/NextMessageField.Previews.swift +++ b/Sources/ChatUI/Previews/ChatInChannel/NextMessageField.Previews.swift @@ -42,17 +42,17 @@ struct NextMessageField_Previews: PreviewProvider { } leftLabel: { HStack { Button(action: {}) { - appearance.images.getCamera(colorScheme).medium + appearance.images.camera(colorScheme).medium } .frame(width: 36, height: 36) Button(action: {}) { - appearance.images.getPhotoLibrary(colorScheme).medium + appearance.images.photoLibrary(colorScheme).medium } .frame(width: 36, height: 36) Button(action: {}) { - appearance.images.getMic(colorScheme).medium + appearance.images.mic(colorScheme).medium } .frame(width: 36, height: 36) } @@ -60,7 +60,7 @@ struct NextMessageField_Previews: PreviewProvider { Button { sendMessagePublisher.send(.text(text)) } label: { - appearance.images.getSend(colorScheme).medium + appearance.images.send(colorScheme).medium } .frame(width: 36, height: 36) } @@ -72,4 +72,3 @@ struct NextMessageField_Previews: PreviewProvider { } -