From 4fa94f0acdd3d0b2f527c9d06deb53950348fcb4 Mon Sep 17 00:00:00 2001 From: Fred Bowker Date: Sun, 10 Sep 2023 10:27:06 +0100 Subject: [PATCH] Added powered by giphy attribution mark --- Package.swift | 26 ++++++++------ .../Giphy/View/GiphyAttributionMarkView.swift | 32 ++++++++++++++++++ .../MessageField/MessageField.swift | 24 ++++++++----- .../Essentials/GiphyConfiguration.swift | 10 ++++-- .../Resources/Media.xcassets/Contents.json | 6 ++++ .../Giphy Attribution Marks/Contents.json | 6 ++++ .../Static Logos/Contents.json | 6 ++++ .../Static Logos/Small/Contents.json | 6 ++++ .../Small/Dark Backgrounds/Contents.json | 6 ++++ .../Contents.json | 9 +++++ .../Poweredby_100px-Black_VertText.png | Bin 0 -> 1427 bytes .../Small/Light Backgrounds/Contents.json | 6 ++++ .../Contents.json | 9 +++++ .../Poweredby_100px-White_VertText.png | Bin 0 -> 1483 bytes 14 files changed, 124 insertions(+), 22 deletions(-) create mode 100644 Sources/ChatUI/ChatInChannel/MessageField/Giphy/View/GiphyAttributionMarkView.swift create mode 100644 Sources/ChatUI/Resources/Media.xcassets/Contents.json create mode 100644 Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Contents.json create mode 100644 Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Contents.json create mode 100644 Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Contents.json create mode 100644 Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Dark Backgrounds/Contents.json create mode 100644 Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Dark Backgrounds/Poweredby_100px-Black_VertText.imageset/Contents.json create mode 100644 Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Dark Backgrounds/Poweredby_100px-Black_VertText.imageset/Poweredby_100px-Black_VertText.png create mode 100644 Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Light Backgrounds/Contents.json create mode 100644 Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Light Backgrounds/Poweredby_100px-White_VertText.imageset/Contents.json create mode 100644 Sources/ChatUI/Resources/Media.xcassets/Giphy Attribution Marks/Static Logos/Small/Light Backgrounds/Poweredby_100px-White_VertText.imageset/Poweredby_100px-White_VertText.png 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 0000000000000000000000000000000000000000..e20ee1b28978d8c6a76895102541e275f3b2ed88 GIT binary patch literal 1427 zcmV;E1#J3>P){>Bz+d2?dgBI`>b@LXD-lEZ4)Gb@nty|r#qu(!R`VZW#Th%RF-OZ!DX;e0C z<-=P%GMl$N3OFK%EAL3kmYo7R;EqM)OcR8lI`h z7}<5&=R2c!=y@BfDg3*F_q~9$hBC)^2G3RyxK98I{p=0Ay99?UU=?!8+F!%s+vho2 z)QIsR)=$Zf^4Q5?4Rz$)DXhT;zJPU(0H_q^ZbCDJ?jXF&reM54V65OhJK+QtqhQ=P+J@ohjIz z!t)(rhTs~a!I=s`z`G+y4plIThV)b@*bNF`j>Z#atPvK^0iw~4t0E{{vU7+0m;~Az zAu6)jzk~7jC}Y;#8hsgJcl8JvYvmQ$RW2&Xkb^baaT6G~j@s1E5Fk`$D-Xu zBlawPfaeV47fDAI+Wew7$hS-8h)75r0%g7W@9OsG9 zdQk@y&VuR4RD_R~W;ow`G$gI*&xWa`tN^_=svrHL;a!)FHS-xdPmHwll}0mWPM6#Y z>vZ|JhG%oZk6f@>GoPtl@B1jr7U0iD&jWVtIlQ}Ovf|(Q{_j z5X_LdONLeMA#e@ zW(Up;A3brkuWwlcD{xeQ-XVVMIfT1rD9Jk^MZ1i=VLgU?20a9IwbXRspsskT>Hvr$ zyYMP-C-o(B;eP5EqQQrsf#9jGfSe+@A@rmPtzHO}aV%-)`epR3@XjWQI0D1~Qk)Q! z(DwV`$bi_6RP9Su5+Jp3&$CA9x^WcK%jC3j%%*};*Y|y>N;-$A0M4$_MWfaE34wTk zvr$NPe1Y?mOE(?oSHeLu*%y$SIrv;W!;Yy9;6KUJkMjO{c`3B3uGa7aEPjzZU4PqO zru3O1Z%*7)oE(q^@bLw6k#>~~(u~Pwmqd4srlMaN+I(O8c3QU5eTOh%EN2 z%dZi@{D7KL4&jZLm|vZw$jfTFZ;j_LZHddT+ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..629da47542ca8fc412457051e7e4b160de4a0437 GIT binary patch literal 1483 zcmV;+1vL7JP)|3Fd+dvF;ItB&-1_1^E1_1#D1_gl!59SjN_A~kkg@p$T4+aJl7!(8)1QZwq z7z7v?7qZl$%?aguAtn#o*juh&{V=}9Z+X0NZW!6a`-W@7;|o6TZ;ZPc92 zWZDq{fpIfte62o(y622>q588@pM)9rQ;ni8RZ#s~Fhu0FW|P@U6rEzMYU z{2=IEsp|)IJyqXR=K2}WZyal(^XTibbxrG3s_TW|fZRRi*+=zxkLxYg*y28_^LKT= zrZ>Oy1W+6By_z(_aYn$<3#iDrOpVijOPmYU@d8Rk7^7uD=1<6?E|CQca*1diQyAX& z*=vBJK?n^1u!jMou)zp0*eU9!JtkWdgC**?Ax72Scp}Emu%Hz@u)%QxV^a`xM4SMY z(WkW3IOu3|sQKH|Ej{OiM*mogL$r|!M1F$kkF{=w6&N{y2|}z}+ayMGo&dm7eLrKq z-wYx}Ug&}R35EUnNKe3EkIRI)Lc`jvutQaS3 z;UozRJag* z!aXUO=LEh@9CT&QQQ#|P9kCT9KeVS?j$zY8)gvD`qfXN`))HbZrqC&|_8Qc+bWxQL zAasJ7R9Ge#=#bT+Uy>ZMVis&b3<(9Et!S%-lDX{2AvFxMf=9PP~jg3IJUD267rTBwZ9WRWcc!bRmS<}@HI-~dCV z0pA}z@2g;!X{SE5P9}L9fFN-v7SB#maZ5mu>@p3 zaCHfuF9n^Sgo9vmLw`-tUmbRP5c+NGeSJ2DIyY>EN$uWGhN>fH799(7 zM0WpZK*SalSjQf!OA^OD1)PQ3cRg@z8912KAl-RaS(xzSfQ4-Y@4S|1{hpxjRRmGL zcdVD|{B9jRv)l_16Az&fzh6 zz;|a~?vN9sKz{czmh7Y`MW@-&{6-k};@W724ysx^COim9e~WM&8;k?9*^-j%8cuSp zDA65NL0z`p_I>9JgMUL(kKB;oShpSWMsNvL z_1YNTI$4e&$G$J2MvRie;RLy_KB0sAQ-(HTQ$y?i4#Vr8?g>VpDh8A$?Ij*N=*RW! zjc`5~1CUaP2wh)4zpax4U<&LkACUgyi}W`;meyB);+vncEl!x2C7N z0fP6_5-16JMz_?n`X7z&o7DFsl#pdG$vA+ZRC~U_sHIQ+JxPy!2tfIQP1z>s*NShD zWG66&bRaxl;YMVGmIx6c{%i(`pX(Ksqa>YEp~{k8`6isxb>%OI-rm18 ln0|HguSUouw~=203;^Y_wOS?=%K`uZ002ovPDHLkV1iU7qP_qC literal 0 HcmV?d00001