diff --git a/demo/src/StorageDemo.ts b/demo/src/StorageDemo.ts index 36d7586a..a25717be 100644 --- a/demo/src/StorageDemo.ts +++ b/demo/src/StorageDemo.ts @@ -7,10 +7,9 @@ class StorageDemo extends Panel { stored!: Text update() { - storage(context).getItem(storedKey).then(e => { - this.stored.text = '12345' - loge('set Text') - modal(context).toast('current in then:' + this.stored.isDirty()) + storage(context).getItem(storedKey, zone).then(e => { + this.stored.text = e || "" + log('Called in then') }) } @@ -42,8 +41,41 @@ class StorageDemo extends Panel { textColor: Color.WHITE, layoutConfig: layoutConfig().exactly(), onClick: () => { - storage(context).setItem(storedKey, 'This is my stored value').then(e => { - log('Stored') + storage(context).getItem(storedKey, zone).then(e => { + modal(context).prompt({ + text: e, + title: "Please input text to store", + defaultText: "Default Value", + }).then(text => { + storage(context).setItem(storedKey, text, zone).then(() => { + this.update() + }) + }) + }) + }, + } as IText), + label('remove value').apply({ + width: 200, + height: 50, + bgColor: colors[0], + textSize: 30, + textColor: Color.WHITE, + layoutConfig: layoutConfig().exactly(), + onClick: () => { + storage(context).remove(storedKey, zone).then(e => { + this.update() + }) + }, + } as IText), + label('clear values').apply({ + width: 200, + height: 50, + bgColor: colors[0], + textSize: 30, + textColor: Color.WHITE, + layoutConfig: layoutConfig().exactly(), + onClick: () => { + storage(context).clear(zone).then(e => { this.update() }) }, @@ -55,6 +87,7 @@ class StorageDemo extends Panel { } as IVLayout)).apply({ layoutConfig: layoutConfig().atmost(), }).in(root) + this.update() } } \ No newline at end of file diff --git a/iOS/Pod/Classes/Plugin/DoricShaderPlugin.m b/iOS/Pod/Classes/Plugin/DoricShaderPlugin.m index 73c796e8..a5039ef6 100644 --- a/iOS/Pod/Classes/Plugin/DoricShaderPlugin.m +++ b/iOS/Pod/Classes/Plugin/DoricShaderPlugin.m @@ -31,6 +31,9 @@ @implementation DoricShaderPlugin - (void)render:(NSDictionary *)argument { + if(!argument) { + return; + } __weak typeof(self) _self = self; dispatch_async(dispatch_get_main_queue(), ^{ __strong typeof(_self) self = _self; diff --git a/iOS/Pod/Classes/Plugin/DoricStoragePlugin.m b/iOS/Pod/Classes/Plugin/DoricStoragePlugin.m index c0f00c7d..95be9b1d 100644 --- a/iOS/Pod/Classes/Plugin/DoricStoragePlugin.m +++ b/iOS/Pod/Classes/Plugin/DoricStoragePlugin.m @@ -33,6 +33,7 @@ - (instancetype)initWithContext:(DoricContext *)doricContext { if (self = [super initWithContext:doricContext]) { _basePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"doric"]; + _cachedMap = [NSMutableDictionary new]; } return self; } diff --git a/js-framework/src/util/nativeModules.ts b/js-framework/src/util/nativeModules.ts index fb4ce699..9673b4e7 100644 --- a/js-framework/src/util/nativeModules.ts +++ b/js-framework/src/util/nativeModules.ts @@ -163,7 +163,7 @@ export function storage(context: BridgeContext) { return context.storage.remove({ key, zone }) }, clear: (zone: string) => { - return context.storage.clear(zone) + return context.storage.clear({ zone }) }, } } \ No newline at end of file