Composable Architecture (pendeknya TCA) adalah library untuk membangun aplikasi dengan cara yang konsisten dan mudah dimengerti, dengan komposisi, testing, dan design ergonomis. TCA dapat digunakan di SwiftUI, UIKit, dan lainnya, dan di platform Apple apa pun (iOS, macOS, tvOS, dan watchOS)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@propertyWrapper | |
struct NonEmptyString { | |
var wrappedValue: String? | |
init(wrappedValue: String?) { | |
if wrappedValue?.isEmpty == true { | |
self.wrappedValue = nil | |
} else { | |
self.wrappedValue = wrappedValue | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image.imageModificationBlock = { image in | |
// try to set rounded corner only to top left and bottom left | |
var modifiedImage: UIImage? | |
var rect = CGRect(origin: CGPoint.zero, size: image.size) | |
UIGraphicsBeginImageContextWithOptions(image.size, false, UIScreen.main.scale) | |
let maskPath = UIBezierPath(roundedRect: rect, byRoundingCorners: [UIRectCorner.topLeft, UIRectCorner.bottomLeft], cornerRadii: CGSize(width: 10, height: 10)) | |
maskPath.addClip() | |
image.draw(in: rect) | |
modifiedImage = UIGraphicsGetImageFromCurrentImageContext() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
myProtocol.h | |
*/ | |
@protocol MyProtocol <NSObject> | |
@property (nonatomic) BOOL myVariable; | |
@end | |
/** | |
MyClass.h | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AsyncDisplayKit | |
class ViewController: ASViewController<ASDisplayNode> { | |
private let storyNode: StoryNode | |
private let postNode: PostNode | |
init() { | |
self.storyNode = StoryNode(stories: Story.generateDummyStory()) | |
self.postNode = PostNode(posts: Post.generateDummyPosts()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AsyncDisplayKit | |
class StoryNode: ASCollectionNode{ | |
let stories: [Story] | |
init(stories: [Story]) { | |
self.stories = stories | |
let layout = UICollectionViewFlowLayout() | |
layout.scrollDirection = .horizontal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AsyncDisplayKit | |
class StoryCell: ASCellNode { | |
private let story: Story | |
// MARK: - Nodes | |
private let userPicture: ASImageNode | |
private let userName: ASTextNode | |
init(story: Story) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AsyncDisplayKit | |
class PostNode: ASTableNode { | |
private let posts: [Post] | |
init(posts: [Post]) { | |
self.posts = posts | |
super.init(style: .plain) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AsyncDisplayKit | |
class PostCell: ASCellNode { | |
let post: Post | |
// MARK: - Nodes | |
let headerNode: HeaderNode | |
let postImage: ASImageNode | |
let actionNode: ActionNode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AsyncDisplayKit | |
class ActionNode: ASDisplayNode { | |
// MARK: - Nodes | |
private let loveButton: ASImageNode | |
private let commentButton: ASImageNode | |
private let shareButton: ASImageNode | |
NewerOlder