feat:set UIRectEdgeNone for iOS
This commit is contained in:
parent
c5caf074cb
commit
7bef2fbd68
@ -1,4 +1,4 @@
|
|||||||
import { Group, Panel, navbar, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout, Gravity, hlayout, Text, scroller, layoutConfig, image, IView, IVLayout, ScaleType, modal, IText, network } from "doric";
|
import { Group, Panel, navbar, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout, Gravity, hlayout, Text, scroller, layoutConfig, image, IView, IVLayout, ScaleType, modal, IText, network, navigator } from "doric";
|
||||||
import { title, label, colors } from "./utils";
|
import { title, label, colors } from "./utils";
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@ -62,6 +62,17 @@ class NavbarDemo extends Panel {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} as IText),
|
} as IText),
|
||||||
|
label('Pop').apply({
|
||||||
|
width: 200,
|
||||||
|
height: 50,
|
||||||
|
bgColor: colors[0],
|
||||||
|
textSize: 30,
|
||||||
|
textColor: Color.WHITE,
|
||||||
|
layoutConfig: layoutConfig().exactly(),
|
||||||
|
onClick: () => {
|
||||||
|
navigator(context).pop()
|
||||||
|
}
|
||||||
|
} as IText),
|
||||||
]).apply({
|
]).apply({
|
||||||
layoutConfig: layoutConfig().atmost().h(LayoutSpec.WRAP_CONTENT),
|
layoutConfig: layoutConfig().atmost().h(LayoutSpec.WRAP_CONTENT),
|
||||||
gravity: gravity().center(),
|
gravity: gravity().center(),
|
||||||
|
@ -86,7 +86,7 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:
|
|||||||
NSString *result = qrObject.stringValue;
|
NSString *result = qrObject.stringValue;
|
||||||
NSLog(@"Scan result is %@", result);
|
NSLog(@"Scan result is %@", result);
|
||||||
[[DoricDriver instance] connectDevKit:[NSString stringWithFormat:@"ws://%@:7777", result]];
|
[[DoricDriver instance] connectDevKit:[NSString stringWithFormat:@"ws://%@:7777", result]];
|
||||||
showToast([NSString stringWithFormat:@"Connected to %@", result], BOTTOM);
|
ShowToast([NSString stringWithFormat:@"Connected to %@", result], BOTTOM);
|
||||||
[self.navigationController popViewControllerAnimated:NO];
|
[self.navigationController popViewControllerAnimated:NO];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,19 @@ @implementation DoricPanel
|
|||||||
- (void)config:(NSString *)script alias:(NSString *)alias {
|
- (void)config:(NSString *)script alias:(NSString *)alias {
|
||||||
self.doricContext = [[[DoricContext alloc] initWithScript:script source:alias] also:^(DoricContext *it) {
|
self.doricContext = [[[DoricContext alloc] initWithScript:script source:alias] also:^(DoricContext *it) {
|
||||||
[it.rootNode setupRootView:[[DoricStackView new] also:^(DoricStackView *it) {
|
[it.rootNode setupRootView:[[DoricStackView new] also:^(DoricStackView *it) {
|
||||||
it.width = self.view.width;
|
|
||||||
it.height = self.view.height;
|
|
||||||
[self.view addSubview:it];
|
[self.view addSubview:it];
|
||||||
}]];
|
}]];
|
||||||
[it initContextWithWidth:self.view.width height:self.view.height];
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)viewWillLayoutSubviews {
|
||||||
|
[super viewWillLayoutSubviews];
|
||||||
|
[self.doricContext.rootNode.view also:^(DoricStackView *it) {
|
||||||
|
if (it.width != self.view.width || it.height != self.view.height) {
|
||||||
|
it.width = self.view.width;
|
||||||
|
it.height = self.view.height;
|
||||||
|
[self.doricContext initContextWithWidth:it.width height:it.height];
|
||||||
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,10 +23,16 @@
|
|||||||
#import "DoricPanel.h"
|
#import "DoricPanel.h"
|
||||||
#import "UIView+Doric.h"
|
#import "UIView+Doric.h"
|
||||||
#import "DoricExtensions.h"
|
#import "DoricExtensions.h"
|
||||||
|
#import "DoricUtil.h"
|
||||||
|
|
||||||
|
@interface DoricViewController ()
|
||||||
|
@property(nonatomic, strong) DoricPanel *doricPanel;
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation DoricViewController
|
@implementation DoricViewController
|
||||||
- (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias {
|
- (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias {
|
||||||
if (self = [super init]) {
|
if (self = [super init]) {
|
||||||
|
self.edgesForExtendedLayout = UIRectEdgeNone;
|
||||||
DoricAsyncResult <NSString *> *result = [DoricJSLoaderManager.instance request:scheme];
|
DoricAsyncResult <NSString *> *result = [DoricJSLoaderManager.instance request:scheme];
|
||||||
result.resultCallback = ^(NSString *result) {
|
result.resultCallback = ^(NSString *result) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
@ -34,20 +40,26 @@ - (instancetype)initWithScheme:(NSString *)scheme alias:(NSString *)alias {
|
|||||||
[panel.view also:^(UIView *it) {
|
[panel.view also:^(UIView *it) {
|
||||||
it.backgroundColor = [UIColor whiteColor];
|
it.backgroundColor = [UIColor whiteColor];
|
||||||
it.width = self.view.width;
|
it.width = self.view.width;
|
||||||
it.height = self.view.height - 88;
|
it.height = self.view.height;
|
||||||
it.top = 88;
|
|
||||||
}];
|
}];
|
||||||
[self.view addSubview:panel.view];
|
[self.view addSubview:panel.view];
|
||||||
[self addChildViewController:panel];
|
[self addChildViewController:panel];
|
||||||
[panel config:result alias:alias];
|
[panel config:result alias:alias];
|
||||||
panel.doricContext.navigator = self;
|
panel.doricContext.navigator = self;
|
||||||
panel.doricContext.navBar = self;
|
panel.doricContext.navBar = self;
|
||||||
|
self.doricPanel = panel;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)viewWillLayoutSubviews {
|
||||||
|
[super viewWillLayoutSubviews];
|
||||||
|
self.doricPanel.view.width = self.view.width;
|
||||||
|
self.doricPanel.view.height = self.view.height;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)doric_navigator_push:(NSString *)scheme alias:(NSString *)alias animated:(BOOL)animated {
|
- (void)doric_navigator_push:(NSString *)scheme alias:(NSString *)alias animated:(BOOL)animated {
|
||||||
DoricViewController *viewController = [[DoricViewController alloc] initWithScheme:scheme alias:alias];
|
DoricViewController *viewController = [[DoricViewController alloc] initWithScheme:scheme alias:alias];
|
||||||
[self.navigationController pushViewController:viewController animated:animated];
|
[self.navigationController pushViewController:viewController animated:animated];
|
||||||
@ -70,7 +82,7 @@ - (void)doric_navBar_setTitle:(NSString *)title {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)doric_navBar_setBackgroundColor:(UIColor *)color {
|
- (void)doric_navBar_setBackgroundColor:(UIColor *)color {
|
||||||
[self.navigationController.navigationBar setBackgroundColor:color];
|
[self.navigationController.navigationBar setBackgroundImage:UIImageWithColor(color) forBarMetrics:UIBarMetricsDefault];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ - (void)toast:(NSDictionary *)dic withPromise:(DoricPromise *)promise {
|
|||||||
[dic[@"gravity"] also:^(NSNumber *it) {
|
[dic[@"gravity"] also:^(NSNumber *it) {
|
||||||
gravity = (DoricGravity) [it integerValue];
|
gravity = (DoricGravity) [it integerValue];
|
||||||
}];
|
}];
|
||||||
showToast(dic[@"msg"], gravity);
|
ShowToast(dic[@"msg"], gravity);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,4 +37,6 @@ NSBundle *_Nonnull DoricBundle(void);
|
|||||||
#define DC_UNLOCK(lock) dispatch_semaphore_signal(lock);
|
#define DC_UNLOCK(lock) dispatch_semaphore_signal(lock);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void showToast(NSString *_Nonnull text, DoricGravity gravity);
|
void ShowToast(NSString *_Nonnull text, DoricGravity gravity);
|
||||||
|
|
||||||
|
UIImage *_Nonnull UIImageWithColor(UIColor *color);
|
@ -48,7 +48,7 @@ void DoricLog(NSString *_Nonnull format, ...) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void showToast(NSString *text, DoricGravity gravity) {
|
void ShowToast(NSString *text, DoricGravity gravity) {
|
||||||
UIView *superView = [UIApplication sharedApplication].windows.lastObject;
|
UIView *superView = [UIApplication sharedApplication].windows.lastObject;
|
||||||
UILabel *label = [[UILabel alloc] init];
|
UILabel *label = [[UILabel alloc] init];
|
||||||
label.font = [UIFont systemFontOfSize:20.f];
|
label.font = [UIFont systemFontOfSize:20.f];
|
||||||
@ -74,4 +74,15 @@ void showToast(NSString *text, DoricGravity gravity) {
|
|||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
[label removeFromSuperview];
|
[label removeFromSuperview];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UIImage *UIImageWithColor(UIColor *color) {
|
||||||
|
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
|
||||||
|
UIGraphicsBeginImageContext(rect.size);
|
||||||
|
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||||
|
CGContextSetFillColorWithColor(context, [color CGColor]);
|
||||||
|
CGContextFillRect(context, rect);
|
||||||
|
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
|
||||||
|
UIGraphicsEndImageContext();
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user