]> git.saurik.com Git - cydia.git/blame - Cydia/LoadingView.mm
Avoid counting a package as "lost" multiple times.
[cydia.git] / Cydia / LoadingView.mm
CommitLineData
70750ab3 1/* Cydia - iPhone UIKit Front-End for Debian APT
4c66fad9 2 * Copyright (C) 2008-2015 Jay Freeman (saurik)
70750ab3
JF
3*/
4
6d9696a5 5/* GNU General Public License, Version 3 {{{ */
70750ab3 6/*
6d9696a5
JF
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.
70750ab3 11 *
6d9696a5
JF
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.
70750ab3 16 *
6d9696a5
JF
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/>.
19**/
70750ab3
JF
20/* }}} */
21
63755c48 22#include "CyteKit/UCPlatform.h"
70750ab3
JF
23#include "CyteKit/Localize.h"
24
63755c48
JF
25#include "Cydia/LoadingView.h"
26
70750ab3
JF
27@implementation CydiaLoadingView
28
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];
33
34 spinner_ = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
35 [spinner_ startAnimating];
36 [container_ addSubview:spinner_];
37
38 label_ = [[[UILabel alloc] init] autorelease];
39 [label_ setFont:[UIFont boldSystemFontOfSize:15.0f]];
40 [label_ setBackgroundColor:[UIColor clearColor]];
c8910aa3 41 [label_ setTextColor:[UIColor viewFlipsideBackgroundColor]];
70750ab3
JF
42 [label_ setShadowColor:[UIColor whiteColor]];
43 [label_ setShadowOffset:CGSizeMake(0, 1)];
44 [label_ setText:[NSString stringWithFormat:Elision_, UCLocalize("LOADING"), nil]];
45 [container_ addSubview:label_];
46
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;
51
52 CGRect containrect = {
53 CGPointMake(floorf((viewsize.width / 2) - (bothwidth / 2)), floorf((viewsize.height / 2) - (spinnersize.height / 2))),
54 CGSizeMake(bothwidth, spinnersize.height)
55 };
56 CGRect textrect = {
57 CGPointMake(spinnersize.width + 5.0f, floorf((spinnersize.height / 2) - (textsize.height / 2))),
58 textsize
59 };
60 CGRect spinrect = {
61 CGPointZero,
62 spinnersize
63 };
64
65 [container_ setFrame:containrect];
66 [spinner_ setFrame:spinrect];
67 [label_ setFrame:textrect];
68 [self addSubview:container_];
69 } return self;
70}
71
72@end