Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project modernisation #32

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ build/
PrettyExample.xcodeproj/*.mode1v3
PrettyExample.xcodeproj/*.pbxuser

PrettyStoryboardExample.xcodeproj/project.xcworkspace
PrettyStoryboardExample.xcodeproj/xcuserdata
Binary file added Default-568h@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 12 additions & 5 deletions PrettyExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
57A6337614FE7672004D2647 /* ExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 57A6337514FE7672004D2647 /* ExampleViewController.m */; };
57CF9FB1151BA08600BC035B /* PlainExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 57CF9FAF151BA08600BC035B /* PlainExample.m */; };
57CF9FB2151BA08600BC035B /* PlainExample.xib in Resources */ = {isa = PBXBuildFile; fileRef = 57CF9FB0151BA08600BC035B /* PlainExample.xib */; };
DB6D861416176E2C004A5CA8 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DB6D861316176E2C004A5CA8 /* Default-568h@2x.png */; };
EDA7DCB11548EBD1002219BA /* PrettyToolbar.m in Sources */ = {isa = PBXBuildFile; fileRef = EDA7DCB01548EBD1002219BA /* PrettyToolbar.m */; };
EDA7DCB61548ED3F002219BA /* ModalViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EDA7DCB41548ED3E002219BA /* ModalViewController.m */; };
EDA7DCB71548ED3F002219BA /* ModalViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = EDA7DCB51548ED3E002219BA /* ModalViewController.xib */; };
Expand Down Expand Up @@ -75,6 +76,7 @@
57CF9FAE151BA08600BC035B /* PlainExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlainExample.h; sourceTree = "<group>"; };
57CF9FAF151BA08600BC035B /* PlainExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlainExample.m; sourceTree = "<group>"; };
57CF9FB0151BA08600BC035B /* PlainExample.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PlainExample.xib; sourceTree = "<group>"; };
DB6D861316176E2C004A5CA8 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../Default-568h@2x.png"; sourceTree = "<group>"; };
EDA7DCAF1548EBD1002219BA /* PrettyToolbar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrettyToolbar.h; sourceTree = "<group>"; };
EDA7DCB01548EBD1002219BA /* PrettyToolbar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PrettyToolbar.m; sourceTree = "<group>"; };
EDA7DCB31548ED3E002219BA /* ModalViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModalViewController.h; sourceTree = "<group>"; };
Expand All @@ -101,6 +103,8 @@
isa = PBXGroup;
children = (
5735F8C114FD2FFC00DD7370 /* PrettyExample */,
578998AF1535E02000E06FCA /* PrettyKit */,
5735F8C214FD2FFC00DD7370 /* Supporting Files */,
5735F8BA14FD2FFC00DD7370 /* Frameworks */,
5735F8B814FD2FFC00DD7370 /* Products */,
);
Expand Down Expand Up @@ -128,14 +132,12 @@
5735F8C114FD2FFC00DD7370 /* PrettyExample */ = {
isa = PBXGroup;
children = (
578998AF1535E02000E06FCA /* PrettyKit */,
5735F8CA14FD2FFC00DD7370 /* AppDelegate.h */,
5735F8CB14FD2FFC00DD7370 /* AppDelegate.m */,
5735F8C214FD2FFC00DD7370 /* Supporting Files */,
57360BDC14FF84F600343B7B /* MainWindow.xib */,
57A6337414FE7672004D2647 /* ExampleViewController.h */,
57A6337514FE7672004D2647 /* ExampleViewController.m */,
57360BDE14FF889B00343B7B /* ExampleViewController.xib */,
57360BDC14FF84F600343B7B /* MainWindow.xib */,
EDA7DCB31548ED3E002219BA /* ModalViewController.h */,
EDA7DCB41548ED3E002219BA /* ModalViewController.m */,
EDA7DCB51548ED3E002219BA /* ModalViewController.xib */,
Expand All @@ -157,8 +159,10 @@
5735F8C414FD2FFC00DD7370 /* InfoPlist.strings */,
5735F8C714FD2FFC00DD7370 /* main.m */,
5735F8C914FD2FFC00DD7370 /* PrettyExample-Prefix.pch */,
DB6D861316176E2C004A5CA8 /* Default-568h@2x.png */,
);
name = "Supporting Files";
path = PrettyExample;
sourceTree = "<group>";
};
578998AF1535E02000E06FCA /* PrettyKit */ = {
Expand Down Expand Up @@ -252,6 +256,7 @@
572B2E6A153496880002228B /* background.png in Resources */,
572B2E6B153496880002228B /* background@2x.png in Resources */,
EDA7DCB71548ED3F002219BA /* ModalViewController.xib in Resources */,
DB6D861416176E2C004A5CA8 /* Default-568h@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -340,10 +345,11 @@
5735F8D014FD2FFC00DD7370 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PrettyExample/PrettyExample-Prefix.pch";
INFOPLIST_FILE = "PrettyExample/PrettyExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
PRODUCT_NAME = PrettyExample;
TARGETED_DEVICE_FAMILY = 1;
WRAPPER_EXTENSION = app;
Expand All @@ -353,10 +359,11 @@
5735F8D114FD2FFC00DD7370 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PrettyExample/PrettyExample-Prefix.pch";
INFOPLIST_FILE = "PrettyExample/PrettyExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
PRODUCT_NAME = PrettyExample;
TARGETED_DEVICE_FAMILY = 1;
WRAPPER_EXTENSION = app;
Expand Down
2 changes: 1 addition & 1 deletion PrettyExample/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

@property (strong, nonatomic) UIWindow *window;

@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@property (nonatomic, strong) IBOutlet UITabBarController *tabBarController;

@end
8 changes: 1 addition & 7 deletions PrettyExample/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,11 @@ @implementation AppDelegate
@synthesize window = _window;
@synthesize tabBarController;

- (void)dealloc
{
self.tabBarController = nil;
[_window release];
[super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];

Expand Down
20 changes: 11 additions & 9 deletions PrettyExample/ExampleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ -(void)onComposeClick:(id)sender
{
ModalViewController *modalView = [[ModalViewController alloc] initWithNibName:@"ModalViewController" bundle:nil];
[self presentModalViewController:modalView animated:YES];
[modalView release];
}

#pragma mark - View lifecycle
Expand All @@ -42,10 +41,11 @@ - (void)viewDidLoad
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
self.navigationItem.title = @"PrettyKit";

self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCompose
target:self
action:@selector(onComposeClick:)] autorelease];
action:@selector(onComposeClick:)];
self.tableView.backgroundView = nil;
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background"]];
}

Expand Down Expand Up @@ -123,7 +123,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

PrettyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[PrettyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell = [[PrettyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.tableViewBackgroundColor = tableView.backgroundColor;
}

Expand All @@ -133,7 +133,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
case 0:
segmentedCell = [tableView dequeueReusableCellWithIdentifier:SegmentedCellIdentifier];
if (segmentedCell == nil) {
segmentedCell = [[[PrettySegmentedControlTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SegmentedCellIdentifier] autorelease];
segmentedCell = [[PrettySegmentedControlTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SegmentedCellIdentifier];
}
[segmentedCell prepareForTableView:tableView indexPath:indexPath];
segmentedCell.titles = [NSArray arrayWithObjects:@"1", @"2", @"3", @"4", nil];
Expand All @@ -147,10 +147,11 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
case 2:
gridCell = [tableView dequeueReusableCellWithIdentifier:GridCellIdentifier];
if (gridCell == nil) {
gridCell = [[[PrettyGridTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:GridCellIdentifier] autorelease];
gridCell = [[PrettyGridTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:GridCellIdentifier];
gridCell.tableViewBackgroundColor = tableView.backgroundColor;
id bGridCell = gridCell;
gridCell.actionBlock = ^(NSIndexPath *indexPath, int selectedIndex) {
[gridCell deselectAnimated:YES];
[bGridCell deselectAnimated:YES];
};
}
[gridCell prepareForTableView:tableView indexPath:indexPath];
Expand All @@ -165,10 +166,11 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
case 4:
gridCell = [tableView dequeueReusableCellWithIdentifier:GridCellIdentifier];
if (gridCell == nil) {
gridCell = [[[PrettyGridTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:GridCellIdentifier] autorelease];
gridCell = [[PrettyGridTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:GridCellIdentifier];
gridCell.tableViewBackgroundColor = tableView.backgroundColor;
id bGridCell = gridCell;
gridCell.actionBlock = ^(NSIndexPath *indexPath, int selectedIndex) {
[gridCell deselectAnimated:YES];
[bGridCell deselectAnimated:YES];
};
}
[gridCell prepareForTableView:tableView indexPath:indexPath];
Expand Down
9 changes: 5 additions & 4 deletions PrettyExample/PlainExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ - (void)viewDidLoad
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.backgroundColor = [UIColor scrollViewTexturedBackgroundColor];

self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:nil action:nil] autorelease];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:nil action:nil];

[self.tableView dropShadows];
[self customizeNavBar];
Expand Down Expand Up @@ -125,14 +125,15 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

PrettyGridTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:GridCellIdentifier];
if (cell == nil) {
cell = [[[PrettyGridTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:GridCellIdentifier] autorelease];
cell = [[PrettyGridTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:GridCellIdentifier];
cell.tableViewBackgroundColor = tableView.backgroundColor;
cell.gradientStartColor = start_color;
cell.gradientEndColor = end_color;
}
cell.numberOfElements = 2;
id bCell = cell;
[cell setActionBlock:^(NSIndexPath *indexPath, int selectedIndex) {
[cell deselectAnimated:YES];
[bCell deselectAnimated:YES];
}];
[cell prepareForTableView:tableView indexPath:indexPath];
cell.textLabel.font = [UIFont boldSystemFontOfSize:18];
Expand All @@ -148,7 +149,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

PrettyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[PrettyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell = [[PrettyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.tableViewBackgroundColor = tableView.backgroundColor;
cell.gradientStartColor = start_color;
cell.gradientEndColor = end_color;
Expand Down
2 changes: 1 addition & 1 deletion PrettyKit/Cells/PrettyCustomViewTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
@interface PrettyCustomViewTableViewCell : PrettyTableViewCell

/** Holds a reference to the custom view. */
@property (nonatomic, retain) UIView *customView;
@property (nonatomic, strong) UIView *customView;

@end
6 changes: 0 additions & 6 deletions PrettyKit/Cells/PrettyCustomViewTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ @implementation PrettyCustomViewTableViewCell

#define shadow_margin 4

- (void) dealloc
{
self.customView = nil;

[super dealloc];
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
Expand Down
4 changes: 2 additions & 2 deletions PrettyKit/Cells/PrettyGridTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@
@property (nonatomic, assign) UITextAlignment textAlignment;

/** Returns an array with all the texts in the grid. */
@property (nonatomic, readonly) NSArray *texts;
@property (weak, nonatomic, readonly) NSArray *texts;

/** Returns an array with all the detail texts in the grid. */
@property (nonatomic, readonly) NSArray *detailTexts;
@property (weak, nonatomic, readonly) NSArray *detailTexts;

/** Specifies if the shadow should be shown only on the selected element.

Expand Down
25 changes: 2 additions & 23 deletions PrettyKit/Cells/PrettyGridTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ @interface PrettyGridSubview : UIButton {
BOOL _gradientVisible;
}

@property (nonatomic, retain) PrettyGridTableViewCell *cell;
@property (nonatomic, strong) PrettyGridTableViewCell *cell;
@property (nonatomic, assign) int selectedSegment;
@property (nonatomic, readonly) CGFloat segmentWidth;

Expand All @@ -49,12 +49,6 @@ - (void) deselectAnimated:(BOOL)animated completion:(void (^)(void))block;
@implementation PrettyGridSubview
@synthesize cell, selectedSegment;

- (void) dealloc
{
self.cell = nil;

[super dealloc];
}

- (CGFloat) segmentWidth
{
Expand Down Expand Up @@ -313,7 +307,6 @@ - (void) deselectAnimated:(BOOL)animated completion:(void (^)(void))block
}
completion:^(BOOL finished) {
[imageView removeFromSuperview];
[imageView release];
if (block) {
block();
}
Expand Down Expand Up @@ -389,30 +382,20 @@ @implementation PrettyGridTableViewCell
- (void) dealloc
{
if (_texts != nil) {
[_texts release];
_texts = nil;
}
if (_detailTexts != nil) {
[_detailTexts release];
_detailTexts = nil;
}
if (_currentIndexPath != nil) {
[_currentIndexPath release];
_currentIndexPath = nil;
}


[super dealloc];
}

- (void) initVars
{
if (_texts != nil) {
[_texts release];
}
if (_detailTexts != nil) {
[_detailTexts release];
}
_texts = [[NSMutableDictionary alloc] init];
_detailTexts = [[NSMutableDictionary alloc] init];

Expand Down Expand Up @@ -443,7 +426,6 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
PrettyGridSubview *subview = [[PrettyGridSubview alloc] init];
subview.cell = self;
self.customView = subview;
[subview release];

self.elementSelectionStyle = UITableViewCellSelectionStyleBlue;
self.textAlignment = UITextAlignmentCenter;
Expand Down Expand Up @@ -520,10 +502,7 @@ - (void) prepareForTableView:(UITableView *)tableView indexPath:(NSIndexPath *)i
{
[super prepareForTableView:tableView indexPath:indexPath];

if (_currentIndexPath != nil) {
[_currentIndexPath release];
}
_currentIndexPath = [indexPath retain];
_currentIndexPath = indexPath;
}

- (void) selectIndex:(int)index
Expand Down
2 changes: 1 addition & 1 deletion PrettyKit/Cells/PrettySegmentedControlTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
@interface PrettySegmentedControlTableViewCell : PrettyGridTableViewCell


@property (nonatomic, retain) NSArray *titles;
@property (nonatomic, strong) NSArray *titles;
@property (nonatomic, assign) NSInteger selectedIndex;

@end
6 changes: 3 additions & 3 deletions PrettyKit/Cells/PrettySegmentedControlTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
// Initialization code
selectedIndex = -1;

UIColor *tmp = [self.selectionGradientStartColor retain];
UIColor *tmp = self.selectionGradientStartColor;
self.selectionGradientStartColor = self.selectionGradientEndColor;
self.selectionGradientEndColor = tmp;
[tmp release];

self.textLabel.shadowColor = [UIColor blackColor];
self.textLabel.shadowOffset = CGSizeMake(0, 1);
Expand Down Expand Up @@ -101,8 +100,9 @@ - (void) setTitles:(NSArray *)titles {


- (void) setActionBlock:(void (^)(NSIndexPath *indexPath, int sselectedIndex))actionBlock {
id bself = self;
[super setActionBlock:^(NSIndexPath *indexPath, int sselectedIndex) {
[self _setSelectedIndex:sselectedIndex notifySuper:NO];
[bself _setSelectedIndex:sselectedIndex notifySuper:NO];

if (actionBlock)
{
Expand Down
Loading