diff --git a/doric-iOS/Devkit/Classes/DoricDev.m b/doric-iOS/Devkit/Classes/DoricDev.m index 522f9602..a9e981b2 100644 --- a/doric-iOS/Devkit/Classes/DoricDev.m +++ b/doric-iOS/Devkit/Classes/DoricDev.m @@ -95,20 +95,20 @@ - (void)sendDevCommand:(NSString *)command { } - (void)onOpenEvent { - ShowToast(@"dev kit connected", BOTTOM); + ShowToast(@"dev kit connected", DoricBottom); } - (void)onEOFEvent { - ShowToast(@"dev kit eof exception", BOTTOM); + ShowToast(@"dev kit eof exception", DoricBottom); } - (void)onConnectExceptionEvent { - ShowToast(@"dev kit connection exception", BOTTOM); + ShowToast(@"dev kit connection exception", DoricBottom); } - (void)onStartDebugEvent:(NSNotification *)notification { NSString *contextId = notification.object; - ShowToast(contextId, BOTTOM); + ShowToast(contextId, DoricBottom); for (NSValue *value in [[DoricContextManager instance] aliveContexts]) { DoricContext *context = value.nonretainedObjectValue; BOOL result = [context.contextId compare:contextId] == NSOrderedSame; diff --git a/doric-iOS/Devkit/Classes/DoricDevViewController.m b/doric-iOS/Devkit/Classes/DoricDevViewController.m index 10cbb6d1..7727dc45 100644 --- a/doric-iOS/Devkit/Classes/DoricDevViewController.m +++ b/doric-iOS/Devkit/Classes/DoricDevViewController.m @@ -53,7 +53,7 @@ - (void)viewDidLoad { NSString *result = @"127.0.0.1"; [DoricJSRemoteExecutor configIp:result]; [[DoricDev instance] connectDevKit:[NSString stringWithFormat:@"ws://%@:7777", result]]; - ShowToast([NSString stringWithFormat:@"Connected to %@", result], BOTTOM); + ShowToast([NSString stringWithFormat:@"Connected to %@", result], DoricBottom); } else { [self.navigationController pushViewController:[QRScanViewController new] animated:NO]; } diff --git a/doric-iOS/Devkit/Classes/QRScanViewController.m b/doric-iOS/Devkit/Classes/QRScanViewController.m index a5ec5536..f649bbeb 100644 --- a/doric-iOS/Devkit/Classes/QRScanViewController.m +++ b/doric-iOS/Devkit/Classes/QRScanViewController.m @@ -106,7 +106,7 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects: NSLog(@"Scan result is %@", result); [[DoricDev instance] connectDevKit:[NSString stringWithFormat:@"ws://%@:7777", result]]; [DoricJSRemoteExecutor configIp:result]; - ShowToast([NSString stringWithFormat:@"Connected to %@", result], BOTTOM); + ShowToast([NSString stringWithFormat:@"Connected to %@", result], DoricBottom); [self.navigationController popViewControllerAnimated:NO]; } } diff --git a/doric-iOS/Example/Example/DemoLibrary.m b/doric-iOS/Example/Example/DemoLibrary.m index 72b1df4b..e29e0b74 100644 --- a/doric-iOS/Example/Example/DemoLibrary.m +++ b/doric-iOS/Example/Example/DemoLibrary.m @@ -12,7 +12,7 @@ @interface DoricDemoPlugin : DoricNativePlugin @implementation DoricDemoPlugin - (void)test { dispatch_async(dispatch_get_main_queue(), ^{ - ShowToast(@"Test called", CENTER); + ShowToast(@"Test called", DoricCenter); }); } @end diff --git a/doric-iOS/Pod/Classes/Plugin/DoricModalPlugin.m b/doric-iOS/Pod/Classes/Plugin/DoricModalPlugin.m index e9596994..cc95d219 100644 --- a/doric-iOS/Pod/Classes/Plugin/DoricModalPlugin.m +++ b/doric-iOS/Pod/Classes/Plugin/DoricModalPlugin.m @@ -28,7 +28,7 @@ @implementation DoricModalPlugin - (void)toast:(NSDictionary *)dic withPromise:(DoricPromise *)promise { dispatch_async(dispatch_get_main_queue(), ^{ - __block DoricGravity gravity = BOTTOM; + __block DoricGravity gravity = DoricBottom; [dic[@"gravity"] also:^(NSNumber *it) { gravity = (DoricGravity) [it integerValue]; }]; diff --git a/doric-iOS/Pod/Classes/Shader/DoricInputNode.m b/doric-iOS/Pod/Classes/Shader/DoricInputNode.m index 1b666bda..11983ded 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricInputNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricInputNode.m @@ -51,9 +51,9 @@ - (void)blendView:(UITextView *)view forPropName:(NSString *)name propValue:(id) } else if ([name isEqualToString:@"textAlignment"]) { DoricGravity gravity = (DoricGravity) [(NSNumber *) prop integerValue]; NSTextAlignment alignment = NSTextAlignmentCenter; - if ((gravity & LEFT) == LEFT) { + if ((gravity & DoricGravityLeft) == DoricGravityLeft) { alignment = NSTextAlignmentLeft; - } else if ((gravity & RIGHT) == RIGHT) { + } else if ((gravity & DoricGravityRight) == DoricGravityRight) { alignment = NSTextAlignmentRight; } view.textAlignment = alignment; diff --git a/doric-iOS/Pod/Classes/Shader/DoricLayouts.h b/doric-iOS/Pod/Classes/Shader/DoricLayouts.h index 6bbf858d..f909f614 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricLayouts.h +++ b/doric-iOS/Pod/Classes/Shader/DoricLayouts.h @@ -33,18 +33,18 @@ typedef NS_ENUM(NSInteger, DoricLayoutSpec) { }; typedef NS_ENUM(NSInteger, DoricGravity) { - SPECIFIED = 1, - START = 1 << 1, - END = 1 << 2, - SHIFT_X = 0, - SHIFT_Y = 4, - LEFT = (START | SPECIFIED) << SHIFT_X, - RIGHT = (END | SPECIFIED) << SHIFT_X, - TOP = (START | SPECIFIED) << SHIFT_Y, - BOTTOM = (END | SPECIFIED) << SHIFT_Y, - CENTER_X = SPECIFIED << SHIFT_X, - CENTER_Y = SPECIFIED << SHIFT_Y, - CENTER = CENTER_X | CENTER_Y, + DoricGravitySpecified = 1, + DoricGravityStart = 1 << 1, + DoricGravityEnd = 1 << 2, + DoricGravityShiftX = 0, + DoricGravityShiftY = 4, + DoricGravityLeft = (DoricGravityStart | DoricGravitySpecified) << DoricGravityShiftX, + DoricGravityRight = (DoricGravityEnd | DoricGravitySpecified) << DoricGravityShiftX, + DoricTOP = (DoricGravityStart | DoricGravitySpecified) << DoricGravityShiftY, + DoricBottom = (DoricGravityEnd | DoricGravitySpecified) << DoricGravityShiftY, + DoricCenterX = DoricGravitySpecified << DoricGravityShiftX, + DoricCenterY = DoricGravitySpecified << DoricGravityShiftY, + DoricCenter = DoricCenterX | DoricCenterY, }; @interface DoricLayoutConfig : NSObject diff --git a/doric-iOS/Pod/Classes/Shader/DoricLayouts.m b/doric-iOS/Pod/Classes/Shader/DoricLayouts.m index 6ab448c4..b5a42721 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricLayouts.m +++ b/doric-iOS/Pod/Classes/Shader/DoricLayouts.m @@ -255,22 +255,22 @@ - (void)layoutSelf:(CGSize)targetSize { DoricGravity gravity = childConfig.alignment; CGPoint point = child.frame.origin; - if ((gravity & LEFT) == LEFT) { + if ((gravity & DoricGravityLeft) == DoricGravityLeft) { point.x = padding.left; - } else if ((gravity & RIGHT) == RIGHT) { + } else if ((gravity & DoricGravityRight) == DoricGravityRight) { point.x = targetSize.width - padding.right - child.width; - } else if ((gravity & CENTER_X) == CENTER_X) { + } else if ((gravity & DoricCenterX) == DoricCenterX) { point.x = targetSize.width / 2 - child.width / 2; } else { if (childConfig.margin.left || childConfig.margin.right) { point.x = padding.left; } } - if ((gravity & TOP) == TOP) { + if ((gravity & DoricTOP) == DoricTOP) { point.y = padding.top; - } else if ((gravity & BOTTOM) == BOTTOM) { + } else if ((gravity & DoricBottom) == DoricBottom) { point.y = targetSize.height - padding.bottom - child.height; - } else if ((gravity & CENTER_Y) == CENTER_Y) { + } else if ((gravity & DoricCenterY) == DoricCenterY) { point.y = targetSize.height / 2 - child.height / 2; } else { if (childConfig.margin.top || childConfig.margin.bottom) { @@ -279,18 +279,18 @@ - (void)layoutSelf:(CGSize)targetSize { } if (!gravity) { - gravity = LEFT | TOP; + gravity = DoricGravityLeft | DoricTOP; } - if (childConfig.margin.left && !((gravity & RIGHT) == RIGHT)) { + if (childConfig.margin.left && !((gravity & DoricGravityRight) == DoricGravityRight)) { point.x += childConfig.margin.left; } - if (childConfig.margin.right && !((gravity & LEFT) == LEFT)) { + if (childConfig.margin.right && !((gravity & DoricGravityLeft) == DoricGravityLeft)) { point.x -= childConfig.margin.right; } - if (childConfig.margin.top && !((gravity & BOTTOM) == BOTTOM)) { + if (childConfig.margin.top && !((gravity & DoricBottom) == DoricBottom)) { point.y += childConfig.margin.top; } - if (childConfig.margin.bottom && !((gravity & TOP) == TOP)) { + if (childConfig.margin.bottom && !((gravity & DoricTOP) == DoricTOP)) { point.y -= childConfig.margin.bottom; } if (point.x != child.x) { @@ -345,11 +345,11 @@ - (void)layoutSelf:(CGSize)targetSize { self.height = targetSize.height; DoricPadding padding = self.padding; CGFloat yStart = padding.top; - if ((self.gravity & TOP) == TOP) { + if ((self.gravity & DoricTOP) == DoricTOP) { yStart = padding.top; - } else if ((self.gravity & BOTTOM) == BOTTOM) { + } else if ((self.gravity & DoricBottom) == DoricBottom) { yStart = targetSize.height - self.contentHeight - padding.bottom; - } else if ((self.gravity & CENTER_Y) == CENTER_Y) { + } else if ((self.gravity & DoricCenterY) == DoricCenterY) { yStart = (targetSize.height - self.contentHeight - padding.top - padding.bottom) / 2 + padding.top; } CGFloat remain = targetSize.height - self.contentHeight - padding.top - padding.bottom; @@ -374,22 +374,22 @@ - (void)layoutSelf:(CGSize)targetSize { [child layoutSelf:size]; DoricGravity gravity = childConfig.alignment | self.gravity; CGPoint point = child.frame.origin; - if ((gravity & LEFT) == LEFT) { + if ((gravity & DoricGravityLeft) == DoricGravityLeft) { point.x = padding.left; - } else if ((gravity & RIGHT) == RIGHT) { + } else if ((gravity & DoricGravityRight) == DoricGravityRight) { point.x = targetSize.width - padding.right - child.width; - } else if ((gravity & CENTER_X) == CENTER_X) { + } else if ((gravity & DoricCenterX) == DoricCenterX) { point.x = targetSize.width / 2 - child.width / 2; } else { point.x = padding.left; } if (!gravity) { - gravity = LEFT; + gravity = DoricGravityLeft; } - if (childConfig.margin.left && !((gravity & RIGHT) == RIGHT)) { + if (childConfig.margin.left && !((gravity & DoricGravityRight) == DoricGravityRight)) { point.x += childConfig.margin.left; } - if (childConfig.margin.right && !((gravity & LEFT) == LEFT)) { + if (childConfig.margin.right && !((gravity & DoricGravityLeft) == DoricGravityLeft)) { point.x -= childConfig.margin.right; } if (point.x != child.x) { @@ -447,11 +447,11 @@ - (void)layoutSelf:(CGSize)targetSize { self.height = targetSize.height; DoricPadding padding = self.padding; CGFloat xStart = padding.left; - if ((self.gravity & LEFT) == LEFT) { + if ((self.gravity & DoricGravityLeft) == DoricGravityLeft) { xStart = padding.left; - } else if ((self.gravity & RIGHT) == RIGHT) { + } else if ((self.gravity & DoricGravityRight) == DoricGravityRight) { xStart = targetSize.width - self.contentWidth - padding.right; - } else if ((self.gravity & CENTER_X) == CENTER_X) { + } else if ((self.gravity & DoricCenterX) == DoricCenterX) { xStart = (targetSize.width - self.contentWidth - padding.left - padding.right) / 2 + padding.left; } CGFloat remain = targetSize.width - self.contentWidth - padding.left - padding.right; @@ -479,22 +479,22 @@ - (void)layoutSelf:(CGSize)targetSize { DoricGravity gravity = childConfig.alignment | self.gravity; CGPoint point = child.frame.origin; - if ((gravity & TOP) == TOP) { + if ((gravity & DoricTOP) == DoricTOP) { point.y = padding.top; - } else if ((gravity & BOTTOM) == BOTTOM) { + } else if ((gravity & DoricBottom) == DoricBottom) { point.y = targetSize.height - padding.bottom - child.height; - } else if ((gravity & CENTER_Y) == CENTER_Y) { + } else if ((gravity & DoricCenterY) == DoricCenterY) { point.y = targetSize.height / 2 - child.height / 2; } else { point.y = padding.top; } if (!gravity) { - gravity = TOP; + gravity = DoricTOP; } - if (childConfig.margin.top && !((gravity & BOTTOM) == BOTTOM)) { + if (childConfig.margin.top && !((gravity & DoricBottom) == DoricBottom)) { point.y += childConfig.margin.top; } - if (childConfig.margin.bottom && !((gravity & TOP) == TOP)) { + if (childConfig.margin.bottom && !((gravity & DoricTOP) == DoricTOP)) { point.y -= childConfig.margin.bottom; } if (point.y != child.y) { diff --git a/doric-iOS/Pod/Classes/Shader/DoricTextNode.m b/doric-iOS/Pod/Classes/Shader/DoricTextNode.m index 56b71832..2d46a9c2 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricTextNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricTextNode.m @@ -83,9 +83,9 @@ - (void)blendView:(UILabel *)view forPropName:(NSString *)name propValue:(id)pro } else if ([name isEqualToString:@"textAlignment"]) { DoricGravity gravity = (DoricGravity) [(NSNumber *) prop integerValue]; NSTextAlignment alignment = NSTextAlignmentCenter; - if ((gravity & LEFT) == LEFT) { + if ((gravity & DoricGravityLeft) == DoricGravityLeft) { alignment = NSTextAlignmentLeft; - } else if ((gravity & RIGHT) == RIGHT) { + } else if ((gravity & DoricGravityRight) == DoricGravityRight) { alignment = NSTextAlignmentRight; } if (self.paragraphStyle) { diff --git a/doric-iOS/Pod/Classes/Util/DoricUtil.m b/doric-iOS/Pod/Classes/Util/DoricUtil.m index e6e8653a..e6dca718 100644 --- a/doric-iOS/Pod/Classes/Util/DoricUtil.m +++ b/doric-iOS/Pod/Classes/Util/DoricUtil.m @@ -71,9 +71,9 @@ void ShowToast(NSString *text, DoricGravity gravity) { label.height += 10; label.layer.cornerRadius = label.height / 2; label.centerX = superView.width / 2; - if ((gravity & BOTTOM) == BOTTOM) { + if ((gravity & DoricBottom) == DoricBottom) { label.bottom = superView.height - 20; - } else if ((gravity & TOP) == TOP) { + } else if ((gravity & DoricTOP) == DoricTOP) { label.top = 108; } else { label.centerY = (superView.height - 88) / 2;