forked from draveness/DKNightVersion
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRootViewController.m
More file actions
107 lines (82 loc) · 3.72 KB
/
RootViewController.m
File metadata and controls
107 lines (82 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//
// RootViewController.m
// DKNightVerision
//
// Created by Draveness on 4/14/15.
// Copyright (c) 2015 Draveness. All rights reserved.
//
#import "RootViewController.h"
#import "SuccViewController.h"
#import "PresentingViewController.h"
#import <DKNightVersion/DKNightVersion.h>
#import "TableViewCell.h"
@pickerify(TableViewCell, cellTintColor)
@interface RootViewController ()
@end
@implementation RootViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self.tableView registerClass:[TableViewCell class] forCellReuseIdentifier:@"Cell"];
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
UILabel *navigationLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 375, 44)];
navigationLabel.text = @"DKNightVersion";
navigationLabel.textAlignment = NSTextAlignmentCenter;
self.navigationItem.titleView = navigationLabel;
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"Present" style:UIBarButtonItemStylePlain target:self action:@selector(present)];
self.navigationItem.leftBarButtonItem = item;
UIBarButtonItem *normalItem = [[UIBarButtonItem alloc] initWithTitle:@"Normal" style:UIBarButtonItemStylePlain target:self action:@selector(normal)];
normalItem.dk_tintColorPicker = DKColorPickerWithKey(TINT);
UIBarButtonItem *nightItem = [[UIBarButtonItem alloc] initWithTitle:@"Night" style:UIBarButtonItemStylePlain target:self action:@selector(night)];
nightItem.dk_tintColorPicker = DKColorPickerWithKey(TINT);
UIBarButtonItem *redItem = [[UIBarButtonItem alloc] initWithTitle:@"Red" style:UIBarButtonItemStylePlain target:self action:@selector(red)];
redItem.dk_tintColorPicker = DKColorPickerWithKey(TINT);
self.navigationItem.rightBarButtonItems = @[normalItem, nightItem, redItem];
// self.tableView.dk_backgroundColorPicker = DKColorPickerWithKey(BG);
self.tableView.dk_backgroundColorPicker = DKColorPickerWithRGB(0xffffff, 0x343434, 0xfafafa);
self.tableView.dk_separatorColorPicker = DKColorPickerWithKey(SEP);
navigationLabel.dk_textColorPicker = DKColorPickerWithKey(TEXT);
self.navigationController.navigationBar.dk_barTintColorPicker = DKColorPickerWithKey(BAR);
self.navigationItem.leftBarButtonItem.dk_tintColorPicker = DKColorPickerWithKey(TINT);
}
- (void)night {
self.dk_manager.themeVersion = DKThemeVersionNight;
}
- (void)normal {
self.dk_manager.themeVersion = DKThemeVersionNormal;
}
- (void)red {
self.dk_manager.themeVersion = @"RED";
}
- (void)change {
if ([self.dk_manager.themeVersion isEqualToString:DKThemeVersionNight]) {
[self.dk_manager dawnComing];
} else {
[self.dk_manager nightFalling];
}
}
- (void)push {
[self.navigationController pushViewController:[[SuccViewController alloc] init] animated:YES];
}
- (void)present {
[self presentViewController:[[PresentingViewController alloc] init] animated:YES completion:nil];
}
#pragma mark - UITableView Delegate & DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 10;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
cell.dk_backgroundColorPicker = DKColorPickerWithRGB(0xffffff, 0x343434, 0xfafafa);
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 100;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[self push];
}
@end