Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize Property Declaration Style in Core Classes #870

Merged
merged 4 commits into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
- Fix an issue where ASConfigurationDelegate would not call out for "control" users. If set, it now receives events whenever an experimental feature decision point occurs, whether it's enabled or not. [Adlai Holler](https://github.com/Adlai-Holler)
- [ASDisplayNode] Fix an issue that causes a node to sometimes return an outdated calculated size or size range. [Huy Nguyen](https://github.com/nguyenhuy) [#808](https://github.com/TextureGroup/Texture/pull/808)
- Add an experimental deallocation queue implementation that's more efficient. [Adlai Holler](https://github.com/Adlai-Holler)
- Standardize property declaration style. [Adlai Holler](https://github.com/Adlai-Holler)

## 2.6
- [Xcode 9] Updated to require Xcode 9 (to fix warnings) [Garrett Moon](https://github.com/garrettmoon)
Expand Down
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ static void someFunction() {
- There is mostly no sense using nullability annotations outside of interface declarations.
```objc
// Properties
@property(nonatomic, strong, nullable) NSNumber *status
// Never include: `atomic`, `readwrite`, `strong`, `assign`.
// Only specify nullability if it isn't assumed from NS_ASSUME.
// (nullability, atomicity, storage class, writability, custom getter, custom setter)
@property (nullable, copy) NSNumber *status

// Methods
- (nullable NSNumber *)doSomethingWithString:(nullable NSString *)str;
Expand Down
18 changes: 9 additions & 9 deletions Source/ASButtonNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,41 +34,41 @@ typedef NS_ENUM(NSInteger, ASButtonNodeImageAlignment) {

@interface ASButtonNode : ASControlNode

@property (nonatomic, readonly) ASTextNode * titleNode;
@property (nonatomic, readonly) ASImageNode * imageNode;
@property (nonatomic, readonly) ASImageNode * backgroundImageNode;
@property (readonly) ASTextNode * titleNode;
@property (readonly) ASImageNode * imageNode;
@property (readonly) ASImageNode * backgroundImageNode;

/**
Spacing between image and title. Defaults to 8.0.
*/
@property (nonatomic, assign) CGFloat contentSpacing;
@property CGFloat contentSpacing;

/**
Whether button should be laid out vertically (image on top of text) or horizontally (image to the left of text).
ASButton node does not yet support RTL but it should be fairly easy to implement.
Defaults to YES.
*/
@property (nonatomic, assign) BOOL laysOutHorizontally;
@property BOOL laysOutHorizontally;

/** Horizontally align content (text or image).
Defaults to ASHorizontalAlignmentMiddle.
*/
@property (nonatomic, assign) ASHorizontalAlignment contentHorizontalAlignment;
@property ASHorizontalAlignment contentHorizontalAlignment;

/** Vertically align content (text or image).
Defaults to ASVerticalAlignmentCenter.
*/
@property (nonatomic, assign) ASVerticalAlignment contentVerticalAlignment;
@property ASVerticalAlignment contentVerticalAlignment;

/**
* @discussion The insets used around the title and image node
*/
@property (nonatomic, assign) UIEdgeInsets contentEdgeInsets;
@property UIEdgeInsets contentEdgeInsets;

/**
* @discusstion Whether the image should be aligned at the beginning or at the end of node. Default is `ASButtonNodeImageAlignmentBeginning`.
*/
@property (nonatomic, assign) ASButtonNodeImageAlignment imageAlignment;
@property ASButtonNodeImageAlignment imageAlignment;

/**
* Returns the styled title associated with the specified state.
Expand Down
27 changes: 8 additions & 19 deletions Source/ASButtonNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ - (instancetype)init

- (ASTextNode *)titleNode
{
ASLockScopeSelf();
if (!_titleNode) {
_titleNode = [[ASTextNode alloc] init];
#if TARGET_OS_IOS
Expand All @@ -92,6 +93,7 @@ - (ASTextNode *)titleNode

- (ASImageNode *)imageNode
{
ASLockScopeSelf();
if (!_imageNode) {
_imageNode = [[ASImageNode alloc] init];
[_imageNode setLayerBacked:YES];
Expand All @@ -101,6 +103,7 @@ - (ASImageNode *)imageNode

- (ASImageNode *)backgroundImageNode
{
ASLockScopeSelf();
if (!_backgroundImageNode) {
_backgroundImageNode = [[ASImageNode alloc] init];
[_backgroundImageNode setLayerBacked:YES];
Expand Down Expand Up @@ -162,7 +165,7 @@ - (void)setDisplaysAsynchronously:(BOOL)displaysAsynchronously
- (void)updateImage
{
[self lock];

UIImage *newImage;
if (self.enabled == NO && _disabledImage) {
newImage = _disabledImage;
Expand Down Expand Up @@ -253,16 +256,9 @@ - (CGFloat)contentSpacing

- (void)setContentSpacing:(CGFloat)contentSpacing
{
{
ASLockScopeSelf();
if (contentSpacing == _contentSpacing) {
return;
}

_contentSpacing = contentSpacing;
if (ASLockedSelfCompareAssign(_contentSpacing, contentSpacing)) {
[self setNeedsLayout];
}

[self setNeedsLayout];
}

- (BOOL)laysOutHorizontally
Expand All @@ -273,16 +269,9 @@ - (BOOL)laysOutHorizontally

- (void)setLaysOutHorizontally:(BOOL)laysOutHorizontally
{
{
ASLockScopeSelf();
if (laysOutHorizontally == _laysOutHorizontally) {
return;
}

_laysOutHorizontally = laysOutHorizontally;
if (ASLockedSelfCompareAssign(_laysOutHorizontally, laysOutHorizontally)) {
[self setNeedsLayout];
}

[self setNeedsLayout];
}

- (ASVerticalAlignment)contentVerticalAlignment
Expand Down
40 changes: 20 additions & 20 deletions Source/ASCellNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) {
* blocking time is very short. If the rangeTuningParameters are set to 0, still this option
* outperforms UIKit: while the main thread is waiting, subnode display executes concurrently.
*/
@property (nonatomic, assign) BOOL neverShowPlaceholders;
@property BOOL neverShowPlaceholders;

/*
* The kind of supplementary element this node represents, if any.
*
* @return The supplementary element kind, or @c nil if this node does not represent a supplementary element.
*/
@property (atomic, copy, readonly, nullable) NSString *supplementaryElementKind;
@property (nullable, copy, readonly) NSString *supplementaryElementKind;

/*
* The layout attributes currently assigned to this node, if any.
Expand All @@ -96,25 +96,25 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) {
* is called, when the node is not yet in the hierarchy and its frame cannot be converted to/from other nodes. Instead
* you can use the layout attributes object to learn where and how the cell will be displayed.
*/
@property (nonatomic, strong, readonly, nullable) UICollectionViewLayoutAttributes *layoutAttributes;
@property (nullable, copy, readonly) UICollectionViewLayoutAttributes *layoutAttributes;

/**
* A Boolean value that is synchronized with the underlying collection or tableView cell property.
* Setting this value is equivalent to calling selectItem / deselectItem on the collection or table.
*/
@property (nonatomic, assign, getter=isSelected) BOOL selected;
@property (getter=isSelected) BOOL selected;

/**
* A Boolean value that is synchronized with the underlying collection or tableView cell property.
* Setting this value is equivalent to calling highlightItem / unHighlightItem on the collection or table.
*/
@property (nonatomic, assign, getter=isHighlighted) BOOL highlighted;
@property (getter=isHighlighted) BOOL highlighted;

/**
* The current index path of this cell node, or @c nil if this node is
* not a valid item inside a table node or collection node.
*/
@property (atomic, readonly, nullable) NSIndexPath *indexPath;
@property (nullable, copy, readonly) NSIndexPath *indexPath;

/**
* BETA: API is under development. We will attempt to provide an easy migration pathway for any changes.
Expand All @@ -123,7 +123,7 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) {
*
* This property may be set off the main thread, but this method will never be invoked concurrently on the
*/
@property (atomic, nullable) id nodeModel;
@property (nullable) id nodeModel;

/**
* Asks the node whether it can be updated to the given node model.
Expand All @@ -136,13 +136,13 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) {
* The backing view controller, or @c nil if the node wasn't initialized with backing view controller
* @note This property must be accessed on the main thread.
*/
@property (nonatomic, readonly, nullable) UIViewController *viewController;
@property (nullable, nonatomic, readonly) UIViewController *viewController;


/**
* The table- or collection-node that this cell is a member of, if any.
*/
@property (atomic, weak, readonly, nullable) id<ASRangeManagingNode> owningNode;
@property (nullable, weak, readonly) id<ASRangeManagingNode> owningNode;

/*
* ASCellNode must forward touch events in order for UITableView and UICollectionView tap handling to work. Overriding
Expand Down Expand Up @@ -188,38 +188,38 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) {
* @default UITableViewCellSelectionStyleDefault
* ASTableView uses these properties when configuring UITableViewCells that host ASCellNodes.
*/
@property (nonatomic) UITableViewCellSelectionStyle selectionStyle;
@property UITableViewCellSelectionStyle selectionStyle;

/* @abstract The focus style when a cell is focused
* @default UITableViewCellFocusStyleDefault
* ASTableView uses these properties when configuring UITableViewCells that host ASCellNodes.
*/
@property (nonatomic) UITableViewCellFocusStyle focusStyle;
@property UITableViewCellFocusStyle focusStyle;

/* @abstract The view used as the background of the cell when it is selected.
* ASTableView uses these properties when configuring UITableViewCells that host ASCellNodes.
* ASCollectionView uses these properties when configuring UICollectionViewCells that host ASCellNodes.
*/
@property (nonatomic, strong, nullable) UIView *selectedBackgroundView;
@property (nullable) UIView *selectedBackgroundView;

/* @abstract The accessory type view on the right side of the cell. Please take care of your ASLayoutSpec so that doesn't overlay the accessoryView
* @default UITableViewCellAccessoryNone
* ASTableView uses these properties when configuring UITableViewCells that host ASCellNodes.
*/
@property (nonatomic) UITableViewCellAccessoryType accessoryType;
@property UITableViewCellAccessoryType accessoryType;

/* @abstract The inset of the cell separator line
* ASTableView uses these properties when configuring UITableViewCells that host ASCellNodes.
*/
@property (nonatomic) UIEdgeInsets separatorInset;
@property UIEdgeInsets separatorInset;

@end

@interface ASCellNode (Unavailable)

- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock __unavailable;
- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE;

- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock __unavailable;
- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(nullable ASDisplayNodeDidLoadBlock)didLoadBlock NS_UNAVAILABLE;

- (void)setLayerBacked:(BOOL)layerBacked AS_UNAVAILABLE("ASCellNode does not support layer-backing, although subnodes may be layer-backed.");

Expand All @@ -239,22 +239,22 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) {
/**
* Text to display.
*/
@property (nonatomic, copy) NSString *text;
@property (nullable, copy) NSString *text;

/**
* A dictionary containing key-value pairs for text attributes. You can specify the font, text color, text shadow color, and text shadow offset using the keys listed in NSString UIKit Additions Reference.
*/
@property (nonatomic, copy) NSDictionary *textAttributes;
@property (copy) NSDictionary<NSAttributedStringKey, id> *textAttributes;

/**
* The text inset or outset for each edge. The default value is 15.0 horizontal and 11.0 vertical padding.
*/
@property (nonatomic, assign) UIEdgeInsets textInsets;
@property UIEdgeInsets textInsets;

/**
* The text node used by this cell node.
*/
@property (nonatomic, strong, readonly) ASTextNode *textNode;
@property (readonly) ASTextNode *textNode;

@end

Expand Down
Loading