Skip to content

Commit

Permalink
🛠 Refactor: Make /Temp Internal
Browse files Browse the repository at this point in the history
Related:
* `TODO:2023-03-28-18-52-17` - Pre-migration to `react-native-ios-utilites`.
* `TODO:2023-03-29-04-34-35` - Copy over `react-native-ios-utilities` native source to `ios/src_library/Temp`.

Summary: Make types marked as `public` in `ios/src_library/Temp/*` as `internal`.
  • Loading branch information
dominicstop committed Mar 28, 2023
1 parent b6c6234 commit 5bff09c
Show file tree
Hide file tree
Showing 30 changed files with 163 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public extension CAGradientLayerType {
internal extension CAGradientLayerType {
init?(string: String){
switch string {
case "axial" : self = .axial;
Expand Down
6 changes: 3 additions & 3 deletions ios/src_library/Temp/Extensions+Init/UIImage+Init.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation
import UIKit

public extension UIImage.RenderingMode {
internal extension UIImage.RenderingMode {
init?(string: String){
switch string {
case "automatic" : self = .automatic;
Expand All @@ -21,7 +21,7 @@ public extension UIImage.RenderingMode {
};

@available(iOS 13.0, *)
public extension UIImage.SymbolWeight {
internal extension UIImage.SymbolWeight {
init?(string: String){
switch string {
case "unspecified": self = .unspecified;
Expand All @@ -41,7 +41,7 @@ public extension UIImage.SymbolWeight {
};

@available(iOS 13.0, *)
public extension UIImage.SymbolScale {
internal extension UIImage.SymbolScale {
init?(string: String){
switch string {
case "default" : self = .`default`;
Expand Down
4 changes: 2 additions & 2 deletions ios/src_library/Temp/Extensions/Encodable+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import Foundation

public struct JSON {
internal struct JSON {
static let encoder = JSONEncoder();
};

public extension Encodable {
internal extension Encodable {
subscript(key: String) -> Any? {
return dictionary[key];
};
Expand Down
2 changes: 1 addition & 1 deletion ios/src_library/Temp/Extensions/UIColor+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ fileprivate class UIColorHelpers {
};
};

public extension UIColor {
internal extension UIColor {

var rgba: (r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat) {
var red : CGFloat = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public extension UIViewController {
internal extension UIViewController {
func attachChildVC(_ child: UIViewController) {
self.addChild(child);
self.view.addSubview(child.view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation
///
/// When a class implements this protocol, it means that it receives a notification from JS-side whenever
/// the component's `componentWillUnmount` lifecycle is triggered.
public protocol RNIJSComponentWillUnmountNotifiable {
internal protocol RNIJSComponentWillUnmountNotifiable {

func notifyOnJSComponentWillUnmount();

Expand Down
2 changes: 1 addition & 1 deletion ios/src_library/Temp/RNICleanup/RNICleanable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
///
/// When a class implements this protocol, it means that the class has "clean-up" related code.
/// This is usually for `UIView` subclasses, and a
public protocol RNICleanable: AnyObject {
internal protocol RNICleanable: AnyObject {

func cleanup();

Expand Down
2 changes: 1 addition & 1 deletion ios/src_library/Temp/RNICleanup/RNICleanupMode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation


/// If a class conforms to `RNICleanable`, this enum determines how the cleanup routine is triggered.
public enum RNICleanupMode: String {
internal enum RNICleanupMode: String {

case automatic;

Expand Down
4 changes: 2 additions & 2 deletions ios/src_library/Temp/RNICleanup/RNIInternalCleanupMode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation


public protocol RNIInternalCleanupMode {
internal protocol RNIInternalCleanupMode {
/// shadow variable for react prop
var synthesizedInternalCleanupMode: RNICleanupMode { get };

Expand All @@ -20,7 +20,7 @@ public protocol RNIInternalCleanupMode {
};

// provide default implementation
public extension RNIInternalCleanupMode {
internal extension RNIInternalCleanupMode {
var shouldEnableAttachToParentVC: Bool {
self.cleanupMode == .viewController
};
Expand Down
16 changes: 8 additions & 8 deletions ios/src_library/Temp/RNIError/RNIError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import Foundation


open class RNIBaseError<E: RawRepresentable>: Error where E.RawValue == String {
internal class RNIBaseError<E: RawRepresentable>: Error where E.RawValue == String {

public var code: E;
public let domain: String;
internal var code: E;
internal let domain: String;

public let message: String?;
public let debug: String?;
internal let message: String?;
internal let debug: String?;

public init(
internal init(
code: E,
domain: String,
message: String? = nil,
Expand All @@ -28,7 +28,7 @@ open class RNIBaseError<E: RawRepresentable>: Error where E.RawValue == String
self.debug = debug;
};

public func createJSONString() -> String? {
internal func createJSONString() -> String? {
let encoder = JSONEncoder();

guard let data = try? encoder.encode(self),
Expand All @@ -48,7 +48,7 @@ extension RNIBaseError: Encodable {
case code, domain, message, debug;
};

public func encode(to encoder: Encoder) throws {
internal func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self);

try container.encode(self.code.rawValue, forKey: .code);
Expand Down
2 changes: 1 addition & 1 deletion ios/src_library/Temp/RNIError/RNIGenericError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation


public class RNIGenericError: RNIBaseError<RNIGenericErrorCode> {
internal class RNIGenericError: RNIBaseError<RNIGenericErrorCode> {

init(
code: RNIGenericErrorCode,
Expand Down
2 changes: 1 addition & 1 deletion ios/src_library/Temp/RNIError/RNIGenericErrorCode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation


public enum RNIGenericErrorCode:
internal enum RNIGenericErrorCode:
String, Codable, CaseIterable, RNIGenericErrorDefaultable {

case runtimeError, libraryError, reactError, unknownError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation


public protocol RNIGenericErrorDefaultable {
internal protocol RNIGenericErrorDefaultable {
static var runtimeError : Self { get };
static var libraryError : Self { get };
static var reactError : Self { get };
Expand Down
32 changes: 16 additions & 16 deletions ios/src_library/Temp/RNIImage/RNIImageGradientMaker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import Foundation
import UIKit


public struct RNIImageGradientMaker {
public enum PointPresets: String {
internal struct RNIImageGradientMaker {
internal enum PointPresets: String {
case top, bottom, left, right;
case bottomLeft, bottomRight, topLeft, topRight;

public var cgPoint: CGPoint {
internal var cgPoint: CGPoint {
switch self {
case .top : return CGPoint(x: 0.5, y: 0.0);
case .bottom: return CGPoint(x: 0.5, y: 1.0);
Expand All @@ -31,7 +31,7 @@ public struct RNIImageGradientMaker {
};
};

public enum DirectionPresets: String {
internal enum DirectionPresets: String {
// horizontal
case leftToRight, rightToLeft;
// vertical
Expand All @@ -40,7 +40,7 @@ public struct RNIImageGradientMaker {
case topLeftToBottomRight, topRightToBottomLeft;
case bottomLeftToTopRight, bottomRightToTopLeft;

public var point: (start: CGPoint, end: CGPoint) {
internal var point: (start: CGPoint, end: CGPoint) {
switch self {
case .leftToRight:
return (CGPoint(x: 0.0, y: 0.5), CGPoint(x: 1.0, y: 1.5));
Expand Down Expand Up @@ -93,17 +93,17 @@ public struct RNIImageGradientMaker {
};
}

public let type: CAGradientLayerType;
internal let type: CAGradientLayerType;

public let colors : [CGColor];
public let locations : [NSNumber]?;
public let startPoint: CGPoint;
public let endPoint : CGPoint;
internal let colors : [CGColor];
internal let locations : [NSNumber]?;
internal let startPoint: CGPoint;
internal let endPoint : CGPoint;

public var size: CGSize;
public let borderRadius: CGFloat;
internal var size: CGSize;
internal let borderRadius: CGFloat;

public var gradientLayer: CALayer {
internal var gradientLayer: CALayer {
let layer = CAGradientLayer();

layer.type = self.type;
Expand All @@ -116,7 +116,7 @@ public struct RNIImageGradientMaker {
return layer;
};

public init?(dict: NSDictionary) {
internal init?(dict: NSDictionary) {
guard let colors = dict["colors"] as? NSArray
else { return nil };

Expand Down Expand Up @@ -155,14 +155,14 @@ public struct RNIImageGradientMaker {
self.borderRadius = dict["borderRadius"] as? CGFloat ?? 0;
};

public mutating func setSizeIfNotSet(_ newSize: CGSize){
internal mutating func setSizeIfNotSet(_ newSize: CGSize){
self.size = CGSize(
width : self.size.width <= 0 ? newSize.width : self.size.width,
height: self.size.height <= 0 ? newSize.height : self.size.height
);
};

public func makeImage() -> UIImage {
internal func makeImage() -> UIImage {
return UIGraphicsImageRenderer(size: self.size).image { context in
let rect = CGRect(origin: .zero, size: self.size);

Expand Down
28 changes: 14 additions & 14 deletions ios/src_library/Temp/RNIImage/RNIImageItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ import Foundation
import UIKit


public class RNIImageItem {
internal class RNIImageItem {

// MARK: - Properties - Config
// ---------------------------

public let type: RNIImageType;
public let imageValue: Any?;
public let imageOptions: RNIImageOptions;
internal let type: RNIImageType;
internal let imageValue: Any?;
internal let imageOptions: RNIImageOptions;

public var defaultSize: CGSize;
internal var defaultSize: CGSize;

// MARK: Properties - Misc
// -----------------------

public let imageConfig: RNIImageConfig;
public var loadedImage: UIImage?;
internal let imageConfig: RNIImageConfig;
internal var loadedImage: UIImage?;

// MARK: Properties - Computed
// ---------------------------

public var baseImage: UIImage? {
internal var baseImage: UIImage? {
switch self.imageConfig {
case let .IMAGE_ASSET(assetName):
return UIImage(named: assetName);
Expand All @@ -55,7 +55,7 @@ public class RNIImageItem {
};
};

public var imageWithTint: UIImage? {
internal var imageWithTint: UIImage? {
guard var image = self.baseImage else { return nil };
guard let tint = self.imageOptions.tint else { return image };

Expand Down Expand Up @@ -87,7 +87,7 @@ public class RNIImageItem {
return image;
};

public var imageWithRoundedEdges: UIImage? {
internal var imageWithRoundedEdges: UIImage? {
guard let image = self.imageWithTint
else { return nil };

Expand All @@ -107,11 +107,11 @@ public class RNIImageItem {
};
};

public var image: UIImage? {
internal var image: UIImage? {
self.imageWithRoundedEdges
};

public var dictionary: [String: Any] {
internal var dictionary: [String: Any] {
var dict: [String: Any] = [
"type": self.type
];
Expand All @@ -126,7 +126,7 @@ public class RNIImageItem {
// MARK: - Init
// -----------

public init?(
internal init?(
type: RNIImageType,
imageValue: Any?,
imageOptions: NSDictionary?,
Expand Down Expand Up @@ -198,7 +198,7 @@ public class RNIImageItem {
self.imageOptions = RNIImageOptions(dict: imageOptions ?? [:]);
};

public convenience init?(dict: NSDictionary){
internal convenience init?(dict: NSDictionary){
guard let typeString = dict["type"] as? String,
let type = RNIImageType(rawValue: typeString)
else { return nil };
Expand Down
10 changes: 5 additions & 5 deletions ios/src_library/Temp/RNIImage/RNIImageLoadingConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
import Foundation


public protocol RNIImageLoadingConfigurable {
internal protocol RNIImageLoadingConfigurable {
var shouldCache: Bool? { get };
var shouldLazyLoad: Bool? { get };
};

// TODO: Per file defaults via extension
public struct RNIImageLoadingConfig: RNIImageLoadingConfigurable {
internal struct RNIImageLoadingConfig: RNIImageLoadingConfigurable {

public let shouldCache: Bool?;
public let shouldLazyLoad: Bool?;
internal let shouldCache: Bool?;
internal let shouldLazyLoad: Bool?;

public init(dict: NSDictionary) {
internal init(dict: NSDictionary) {
self.shouldCache = dict["shouldCache"] as? Bool;
self.shouldLazyLoad = dict["shouldLazyLoad"] as? Bool;
};
Expand Down
Loading

0 comments on commit 5bff09c

Please sign in to comment.