diff --git a/Package.swift b/Package.swift index d012ec3..c90e161 100644 --- a/Package.swift +++ b/Package.swift @@ -18,15 +18,19 @@ let package = Package( .package(url: "https://github.com/Giphy/giphy-ios-sdk", .upToNextMajor(from: "2.1.3")) ], targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages this package depends on. - .target( - name: "ChatUI", - dependencies: [ - .product(name: "GiphyUISDK", package: "giphy-ios-sdk") - ]), - .testTarget( - name: "ChatUITests", - dependencies: ["ChatUI"]), - ] + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "ChatUI", + dependencies: [ + .product(name: "GiphyUISDK", package: "giphy-ios-sdk") + ], + resources: [ + .process("Resources") + ] + ), + .testTarget( + name: "ChatUITests", + dependencies: ["ChatUI"]), + ] ) diff --git a/Sources/ChatUI/ChatInChannel/MessageField/Giphy/View/GiphyAttributionMarkView.swift b/Sources/ChatUI/ChatInChannel/MessageField/Giphy/View/GiphyAttributionMarkView.swift new file mode 100644 index 0000000..0eaf948 --- /dev/null +++ b/Sources/ChatUI/ChatInChannel/MessageField/Giphy/View/GiphyAttributionMarkView.swift @@ -0,0 +1,32 @@ +import SwiftUI + +class CustomTabBarController: UITabBarController { + var tabBarHeight: CGFloat { + tabBar.frame.size.height + } +} + +struct GiphyAttributionMarkView: View { + + private let PADDING_ABOVE_TAB = 2.5 + + @Environment(\.colorScheme) private var colorScheme + + var body: some View { + VStack { + Spacer() + HStack { + Spacer() + Image(getImageName() , bundle: .module) + .padding(.bottom, CustomTabBarController().tabBarHeight + PADDING_ABOVE_TAB) + } + } + } + + private func getImageName() -> String { + colorScheme == .dark + ? "Poweredby_100px-Black_VertText" + : "Poweredby_100px-White_VertText" + } +} + diff --git a/Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift b/Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift index a66917d..5fa1094 100644 --- a/Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift +++ b/Sources/ChatUI/ChatInChannel/MessageField/MessageField.swift @@ -183,15 +183,21 @@ public struct MessageField: View { } .sheet(isPresented: $isGIFPickerPresented) { if let giphyKey = configuration.giphyKey { - GiphyPicker( - giphyKey: giphyKey, - giphyConfig: configuration.giphyConfig - ) - .ignoresSafeArea() - .presentationDetents( - [.fraction(configuration.giphyConfig.presentationDetents)] - ) - .presentationDragIndicator(.hidden) + ZStack { + GiphyPicker( + giphyKey: giphyKey, + giphyConfig: configuration.giphyConfig + ) + .ignoresSafeArea() + .presentationDetents( + [.fraction(configuration.giphyConfig.presentationDetents)] + ) + .presentationDragIndicator(.hidden) + + if (configuration.giphyConfig.showsAttributionMark) { + GiphyAttributionMarkView() + } + } } else { Text("No Giphy Key") } diff --git a/Sources/ChatUI/Essentials/GiphyConfiguration.swift b/Sources/ChatUI/Essentials/GiphyConfiguration.swift index 2ab8932..ff8c676 100644 --- a/Sources/ChatUI/Essentials/GiphyConfiguration.swift +++ b/Sources/ChatUI/Essentials/GiphyConfiguration.swift @@ -7,18 +7,24 @@ public struct GiphyConfiguration { public let shouldLocalizeSearch: Bool public let mediaTypeConfig: [GiphyUISDK.GPHContentType] public let presentationDetents: CGFloat + + /// When moving from beta key to production key 'Giphy' asks to clearly display "Powered By GIPHY" attribution marks where the API is utilized. + /// setting this value to true will show the attribution mark on the giphy select display. + public let showsAttributionMark: Bool public init( dimBackground: Bool = false, showConfirmationScreen: Bool = false, shouldLocalizeSearch: Bool = false, mediaTypeConfig: [GiphyUISDK.GPHContentType] = [.gifs, .stickers, .recents], - presentationDetents: CGFloat = 0.9 + presentationDetents: CGFloat = 0.9, + showsAttributionMark: Bool = false ) { self.dimBackground = dimBackground self.showConfirmationScreen = showConfirmationScreen self.shouldLocalizeSearch = shouldLocalizeSearch self.mediaTypeConfig = mediaTypeConfig self.presentationDetents = presentationDetents + self.showsAttributionMark = showsAttributionMark } -} \ No newline at end of file +} diff --git a/Sources/ChatUI/Resources/Media.xcassets/Contents.json b/Sources/ChatUI/Resources/Media.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Sources/ChatUI/Resources/Media.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Contents.json b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Contents.json b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Contents.json b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Dark Backgrounds/Contents.json b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Dark Backgrounds/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Dark Backgrounds/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Dark Backgrounds/Poweredby_100px-Black_VertText.imageset/Contents.json b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Dark Backgrounds/Poweredby_100px-Black_VertText.imageset/Contents.json new file mode 100644 index 0000000..3dcbc3d --- /dev/null +++ b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Dark Backgrounds/Poweredby_100px-Black_VertText.imageset/Contents.json @@ -0,0 +1,9 @@ +{ + "images" : [ + + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Dark Backgrounds/Poweredby_100px-Black_VertText.imageset/Poweredby_100px-Black_VertText.png b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Dark Backgrounds/Poweredby_100px-Black_VertText.imageset/Poweredby_100px-Black_VertText.png new file mode 100644 index 0000000..e20ee1b Binary files /dev/null and b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Dark Backgrounds/Poweredby_100px-Black_VertText.imageset/Poweredby_100px-Black_VertText.png differ diff --git a/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Light Backgrounds/Contents.json b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Light Backgrounds/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Light Backgrounds/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Light Backgrounds/Poweredby_100px-White_VertText.imageset/Contents.json b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Light Backgrounds/Poweredby_100px-White_VertText.imageset/Contents.json new file mode 100644 index 0000000..3dcbc3d --- /dev/null +++ b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Light Backgrounds/Poweredby_100px-White_VertText.imageset/Contents.json @@ -0,0 +1,9 @@ +{ + "images" : [ + + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Light Backgrounds/Poweredby_100px-White_VertText.imageset/Poweredby_100px-White_VertText.png b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Light Backgrounds/Poweredby_100px-White_VertText.imageset/Poweredby_100px-White_VertText.png new file mode 100644 index 0000000..629da47 Binary files /dev/null and b/Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Light Backgrounds/Poweredby_100px-White_VertText.imageset/Poweredby_100px-White_VertText.png differ