Skip to content

Commit

Permalink
iOS:Change DoricGravity enum name
Browse files Browse the repository at this point in the history
  • Loading branch information
penfeizhou committed Mar 27, 2020
1 parent 0abf853 commit 438f729
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 55 deletions.
8 changes: 4 additions & 4 deletions doric-iOS/Devkit/Classes/DoricDev.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion doric-iOS/Devkit/Classes/DoricDevViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
2 changes: 1 addition & 1 deletion doric-iOS/Devkit/Classes/QRScanViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
Expand Down
2 changes: 1 addition & 1 deletion doric-iOS/Example/Example/DemoLibrary.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion doric-iOS/Pod/Classes/Plugin/DoricModalPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}];
Expand Down
4 changes: 2 additions & 2 deletions doric-iOS/Pod/Classes/Shader/DoricInputNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 12 additions & 12 deletions doric-iOS/Pod/Classes/Shader/DoricLayouts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 29 additions & 29 deletions doric-iOS/Pod/Classes/Shader/DoricLayouts.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions doric-iOS/Pod/Classes/Shader/DoricTextNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions doric-iOS/Pod/Classes/Util/DoricUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 438f729

Please sign in to comment.