OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/showcase/core/app_delegate.h" | 5 #import "ios/showcase/core/app_delegate.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "ios/chrome/app/startup/ios_chrome_main.h" | 8 #include "ios/chrome/app/startup/ios_chrome_main.h" |
9 #import "ios/showcase/core/showcase_model.h" | 9 #import "ios/showcase/core/showcase_model.h" |
10 #import "ios/showcase/core/showcase_view_controller.h" | 10 #import "ios/showcase/core/showcase_view_controller.h" |
11 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" | 11 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
12 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MDCTypographyAd
ditions/MDFRobotoFontLoader+MDCTypographyAdditions.h" | |
13 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | |
14 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
15 | 13 |
16 #if !defined(__has_feature) || !__has_feature(objc_arc) | 14 #if !defined(__has_feature) || !__has_feature(objc_arc) |
17 #error "This file requires ARC support." | 15 #error "This file requires ARC support." |
18 #endif | 16 #endif |
19 | 17 |
20 @implementation AppDelegate | 18 @implementation AppDelegate |
21 @synthesize window = _window; | 19 @synthesize window = _window; |
22 | 20 |
23 - (BOOL)application:(UIApplication*)application | 21 - (BOOL)application:(UIApplication*)application |
24 didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { | 22 didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { |
25 base::MakeUnique<IOSChromeMain>(); | 23 base::MakeUnique<IOSChromeMain>(); |
26 ResourceBundle::InitSharedInstanceWithLocale( | 24 ResourceBundle::InitSharedInstanceWithLocale( |
27 std::string(), nullptr, ResourceBundle::LOAD_COMMON_RESOURCES); | 25 std::string(), nullptr, ResourceBundle::LOAD_COMMON_RESOURCES); |
28 [MDCTypography setFontLoader:[MDFRobotoFontLoader sharedInstance]]; | |
29 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | 26 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; |
30 ShowcaseViewController* viewController = | 27 ShowcaseViewController* viewController = |
31 [[ShowcaseViewController alloc] initWithRows:[self rowsToDisplay]]; | 28 [[ShowcaseViewController alloc] initWithRows:[self rowsToDisplay]]; |
32 UINavigationController* navigationController = [[UINavigationController alloc] | 29 UINavigationController* navigationController = [[UINavigationController alloc] |
33 initWithRootViewController:viewController]; | 30 initWithRootViewController:viewController]; |
34 self.window.rootViewController = navigationController; | 31 self.window.rootViewController = navigationController; |
35 [self.window makeKeyAndVisible]; | 32 [self.window makeKeyAndVisible]; |
36 | 33 |
37 return YES; | 34 return YES; |
38 } | 35 } |
39 | 36 |
40 #pragma mark - Private | 37 #pragma mark - Private |
41 | 38 |
42 // Creates model data to display in the view controller. | 39 // Creates model data to display in the view controller. |
43 - (NSArray<showcase::ModelRow*>*)rowsToDisplay { | 40 - (NSArray<showcase::ModelRow*>*)rowsToDisplay { |
44 NSArray<showcase::ModelRow*>* rows = [ShowcaseModel model]; | 41 NSArray<showcase::ModelRow*>* rows = [ShowcaseModel model]; |
45 NSSortDescriptor* sortDescriptor = | 42 NSSortDescriptor* sortDescriptor = |
46 [NSSortDescriptor sortDescriptorWithKey:showcase::kClassForDisplayKey | 43 [NSSortDescriptor sortDescriptorWithKey:showcase::kClassForDisplayKey |
47 ascending:YES]; | 44 ascending:YES]; |
48 return [rows sortedArrayUsingDescriptors:@[ sortDescriptor ]]; | 45 return [rows sortedArrayUsingDescriptors:@[ sortDescriptor ]]; |
49 } | 46 } |
50 | 47 |
51 @end | 48 @end |
OLD | NEW |