Skip to content

Commit

Permalink
release 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
changsanjiang committed Dec 27, 2021
1 parent ff3910d commit f10b574
Show file tree
Hide file tree
Showing 363 changed files with 24,793 additions and 61 deletions.
508 changes: 477 additions & 31 deletions Example/LWZComponents.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions Example/LWZComponents.xcworkspace/contents.xcworkspacedata

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
98 changes: 92 additions & 6 deletions Example/LWZComponents/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="whP-gf-Uak">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="tth-ip-xxy">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -20,12 +18,100 @@
<view key="view" contentMode="scaleToFill" id="TpU-gO-2f1">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="2x7-MP-er2">
<rect key="frame" x="0.0" y="44" width="375" height="623"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="o8A-kq-vtz">
<rect key="frame" x="0.0" y="0.0" width="375" height="89"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="WeightLayout"/>
<connections>
<action selector="pushWeightLayout:" destination="whP-gf-Uak" eventType="touchUpInside" id="Kjv-8S-oBY"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="BcK-PX-EDM" userLabel="WaterfallFlowLayout">
<rect key="frame" x="0.0" y="89" width="375" height="89"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="WaterfallFlowLayout"/>
<connections>
<action selector="pushWaterfallFlowLayout:" destination="whP-gf-Uak" eventType="touchUpInside" id="PBV-Lg-C2O"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Sh9-cf-1I5">
<rect key="frame" x="0.0" y="178" width="375" height="89"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="ListLayout"/>
<connections>
<action selector="pushListLayout:" destination="whP-gf-Uak" eventType="touchUpInside" id="HWl-yZ-bQN"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="svZ-zS-hYH">
<rect key="frame" x="0.0" y="267" width="375" height="89"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="RestrictedLayout"/>
<connections>
<action selector="pushRestrictedLayout:" destination="whP-gf-Uak" eventType="touchUpInside" id="LWi-eN-2Hj"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="aem-ub-2LJ" userLabel="WaterfallFlowLayout">
<rect key="frame" x="0.0" y="356" width="375" height="89"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="TemplateLayout"/>
<connections>
<action selector="pushTemplateLayout:" destination="whP-gf-Uak" eventType="touchUpInside" id="Z6X-e1-XHk"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xto-tf-HnK" userLabel="WaterfallFlowLayout">
<rect key="frame" x="0.0" y="445" width="375" height="89"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="CompositionalLayout"/>
<connections>
<action selector="pushCompositionalLayout:" destination="whP-gf-Uak" eventType="touchUpInside" id="Wr7-i5-f2m"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tHP-0m-yQG" userLabel="WaterfallFlowLayout">
<rect key="frame" x="0.0" y="534" width="375" height="89"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="HybridLayout(Mix)"/>
<connections>
<action selector="pushHybridLayout:" destination="whP-gf-Uak" eventType="touchUpInside" id="WNR-ck-v8L"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="2x7-MP-er2" secondAttribute="trailing" id="OKb-tn-m7Y"/>
<constraint firstItem="2x7-MP-er2" firstAttribute="top" secondItem="uEw-UM-LJ8" secondAttribute="bottom" id="PYH-T1-gPh"/>
<constraint firstItem="2x7-MP-er2" firstAttribute="leading" secondItem="TpU-gO-2f1" secondAttribute="leading" id="Wyq-A5-rtF"/>
<constraint firstItem="Mvr-aV-6Um" firstAttribute="top" secondItem="2x7-MP-er2" secondAttribute="bottom" id="yma-yY-IKe"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="y04-VO-5YG"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="tc2-Qw-aMS" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="305" y="433"/>
<point key="canvasLocation" x="1244" y="432.23388305847078"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="x1O-Cp-jUV">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="tth-ip-xxy" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="8cI-8C-OkU">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="whP-gf-Uak" kind="relationship" relationship="rootViewController" id="qKE-JZ-HYZ"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="YXW-ix-CVy" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="304.80000000000001" y="432.23388305847078"/>
</scene>
</scenes>
</document>
19 changes: 19 additions & 0 deletions Example/LWZComponents/Common/CommonDependencies.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// CommonDependencies.h
// LWZCollectionViewComponents
//
// Created by changsanjiang on 2021/11/25.
// Copyright © 2021 changsanjiang@gmail.com. All rights reserved.
//

#ifndef CommonDependencies_h
#define CommonDependencies_h


#import <YYModel/YYModel.h>
#import <Masonry/Masonry.h>
#import <SJUIKit/NSAttributedString+SJMake.h>

#import <LWZComponents/LWZCollectionViewComponents.h>

#endif /* CommonDependencies_h */
19 changes: 19 additions & 0 deletions Example/LWZComponents/Common/CommonImageView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// CommonImageView.h
// LWZCollectionViewComponents_Example
//
// Created by changsanjiang on 2021/11/26.
// Copyright © 2021 changsanjiang@gmail.com. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface CommonImageView : UIImageView

@property (nonatomic, copy, nullable) void(^layoutSubviewsExeBlock)(__kindof CommonImageView *view);

@end

NS_ASSUME_NONNULL_END
16 changes: 16 additions & 0 deletions Example/LWZComponents/Common/CommonImageView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// CommonImageView.m
// LWZCollectionViewComponents_Example
//
// Created by changsanjiang on 2021/11/26.
// Copyright © 2021 changsanjiang@gmail.com. All rights reserved.
//

#import "CommonImageView.h"

@implementation CommonImageView
- (void)layoutSubviews {
[super layoutSubviews];
if ( _layoutSubviewsExeBlock ) _layoutSubviewsExeBlock(self);
}
@end
29 changes: 29 additions & 0 deletions Example/LWZComponents/Common/CommonLabel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// LWZAttributeLabel.h
// Pods
//
// Created by changsanjiang on 2020/2/23.
//

