/* Cydia - iPhone UIKit Front-End for Debian APT * Copyright (C) 2008-2015 Jay Freeman (saurik) */ /* GNU General Public License, Version 3 {{{ */ /* * Cydia is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, * or (at your option) any later version. * * Cydia is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Cydia. If not, see . **/ /* }}} */ #include "CyteKit/UCPlatform.h" #include "CyteKit/Localize.h" #include "Cydia/LoadingView.h" @implementation CydiaLoadingView - (id) initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame]) != nil) { container_ = [[[UIView alloc] init] autorelease]; [container_ setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin]; spinner_ = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease]; [spinner_ startAnimating]; [container_ addSubview:spinner_]; label_ = [[[UILabel alloc] init] autorelease]; [label_ setFont:[UIFont boldSystemFontOfSize:15.0f]]; [label_ setBackgroundColor:[UIColor clearColor]]; [label_ setTextColor:[UIColor viewFlipsideBackgroundColor]]; [label_ setShadowColor:[UIColor whiteColor]]; [label_ setShadowOffset:CGSizeMake(0, 1)]; [label_ setText:[NSString stringWithFormat:Elision_, UCLocalize("LOADING"), nil]]; [container_ addSubview:label_]; CGSize viewsize = frame.size; CGSize spinnersize = [spinner_ bounds].size; CGSize textsize = [[label_ text] sizeWithFont:[label_ font]]; float bothwidth = spinnersize.width + textsize.width + 5.0f; CGRect containrect = { CGPointMake(floorf((viewsize.width / 2) - (bothwidth / 2)), floorf((viewsize.height / 2) - (spinnersize.height / 2))), CGSizeMake(bothwidth, spinnersize.height) }; CGRect textrect = { CGPointMake(spinnersize.width + 5.0f, floorf((spinnersize.height / 2) - (textsize.height / 2))), textsize }; CGRect spinrect = { CGPointZero, spinnersize }; [container_ setFrame:containrect]; [spinner_ setFrame:spinrect]; [label_ setFrame:textrect]; [self addSubview:container_]; } return self; } @end