Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / darwin / CHIPTool / CHIPTool / View Controllers / RootViewController.m
1 /**
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *
5  *    Licensed under the Apache License, Version 2.0 (the "License");
6  *    you may not use this file except in compliance with the License.
7  *    You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *    Unless required by applicable law or agreed to in writing, software
12  *    distributed under the License is distributed on an "AS IS" BASIS,
13  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *    See the License for the specific language governing permissions and
15  *    limitations under the License.
16  */
17
18 #import "RootViewController.h"
19 #import "BindingsViewController.h"
20 #import "EchoViewController.h"
21 #import "MultiAdminViewController.h"
22 #import "OnOffViewController.h"
23 #import "QRCodeViewController.h"
24 #import "TemperatureSensorViewController.h"
25 #import "UnpairDevicesViewController.h"
26 #import "WifiViewController.h"
27
28 @implementation RootViewController
29
30 - (void)viewDidLoad
31 {
32     [super viewDidLoad];
33     self.self.navigationItem.title = @"Connected Home over IP";
34     [self setUpTableView];
35 }
36
37 - (void)setUpTableView
38 {
39     self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
40     self.tableView.delegate = self;
41     self.tableView.dataSource = self;
42     [self.view addSubview:self.tableView];
43     self.options = @[
44         @"QRCode scanner", @"Echo client", @"Light on / off cluster", @"Temperature Sensor", @"Bindings", @"Wifi Configuration",
45         @"Enable Pairing", @"Unpair Devices"
46     ];
47 }
48
49 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
50 {
51     return _options.count;
52 }
53
54 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
55 {
56     static NSString * cellIdentifier = @"CHIPToolOptionCell";
57
58     UITableViewCell * cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifier];
59
60     if (cell == nil) {
61         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
62     }
63     cell.textLabel.text = [_options objectAtIndex:indexPath.row];
64     return cell;
65 }
66
67 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
68 {
69     [tableView deselectRowAtIndexPath:indexPath animated:YES];
70     switch (indexPath.row) {
71     case 0:
72         [self pushQRCodeScanner];
73         break;
74     case 1:
75         [self pushEchoClient];
76         break;
77     case 2:
78         [self pushLightOnOffCluster];
79         break;
80     case 3:
81         [self pushTemperatureSensor];
82         break;
83     case 4:
84         [self pushBindings];
85         break;
86     case 5:
87         [self pushNetworkConfiguration];
88         break;
89     case 6:
90         [self pushMultiAdmin];
91         break;
92     case 7:
93         [self pushUnpairDevices];
94         break;
95     default:
96         break;
97     }
98 }
99
100 - (void)pushBindings
101 {
102     BindingsViewController * controller = [BindingsViewController new];
103     [self.navigationController pushViewController:controller animated:YES];
104 }
105
106 - (void)pushTemperatureSensor
107 {
108     TemperatureSensorViewController * controller = [TemperatureSensorViewController new];
109     [self.navigationController pushViewController:controller animated:YES];
110 }
111
112 - (void)pushNetworkConfiguration
113 {
114     WifiViewController * controller = [WifiViewController new];
115     [self.navigationController pushViewController:controller animated:YES];
116 }
117
118 - (void)pushQRCodeScanner
119 {
120     QRCodeViewController * controller = [QRCodeViewController new];
121     [self.navigationController pushViewController:controller animated:YES];
122 }
123
124 - (void)pushEchoClient
125 {
126     EchoViewController * controller = [EchoViewController new];
127     [self.navigationController pushViewController:controller animated:YES];
128 }
129
130 - (void)pushMultiAdmin
131 {
132     MultiAdminViewController * controller = [MultiAdminViewController new];
133     [self.navigationController pushViewController:controller animated:YES];
134 }
135
136 - (void)pushLightOnOffCluster
137 {
138     OnOffViewController * controller = [OnOffViewController new];
139     [self.navigationController pushViewController:controller animated:YES];
140 }
141
142 - (void)pushUnpairDevices
143 {
144     UnpairDevicesViewController * controller = [UnpairDevicesViewController new];
145     [self.navigationController pushViewController:controller animated:YES];
146 }
147 @end