2019-10-21 09:59:22 +08:00
|
|
|
/*
|
|
|
|
* Copyright [2019] [Doric.Pub]
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2019-07-30 19:07:46 +08:00
|
|
|
//
|
|
|
|
// DoricViewContainer.m
|
|
|
|
// Doric
|
|
|
|
//
|
|
|
|
// Created by pengfei.zhou on 2019/7/30.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "DoricViewContainer.h"
|
|
|
|
#import <objc/runtime.h>
|
|
|
|
|
|
|
|
@implementation DoricRect
|
2019-07-31 14:18:20 +08:00
|
|
|
- (instancetype)init {
|
2019-10-12 14:48:19 +08:00
|
|
|
if (self = [super init]) {
|
2019-07-31 14:18:20 +08:00
|
|
|
_left = 0;
|
|
|
|
_right = 0;
|
|
|
|
_top = 0;
|
|
|
|
_bottom = 0;
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
2019-07-30 19:07:46 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation LayoutParams
|
2019-07-31 17:43:26 +08:00
|
|
|
- (instancetype)init {
|
2019-10-12 14:48:19 +08:00
|
|
|
if (self = [super init]) {
|
2019-07-31 17:43:26 +08:00
|
|
|
_width = LAYOUT_WRAP_CONTENT;
|
|
|
|
_height = LAYOUT_WRAP_CONTENT;
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
@end
|
2019-10-12 14:48:19 +08:00
|
|
|
|
2019-07-31 17:43:26 +08:00
|
|
|
@implementation MarginLayoutParams
|
2019-07-30 21:05:27 +08:00
|
|
|
- (instancetype)init {
|
2019-10-12 14:48:19 +08:00
|
|
|
if (self = [super init]) {
|
2019-07-30 21:05:27 +08:00
|
|
|
_margin = [[DoricRect alloc] init];
|
2019-07-31 17:43:26 +08:00
|
|
|
}
|
|
|
|
return self;
|
2019-10-12 14:48:19 +08:00
|
|
|
}
|
|
|
|
@end
|
2019-07-31 17:43:26 +08:00
|
|
|
|
|
|
|
@implementation StackLayoutParams
|
|
|
|
- (instancetype)init {
|
2019-10-12 14:48:19 +08:00
|
|
|
if (self = [super init]) {
|
2019-07-31 17:43:26 +08:00
|
|
|
_alignment = 0;
|
|
|
|
}
|
|
|
|
return self;
|
2019-10-12 14:48:19 +08:00
|
|
|
}
|
|
|
|
@end
|
2019-07-31 17:43:26 +08:00
|
|
|
|
|
|
|
@implementation VHLayoutParams
|
|
|
|
- (instancetype)init {
|
2019-10-12 14:48:19 +08:00
|
|
|
if (self = [super init]) {
|
2019-07-31 14:18:20 +08:00
|
|
|
_alignment = 0;
|
2019-07-31 17:43:26 +08:00
|
|
|
_weight = 0;
|
2019-07-30 21:05:27 +08:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
2019-07-30 19:07:46 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
|
2019-10-12 14:48:19 +08:00
|
|
|
@implementation UIView (DoricContainer)
|
2019-07-30 19:07:46 +08:00
|
|
|
|
|
|
|
- (LayoutParams *)layoutParams {
|
|
|
|
return objc_getAssociatedObject(self, _cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setLayoutParams:(LayoutParams *)layoutParams {
|
|
|
|
objc_setAssociatedObject(self, @selector(layoutParams), layoutParams, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)layout {
|
2019-10-12 14:48:19 +08:00
|
|
|
|
2019-07-30 19:07:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)measure {
|
2019-10-12 14:48:19 +08:00
|
|
|
if (self.layoutParams) {
|
|
|
|
|
2019-07-30 19:07:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation Stack
|
2019-07-30 21:05:27 +08:00
|
|
|
@end
|
2019-07-30 19:07:46 +08:00
|
|
|
|
2019-07-30 21:05:27 +08:00
|
|
|
@implementation LinearLayout
|
2019-07-30 19:07:46 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation VLayout
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation HLayout
|
|
|
|
@end
|