-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathASMainViewController.m
More file actions
147 lines (125 loc) · 4.73 KB
/
Copy pathASMainViewController.m
File metadata and controls
147 lines (125 loc) · 4.73 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
//
// ASMainViewController.m
// ASDepthModal
//
// Created by Philippe Converset on 03/10/12.
// Copyright (c) 2012 AutreSphere. All rights reserved.
//
#import "ASMainViewController.h"
#import "ASDepthModalViewController.h"
#import <QuartzCore/QuartzCore.h>
@interface ASMainViewController ()
@property (nonatomic, strong) NSArray *configurationColors;
@property (nonatomic, strong) NSArray *configurationStyles;
@end
@implementation ASMainViewController
@synthesize configurationColors;
- (void)setupConfigurations
{
self.configurationColors = [NSArray arrayWithObjects:@"black (default)", @"pattern", nil];
self.configurationStyles = [NSArray arrayWithObjects:@"grow (default)", @"shrink", @"none",@"dropDown", nil];
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.popupView.layer.cornerRadius = 12;
self.popupView.layer.shadowOpacity = 0.7;
self.popupView.layer.shadowOffset = CGSizeMake(6, 6);
self.popupView.layer.shouldRasterize = YES;
self.popupView.layer.rasterizationScale = [[UIScreen mainScreen] scale];
[self setupConfigurations];
[self.colorTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone];
[self.styleTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone];
self.colorTableView.backgroundColor = [UIColor whiteColor];
self.colorTableView.backgroundView = nil;
self.styleTableView.backgroundColor = [UIColor whiteColor];
self.styleTableView.backgroundView = nil;
UIScrollView *scrollView;
scrollView = (UIScrollView *)self.styleTableView.superview.superview;
scrollView.contentSize = self.styleTableView.superview.bounds.size;
scrollView.alwaysBounceVertical = NO;
}
#pragma mark - Actions
- (IBAction)showModalViewAction:(id)sender
{
UIColor *color = nil;
ASDepthModalOptions style = ASDepthModalOptionAnimationGrow;
ASDepthModalOptions options;
NSInteger colorConfigurationIndex;
NSInteger styleConfigurationIndex;
colorConfigurationIndex = [self.colorTableView indexPathForSelectedRow].row;
if(colorConfigurationIndex == 1)
{
UIImage *image;
// This image comes from http://www.numero111.com/wp-content/uploads/2010/11/ist2_7360872-elegant-abstract-wallpaper-pattern-background-tiles-seamlessly.jpg
image = [UIImage imageNamed:@"pattern1.jpg"];
color = [UIColor colorWithPatternImage:image];
}
styleConfigurationIndex = [self.styleTableView indexPathForSelectedRow].row;
if(styleConfigurationIndex == 1)
{
style = ASDepthModalOptionAnimationShrink;
}
else if(styleConfigurationIndex == 2)
{
style = ASDepthModalOptionAnimationNone;
}
else if(styleConfigurationIndex == 3)
{
style = ASDepthModalOptionAnimationDropDown;
}
options = style | ASDepthModalOptionAnimationCloseDropDown | (self.blurSwitch.on?ASDepthModalOptionBlur:ASDepthModalOptionBlurNone) | (self.tapOutsideSwitch.on?ASDepthModalOptionTapOutsideToClose:ASDepthModalOptionTapOutsideInactive);
[ASDepthModalViewController presentView:self.popupView
backgroundColor:color
options:options
completionHandler:^{
NSLog(@"Modal view closed.");
}];
}
- (IBAction)closePopupAction:(id)sender
{
[ASDepthModalViewController dismiss];
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(tableView == self.colorTableView)
{
return self.configurationColors.count;
}
else
{
return self.configurationStyles.count;
}
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if(tableView == self.colorTableView)
{
return @"Back view color";
}
else
{
return @"Popup animation effect";
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell;
NSArray *titles;
titles = (tableView == self.colorTableView?self.configurationColors:self.configurationStyles);
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
cell.textLabel.text = [titles objectAtIndex:indexPath.row];
cell.backgroundColor = [UIColor whiteColor];
return cell;
}
- (void)viewDidUnload {
[self setBlurSwitch:nil];
[self setTapOutsideSwitch:nil];
[super viewDidUnload];
}
@end