Skip to content

Commit

Permalink
增加链式调用支持
Browse files Browse the repository at this point in the history
  • Loading branch information
郑立宝 committed Mar 18, 2024
1 parent 44e5f0d commit 73e5652
Show file tree
Hide file tree
Showing 20 changed files with 1,244 additions and 671 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,15 @@
**FlexLib**的所有版本的变更日志都将会在这里记录.

---
## 3.3.0
增加通过链式调用修改布局属性

## 3.2.0
集成yoga库,更新yoga到最新版本

## 3.1.6
FlexCustomBaseView布局优化

## 3.1.2
1.FlexCollectionCell和FlexBaseTableCell对iOS15的适配

Expand Down
7 changes: 7 additions & 0 deletions Example_oc/FlexLib/FlexViewController.m
Expand Up @@ -27,6 +27,9 @@ @interface FlexViewController ()
FlexScrollView* _scroll;
UILabel* _label;
}
@property(nonatomic,strong) UIView* mainView;
@property(nonatomic,strong) UIView* bottomBtn;

@end
@implementation FlexViewController

Expand All @@ -35,6 +38,10 @@ - (void)viewDidLoad
[super viewDidLoad];

self.navigationItem.title = @"FlexLib Demo";

[self view];

// self.bottomBtn.flexLayout.height(100).width(200);
}
- (void)didReceiveMemoryWarning
{
Expand Down
4 changes: 2 additions & 2 deletions Example_oc/FlexLib/res/FlexViewController.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<UIView
<UIView name="mainView"
layout="
flex:1,
justifyContent:center,
Expand Down Expand Up @@ -80,7 +80,7 @@



</FlexScrollView><UIView layout="$width:ScreenWidth*0.6,height:50,alignItems:center,justifyContent:center" attr="bgColor:#e5e5e5,borderRadius:6">
</FlexScrollView><UIView name="bottomBtn" layout="$width:ScreenWidth*0.6,height:50,alignItems:center,justifyContent:center" attr="bgColor:#e5e5e5,borderRadius:6">
<UILabel
attr="@:system/buttonText,text:表达式计算,屏幕宽度的60%"/>
</UIView>
Expand Down
18 changes: 9 additions & 9 deletions Example_oc/Podfile.lock
@@ -1,15 +1,15 @@
PODS:
- Expecta (1.0.6)
- FlexLib (3.2.0):
- FlexLib/standard (= 3.2.0)
- FlexLib/preview (3.2.0):
- FlexLib (3.2.2):
- FlexLib/standard (= 3.2.2)
- FlexLib/preview (3.2.2):
- FlexLib/standard
- FlexLib/standard (3.2.0):
- FlexLib/standard/no-arc (= 3.2.0)
- FlexLib/standard (3.2.2):
- FlexLib/standard/no-arc (= 3.2.2)
- FlexLib/yoga
- FlexLib/standard/no-arc (3.2.0):
- FlexLib/standard/no-arc (3.2.2):
- FlexLib/yoga
- FlexLib/yoga (3.2.0)
- FlexLib/yoga (3.2.2)
- Specta (2.0.0)

DEPENDENCIES:
Expand All @@ -29,9 +29,9 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Expecta: 3b6bd90a64b9a1dcb0b70aa0e10a7f8f631667d5
FlexLib: df896590c1d366c983ef5c7e75b57480b240d300
FlexLib: d4ef2f4ab09c0307dc43704af531e0a2544b9169
Specta: b79d84043684b35ffdc2680df578dc318ec2efc2

PODFILE CHECKSUM: a49fb91284d8736ae14f8f4e196af95287a9e035

COCOAPODS: 1.12.0
COCOAPODS: 1.15.2
1 change: 1 addition & 0 deletions Example_oc/Pods/Headers/Private/FlexLib/FlexLayout.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Example_oc/Pods/Headers/Public/FlexLib/FlexLayout.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Example_oc/Pods/Local Podspecs/FlexLib.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions Example_oc/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,292 changes: 650 additions & 642 deletions Example_oc/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion FlexLib.podspec
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'FlexLib'
s.version = '3.2.2'
s.version = '3.3.0'
s.summary = 'An obj-c flex layout framework for IOS & mac'

# This description is used to generate tags and improve search results.
Expand Down
169 changes: 169 additions & 0 deletions FlexLib/Classes/Flexlib/FlexLayout.h
@@ -0,0 +1,169 @@
/**
* Copyright (c) 2017-present, zhenglibao, Inc.
* email: 798393829@qq.com
* All rights reserved.
*
* This source code is licensed under the MIT-style license found in the
* LICENSE file in the root directory of this source tree.
*/


#import <Foundation/Foundation.h>

@class YGLayout;
@class FlexLayout;

typedef FlexLayout*_Nonnull(^FlexNumAttr)(float); //数值类型
typedef FlexLayout*_Nonnull(^FlexPercentAttr)(float); //百分比类型
typedef FlexLayout*_Nonnull(^FlexNoneAttr)(void); //None类型
typedef FlexLayout*_Nonnull(^FlexAutoAttr)(void); //Auto类型


#define FLEX_AUTO_VALUE_PROPERTY(attr) \
@property(readonly) FlexNumAttr attr; \
@property(readonly) FlexPercentAttr attr##Percent;\
@property(readonly) FlexAutoAttr attr##Auto;

#define FLEX_VALUE_PROPERTY(attr) \
@property(readonly) FlexNumAttr attr; \
@property(readonly) FlexPercentAttr attr##Percent;\
@property(readonly) FlexNoneAttr attr##None;


typedef enum : int
{
dirInherit = 0,
dirLtr,
dirRtl,
}EmDirection;

typedef enum : int
{
flexDirCol = 0,
flexDirColReverse,
flexDirRow,
flexDirRowReverse,
}EmFlexDirection;

typedef enum : int
{
justifyFlexStart = 0,
justifyCenter,
justifyFlexEnd,
justifySpaceBetween,
justifySpaceAround,
justifySpaceEvenly,
}EmJustify;

typedef enum : int
{
alignAuto = 0,
alignFlexStart,
alignCenter,
alignFlexEnd,
alignStretch,
alignBaseline,
alignSpaceBetween,
alignSpaceAround,
}EmAlign;

typedef enum : int
{
posStatic = 0,
posRelative,
posAbsolute,
}EmPositionType;


typedef enum : int
{
flexNoWrap = 0,
flexWrap,
flexWrapReverse,
}EmFlexWrap;

typedef enum : int
{
overflowVisible = 0,
overflowHidden,
overflowScroll,
}EmOverflow;

typedef enum : int
{
displayFlex = 0,
displayNone,
}EmDisplay;


NS_ASSUME_NONNULL_BEGIN

/**
* 增加通过链式调用设置布局属性,如
* view.flexLayout.top(10).minWidth(20).bottom.(-30)
*/

@interface FlexLayout : NSObject

@property(readonly) FlexLayout* (^direction)(EmDirection);
@property(readonly) FlexLayout* (^flexDirection)(EmFlexDirection);
@property(readonly) FlexLayout* (^justifyContent)(EmJustify);
@property(readonly) FlexLayout* (^alignContent)(EmAlign);
@property(readonly) FlexLayout* (^alignItems)(EmAlign);
@property(readonly) FlexLayout* (^alignSelf)(EmAlign);
@property(readonly) FlexLayout* (^position)(EmPositionType);
@property(readonly) FlexLayout* (^flexWrap)(EmFlexWrap);
@property(readonly) FlexLayout* (^overflow)(EmOverflow);
@property(readonly) FlexLayout* (^display)(EmDisplay);

@property(readonly) FlexNumAttr flex;
@property(readonly) FlexNumAttr flexGrow;
@property(readonly) FlexNumAttr flexShrink;
@property(readonly) FlexNumAttr aspectRatio;

/**
* 定义数值属性、百分比属性、Auto属性
*/
FLEX_AUTO_VALUE_PROPERTY(flexBasis)
FLEX_AUTO_VALUE_PROPERTY(width)
FLEX_AUTO_VALUE_PROPERTY(height)


/**
* 定义数值属性、百分比属性、None属性
*/
FLEX_VALUE_PROPERTY(minWidth)
FLEX_VALUE_PROPERTY(minHeight)
FLEX_VALUE_PROPERTY(maxWidth)
FLEX_VALUE_PROPERTY(maxHeight)
FLEX_VALUE_PROPERTY(left)
FLEX_VALUE_PROPERTY(top)
FLEX_VALUE_PROPERTY(right)
FLEX_VALUE_PROPERTY(bottom)
FLEX_VALUE_PROPERTY(start)
FLEX_VALUE_PROPERTY(end)
FLEX_VALUE_PROPERTY(margin)
FLEX_VALUE_PROPERTY(marginLeft)
FLEX_VALUE_PROPERTY(marginTop)
FLEX_VALUE_PROPERTY(marginRight)
FLEX_VALUE_PROPERTY(marginBottom)
FLEX_VALUE_PROPERTY(marginStart)
FLEX_VALUE_PROPERTY(marginEnd)
FLEX_VALUE_PROPERTY(marginHorizontal)
FLEX_VALUE_PROPERTY(marginVertical)
FLEX_VALUE_PROPERTY(paddingLeft)
FLEX_VALUE_PROPERTY(paddingTop)
FLEX_VALUE_PROPERTY(paddingRight)
FLEX_VALUE_PROPERTY(paddingBottom)
FLEX_VALUE_PROPERTY(paddingStart)
FLEX_VALUE_PROPERTY(paddingEnd)
FLEX_VALUE_PROPERTY(paddingHorizontal)
FLEX_VALUE_PROPERTY(paddingVertical)
FLEX_VALUE_PROPERTY(padding)


-(instancetype)initWithYGLayout:(YGLayout*)layout;

@end

NS_ASSUME_NONNULL_END

0 comments on commit 73e5652

Please sign in to comment.