Skip to content

Commit 35cb34a

Browse files
Turn more of the view creation junk into static methods.
1 parent 20cc047 commit 35cb34a

1 file changed

Lines changed: 43 additions & 39 deletions

File tree

ABReleaseNotesViewController/ABReleaseNotesViewController.m

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
@interface ABReleaseNotesViewController ()<UIViewControllerTransitioningDelegate>
3434
@property(nonatomic,copy) NSString *appIdentifier;
3535
@property(nonatomic,strong) ABReleaseNotesDownloader *downloader;
36-
@property(nonatomic,strong) UIView *roundedCornerView;
37-
@property(nonatomic,strong) UIVisualEffectView *vibrancyView;
3836
@property(nonatomic,strong) UILabel *titleLabel;
3937
@property(nonatomic,strong) UITextView *bodyText;
4038
@property(nonatomic,copy) UIColor *lineViewColor;
@@ -118,52 +116,18 @@ - (void)viewDidLoad {
118116
});
119117

120118
NSString *title = self.mode == ABReleaseNotesViewControllerModeProduction ? self.title : [NSString stringWithFormat:@"TESTING - %@", self.title];
121-
UINavigationBar *navigationBar = [self createNavigationBarWithTitle:title];
119+
UINavigationBar *navigationBar = [self.class createNavigationBarWithTitle:title];
122120

123121
NSArray *subviews = @[navigationBar, self.bodyText, [self.class makeLineViewWithColor:self.lineViewColor], closeButton];
124122

125-
[self createContainerViewsWithContentView:({
123+
UIView *view = [self.class createEffectsViewsWithFrame:self.view.bounds blurEffectStyle:self.blurEffectStyle contentView:({
126124
UIStackView *stackView = [[UIStackView alloc] initWithArrangedSubviews:subviews];
127125
stackView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
128126
stackView.axis = UILayoutConstraintAxisVertical;
129127
stackView;
130128
})];
131-
}
132-
133-
- (UINavigationBar*)createNavigationBarWithTitle:(NSString*)title {
134-
UINavigationBar *navigationBar = [[UINavigationBar alloc] init];
135-
[navigationBar pushNavigationItem:[[UINavigationItem alloc] initWithTitle:title] animated:YES];
136-
return navigationBar;
137-
}
138-
139-
- (void)createContainerViewsWithContentView:(UIView*)contentView {
140-
141-
self.roundedCornerView = [[UIView alloc] initWithFrame:self.view.bounds];
142-
self.roundedCornerView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
143-
self.roundedCornerView.clipsToBounds = YES;
144-
self.roundedCornerView.layer.cornerRadius = 8.f;
145-
[self.view addSubview:self.roundedCornerView];
146-
147-
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:self.blurEffectStyle];
148-
149-
UIVisualEffectView *background = ({
150-
UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
151-
effectView.frame = self.view.bounds;
152-
effectView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
153-
effectView;
154-
});
155-
[self.roundedCornerView addSubview:background];
156-
157-
self.vibrancyView = ({
158-
UIVisualEffectView *v = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
159-
v.frame = background.contentView.bounds;
160-
v.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
161-
v;
162-
});
163-
[background.contentView addSubview:self.vibrancyView];
164129

165-
contentView.frame = self.vibrancyView.contentView.bounds;
166-
[self.vibrancyView.contentView addSubview:contentView];
130+
[self.view addSubview:view];
167131
}
168132

169133
#pragma mark - Actions
@@ -230,4 +194,44 @@ + (UIView*)makeLineViewWithColor:(UIColor*)color {
230194
[v addConstraint:[NSLayoutConstraint constraintWithItem:v attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:0 multiplier:0 constant:1]];
231195
return v;
232196
}
197+
198+
199+
200+
+ (UINavigationBar*)createNavigationBarWithTitle:(NSString*)title {
201+
UINavigationBar *navigationBar = [[UINavigationBar alloc] init];
202+
[navigationBar pushNavigationItem:[[UINavigationItem alloc] initWithTitle:title] animated:YES];
203+
return navigationBar;
204+
}
205+
206+
+ (UIView*)createEffectsViewsWithFrame:(CGRect)frame blurEffectStyle:(UIBlurEffectStyle)blurEffectStyle contentView:(UIView*)contentView {
207+
208+
UIView *roundedCornerView = [[UIView alloc] initWithFrame:frame];
209+
roundedCornerView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
210+
roundedCornerView.clipsToBounds = YES;
211+
roundedCornerView.layer.cornerRadius = 8.f;
212+
213+
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:blurEffectStyle];
214+
215+
UIVisualEffectView *background = ({
216+
UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
217+
effectView.frame = frame;
218+
effectView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
219+
effectView;
220+
});
221+
[roundedCornerView addSubview:background];
222+
223+
UIVisualEffectView *vibrancyView = ({
224+
UIVisualEffectView *v = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
225+
v.frame = background.contentView.bounds;
226+
v.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
227+
v;
228+
});
229+
[background.contentView addSubview:vibrancyView];
230+
231+
contentView.frame = vibrancyView.contentView.bounds;
232+
[vibrancyView.contentView addSubview:contentView];
233+
234+
return roundedCornerView;
235+
}
236+
233237
@end

0 commit comments

Comments
 (0)