| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- //
- // ThingsAddViewController.m
- // kneet
- //
- // Created by Jason Lee on 5/8/15.
- // Copyright (c) 2015 ntels. All rights reserved.
- //
- #import "JDObject.h"
- #import "RequestHandler.h"
- #import "DeviceModel.h"
- #import "CustomLabel.h"
- #import "CustomButton.h"
- #import "CustomImageView.h"
- #import "ThingsAddStartViewController.h"
- #import "ThingsAddViewController.h"
- @implementation ThingsAddTableViewCell
- // 가스 밸브 이미지명 : img_things_product_01_smartgasvalve
- // 도어센서 이미지 명 : img_things_product_02_mutisensor_door
- // 스마트플러그 이미지 명 : img_things_product_03_smartplug
- @end
- @interface ThingsAddViewController () <UITableViewDataSource, UITableViewDelegate> {
- NSArray *_addableDeviceList;
- }
- @end
- #pragma mark - Class Definition
- @implementation ThingsAddViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- [self initUI];
- [self prepareViewDidLoad];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- }
- - (void)initUI {
- [self initTableViewAsDefaultStyle:_tableView];
- }
- - (void)prepareViewDidLoad {
- _addableDeviceList = @[@{@"deviceName" : @"다원 스마트 플러그",
- @"manufacturer" : @"다원",
- @"nodeName" : @"스마트 플러그",
- @"deviceKey": @"DAOWN"},
-
- @{@"deviceName" : @"다우앤텍 멀티 센서",
- @"manufacturer" : @"다우엔텍",
- @"nodeName" : @"멀티센서",
- @"deviceKey": @"DAWOO"}];
-
- }
- #pragma mark - Main Logic
- #pragma mark - UITableView DataSource & Delegate
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return _addableDeviceList.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- CGFloat height = 220;
- return height;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- ThingsAddTableViewCell *cell = (ThingsAddTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"AddCellIdentifier"];
- NSDictionary *addableDevice = _addableDeviceList[indexPath.row];
- cell.lblDeviceName.text = addableDevice[@"deviceName"];
- cell.lblVendor.text = addableDevice[@"manufacturer"];
-
- // if (![cell.btnAdd actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
- // [cell.btnAdd addTarget:self action:@selector(btnAddDeviceTouched:) forControlEvents:UIControlEventTouchUpInside];
- // }
-
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
-
- NSDictionary *addableDevice = _addableDeviceList[indexPath.row];
-
- ThingsAddStartViewController *vc = (ThingsAddStartViewController *)[CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddStartViewController" storyboardName:@"Things"];
- vc.addableDevice = addableDevice;
- vc.providesPresentationContextTransitionStyle = YES;
- vc.definesPresentationContext = YES;
-
- [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
-
- [self presentViewController:vc animated:NO completion:nil];
- }
- #pragma mark - TableView Delegate
- - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
- // Remove seperator inset
- if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
- [cell setSeparatorInset:UIEdgeInsetsZero];
- }
- // Prevent the cell from inheriting the Table View's margin settings
- if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
- [cell setPreservesSuperviewLayoutMargins:NO];
- }
- // Explictly set your cell's layout margins
- if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
- [cell setLayoutMargins:UIEdgeInsetsZero];
- }
- }
- #pragma mark - UI Events
- - (IBAction)btnAddDeviceTouched:(id)sender {
-
- }
- - (IBAction)btnCloseTouched:(id)sender {
- [self dismissViewControllerAnimated:YES completion:nil];
- }
- #pragma mark - MemoryWarning
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
|