forked from Grouper/FlatUIKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewController.m
More file actions
184 lines (152 loc) · 8.83 KB
/
ViewController.m
File metadata and controls
184 lines (152 loc) · 8.83 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//
// ViewController.m
// FlatUI
//
// Created by Jack Flintermann on 5/3/13.
// Copyright (c) 2013 Jack Flintermann. All rights reserved.
//
#import "ViewController.h"
#import "TableViewController.h"
#import "UIColor+FlatUI.h"
#import "UISlider+FlatUI.h"
#import "UIStepper+FlatUI.h"
#import "UITabBar+FlatUI.h"
#import "UINavigationBar+FlatUI.h"
#import "FUIButton.h"
#import "FUISwitch.h"
#import "UIFont+FlatUI.h"
#import "FUIAlertView.h"
#import "UIBarButtonItem+FlatUI.h"
#import "UIProgressView+FlatUI.h"
#import "FUISegmentedControl.h"
#import "UIPopoverController+FlatUI.h"
@interface ViewController () {
UIPopoverController *_popoverController;
}
@property (weak, nonatomic) IBOutlet FUIButton *alertViewButton;
@property (weak, nonatomic) IBOutlet FUIButton *popoverButton;
@property (weak, nonatomic) IBOutlet UISlider *slider;
@property (weak, nonatomic) IBOutlet UIStepper *stepper;
@property (weak, nonatomic) IBOutlet FUISwitch *flatSwitch;
@property (strong, nonatomic) IBOutletCollection(UILabel) NSArray *labels;
@property (weak, nonatomic) IBOutlet UIProgressView *flatProgress;
@property (weak, nonatomic) IBOutlet FUISegmentedControl *flatSegmentedControl;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
if ([UIDevice currentDevice].systemVersion.floatValue >= 7) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
self.title = @"Flat UI";
self.view.backgroundColor = [UIColor cloudsColor];
[UIBarButtonItem configureFlatButtonsWithColor:[UIColor peterRiverColor]
highlightedColor:[UIColor belizeHoleColor]
cornerRadius:3
whenContainedIn:[UINavigationBar class], nil];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Plain Table"
style:UIBarButtonItemStylePlain
target:self
action:@selector(showPlainTableView:)];
[self.navigationItem.rightBarButtonItem removeTitleShadow];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Grouped Table"
style:UIBarButtonItemStylePlain
target:self
action:@selector(showTableView:)];
[self.navigationItem.leftBarButtonItem removeTitleShadow];
[self.navigationItem.leftBarButtonItem configureFlatButtonWithColor:[UIColor alizarinColor]
highlightedColor:[UIColor pomegranateColor]
cornerRadius:3];
self.alertViewButton.buttonColor = [UIColor turquoiseColor];
self.alertViewButton.shadowColor = [UIColor greenSeaColor];
self.alertViewButton.shadowHeight = 3.0f;
self.alertViewButton.cornerRadius = 6.0f;
self.alertViewButton.titleLabel.font = [UIFont boldFlatFontOfSize:16];
[self.alertViewButton setTitleColor:[UIColor cloudsColor] forState:UIControlStateNormal];
[self.alertViewButton setTitleColor:[UIColor cloudsColor] forState:UIControlStateHighlighted];
[self.slider configureFlatSliderWithTrackColor:[UIColor silverColor]
progressColor:[UIColor alizarinColor]
thumbColor:[UIColor pomegranateColor]];
[self.stepper configureFlatStepperWithColor:[UIColor wisteriaColor]
highlightedColor:[UIColor wisteriaColor]
disabledColor:[UIColor amethystColor]
iconColor:[UIColor cloudsColor]];
self.navigationController.navigationBar.titleTextAttributes = @{UITextAttributeFont: [UIFont boldFlatFontOfSize:18],
UITextAttributeTextColor: [UIColor whiteColor]};
[self.navigationController.navigationBar configureFlatNavigationBarWithColor:[UIColor midnightBlueColor]];
self.flatSwitch.onColor = [UIColor turquoiseColor];
self.flatSwitch.offColor = [UIColor cloudsColor];
self.flatSwitch.onBackgroundColor = [UIColor midnightBlueColor];
self.flatSwitch.offBackgroundColor = [UIColor silverColor];
self.flatSwitch.offLabel.font = [UIFont boldFlatFontOfSize:14];
self.flatSwitch.onLabel.font = [UIFont boldFlatFontOfSize:14];
[self.labels enumerateObjectsUsingBlock:^(UILabel *label, NSUInteger idx, BOOL *stop) {
label.font = [UIFont flatFontOfSize:16];
label.textColor = [UIColor midnightBlueColor];
}];
[self.flatProgress configureFlatProgressViewWithTrackColor:[UIColor silverColor] progressColor:[UIColor wisteriaColor]];
self.flatSegmentedControl.selectedFont = [UIFont boldFlatFontOfSize:16];
self.flatSegmentedControl.selectedFontColor = [UIColor cloudsColor];
self.flatSegmentedControl.deselectedFont = [UIFont flatFontOfSize:16];
self.flatSegmentedControl.deselectedFontColor = [UIColor cloudsColor];
self.flatSegmentedControl.selectedColor = [UIColor amethystColor];
self.flatSegmentedControl.deselectedColor = [UIColor silverColor];
self.flatSegmentedControl.dividerColor = [UIColor midnightBlueColor];
self.flatSegmentedControl.cornerRadius = 5.0;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
self.popoverButton.buttonColor = [UIColor carrotColor];
self.popoverButton.shadowColor = [UIColor alizarinColor];
self.popoverButton.shadowHeight = 3.0f;
self.popoverButton.cornerRadius = 6.0f;
self.popoverButton.titleLabel.font = [UIFont boldFlatFontOfSize:16];
[self.popoverButton setTitleColor:[UIColor cloudsColor] forState:UIControlStateNormal];
[self.popoverButton setTitleColor:[UIColor cloudsColor] forState:UIControlStateHighlighted];
}
}
- (IBAction)showAlertView:(id)sender {
FUIAlertView *alertView = [[FUIAlertView alloc] initWithTitle:@"Hello" message:@"This is an alert view" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:@"Do Something", nil];
alertView.delegate = self;
alertView.titleLabel.textColor = [UIColor cloudsColor];
alertView.titleLabel.font = [UIFont boldFlatFontOfSize:16];
alertView.messageLabel.textColor = [UIColor cloudsColor];
alertView.messageLabel.font = [UIFont flatFontOfSize:14];
alertView.backgroundOverlay.backgroundColor = [[UIColor cloudsColor] colorWithAlphaComponent:0.8];
alertView.alertContainer.backgroundColor = [UIColor midnightBlueColor];
alertView.defaultButtonColor = [UIColor cloudsColor];
alertView.defaultButtonShadowColor = [UIColor asbestosColor];
alertView.defaultButtonFont = [UIFont boldFlatFontOfSize:16];
alertView.defaultButtonTitleColor = [UIColor asbestosColor];
[alertView show];
}
- (IBAction)showPopover:(id)sender {
UIButton *button = (UIButton *)sender;
UIViewController *vc = [[UIViewController alloc] init];
vc.contentSizeForViewInPopover = CGSizeMake(320, 480);
vc.view.backgroundColor = [UIColor whiteColor];
vc.title = @"FUIPopoverController";
vc.navigationController.navigationBar.titleTextAttributes = @{UITextAttributeFont: [UIFont boldFlatFontOfSize:18],
UITextAttributeTextColor: [UIColor whiteColor]};
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:vc];
_popoverController = [[UIPopoverController alloc] initWithContentViewController:nc];
[_popoverController configureFlatPopoverWithBackgroundColor:[UIColor turquoiseColor] cornerRadius:9.0];
_popoverController.delegate = self;
[_popoverController presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
- (void)showTableView:(id)sender {
TableViewController* tableViewController = [[TableViewController alloc] initWithStyle:UITableViewStyleGrouped];
[self.navigationController pushViewController:tableViewController animated:YES];
}
- (void)showPlainTableView:(id)sender {
TableViewController* tableViewController = [[TableViewController alloc] initWithStyle:UITableViewStylePlain];
[self.navigationController pushViewController:tableViewController animated:YES];
}
#pragma mark - UIPopoverControllerDelegate Methods
- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController
{
return YES;
}
- (void) popoverControllerDidDismissPopover:(UIPopoverController *)popoverController {
_popoverController = nil;
}
@end