feat:storage plugin done
This commit is contained in:
parent
b19a3e32f3
commit
4835030ef3
@ -7,10 +7,9 @@ class StorageDemo extends Panel {
|
|||||||
stored!: Text
|
stored!: Text
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
storage(context).getItem(storedKey).then(e => {
|
storage(context).getItem(storedKey, zone).then(e => {
|
||||||
this.stored.text = '12345'
|
this.stored.text = e || ""
|
||||||
loge('set Text')
|
log('Called in then')
|
||||||
modal(context).toast('current in then:' + this.stored.isDirty())
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,8 +41,41 @@ class StorageDemo extends Panel {
|
|||||||
textColor: Color.WHITE,
|
textColor: Color.WHITE,
|
||||||
layoutConfig: layoutConfig().exactly(),
|
layoutConfig: layoutConfig().exactly(),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
storage(context).setItem(storedKey, 'This is my stored value').then(e => {
|
storage(context).getItem(storedKey, zone).then(e => {
|
||||||
log('Stored')
|
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()
|
this.update()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -55,6 +87,7 @@ class StorageDemo extends Panel {
|
|||||||
} as IVLayout)).apply({
|
} as IVLayout)).apply({
|
||||||
layoutConfig: layoutConfig().atmost(),
|
layoutConfig: layoutConfig().atmost(),
|
||||||
}).in(root)
|
}).in(root)
|
||||||
|
this.update()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -31,6 +31,9 @@
|
|||||||
@implementation DoricShaderPlugin
|
@implementation DoricShaderPlugin
|
||||||
|
|
||||||
- (void)render:(NSDictionary *)argument {
|
- (void)render:(NSDictionary *)argument {
|
||||||
|
if(!argument) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
__weak typeof(self) _self = self;
|
__weak typeof(self) _self = self;
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
__strong typeof(_self) self = _self;
|
__strong typeof(_self) self = _self;
|
||||||
|
@ -33,6 +33,7 @@ - (instancetype)initWithContext:(DoricContext *)doricContext {
|
|||||||
if (self = [super initWithContext:doricContext]) {
|
if (self = [super initWithContext:doricContext]) {
|
||||||
_basePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
|
_basePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
|
||||||
stringByAppendingPathComponent:@"doric"];
|
stringByAppendingPathComponent:@"doric"];
|
||||||
|
_cachedMap = [NSMutableDictionary new];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ export function storage(context: BridgeContext) {
|
|||||||
return context.storage.remove({ key, zone })
|
return context.storage.remove({ key, zone })
|
||||||
},
|
},
|
||||||
clear: (zone: string) => {
|
clear: (zone: string) => {
|
||||||
return context.storage.clear(zone)
|
return context.storage.clear({ zone })
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user