1 /* Cydia - iPhone UIKit Front-End for Debian APT
2 * Copyright (C) 2008-2015 Jay Freeman (saurik)
5 /* GNU General Public License, Version 3 {{{ */
7 * Cydia is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation, either version 3 of the License,
10 * or (at your option) any later version.
12 * Cydia is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Cydia. If not, see <http://www.gnu.org/licenses/>.
22 #include "Cydia/LoadingView.h"
23 #include "CyteKit/Localize.h"
25 @implementation CydiaLoadingView
27 - (id) initWithFrame:(CGRect)frame {
28 if ((self = [super initWithFrame:frame]) != nil) {
29 container_ = [[[UIView alloc] init] autorelease];
30 [container_ setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin];
32 spinner_ = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
33 [spinner_ startAnimating];
34 [container_ addSubview:spinner_];
36 label_ = [[[UILabel alloc] init] autorelease];
37 [label_ setFont:[UIFont boldSystemFontOfSize:15.0f]];
38 [label_ setBackgroundColor:[UIColor clearColor]];
39 [label_ setTextColor:[UIColor viewFlipsideBackgroundColor]];
40 [label_ setShadowColor:[UIColor whiteColor]];
41 [label_ setShadowOffset:CGSizeMake(0, 1)];
42 [label_ setText:[NSString stringWithFormat:Elision_, UCLocalize("LOADING"), nil]];
43 [container_ addSubview:label_];
45 CGSize viewsize = frame.size;
46 CGSize spinnersize = [spinner_ bounds].size;
47 CGSize textsize = [[label_ text] sizeWithFont:[label_ font]];
48 float bothwidth = spinnersize.width + textsize.width + 5.0f;
50 CGRect containrect = {
51 CGPointMake(floorf((viewsize.width / 2) - (bothwidth / 2)), floorf((viewsize.height / 2) - (spinnersize.height / 2))),
52 CGSizeMake(bothwidth, spinnersize.height)
55 CGPointMake(spinnersize.width + 5.0f, floorf((spinnersize.height / 2) - (textsize.height / 2))),
63 [container_ setFrame:containrect];
64 [spinner_ setFrame:spinrect];
65 [label_ setFrame:textrect];
66 [self addSubview:container_];