21 [
self setView:[[UIView alloc] init]];
27 #if (defined(SK_GANESH) && defined(SK_METAL) && !defined(SK_BUILD_FOR_GOOGLE3))
28 [
self setSkiaContext:MakeSkiaMetalContext()];
29 #elif (defined(SK_GANESH) && defined(SK_GL) && !defined(SK_BUILD_FOR_GOOGLE3))
30 [
self setSkiaContext:MakeSkiaGLContext()];
32 [
self setSkiaContext:MakeSkiaUIContext()];
35 NSLog(
@"abort: failed to make skia context.");
39 CGFloat screenWidth = [[UIScreen mainScreen] bounds].size.width;
41 UIStackView* stack = [[UIStackView alloc] init];
42 [stack setAxis:UILayoutConstraintAxisVertical];
43 [stack setDistribution:UIStackViewDistributionEqualSpacing];
45 NSBundle* mainBundle = [NSBundle mainBundle];
46 NSArray<NSString*>* paths = [mainBundle pathsForResourcesOfType:@"json"
48 constexpr CGFloat kSpacing = 2;
49 CGFloat totalHeight = kSpacing;
50 for (NSUInteger
i = 0;
i < [paths count]; ++
i) {
51 NSString*
path = [paths objectAtIndex:i];
52 NSData*
content = [NSData dataWithContentsOfFile:path];
54 NSLog(
@"'%@' not found",
path);
58 if (![controller loadAnimation:
content]) {
61 CGSize animSize = [controller
size];
62 CGFloat
height = animSize.width ? (screenWidth * animSize.height / animSize.width) : 0;
64 UIView* skiaView = [[
self skiaContext] makeViewWithController:controller withFrame:frame];
65 [[[skiaView heightAnchor] constraintEqualToConstant:height] setActive:true];
66 [[[skiaView widthAnchor] constraintEqualToConstant:screenWidth] setActive:true];
67 [skiaView setNeedsDisplay];
68 [stack addArrangedSubview:skiaView];
69 totalHeight +=
height + kSpacing;
71 [stack setFrame:{{0, 0}, {screenWidth, totalHeight}}];
72 [stack setNeedsDisplay];
74 CGFloat statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
75 CGSize mainScreenSize = [[UIScreen mainScreen] bounds].size;
76 CGRect scrollViewBounds = {{0, statusBarHeight},
77 {mainScreenSize.width, mainScreenSize.height - statusBarHeight}};
78 UIScrollView* scrollView = [[UIScrollView alloc] initWithFrame:scrollViewBounds];
79 [scrollView setContentSize:[stack frame].size];
80 [scrollView addSubview:stack];
81 [scrollView setBackgroundColor:[UIColor blackColor]];
82 [scrollView setNeedsDisplay];
84 [
self setStackView:stack];
86 UIView* mainView = [
self view];
87 [mainView setBounds:{{0, 0}, mainScreenSize}];
88 [mainView setBackgroundColor:[UIColor whiteColor]];
89 [mainView addSubview:scrollView];
90 [mainView setNeedsDisplay];
92 UITapGestureRecognizer* tapGestureRecognizer = [[UITapGestureRecognizer alloc] init];
93 [tapGestureRecognizer addTarget:self action:@selector(handleTap:)];
94 [mainView addGestureRecognizer:tapGestureRecognizer];
97- (void)handleTap:(UIGestureRecognizer*)sender {
98 if ([sender
state] != UIGestureRecognizerStateEnded) {
101 NSArray<UIView*>* subviews = [[
self stackView] subviews];
102 for (NSUInteger
i = 0;
i < [subviews count]; ++
i) {
103 UIView* uIView = [subviews objectAtIndex:i];
106 [uIView setNeedsDisplay];
112@interface AppDelegate : UIResponder <UIApplicationDelegate>
113 @property (strong, nonatomic) UIWindow*
window;
118- (
BOOL)application:(UIApplication*)app didFinishLaunchingWithOptions:(NSDictionary*)ops {
119 [
self setWindow:[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]];
121 [[
self window] makeKeyAndVisible];
128 return UIApplicationMain(argc,
argv, nil, NSStringFromClass([
AppDelegate class]));
SkiaContext * skiaContext
union flutter::testing::@2836::KeyboardChange::@76 content
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
int main(int argc, char *argv[])