This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface SwiftUIStoreViewViewManager : RCTViewManager | |
@end | |
@implementation SwiftUIStoreViewViewManager | |
/... | |
RCT_EXPORT_VIEW_PROPERTY(productIDs, NSArray<NSString *>) | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const productIDs = ["com.swiftui.montly.storeview", "com.swiftui.yearly.storeview"]; | |
export default function App() { | |
return ( | |
<SwiftUIStoreViewView style={styles.container} productIDs={productIDs} /> | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<SwiftUIStoreViewView style={styles.storeView} productIDs={["Test"]} /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@objc public class StoreViewProvider: UIView { | |
// ... | |
@objc public var productIDs: [String] = [] { | |
didSet { | |
props.productIDs = productIDs | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps | |
{ | |
const auto &oldViewProps = *std::static_pointer_cast<SwiftUIStoreViewViewProps const>(_props); | |
const auto &newViewProps = *std::static_pointer_cast<SwiftUIStoreViewViewProps const>(props); | |
if (oldViewProps.productIDs != newViewProps.productIDs) { | |
NSMutableArray *productIds = [[NSMutableArray alloc] initWithCapacity:newViewProps.productIDs.size()]; | |
for (auto &productId : newViewProps.productIDs) { | |
[productIds addObject:[NSString stringWithUTF8String:productId.c_str()]]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface NativeProps extends ViewProps { | |
productIDs: string[]; // <- productIds | |
} | |
export default codegenNativeComponent<NativeProps>('SwiftUIStoreViewView'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { StyleSheet } from 'react-native'; | |
import { SwiftUIStoreViewView } from 'swiftui-store-view'; | |
export default function App() { | |
return ( | |
<SwiftUIStoreViewView style={styles.container} /> | |
); | |
} | |
const styles = StyleSheet.create({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface SwiftUIStoreViewViewManager : RCTViewManager | |
@end | |
@implementation SwiftUIStoreViewViewManager | |
RCT_EXPORT_MODULE(SwiftUIStoreViewView) | |
- (UIView *)view | |
{ | |
return [[StoreViewProvider alloc] init]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (instancetype)initWithFrame:(CGRect)frame | |
{ | |
if (self = [super initWithFrame:frame]) { | |
static const auto defaultProps = std::make_shared<const SwiftUIStoreViewViewProps>(); | |
_props = defaultProps; | |
_view = [[StoreViewProvider alloc] init]; | |
self.contentView = _view; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation SwiftUIStoreViewView { | |
StoreViewProvider* _view; | |
} |
NewerOlder