Skip to content

Commit

Permalink
🛠 Refactor: Remove RNIComputableValue
Browse files Browse the repository at this point in the history
Summary: Remove `RNIComputableValue`, and related types.
  • Loading branch information
dominicstop committed Apr 28, 2023
1 parent 24e9a0c commit 7942f50
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 451 deletions.

This file was deleted.

34 changes: 34 additions & 0 deletions ios/src_library/React Native/RNIComputable/RNIComputableSize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,40 @@ public struct RNIComputableSize {
height: offsetHeight ?? size.height
);
};

func compute(
withTargetSize targetSize: CGSize,
currentSize: CGSize
) -> CGSize {
switch self.mode {
case .current:
return currentSize;

case .stretch:
return targetSize;

case let .constant(constantWidth, constantHeight):
return CGSize(width: constantWidth, height: constantHeight);

case let .percent(percentWidth, percentHeight):
return CGSize(
width: percentWidth * targetSize.width,
height: percentHeight * targetSize.height
);
};
};

func computeWithOffsets(
withTargetSize targetSize: CGSize,
currentSize: CGSize
) -> CGSize {
let computedSize = self.compute(
withTargetSize: targetSize,
currentSize: currentSize
);

return self.computeOffsets(withSize: computedSize);
};
};

extension RNIComputableSize {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
import Foundation

public enum RNIComputableSizeMode {
case unspecified;
case current;
case stretch;
case constant(constantWidth: Double, constantHeight: Double);
case percent(percentWidth: Double, percentHeight: Double);
case function(valueFunction: String);
};

extension RNIComputableSizeMode {
Expand Down Expand Up @@ -47,10 +45,6 @@ extension RNIComputableSizeMode {
percentHeight: height.doubleValue
);

case "function":
guard let value = dict["valueFunction"] as? String else { return nil };
self = .function(valueFunction: value);

default:
return nil;
};
Expand Down

This file was deleted.

Loading

0 comments on commit 7942f50

Please sign in to comment.