All pastes #834407 Raw Edit

Someone

public text v1 · immutable
#834407 ·published 2007-12-28 04:41 UTC
rendered paste body
#import "iCleanUp.h"
#import "MainView.h"
#import "About.h"

static AboutView *sharedInstance = nil;

@implementation AboutView

+ (AboutView *) sharedInstance {
	return ( sharedInstance ? sharedInstance : ( sharedInstance = [[self alloc] init] ) );
}

-(id)init{
	struct CGRect rect = [UIHardware fullScreenApplicationContentRect];
    rect.origin.x = rect.origin.y = 0.0f;

	return [self initWithFrame:rect];	
}

// designated initializer
-(id)initWithFrame:(CGRect)rect
{
	self = [super initWithFrame:rect];
		
	preferencesTable = [[UIPreferencesTable alloc] initWithFrame: CGRectMake(0.0f, 48.0f, 320.0f, 480.0f-48.0f)];
	
	[preferencesTable setDataSource: self];
	[preferencesTable setDelegate: self];

	topBar = [[UINavigationBar alloc] init];
	[topBar setFrame:CGRectMake(0.0f, 0.0f, 320.0f, 48.0f)];
 	[topBar pushNavigationItem: [[UINavigationItem alloc] initWithTitle: @"iCleanUp 1.0"]];
	[topBar showButtonsWithLeftTitle: @"Back" rightTitle: nil leftBack: YES ]; 
	[topBar enableAnimation];
	[topBar setBarStyle:0];
	[topBar setDelegate:self];

	MainGroup = [[UIPreferencesTableCell alloc] init];
	[MainGroup setTitle:@""];

		Donate = [[UIPreferencesTableCell alloc] init];
		[Donate setTitle: @"Donate!"];
		[Donate setShowDisclosure:YES];
		[Donate setDisclosureStyle:2];

		Site = [[UIPreferencesTableCell alloc] init];
		[Site setTitle: @"Visit Our Site"];
		[Site setShowDisclosure:YES];
		[Site setDisclosureStyle:2];


		EMail = [[UIPreferencesTableCell alloc] init];
		[EMail setTitle: @"E-Mail Us"];
		[EMail setShowDisclosure:YES];
		[EMail setDisclosureStyle:2];

	TextAGroup = [[UIPreferencesTableCell alloc] init];
	[TextAGroup setTitle:@"(C)opyright 2007 iDevNetwork"];

	aboutGroup = [[UIPreferencesTableCell alloc] init];
	aboutCell = [[UIPreferencesTableCell alloc] init];
	[aboutCell setTitle: @""];
	[aboutCell setEnabled: NO];

	aboutView = [[UIView alloc] initWithFrame: CGRectMake(0.0f, 5.0f, rect.size.width, 60.0f)];
	aboutText = [[UITextView alloc] initWithFrame: CGRectMake(75.0f, 3.0f, 230.0f, 60.0f)];
	[aboutText setEditable: NO];
	[aboutText setTextSize: 11];
	[aboutText setText: @"iCleanUp v1.0 Beta\nCopyright 2007 iDevNetWork.Net\nCredits: Jonathan McAllister"];
	UIImageView *aboutImage = [[UIImageView alloc] initWithFrame: CGRectMake(15.0f, 0.0f, 32.0f, 32.0f)];
	[aboutImage setImage: [UIImage applicationImageNamed: @"icon.png"]];
	
	[aboutView addSubview: aboutText];
	[aboutView addSubview: aboutImage];
	[aboutCell addSubview: aboutView];

	
	[self addSubview:topBar];
	[self addSubview:preferencesTable];

	[preferencesTable reloadData];

	
	return self;
}

// -----------------------------------------------------------------------------------
// - These classes create the Preference Table Groups, Cells And Rows
// -----------------------------------------------------------------------------------
- (int) numberOfGroupsInPreferencesTable: (UIPreferencesTable *)table {
	return 3;
}

- (UIPreferencesTableCell *)preferencesTable: (UIPreferencesTable *)table cellForGroup: (int)group {
	switch(group) {

		case 0: return TextAGroup;

		default: return nil;
	}
}

- (int) preferencesTable: (UIPreferencesTable *)table numberOfRowsInGroup: (int) group {
	switch(group) {
		case 0: return 0;
		case 1: return 3;
		case 2: return 1;
		default: return 0;
	}
}



- (UIPreferencesTableCell *)preferencesTable: (UIPreferencesTable *)table cellForRow: (int)row inGroup: (int)group {
	switch(group) {
		case 0: return TextAGroup;
		case 1:
			switch(row) {

				case 0: return Donate;
				case 1: return Site;
				case 2: return EMail;
				
		}
		case 2:
			switch(row) {
				case 0: return Donate;
			}

		default: return nil;
	}
}

- (float)preferencesTable: (UIPreferencesTable *)table heightForRow: (int)row inGroup:(int)group withProposedHeight: (float)proposed {
	switch(group) {
		case 0: return 26;
		case 1:
			switch (row)
			{

			case 0 : return 46;
			case 1 : return 46;
			case 2 : return 46;

			}

		case 2: return 69;
		default: return proposed;
	}
}

- (void)tableRowSelected:(NSNotification *)notification
{
	
	if ([preferencesTable selectedRow] == 2) {
		
		UITransitionApplication *_UITransitionApplication = [UITransitionApplication sharedInstance];
		[_UITransitionApplication openURL:[NSURL URLWithString:@"https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=andreas%40schwelling%2ede&item_name=ZIPcodes.app%20donation&no_shipping=0&no_note=1&tax=0&currency_code=EUR&bn=PP%2dDonationsBF&charset=UTF%2d8"]];
	
		return;

		
	}
	
	if ([preferencesTable selectedRow] == 3) {
		


		UITransitionApplication *_UITransitionApplication = [UITransitionApplication sharedInstance];
		[_UITransitionApplication openURL:[NSURL URLWithString:@"http://google.com/"]];


		
	}
	
	if ([preferencesTable selectedRow] == 4) {
		

		
		UITransitionApplication *_UITransitionApplication = [UITransitionApplication sharedInstance];
		[_UITransitionApplication openURL:[NSURL URLWithString:@"http://google.com/"]];
		
	}
	
	
}



- (void)navigationBar:(UINavigationBar*)bar buttonClicked:(int)button
{
	// go back to screen one
	NSLog(@"navigationBar:%@, buttonClicked:%i",bar, button);
	[[UITransitionApplication sharedInstance] showView:[MainView sharedInstance]];
}



@end