syrjs / core

Light Dynamic UI Engine for Native and Web with a React Like API
http://syr.js.org
MIT License
56 stars 24 forks source link

updates syr to take dynamic values for bundles and resourceS #216

Closed dmikey closed 6 years ago

dmikey commented 6 years ago

Syr can now use dynamic paths for JS Bundles, as well as Dynamic paths for Resources on iOS.

How this works.

[[SyrRootView alloc] initWithBundlePath:filePath initialProperties:appProps withResourceBundlePath:pyplBundlePath];

initWithBundlePath now works as expected. the path passed to this will be loaded.

withResourceBundlePath is new, provide a bundle resource path where assets/images should be loaded. It is still on component authors, to ensure they are looking for resources.

Authors should do a fall through like so

// check main bundle/xcassets for an image to load
 image = [UIImage imageNamed:source];
// no image loaded, check resourceBundlePath 
 if(image == nil) {
   NSString* resourceBundlePath = [[[SyrRaster sharedInstance] bridge] resourceBundlePath];
   NSBundle* bundle = [[NSBundle alloc] initWithPath:resourceBundlePath];
   image = [UIImage imageNamed:source inBundle:bundle compatibleWithTraitCollection:nil];
 }