Initial commit 🎉
fbshipit-source-id: b6fc29740c6875d2e78953b8a7123890a67930f2 Co-authored-by: Sebastian McKenzie <sebmck@fb.com> Co-authored-by: John Knox <jknox@fb.com> Co-authored-by: Emil Sjölander <emilsj@fb.com> Co-authored-by: Pritesh Nandgaonkar <prit91@fb.com>
This commit is contained in:
99
iOS/Sample/RootViewController.mm
Normal file
99
iOS/Sample/RootViewController.mm
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2018-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
#import "RootViewController.h"
|
||||
|
||||
#import <ComponentKit/CKBackgroundLayoutComponent.h>
|
||||
#import <ComponentKit/CKButtonComponent.h>
|
||||
#import <ComponentKit/CKComponent.h>
|
||||
#import <ComponentKit/CKComponentFlexibleSizeRangeProvider.h>
|
||||
#import <ComponentKit/CKComponentHostingView.h>
|
||||
#import <ComponentKit/CKComponentProvider.h>
|
||||
#import <ComponentKit/CKCompositeComponent.h>
|
||||
#import <ComponentKit/CKFlexboxComponent.h>
|
||||
#import <ComponentKit/CKImageComponent.h>
|
||||
#import <ComponentKit/CKInsetComponent.h>
|
||||
|
||||
@interface RootViewController ()
|
||||
|
||||
@property (strong, nonatomic) CKComponentHostingView *rootCKHostingView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RootViewController
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
_rootCKHostingView = [[CKComponentHostingView alloc]
|
||||
initWithComponentProvider:[self class]
|
||||
sizeRangeProvider:
|
||||
[CKComponentFlexibleSizeRangeProvider providerWithFlexibility:CKComponentSizeRangeFlexibleHeight]];
|
||||
|
||||
[self.view addSubview:_rootCKHostingView];
|
||||
[self loadViewIfNeeded];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.navigationItem.title = @"ComponentKit Layout";
|
||||
self.edgesForExtendedLayout = UIRectEdgeNone;
|
||||
}
|
||||
|
||||
- (void)viewDidLayoutSubviews
|
||||
{
|
||||
[super viewDidLayoutSubviews];
|
||||
_rootCKHostingView.frame = self.view.bounds;
|
||||
}
|
||||
|
||||
+ (CKComponent *)componentForModel:(id<NSObject>)model context:(id<NSObject>)context {
|
||||
return [CKBackgroundLayoutComponent
|
||||
newWithComponent:
|
||||
[CKFlexboxComponent
|
||||
newWithView:{
|
||||
}
|
||||
size:{}
|
||||
style:{}
|
||||
children: {
|
||||
{
|
||||
[CKButtonComponent
|
||||
newWithAction:nil
|
||||
options:{
|
||||
.titles = @"Purple",
|
||||
.titleColors = UIColor.purpleColor,
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
[CKButtonComponent
|
||||
newWithAction:nil
|
||||
options:{
|
||||
.titles = @"Brown",
|
||||
.titleColors = UIColor.brownColor,
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
[CKButtonComponent
|
||||
newWithAction:nil
|
||||
options:{
|
||||
.titles = @"Cyan",
|
||||
.titleColors = UIColor.cyanColor,
|
||||
}
|
||||
]
|
||||
},
|
||||
}]
|
||||
background:
|
||||
[CKImageComponent
|
||||
newWithImage:[UIImage imageNamed:@"sonarpattern"]
|
||||
attributes:{}
|
||||
size:{}]];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user