2019-07-30 19:07:46 +08:00
|
|
|
//
|
|
|
|
// DoricViewContainer.h
|
|
|
|
// Doric
|
|
|
|
//
|
|
|
|
// Created by pengfei.zhou on 2019/7/30.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "UIView+Doric.h"
|
|
|
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2019-07-31 14:18:20 +08:00
|
|
|
typedef NS_ENUM(NSInteger,DoricLayoutDesc) {
|
|
|
|
LAYOUT_DEFAULT = 0,
|
|
|
|
LAYOUT_MATCH_PARENT = -1,
|
|
|
|
LAYOUT_WRAP_CONTENT = -2,
|
|
|
|
};
|
|
|
|
|
2019-07-30 19:07:46 +08:00
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
@interface DoricRect :NSObject
|
|
|
|
@property (nonatomic) CGFloat left;
|
|
|
|
@property (nonatomic) CGFloat right;
|
|
|
|
@property (nonatomic) CGFloat top;
|
|
|
|
@property (nonatomic) CGFloat bottom;
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
2019-07-31 14:18:20 +08:00
|
|
|
|
2019-07-30 19:07:46 +08:00
|
|
|
@interface LayoutParams : NSObject
|
2019-07-31 14:18:20 +08:00
|
|
|
@property (nonatomic) DoricLayoutDesc width;
|
|
|
|
@property (nonatomic) DoricLayoutDesc height;
|
2019-07-30 19:07:46 +08:00
|
|
|
@property (nonatomic) DoricGravity alignment;
|
|
|
|
@property (nonatomic,strong) DoricRect *margin;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface UIView(DoricContainer)
|
|
|
|
|
|
|
|
@property (nonatomic,strong) LayoutParams *layoutParams;
|
|
|
|
|
|
|
|
- (void) layout;
|
|
|
|
|
|
|
|
- (void) measure;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface Stack : UIView
|
|
|
|
@property (nonatomic) DoricGravity gravity;
|
|
|
|
@end
|
|
|
|
|
2019-07-30 21:05:27 +08:00
|
|
|
@interface LinearLayout : UIView
|
2019-07-30 19:07:46 +08:00
|
|
|
@property (nonatomic) DoricGravity gravity;
|
|
|
|
@property (nonatomic) CGFloat space;
|
|
|
|
@end
|
|
|
|
|
2019-07-30 21:05:27 +08:00
|
|
|
|
|
|
|
@interface VLayout : LinearLayout
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface HLayout : LinearLayout
|
2019-07-30 19:07:46 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|