iOS:Change DoricGravity enum name

This commit is contained in:
pengfei.zhou 2020-03-27 10:07:53 +08:00 committed by osborn
parent 0abf8533db
commit 438f729ec6
10 changed files with 55 additions and 55 deletions

View File

@ -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;

View File

@ -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];
}

View File

@ -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];
}
}

View File

@ -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

View File

@ -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];
}];

View File

@ -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;

View File

@ -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

View File

@ -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) {

View File

@ -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) {

View File

@ -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;