Permalink
Browse files

First commit

  • Loading branch information...
macbury committed Sep 20, 2009
0 parents commit 84a297094b5b9ef8a895f263e883223dd526f43c
BIN .DS_Store
Binary file not shown.
@@ -0,0 +1,35 @@
+//
+// Female_Male_Color_ConventerAppDelegate.h
+// Female-Male Color Conventer
+//
+// Created by MacBury on 08-07-29.
+// Copyright __MyCompanyName__ 2008. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@class Female_Male_Color_ConventerViewController;
+
+@interface Female_Male_Color_ConventerAppDelegate : NSObject <UIApplicationDelegate> {
+ IBOutlet UIWindow *window;
+ IBOutlet UINavigationController*pageController;
+ IBOutlet UIViewController * colorViewer;
+ IBOutlet UISearchBar * searchBar;
+
+ IBOutlet UITableView * colorTableView;
+ IBOutlet UILabel * hexLabel;
+ IBOutlet UILabel * colorLabel;
+
+ NSArray * kolory;
+ NSMutableArray * filteredListContent;
+
+ NSMutableDictionary * colorList;
+}
+
+- (IBAction) showInfo:(id)sender;
+
+@property (nonatomic, retain) UIWindow *window;
+
+@end
+
@@ -0,0 +1,153 @@
+//
+// Female_Male_Color_ConventerAppDelegate.m
+// Female-Male Color Conventer
+//
+// Created by MacBury on 08-07-29.
+// Copyright __MyCompanyName__ 2008. All rights reserved.
+//
+
+#import "Female_Male_Color_ConventerAppDelegate.h"
+#import "colorDataCell.h"
+
+@implementation Female_Male_Color_ConventerAppDelegate
+
+@synthesize window;
+
+- (void)applicationDidFinishLaunching:(UIApplication *)application {
+
+ NSString * pathToUserCopyOfPlist = [[NSBundle mainBundle] pathForResource:@"colorDataList" ofType:@"plist"];
+ kolory = [[NSArray alloc] initWithContentsOfFile:pathToUserCopyOfPlist];
+
+ filteredListContent = [[NSMutableArray alloc] initWithCapacity: [kolory count]];
+ [filteredListContent addObjectsFromArray: kolory];
+
+ [pageController setNavigationBarHidden:YES];
+
+ searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
+ searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
+ searchBar.showsCancelButton = NO;
+
+ [window addSubview:[pageController view]];
+ [window makeKeyAndVisible];
+
+}
+
+- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section {
+ return [filteredListContent count];
+}
+
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ if ([searchBar isFirstResponder])
+ [searchBar resignFirstResponder];
+ NSDictionary * color = [filteredListContent objectAtIndex:indexPath.row];
+
+ [hexLabel setText:[NSString stringWithFormat:@"HEX: %@", [color objectForKey:@"Geek"]]];
+ [colorLabel setText:[color objectForKey:@"Male"]];
+
+ colorViewer.navigationItem.title = [color objectForKey:@"Female"];
+ [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent;
+ colorViewer.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
+ colorViewer.view.backgroundColor = [UIColor colorWithRed:[[color objectForKey:@"Red"] floatValue]
+ green:[[color objectForKey:@"Green"] floatValue]
+ blue:[[color objectForKey:@"Blue"] floatValue]
+ alpha:1.0];
+ [pageController pushViewController:colorViewer animated:YES];
+}
+
+- (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath
+{
+ return UITableViewCellAccessoryDisclosureIndicator;
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+
+ static NSString * id = @"colorDataCell";
+ colorDataCell * cell = (colorDataCell *)[tableView dequeueReusableCellWithIdentifier:id];
+ NSDictionary * color = [filteredListContent objectAtIndex:indexPath.row];
+
+ if (cell == nil) {
+ cell = [[[colorDataCell alloc] initWithFrame:CGRectMake(0,0,0,0) reuseIdentifier:id] autorelease];
+ }
+
+ cell.colorView.backgroundColor = [UIColor colorWithRed:[[color objectForKey:@"Red"] floatValue]
+ green:[[color objectForKey:@"Green"] floatValue]
+ blue:[[color objectForKey:@"Blue"] floatValue]
+ alpha:1.0];
+ cell.colorName.text = [color objectForKey:@"Female"];
+ //cell.text = [[filteredListContent objectAtIndex:indexPath.row] objectForKey:@"Female"];
+
+ return cell;
+
+}
+
+
+- (void)searchBarTextDidBeginEditing:(UISearchBar *)sb
+{
+ searchBar.showsCancelButton = YES;
+}
+
+- (void)searchBarTextDidEndEditing:(UISearchBar *)sb
+{
+ searchBar.showsCancelButton = NO;
+}
+
+- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
+{
+ [filteredListContent removeAllObjects];
+
+ NSDictionary *cell;
+ for (cell in kolory)
+ {
+ NSString * cellTitle = [cell objectForKey:@"Female"];
+
+ NSComparisonResult result = [cellTitle compare:searchText options:NSCaseInsensitiveSearch
+ range:NSMakeRange(0, [searchText length])];
+ if (result == NSOrderedSame)
+ {
+ [filteredListContent addObject:cell];
+ }
+ }
+
+ [colorTableView reloadData];
+}
+
+
+- (void)searchBarCancelButtonClicked:(UISearchBar *)sb
+{
+ if (searchBar.text.length > 0)
+ {
+ [filteredListContent removeAllObjects];
+ [filteredListContent addObjectsFromArray: kolory];
+ }
+
+ [colorTableView reloadData];
+
+ [searchBar resignFirstResponder];
+ searchBar.text = @"";
+}
+
+- (void)searchBarSearchButtonClicked:(UISearchBar *)sb
+{
+ [searchBar resignFirstResponder];
+}
+
+- (IBAction) showInfo:(id)sender {
+ NSString * msg = @"Autor: macbury\n WWW: http://macbury.jogger.pl \nPomysł:pziewiec@gmail.com \nWersja web:http://ania.cc/fmcc/";
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"O programie" message:msg
+ delegate:self cancelButtonTitle:@"Może być" otherButtonTitles: nil];
+ [alert show];
+ [alert release];
+}
+
+- (void)dealloc {
+ [filteredListContent release];
+ [kolory release];
+ [window release];
+ [super dealloc];
+}
+
+
+
+@end
@@ -0,0 +1,16 @@
+//
+// colorViewController.h
+// CC
+//
+// Created by MacBury on 08-07-28.
+// Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface colorViewController : UIViewController {
+
+}
+
+@end
@@ -0,0 +1,53 @@
+//
+// colorViewController.m
+// CC
+//
+// Created by MacBury on 08-07-28.
+// Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import "colorViewController.h"
+
+
+@implementation colorViewController
+
+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
+ if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
+ // Initialization code
+ }
+ return self;
+}
+
+
+- (void)viewWillDisappear:(BOOL)animated
+{
+ [self.navigationController setNavigationBarHidden:YES animated:YES];
+ [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
+}
+
+- (void)viewWillAppear:(BOOL)animated
+{
+ self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
+ [self.navigationController setNavigationBarHidden:NO animated:YES];
+ [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent;
+}
+
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
+ // Return YES for supported orientations
+ return (interfaceOrientation == UIInterfaceOrientationPortrait);
+}
+
+
+- (void)didReceiveMemoryWarning {
+ [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
+ // Release anything that's not essential, such as cached data
+}
+
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+
+@end
Binary file not shown.
Oops, something went wrong.

0 comments on commit 84a2970

Please sign in to comment.