@@ -68,9 +68,7 @@ - (void)viewDidLoad {
6868 collectionView.delegate = self.adapter ;
6969 collectionView.dataSource = self.adapter ;
7070
71- LOKSizeLayoutBuilder *cellLayoutBuilder = [LOKSizeLayoutBuilder withSublayout: self .helloWorldLayout];
72- cellLayoutBuilder.width = self.view .bounds .size .width ;
73- LOKSizeLayout *cellLayout = [cellLayoutBuilder build ];
71+ __auto_type cellLayout = [LOKSizeLayoutBuilder withSublayout: self .helloWorldLayout].withWidth (self.view .bounds .size .width ).layout ;
7472
7573 NSArray *items = @[
7674 cellLayout, cellLayout, cellLayout, cellLayout,
@@ -106,26 +104,31 @@ - (void)viewDidLayoutSubviews {
106104}
107105
108106+ (id <LOKLayout>)makeHelloLayout {
109- LOKLabelLayoutBuilder *labelLayoutBuilderA = [LOKLabelLayoutBuilder withString: @" Hello" ];
110- labelLayoutBuilderA.viewClass = MyLabelView.class ;
111- labelLayoutBuilderA.configure = ^(UIView * _Nonnull label) {
107+ __auto_type labelLayoutA =
108+ [LOKLabelLayoutBuilder withString: @" Hello" ]
109+ .withViewClass ([MyLabelView class ])
110+ .withConfig (^(UIView * _Nonnull label) {
112111 label.backgroundColor = UIColor.whiteColor ;
113- };
114- LOKLabelLayout *labelLayoutA = [labelLayoutBuilderA build ];
115- LOKLabelLayoutBuilder *labelLayoutBuilderB = [LOKLabelLayoutBuilder withString: @" world!" ];
116- labelLayoutBuilderB.viewClass = MyLabelView.class ;
117- labelLayoutBuilderB.configure = ^(UIView * _Nonnull label) {
112+ })
113+ .layout ;
114+
115+ __auto_type labelLayoutB = [LOKLabelLayoutBuilder withString: @" world!" ]
116+ .withViewClass ([MyLabelView class ])
117+ .withConfig (^(UIView * _Nonnull label) {
118118 label.backgroundColor = UIColor.whiteColor ;
119- };
120- LOKLabelLayout *labelLayoutB = [labelLayoutBuilderB build ];
121- LOKStackLayoutBuilder *stackLayoutBuilder = [LOKStackLayoutBuilder withSublayouts: @[labelLayoutA, labelLayoutB]];
122- stackLayoutBuilder.axis = LOKAxisHorizontal;
123- stackLayoutBuilder.spacing = 10 ;
124- LOKInsetLayoutBuilder *insetLayoutBuilder = [LOKInsetLayoutBuilder withInsets: UIEdgeInsetsMake (20 , 20 , 20 , 20 ) around: [stackLayoutBuilder build ]];
125- insetLayoutBuilder.alignment = LOKAlignment.fill ;
126- insetLayoutBuilder.viewClass = LabelBackgroundView.class ;
127- insetLayoutBuilder.configure = ^(UIView * _Nonnull view) { };
128- return [[RotationLayout alloc ] initWithSublayout: [insetLayoutBuilder build ]
119+ })
120+ .layout ;
121+
122+ __auto_type layout = [LOKStackLayoutBuilder withSublayouts: @[labelLayoutA, labelLayoutB]]
123+ .withAxis (LOKAxisHorizontal)
124+ .withSpacing (10 )
125+ .withInsets (UIEdgeInsetsMake (20 , 20 , 20 , 20 ))
126+ .withAlignment (LOKAlignment.fill )
127+ .withViewClass (LabelBackgroundView.class )
128+ .withConfig (^(UIView * _Nonnull view) { })
129+ .layout ;
130+
131+ return [[RotationLayout alloc ] initWithSublayout: layout
129132 alignment: LOKAlignment.center
130133 viewReuseId: nil ];
131134}
0 commit comments