Permalink
Browse files

Initial commit for all files

  • Loading branch information...
1 parent 89590b8 commit 3dca9d881be2f8c68a5158572971f55c783d6cf5 Edward Chiang committed Feb 23, 2012
View
@@ -0,0 +1,12 @@
+.DS_Store
+build
+Build
+Products
+*.pbxuser
+*.perspectivev3
+*.mode1v3
+*.xcworkspace
+xcuserdata
+.DS_Store
+
+*.pyc
@@ -0,0 +1,20 @@
+//
+// AppDelegate.h
+// RateStars
+//
+// Created by Edward Chiang on 12/2/23.
+// Copyright (c) 2012年 Polydice Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@class DemoViewController;
+
+@interface AppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+
+@property (strong, nonatomic) DemoViewController *viewController;
+@property (nonatomic, retain) UINavigationController *navigationController;
+
+@end
@@ -0,0 +1,65 @@
+//
+// AppDelegate.m
+// RateStars
+//
+// Created by Edward Chiang on 12/2/23.
+// Copyright (c) 2012年 Polydice Inc. All rights reserved.
+//
+
+#import "AppDelegate.h"
+
+#import "DemoViewController.h"
+
+@implementation AppDelegate
+
+@synthesize window = _window;
+@synthesize viewController = _viewController;
+@synthesize navigationController = _navigationController;
+
+- (void)dealloc
+{
+ [_window release];
+ [_viewController release];
+ [_navigationController release];
+ [super dealloc];
+}
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
+ // Override point for customization after application launch.
+ self.viewController = [[[DemoViewController alloc] initWithNibName:@"DemoViewController" bundle:nil] autorelease];
+ _navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
+ self.window.rootViewController = self.navigationController;
+ [self.window makeKeyAndVisible];
+ return YES;
+}
+
+- (void)applicationWillResignActive:(UIApplication *)application
+{
+ // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+}
+
+- (void)applicationDidEnterBackground:(UIApplication *)application
+{
+ // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+}
+
+- (void)applicationWillEnterForeground:(UIApplication *)application
+{
+ // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
+}
+
+- (void)applicationDidBecomeActive:(UIApplication *)application
+{
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
+}
+
+@end
@@ -0,0 +1,16 @@
+//
+// ViewController.h
+// RateStars
+//
+// Created by Edward Chiang on 12/2/23.
+// Copyright (c) 2012年 Polydice Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "RSTapRateView.h"
+
+@interface DemoViewController : UIViewController <RSTapRateViewDelegate>
+
+@property (nonatomic, retain) RSTapRateView *tapRateView;
+
+@end
@@ -0,0 +1,70 @@
+//
+// ViewController.m
+// RateStars
+//
+// Created by Edward Chiang on 12/2/23.
+// Copyright (c) 2012年 Polydice Inc. All rights reserved.
+//
+
+#import "DemoViewController.h"
+
+@interface DemoViewController ()
+
+@end
+
+@implementation DemoViewController
+
+@synthesize tapRateView = _tapRateView;
+
+- (void)loadView {
+ [super loadView];
+ self.title = @"Submit Review";
+ _tapRateView = [[RSTapRateView alloc] initWithFrame:CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y, self.view.bounds.size.width, 50.f)];
+ _tapRateView.delegate = self;
+ [self.view addSubview:_tapRateView];
+
+ UIBarButtonItem *sendButton = [[[UIBarButtonItem alloc] initWithTitle:@"Send" style:UIBarButtonItemStyleDone target:self action:@selector(send:)] autorelease];
+ self.navigationItem.rightBarButtonItem = sendButton;
+
+ self.view.backgroundColor = [UIColor whiteColor];
+}
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ // Do any additional setup after loading the view, typically from a nib.
+}
+
+- (void)viewDidUnload {
+ [super viewDidUnload];
+ // Release any retained subviews of the main view.
+ [_tapRateView release];
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
+ return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
+}
+
+#pragma mark -
+#pragma mark RSTapRateViewDelegate
+
+- (void)tapDidRateView:(RSTapRateView*)view rating:(NSInteger)rating {
+ NSLog(@"Current rating: %i", rating);
+}
+
+#pragma mark -
+#pragma mark private
+
+- (void)send:(id)object {
+ UIAlertView *alertResult = [[UIAlertView alloc] initWithTitle:@"Thanks" message:[NSString stringWithFormat:@"You gave it %i-Stars rating!", self.tapRateView.rating] delegate:self cancelButtonTitle:nil otherButtonTitles:@"Ok", nil];
+ [alertResult show];
+ [alertResult release];
+}
+
+#pragma mark -
+#pragma mark UIAlertViewDelegate
+
+- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
+ [self.tapRateView refresh];
+}
+
+@end
@@ -0,0 +1,39 @@
+//
+// RSTapRateView.h
+// RateStars
+//
+// Created by Edward Chiang on 12/2/23.
+// Copyright (c) 2012年 Polydice Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@protocol RSTapRateViewDelegate;
+
+@interface RSTapRateView : UIView
+
+@property (nonatomic, assign) id<RSTapRateViewDelegate> delegate;
+
+@property (nonatomic, retain) UIButton *oneStarButton;
+@property (nonatomic, retain) UIButton *twoStarButton;
+@property (nonatomic, retain) UIButton *threeStarButton;
+@property (nonatomic, retain) UIButton *fourStarButton;
+@property (nonatomic, retain) UIButton *fiveStarButton;
+
+@property (nonatomic, retain) UIImageView *oneStarReflectionView;
+@property (nonatomic, retain) UIImageView *twoStarReflectionView;
+@property (nonatomic, retain) UIImageView *threeStarReflectionView;
+@property (nonatomic, retain) UIImageView *fourStarReflectionView;
+@property (nonatomic, retain) UIImageView *fiveStarReflectionView;
+
+@property (nonatomic, retain) UILabel *textLabel;
+@property (nonatomic, assign) NSInteger rating;
+
+- (void)refresh;
+
+@end
+
+@protocol RSTapRateViewDelegate
+@optional
+- (void)tapDidRateView:(RSTapRateView*)view rating:(NSInteger)rating;
+@end
Oops, something went wrong.

0 comments on commit 3dca9d8

Please sign in to comment.