Skip to content

Commit

Permalink
fix(iOS): issues with ios in rn versions starting from 0.73.0 and onw…
Browse files Browse the repository at this point in the history
…ards

fix #161
  • Loading branch information
ALexanderLonsky committed Jan 4, 2024
1 parent c9a89fb commit 41df28f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 46 deletions.
64 changes: 32 additions & 32 deletions ios/RTNGiphyTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,141 +52,141 @@ private func deserializeRNConfig(_ rawConfig: NSDictionary?) -> NSDictionary {
return config
}

public class RTNGiphyTheme: GPHTheme {
class RTNGiphyTheme: GPHTheme {
var config: NSDictionary

public init(rnConfig: NSDictionary?) {
init(rnConfig: NSDictionary?) {
config = deserializeRNConfig(rnConfig)
super.init()
type = config["preset"] as? GPHThemeType ?? .light
}

// MARK: - Dialog's Handle
public override var handleBarColor: UIColor {
override var handleBarColor: UIColor {
config["handleBarColor"] as? UIColor ?? super.handleBarColor
}

// MARK: - Emoji Drawer
public override var emojiDrawerScrollIndicatorStyle: UIScrollView.IndicatorStyle {
override var emojiDrawerScrollIndicatorStyle: UIScrollView.IndicatorStyle {
config["emojiDrawerScrollIndicatorStyle"] as? UIScrollView.IndicatorStyle ?? super.emojiDrawerScrollIndicatorStyle
}

public override var emojiDrawerGradientTopColor: UIColor {
override var emojiDrawerGradientTopColor: UIColor {
config["emojiDrawerGradientTopColor"] as? UIColor ?? super.emojiDrawerGradientTopColor
}

public override var emojiDrawerGradientBottomColor: UIColor {
override var emojiDrawerGradientBottomColor: UIColor {
config["emojiDrawerGradientBottomColor"] as? UIColor ?? super.emojiDrawerGradientBottomColor
}

public override var emojiDrawerSeparatorColor: UIColor {
override var emojiDrawerSeparatorColor: UIColor {
config["emojiDrawerSeparatorColor"] as? UIColor ?? super.emojiDrawerSeparatorColor
}

// MARK: - Search Bar
public override var searchBackButtonColor: UIColor {
override var searchBackButtonColor: UIColor {
config["searchBackButtonColor"] as? UIColor ?? super.searchBackButtonColor
}

public override var searchPlaceholderTextColor: UIColor {
override var searchPlaceholderTextColor: UIColor {
config["searchPlaceholderTextColor"] as? UIColor ?? super.searchPlaceholderTextColor
}

public override var searchTextColor: UIColor {
override var searchTextColor: UIColor {
config["searchTextColor"] as? UIColor ?? super.searchTextColor
}

public override var searchBarBackgroundColor: UIColor {
override var searchBarBackgroundColor: UIColor {
config["searchBarBackgroundColor"] as? UIColor ?? super.searchBarBackgroundColor
}

public override var searchBarPadding: CGFloat {
override var searchBarPadding: CGFloat {
config["searchBarPadding"] as? CGFloat ?? super.searchBarPadding
}

public override var searchBarCornerRadius: CGFloat {
override var searchBarCornerRadius: CGFloat {
config["searchBarCornerRadius"] as? CGFloat ?? super.searchBarCornerRadius
}

// MARK: - Suggestions
public override var showSuggestionsBar: Bool {
override var showSuggestionsBar: Bool {
config["showSuggestionsBar"] as? Bool ?? super.showSuggestionsBar
}

public override var suggestionCellBackgroundColor: UIColor {
override var suggestionCellBackgroundColor: UIColor {
config["suggestionCellBackgroundColor"] as? UIColor ?? super.suggestionCellBackgroundColor
}

public override var suggestionCellTextColor: UIColor {
override var suggestionCellTextColor: UIColor {
config["suggestionCellTextColor"] as? UIColor ?? super.suggestionCellTextColor
}

// MARK: - Tab Bar
public override var tabBarSwitchSelectedColor: UIColor {
override var tabBarSwitchSelectedColor: UIColor {
config["tabBarSwitchSelectedColor"] as? UIColor ?? super.tabBarSwitchSelectedColor
}

public override var tabBarSwitchDefaultColor: UIColor? {
override var tabBarSwitchDefaultColor: UIColor? {
config["tabBarSwitchDefaultColor"] as? UIColor ?? super.tabBarSwitchDefaultColor
}

public override var tabBarBackgroundAlpha: CGFloat {
override var tabBarBackgroundAlpha: CGFloat {
config["tabBarBackgroundAlpha"] as? CGFloat ?? super.tabBarBackgroundAlpha
}

// MARK: - Confirmation
public override var confirmationSelectButtonColor: UIColor {
override var confirmationSelectButtonColor: UIColor {
config["confirmationSelectButtonColor"] as? UIColor ?? super.confirmationSelectButtonColor
}

public override var confirmationSelectButtonTextColor: UIColor {
override var confirmationSelectButtonTextColor: UIColor {
config["confirmationSelectButtonTextColor"] as? UIColor ?? super.confirmationSelectButtonTextColor
}

public override var usernameColor: UIColor {
override var usernameColor: UIColor {
config["usernameColor"] as? UIColor ?? super.usernameColor
}

public override var confirmationBackButtonColor: UIColor {
override var confirmationBackButtonColor: UIColor {
config["confirmationBackButtonColor"] as? UIColor ?? super.confirmationBackButtonColor
}

public override var confirmationViewOnGiphyColor: UIColor {
override var confirmationViewOnGiphyColor: UIColor {
config["confirmationViewOnGiphyColor"] as? UIColor ?? super.confirmationViewOnGiphyColor
}

public override var avatarPlaceholderColor: UIColor {
override var avatarPlaceholderColor: UIColor {
config["avatarPlaceholderColor"] as? UIColor ?? super.avatarPlaceholderColor
}

// MARK: - Grid Content
public override var cellCornerRadius: CGFloat {
override var cellCornerRadius: CGFloat {
config["cellCornerRadius"] as? CGFloat ?? super.cellCornerRadius
}

public override var stickerBackgroundColor: UIColor {
override var stickerBackgroundColor: UIColor {
config["stickerBackgroundColor"] as? UIColor ?? super.stickerBackgroundColor
}

public override var fixedSizeCells: Bool {
override var fixedSizeCells: Bool {
config["fixedSizeCells"] as? Bool ?? super.fixedSizeCells
}

public override var backgroundColorForLoadingCells: UIColor {
override var backgroundColorForLoadingCells: UIColor {
config["backgroundColorForLoadingCells"] as? UIColor ?? super.backgroundColorForLoadingCells
}

// MARK: - Keyboard
public override var keyboardAppearance: UIKeyboardAppearance {
override var keyboardAppearance: UIKeyboardAppearance {
config["keyboardAppearance"] as? UIKeyboardAppearance ?? super.keyboardAppearance
}

// MARK: - Other
public override var backgroundColor: UIColor {
override var backgroundColor: UIColor {
config["backgroundColor"] as? UIColor ?? super.backgroundColor
}

public override var defaultTextColor: UIColor {
override var defaultTextColor: UIColor {
config["defaultTextColor"] as? UIColor ?? super.defaultTextColor
}
}
28 changes: 14 additions & 14 deletions ios/Utils/RTNGiphyTypeExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import UIKit

import GiphyUISDK

public extension GPHContentType {
extension GPHContentType {
static func fromRNValue(value: String?) -> GPHContentType? {
switch value {
case "emoji":
Expand All @@ -23,7 +23,7 @@ public extension GPHContentType {
}
}

public extension GPHRatingType {
extension GPHRatingType {
static func fromRNValue(value: String?) -> GPHRatingType? {
switch value {
case "g":
Expand All @@ -44,7 +44,7 @@ public extension GPHRatingType {
}
}

public extension GPHRenditionType {
extension GPHRenditionType {
static func fromRNValue(value: String?) -> GPHRenditionType? {
switch value {
case "original":
Expand Down Expand Up @@ -91,7 +91,7 @@ public extension GPHRenditionType {
}
}

public extension GPHStickerColumnCount {
extension GPHStickerColumnCount {
static func fromRNValue(value: Int?) -> GPHStickerColumnCount? {
switch value {
case 2:
Expand All @@ -106,7 +106,7 @@ public extension GPHStickerColumnCount {
}
}

public extension GPHFileExtension {
extension GPHFileExtension {
static func fromRNValue(value: String) -> GPHFileExtension? {
switch value {
case "gif":
Expand All @@ -121,7 +121,7 @@ public extension GPHFileExtension {
}
}

public extension UICollectionView.ScrollDirection {
extension UICollectionView.ScrollDirection {
static func fromRNValue(value: String) -> UICollectionView.ScrollDirection {
switch value {
case "horizontal":
Expand All @@ -134,7 +134,7 @@ public extension UICollectionView.ScrollDirection {
}
}

public extension UIKeyboardAppearance {
extension UIKeyboardAppearance {
static func fromRNValue(_ value: String) -> UIKeyboardAppearance? {
switch value {
case "default":
Expand All @@ -149,7 +149,7 @@ public extension UIKeyboardAppearance {
}
}

public extension UIScrollView.IndicatorStyle {
extension UIScrollView.IndicatorStyle {
static func fromRNValue(_ value: String) -> UIScrollView.IndicatorStyle? {
switch value {
case "default":
Expand All @@ -164,13 +164,13 @@ public extension UIScrollView.IndicatorStyle {
}
}

public extension GPHMediaType {
extension GPHMediaType {
static func fromRNValue(value: String) -> GPHMediaType {
return GPHMediaType.init(rawValue: value) ?? .gif
}
}

public extension GPHContent {
extension GPHContent {
static func fromRNValue(value: NSDictionary) -> GPHContent {
let requestType = value["requestType"] as? String
let searchQuery = value["searchQuery"] as? String ?? ""
Expand All @@ -193,7 +193,7 @@ public extension GPHContent {
}
}

public enum RNGPHVideoPlayerState: Int {
enum RNGPHVideoPlayerState: Int {
case unknown = 0
case readyToPlay = 3
case playing = 4
Expand All @@ -204,7 +204,7 @@ public enum RNGPHVideoPlayerState: Int {
}
}

public extension GPHVideoPlayerState {
extension GPHVideoPlayerState {
func toRNValue() -> Int {
var rnState: RNGPHVideoPlayerState {
switch self {
Expand All @@ -224,7 +224,7 @@ public extension GPHVideoPlayerState {
}
}

public extension GPHThemeType {
extension GPHThemeType {
static func fromRNValue(_ value: String) -> GPHThemeType? {
switch value {
case "automatic":
Expand All @@ -239,7 +239,7 @@ public extension GPHThemeType {
}
}

public extension GiphyViewController {
extension GiphyViewController {
func applyRNConfig(_ options: NSDictionary) -> Void {
if let rawMediaTypeConfig = options["mediaTypeConfig"] as? [String] {
mediaTypeConfig = rawMediaTypeConfig.compactMap {
Expand Down

0 comments on commit 41df28f

Please sign in to comment.