All pastes #832778 Raw Edit

Miscellany

public text v1 · immutable
#832778 ·published 2007-12-26 16:44 UTC
rendered paste body
#import <UIKit/UIImageView.h>
#import "iCleanUp.h"
#import "MainView.h"

#import "About.h"



static About *sharedInstance = nil;

@implementation About

+ (About *) 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];	
}

-(id)initWithFrame:(CGRect)rect
{

	self = [super initWithFrame: rect];
	sharedInstance = self;

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

	preferencesTable = [[UIPreferencesTable alloc] initWithFrame:CGRectMake(0.0f, 45.0f, 320.0f, 415.0f)];	

	[preferencesTable setDataSource: self];
	[preferencesTable setDelegate: self];
	
	optionsGroup = [[UIPreferencesTableCell alloc] init];
	[optionsGroup setTitle:@""];


		ACache = [[UIPreferencesTableCell alloc] init];
		[ACache setTitle: @"Visit Our Site"];

		MTrash = [[UIPreferencesTableCell alloc] init];
		[MTrash setTitle: @"Donate"];


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


	DonateGroup = [[UIPreferencesTableCell alloc] init];
	DonateCell = [[UIPreferencesTableCell alloc] init];
	[DonateCell setTitle: nil];
	[DonateCell setEnabled: NO];

	DonateView = [[UIView alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 0.0f, 100.0f)];
	DonateText = [[UITextView alloc] initWithFrame: CGRectMake(75.0f, 3.0f, 230.0f, 60.0f)];
	[DonateText setEditable: NO];
	[DonateText setTextSize: 11];
	[DonateText setText: @"iCleanUp v1.0 Beta\nCopyright 2007 iDevNetWork.Net\nCredits: Jonathan McAllister"];
	
	[DonateView addSubview: DonateText];
	[DonateCell addSubview: DonateView];



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

	aboutView = [[UIView alloc] initWithFrame: CGRectMake(0.0f, 5.0f, rect.size.width, 100.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];



	return self;
}

// -----------------------------------------------------------------------------------
// - These classes create and control the Alert Box
// -----------------------------------------------------------------------------------
- (void)showAlert:(NSString *)aMessage withTitle:(NSString *)aTitle
{
	UIAlertSheet *alertSheet = [[UIAlertSheet alloc] initWithFrame:CGRectMake(0, 240, 320, 240)];
	[alertSheet setTitle:aTitle];
	[alertSheet setBodyText:aMessage];
	[alertSheet addButtonWithTitle:@"OK"];
	[alertSheet setDelegate:self];
	[alertSheet popupAlertAnimated:YES];
}


- (void)alertSheet:(UIAlertSheet *)sheet buttonClicked:(int)button
{
	[sheet dismissAnimated:YES];
}
// -----------------------------------------------------------------------------------
// - These classes create the Preference Table Groups, Cells And Rows
// -----------------------------------------------------------------------------------
- (int) numberOfGroupsInPreferencesTable: (UIPreferencesTable *)table {
	return 6;
}

- (UIPreferencesTableCell *)preferencesTable: (UIPreferencesTable *)table cellForGroup: (int)group {
	switch(group) {
		case 0: return optionsGroup;
		case 2: return aboutGroup;
		case 4: return aboutGroup;
		default: return nil;
	}
}

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



- (UIPreferencesTableCell *)preferencesTable: (UIPreferencesTable *)table cellForRow: (int)row inGroup: (int)group {
	switch(group) {

		case 0: return aboutGroup;
		case 1:
			switch(row) {

				case 0: return ACache;
				case 1: return MTrash;
				
		}
		case 2: return optionsGroup;
		case 3:
			switch(row) {
				case 0: return DonateCell;
			}
		case 4: return optionsGroup;
		case 5:
			switch(row) {
				case 0: return aboutCell;
			}

		default: return nil;
	}
}

- (float)preferencesTable: (UIPreferencesTable *)table heightForRow: (int)row inGroup:(int)group withProposedHeight: (float)proposed {
	switch(group) {
		case 0: return 20;
		case 1:
			switch (row)
			{
			case 0 : return 46.0f;
			case 1 : return 46.0f;
			}
		case 2: return 0;
		case 3: return 69.0f;
		case 4: return 0;
		case 5: return 69.0f;

		default: return proposed;
	}
}

// -----------------------------------------------------------------------------------
// - This class catches the NavBar Control events
// -----------------------------------------------------------------------------------
-(void)navigationBar:(UINavigationBar*)bar buttonClicked:(int)button{


	if (button == 1) //left, go to the about screen
	{

		[[UITransitionApplication sharedInstance] showView:[MainView sharedInstance]];

	}
}



@end