Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: pkg/immi_samples/lib/ios/ImmiSamples/MenuPresenter.mm

Issue 2035023003: Remove service-compiler related code. (Closed) Base URL: git@github.com:dartino/sdk.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE.md file.
4
5 #import "MenuPresenter.h"
6
7 @interface MenuPresenter ()
8
9 @property (weak) MenuNode* root;
10 @property UINavigationController* navigationController;
11
12 @end
13
14 @implementation MenuPresenter
15
16 - (id)initWithCoder:(NSCoder*)aDecoder {
17 self = [super initWithCoder:aDecoder];
18 self.navigationController =
19 [[UINavigationController alloc] initWithRootViewController:self];
20 return self;
21 }
22
23 - (void)presentMenu:(MenuNode*)node {
24 self.root = node;
25 [self performSelectorOnMainThread:@selector(presentOnMainThread:)
26 withObject:node
27 waitUntilDone:NO];
28 }
29
30 - (void)presentOnMainThread:(MenuNode*)node {
31 self.navigationController.title = node.title;
32 [self.tableView reloadData];
33 }
34
35 - (void)patchMenu:(MenuPatch*)patch {
36 [self performSelectorOnMainThread:@selector(patchOnMainThread:)
37 withObject:patch
38 waitUntilDone:NO];
39 }
40
41 - (void)patchOnMainThread:(MenuPatch*)patch {
42 if (patch.title.changed) {
43 self.navigationController.title = patch.title.current;
44 }
45 if (patch.items.changed) {
46 // TODO(zerny): selectively reload only changed cells.
47 [self.tableView reloadData];
48 }
49 }
50
51 - (UIViewController *)viewController {
52 return self.navigationController;
53 }
54
55 - (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView {
56 return 1;
57 }
58
59 - (NSInteger)tableView:(UITableView*)tableView
60 numberOfRowsInSection:(NSInteger)section {
61 assert(section == 0);
62 return self.root.items.count;
63 }
64
65 - (UITableViewCell*)tableView:(UITableView*)tableView
66 cellForRowAtIndexPath:(NSIndexPath*)indexPath {
67 UITableViewCell* cell =
68 [tableView dequeueReusableCellWithIdentifier:@"MenuItemPrototypeCell"
69 forIndexPath:indexPath];
70 MenuItemNode* item = self.root.items[indexPath.row];
71 cell.textLabel.text = item.title;
72 return cell;
73 }
74
75 - (void)tableView:(UITableView*)tableView
76 didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
77 MenuItemNode* item = self.root.items[indexPath.row];
78 item.select();
79 }
80
81 @end
OLDNEW
« no previous file with comments | « pkg/immi_samples/lib/ios/ImmiSamples/MenuPresenter.h ('k') | pkg/immi_samples/lib/ios/ImmiSamples/SlidingWindowPresenter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698