+ All Categories
Home > Software > ComponentKit basics presentation: Improving View Performance with ComponentKit

ComponentKit basics presentation: Improving View Performance with ComponentKit

Date post: 24-Jan-2018
Category:
Upload: corneliu-chitanu
View: 390 times
Download: 2 times
Share this document with a friend
16
Improving View Performance with ComponentKit
Transcript
Page 1: ComponentKit basics presentation: Improving View Performance with ComponentKit

Improving View Performance with

ComponentKit

Page 2: ComponentKit basics presentation: Improving View Performance with ComponentKit

1. Caracteristici ComponentKit 2. De tinut cont in utilizarea

ComponentKit 3. Code:

1.Sintaxa 2.Componente de bază 3.Good practices

Page 3: ComponentKit basics presentation: Improving View Performance with ComponentKit

Caracteristicile

ComponentKit

Page 4: ComponentKit basics presentation: Improving View Performance with ComponentKit

Facebook și-a dorit să mute complexitatea în

infrastructură

Page 5: ComponentKit basics presentation: Improving View Performance with ComponentKit
Page 6: ComponentKit basics presentation: Improving View Performance with ComponentKit

Immutability

Page 7: ComponentKit basics presentation: Improving View Performance with ComponentKit

Immutability

Page 8: ComponentKit basics presentation: Improving View Performance with ComponentKit

E declarativ

pentru specificarea 1. ierarhiei de view-uri 2. layout 3. modificarilor de stare

Page 9: ComponentKit basics presentation: Improving View Performance with ComponentKit

@implementation DCCTextComponent

+(instancetype)newWithText:(NSString *)postText context:(id)context { CGFloat componentWidth = [[context objectForKey:@"componentWidth"] doubleValue]; return [super newWithComponent: [CKStackLayoutComponent newWithView:{} size:{.width = componentWidth - 20} style:{} children:{ {[CKTextComponent newWithTextAttributes:{ .attributedString = [[NSAttributedString alloc] initWithString:postText attributes:@{NSFontAttributeName:[UIFont preferredFontForTextStyle:UIFontTextStyleBody], NSForegroundColorAttributeName:[UIColor blackColor]}], } viewAttributes:{ } accessibilityContext:{}]} }]];}

@end

Page 10: ComponentKit basics presentation: Improving View Performance with ComponentKit

Componentele = functii pure@implementation DCCTextComponent

+(instancetype)newWithText:(NSString *)postText context:(id)context { CGFloat componentWidth = [[context objectForKey:@"componentWidth"] doubleValue]; return [super newWithComponent: [CKStackLayoutComponent newWithView:{} size:{.width = componentWidth - 20} style:{} children:{ {[CKTextComponent newWithTextAttributes:{ .attributedString = [[NSAttributedString alloc] initWithString:postText attributes:@{NSFontAttributeName:[UIFont preferredFontForTextStyle:UIFontTextStyleBody], NSForegroundColorAttributeName:[UIColor blackColor]}], } viewAttributes:{ } accessibilityContext:{}]} }]];}

@end

Page 11: ComponentKit basics presentation: Improving View Performance with ComponentKit

Composable & Reusable@implementation DCCTextComponent

+(instancetype)newWithText:(NSString *)postText context:(id)context { CGFloat componentWidth = [[context objectForKey:@"componentWidth"] doubleValue]; return [super newWithComponent: [CKStackLayoutComponent newWithView:{} size:{.width = componentWidth - 20} style:{} children:{ {[CKTextComponent newWithTextAttributes:{ .attributedString = [[NSAttributedString alloc] initWithString:postText attributes:@{NSFontAttributeName:[UIFont preferredFontForTextStyle:UIFontTextStyleBody], NSForegroundColorAttributeName:[UIColor blackColor]}], } viewAttributes:{ } accessibilityContext:{}]} }]];}

@end

Page 12: ComponentKit basics presentation: Improving View Performance with ComponentKit

De tinut cont cand utilizam

ComponentKit

Page 13: ComponentKit basics presentation: Improving View Performance with ComponentKit

Tipuri de view potrivite pentru ComponentKit:

Liste care au un continut

complex

Page 14: ComponentKit basics presentation: Improving View Performance with ComponentKit

Puncte forte:

1.Performanta la scroll 2.Reciclarea view-urilor 3.Putin cod pentru o componentă

(if done right)

Page 15: ComponentKit basics presentation: Improving View Performance with ComponentKit

Puncte slabe:

1.Animațiile sunt mai greu de implementat

2.Nu e potrivit pentru view-uri dinamice, care se modifica des la interactiunea cu utilizatorul

3.Nu se poate integra cu Swift (Swift nu poate conlucra cu C++)

Page 16: ComponentKit basics presentation: Improving View Performance with ComponentKit

Code


Recommended