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 "CyteKit/UCPlatform.h"
23 #include "CyteKit/Localize.h"
25 #include "Cydia/LoadingView.h"
27 @implementation CydiaLoadingView
29 - (id) initWithFrame:(CGRect)frame {
30 if ((self = [super initWithFrame:frame]) != nil) {
31 container_ = [[[UIView alloc] init] autorelease];
32 [container_ setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin];
34 spinner_ = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
35 [spinner_ startAnimating];
36 [container_ addSubview:spinner_];
38 label_ = [[[UILabel alloc] init] autorelease];
39 [label_ setFont:[UIFont boldSystemFontOfSize:15.0f]];
40 [label_ setBackgroundColor:[UIColor clearColor]];
41 [label_ setTextColor:[UIColor viewFlipsideBackgroundColor]];
42 [label_ setShadowColor:[UIColor whiteColor]];
43 [label_ setShadowOffset:CGSizeMake(0, 1)];
44 [label_ setText:[NSString stringWithFormat:Elision_, UCLocalize("LOADING"), nil]];
45 [container_ addSubview:label_];
47 CGSize viewsize = frame.size;
48 CGSize spinnersize = [spinner_ bounds].size;
49 CGSize textsize = [[label_ text] sizeWithFont:[label_ font]];
50 float bothwidth = spinnersize.width + textsize.width + 5.0f;
52 CGRect containrect = {
53 CGPointMake(floorf((viewsize.width / 2) - (bothwidth / 2)), floorf((viewsize.height / 2) - (spinnersize.height / 2))),
54 CGSizeMake(bothwidth, spinnersize.height)
57 CGPointMake(spinnersize.width + 5.0f, floorf((spinnersize.height / 2) - (textsize.height / 2))),
65 [container_ setFrame:containrect];
66 [spinner_ setFrame:spinrect];
67 [label_ setFrame:textrect];
68 [self addSubview:container_];