#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface CommonLabel : UILabel
@property (nonatomic, copy, nullable) void(^layoutSubviewsExeBlock)(__kindof CommonLabel *label);

///
/// 配置文本区域inset
///
/// 当设置了富文本垂直方向不起作用时, 请设置段落的lineBreakMode.
///
@property (nonatomic) UIEdgeInsets contentInsets;
@end

#if TARGET_INTERFACE_BUILDER
@interface CommonLabel (CommonIBSupported)
@property (nonatomic) IBInspectable CGFloat topInset;
@property (nonatomic) IBInspectable CGFloat leftInset;
@property (nonatomic) IBInspectable CGFloat bottomInset;
@property (nonatomic) IBInspectable CGFloat rightInset;
@end
#endif
NS_ASSUME_NONNULL_END
93 changes: 93 additions & 0 deletions Example/LWZComponents/Common/CommonLabel.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//
// LWZAttributeLabel.m
// Pods
//
// Created by changsanjiang on 2020/2/23.
//

#import "CommonLabel.h"

@implementation CommonLabel
- (void)layoutSubviews {
[super layoutSubviews];
if ( _layoutSubviewsExeBlock ) _layoutSubviewsExeBlock(self);
}

#pragma mark -

- (void)drawTextInRect:(CGRect)rect {
rect.origin.x += _contentInsets.left;
rect.size.width -= _contentInsets.left + _contentInsets.right;
rect.origin.y += _contentInsets.top;
rect.size.height -= _contentInsets.top + _contentInsets.bottom;
[super drawTextInRect:rect];
}

- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines {
if ( self.text.length != 0 ) {
bounds.size.width -= _contentInsets.left + _contentInsets.right;
bounds.size.height -= _contentInsets.top + _contentInsets.bottom;
}

if ( bounds.size.width < 0 || bounds.size.height < 0 )
return CGRectZero;

CGRect rect = [super textRectForBounds:bounds limitedToNumberOfLines:numberOfLines];
if ( self.text.length != 0 ) {
rect.size.width += _contentInsets.left + _contentInsets.right;
rect.size.height += _contentInsets.top + _contentInsets.bottom;
}
return rect;
}

- (void)setContentInsets:(UIEdgeInsets)contentInsets {
if ( !UIEdgeInsetsEqualToEdgeInsets(contentInsets, _contentInsets) ) {
_contentInsets = contentInsets;
[self setNeedsDisplay];
[self invalidateIntrinsicContentSize];
}
}

@end

@implementation CommonLabel (CommonIBSupported)
- (void)setTopInset:(CGFloat)topInset {
if ( topInset != _contentInsets.top ) {
_contentInsets.top = topInset;
[self setNeedsDisplay];
}
}
- (CGFloat)topInset {
return _contentInsets.top;
}

- (void)setLeftInset:(CGFloat)leftInset {
if ( leftInset != _contentInsets.left ) {
_contentInsets.left = leftInset;
[self setNeedsDisplay];
}
}
- (CGFloat)leftInset {
return _contentInsets.left;
}

- (void)setBottomInset:(CGFloat)bottomInset {
if ( bottomInset != _contentInsets.bottom ) {
_contentInsets.bottom = bottomInset;
[self setNeedsDisplay];
}
}
- (CGFloat)bottomInset {
return _contentInsets.bottom;
}

- (void)setRightInset:(CGFloat)rightInset {
if ( rightInset != _contentInsets.right ) {
_contentInsets.right = rightInset;
[self setNeedsDisplay];
}
}
- (CGFloat)rightInset {
return _contentInsets.right;
}
@end
38 changes: 38 additions & 0 deletions Example/LWZComponents/Common/CommonTextLayoutSize.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// CommonTextLayoutSize.h
// LWZAppComponents
//
// Created by changsanjiang on 2021/8/27.
//

#import <UIKit/UIKit.h>
@class LWZTextContainer;

NS_ASSUME_NONNULL_BEGIN
@interface NSString (CommonTextLayoutSizeAdditions)
- (CGSize)lwz_layoutSizeThatFits:(CGSize)sizeLimit font:(UIFont *)font limitedToNumberOfLines:(NSInteger)limitedToNumberOfLines;
@end

@interface NSAttributedString (CommonTextLayoutSizeAdditions)
- (CGSize)lwz_layoutSizeThatFits:(CGSize)sizeLimit limitedToNumberOfLines:(NSInteger)limitedToNumberOfLines;
- (LWZTextContainer *)lwz_textContainerWithLayoutSizeThatFits:(CGSize)size limitedToNumberOfLines:(NSInteger)limitedToNumberOfLines;
- (LWZTextContainer *)lwz_textContainerWithLayoutSizeThatFits:(CGSize)size limitedToNumberOfLines:(NSInteger)limitedToNumberOfLines fixesSingleLineSpacing:(BOOL)fixesSingleLineSpacing;
@end

@interface LWZTextContainer : NSObject
@property (nonatomic, readonly) NSAttributedString *text;
/// text布局宽高.
///
/// 注意: 单行时高度不包含 lineSpacing; 如果要在单行 UILabel 上显示, label的布局高度需要考虑加上 lineSpacing;
///\code
/// CGFloat lineSpacing = ...;
/// if ( container.numberOfLines == 1 ) {
/// CGSize layoutSize = container.layoutSize;
/// layoutSize.height += lineSpacing;
/// }
///\endcode
///
@property (nonatomic, readonly) CGSize layoutSize;
@property (nonatomic, readonly) NSInteger numberOfLines;
@end
NS_ASSUME_NONNULL_END
Loading

0 comments on commit f10b574

Please sign in to comment.