Skip to content

Commit

Permalink
Updated text size and color for results. Also the clearbutton now sho…
Browse files Browse the repository at this point in the history
…ws up after a search is completed.
  • Loading branch information
Sahil Desai committed Oct 21, 2009
1 parent 565f80a commit 1f9da44
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 25 deletions.
6 changes: 6 additions & 0 deletions Classes/MainViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
IBOutlet UITableView *myTableView;
IBOutlet UISearchBar *mySearchBar;
IBOutlet UIActivityIndicatorView *activityIndicator;
IBOutlet UIView *whiteBgView;

NSData *jsonData;
NSURL *jsonURL;
Expand All @@ -33,6 +34,11 @@

- (void) toggleActivityIndicator:(BOOL)show;
- (void) setKeyboardState:(BOOL)show;
- (void)_showKeyboardWorkAround;

/* i know, these are hacky, got a better idea? ok fine, then fork it and fix it. jeez */
- (void)_showClearButton;
- (void)_hideClearButton;

- (void) search;
- (BOOL) networkAvailable;
Expand Down
25 changes: 17 additions & 8 deletions Classes/MainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ - (void)viewDidLoad {
[super viewDidLoad];
}

- (void)viewDidUnload {
}

- (BOOL)networkAvailable {

if ([internetReach currentReachabilityStatus] == NotReachable) {
Expand All @@ -72,14 +69,16 @@ - (BOOL)networkAvailable {
#pragma mark UISearchBarDelegate methods

- (void)toggleActivityIndicator:(BOOL)show; {
[self _hideClearButton];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 0.3];
[UIView setAnimationDelegate:self];
if(show)
[activityIndicator startAnimating];
else
[activityIndicator stopAnimating];
[activityIndicator setAlpha:show ? 1 : 0];
[UIView commitAnimations];
[UIView commitAnimations];
}

- (void)setKeyboardState:(BOOL)show; {
Expand Down Expand Up @@ -169,8 +168,9 @@ - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(_showClearButton) object:nil];

jsonString = [[NSString alloc] initWithData:receivedData encoding:NSASCIIStringEncoding];
//NSLog(@"JSON: %@",jsonString);
jsonData = [jsonString dataUsingEncoding:NSUTF32BigEndianStringEncoding];
NSDictionary *dictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:nil];

Expand All @@ -182,7 +182,7 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
Result *newResult = [[Result alloc] init];
newResult.domainName = [result objectForKey:@"domain"];
newResult.availability = [result objectForKey:@"availability"];

newResult.path = [result objectForKey:@"path"];

NSMutableArray *registrars = [result objectForKey:@"registrars"];
for (NSString *registrar in registrars) {
Expand All @@ -198,6 +198,15 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[myTableView reloadData];
loading = NO;
[self toggleActivityIndicator:NO];
[self performSelector:@selector(_showClearButton) withObject:nil afterDelay:0.3];
}

- (void)_showClearButton; {
[whiteBgView setHidden:YES];
}

- (void)_hideClearButton; {
[whiteBgView setHidden:NO];
}

#pragma mark Table view methods
Expand All @@ -207,8 +216,8 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa

NSString *domainNameString = [[results objectAtIndexA:indexPath.row] domainName];
CGSize aSize;
aSize = [domainNameString sizeWithFont:[UIFont systemFontOfSize:16]
constrainedToSize:CGSizeMake(UIInterfaceOrientationIsPortrait(self.interfaceOrientation) ? 230.0 : 390, 1000)
aSize = [domainNameString sizeWithFont:[UIFont systemFontOfSize:17]
constrainedToSize:CGSizeMake(UIInterfaceOrientationIsPortrait(self.interfaceOrientation) ? 260.0 : 420, 1000)
lineBreakMode:UILineBreakModeTailTruncation];
return aSize.height+35;
}
Expand Down
21 changes: 11 additions & 10 deletions Classes/ResultCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ - (void) setResult: (Result*) theResult; {

- (void) drawCellInteriorInRect: (CGRect) rect isSelected: (BOOL) isSelected; {
if (!domainFont) {
domainFont = [[UIFont systemFontOfSize:16] retain];
domainFont = [[UIFont systemFontOfSize:17] retain];
availabilityFont = [[UIFont systemFontOfSize:14] retain];
}

Expand All @@ -91,26 +91,27 @@ - (void) drawCellInteriorInRect: (CGRect) rect isSelected: (BOOL) isSelected; {
lightTextColor = [UIColor whiteColor];
}
else {
mainTextColor = [UIColor blackColor];
if(result.imageType == kUnavailable)
mainTextColor = [UIColor blackColor];
else
mainTextColor = UIColorFromRGB(0x2160AD);
lightTextColor = [UIColor grayColor];
self.backgroundColor = [UIColor whiteColor];
}

[mainTextColor set];
[result.domainName drawInRect:CGRectMake(40, 10, rect.size.width - 50, rect.size.height) withFont:domainFont lineBreakMode:UILineBreakModeWordWrap];
[result.domainName drawInRect:CGRectMake(30, 8, rect.size.width - 60, rect.size.height) withFont:domainFont lineBreakMode:UILineBreakModeWordWrap];

[lightTextColor set];
[result.availability drawInRect:CGRectMake(40, rect.size.height - 25, rect.size.width - 50, 20) withFont:availabilityFont lineBreakMode:UILineBreakModeWordWrap];
[result.availability drawInRect:CGRectMake(30, rect.size.height - 25, rect.size.width - 50, 20) withFont:availabilityFont lineBreakMode:UILineBreakModeWordWrap];

if(result.imageType == kAvailable)
[[UIImage imageNamed:@"available.png"] drawInRect: CGRectMake(12.5, (rect.size.height - 20) / 2.0, 15, 15) blendMode: kCGBlendModeNormal alpha: 1.0];
[[UIImage imageNamed:@"available.png"] drawInRect: CGRectMake(10, 15, 10, 10) blendMode: kCGBlendModeNormal alpha: 1.0];
else if(result.imageType == kMaybe)
[[UIImage imageNamed:@"maybe.png"] drawInRect: CGRectMake(12.5, (rect.size.height - 20) / 2.0, 15, 15) blendMode: kCGBlendModeNormal alpha: 1.0];
[[UIImage imageNamed:@"maybe.png"] drawInRect: CGRectMake(10, 15, 10, 10) blendMode: kCGBlendModeNormal alpha: 1.0];
else if(result.imageType == kTLD)
[[UIImage imageNamed:@"tld.png"] drawInRect: CGRectMake(12.5, (rect.size.height - 20) / 2.0, 15, 15) blendMode: kCGBlendModeNormal alpha: 1.0];
else if(result.imageType == kTaken) {
//currentImage = [UIImage imageNamed: @"taken.png"];
}
[[UIImage imageNamed:@"tld.png"] drawInRect: CGRectMake(10, 15, 10, 10) blendMode: kCGBlendModeNormal alpha: 1.0];

}

- (void) drawCellBackgroundInRect: (CGRect) theRect; {
Expand Down
24 changes: 17 additions & 7 deletions MainViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<data>
<int key="IBDocument.SystemTarget">768</int>
<string key="IBDocument.SystemVersion">10B504</string>
<string key="IBDocument.InterfaceBuilderVersion">732</string>
<string key="IBDocument.InterfaceBuilderVersion">740</string>
<string key="IBDocument.AppKitVersion">1038.2</string>
<string key="IBDocument.HIToolboxVersion">437.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
Expand All @@ -12,7 +12,7 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="4"/>
<integer value="1"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -58,7 +58,7 @@
<bool key="IBUIShowsSelectionImmediatelyOnTouchBegin">YES</bool>
<float key="IBUIRowHeight">44</float>
</object>
<object class="IBUIImageView" id="9962199">
<object class="IBUIImageView" id="266356808">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{0, 44}, {320, 14}}</string>
Expand Down Expand Up @@ -177,6 +177,14 @@
</object>
<int key="connectionID">12</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">whiteBgView</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="684114060"/>
</object>
<int key="connectionID">18</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
Expand All @@ -196,7 +204,7 @@
<reference ref="763504698"/>
<reference ref="386003855"/>
<reference ref="684114060"/>
<reference ref="9962199"/>
<reference ref="266356808"/>
</object>
<reference key="parent" ref="0"/>
</object>
Expand Down Expand Up @@ -239,7 +247,7 @@
</object>
<object class="IBObjectRecord">
<int key="objectID">17</int>
<reference key="object" ref="9962199"/>
<reference key="object" ref="266356808"/>
<reference key="parent" ref="191373211"/>
</object>
</object>
Expand All @@ -263,7 +271,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>MainViewController</string>
<string>UIResponder</string>
<string>{{629, 546}, {320, 460}}</string>
<string>{{85, 546}, {320, 460}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>{{300, 605}, {20, 20}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
Expand All @@ -289,7 +297,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">17</int>
<int key="maxID">18</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand All @@ -304,12 +312,14 @@
<string>activityIndicator</string>
<string>mySearchBar</string>
<string>myTableView</string>
<string>whiteBgView</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>UIActivityIndicatorView</string>
<string>UISearchBar</string>
<string>UITableView</string>
<string>UIView</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
Expand Down

0 comments on commit 1f9da44

Please sign in to comment.