Permalink
Browse files

send feedback email

  • Loading branch information...
1 parent a0f2253 commit 7eab5d668f415259b624ebbc5e358d30aaec163e @trivektor committed Mar 23, 2013
View
12 Gitos-iPad.xcodeproj/project.pbxproj
@@ -1583,6 +1583,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/../../include";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -1605,6 +1606,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/../../include";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
@@ -1616,8 +1618,13 @@
B55D90BE16B7AA27009CB90F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Gitos-iPad/Gitos-iPad-Prefix.pch";
+ HEADER_SEARCH_PATHS = "";
INFOPLIST_FILE = "Gitos-iPad/Gitos-iPad-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
"OTHER_LDFLAGS[arch=*]" = "-ObjC";
@@ -1629,8 +1636,13 @@
B55D90BF16B7AA27009CB90F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Gitos-iPad/Gitos-iPad-Prefix.pch";
+ HEADER_SEARCH_PATHS = "";
INFOPLIST_FILE = "Gitos-iPad/Gitos-iPad-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
"OTHER_LDFLAGS[arch=*]" = "-ObjC";
View
BIN ...deproj/project.xcworkspace/xcuserdata/trivuong.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
View
17 Gitos-iPad/Controllers/FeedbackViewController.h
@@ -7,12 +7,25 @@
//
#import <UIKit/UIKit.h>
+#import <QuartzCore/QuartzCore.h>
@interface FeedbackViewController : UIViewController <UIWebViewDelegate>
-@property (nonatomic, weak) IBOutlet UIWebView *formWebView;
+@property (nonatomic, strong) IBOutlet UITextField *nameField;
+@property (nonatomic, strong) IBOutlet UITextField *emailField;
+@property (nonatomic, strong) IBOutlet UITextView *messageField;
+@property (nonatomic, strong) MBProgressHUD *hud;
- (void)performHouseKeepingTasks;
-- (void)loadFeedbackForm;
+- (void)applyCustomStyling;
+- (void)sendFeedback;
@end
+
+@interface CustomUITextField : UITextField
+
+@property (nonatomic, assign) float verticalPadding;
+@property (nonatomic, assign) float horizontalPadding;
+
+@end
+
View
95 Gitos-iPad/Controllers/FeedbackViewController.m
@@ -12,6 +12,20 @@ @interface FeedbackViewController ()
@end
+@implementation CustomUITextField
+
+@synthesize horizontalPadding, verticalPadding;
+
+- (CGRect)textRectForBounds:(CGRect)bounds {
+ return CGRectMake(bounds.origin.x + horizontalPadding, bounds.origin.y + verticalPadding, bounds.size.width - horizontalPadding*2, bounds.size.height - verticalPadding*2);
+}
+
+- (CGRect)editingRectForBounds:(CGRect)bounds {
+ return [self textRectForBounds:bounds];
+}
+
+@end
+
@implementation FeedbackViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
@@ -28,27 +42,92 @@ - (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[self performHouseKeepingTasks];
+ [self applyCustomStyling];
[self loadFeedbackForm];
+
+ UIBarButtonItem *submitButton = [[UIBarButtonItem alloc] initWithTitle:@"Submit" style:UIBarButtonItemStyleBordered target:self action:@selector(sendFeedback)];
+ [self.navigationItem setRightBarButtonItem:submitButton];
}
- (void)performHouseKeepingTasks
{
self.navigationItem.title = @"Feedback";
self.navigationItem.hidesBackButton = YES;
+
+ self.hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
+ self.hud.hidden = YES;
+ self.hud.mode = MBProgressHUDAnimationFade;
+ self.hud.labelText = @"Loading";
}
-- (void)didReceiveMemoryWarning
+- (void)applyCustomStyling
{
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
+ NSArray *fields = @[self.nameField, self.emailField];
+
+ UIView *namePaddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, 20)];
+ UIView *emailPaddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, 20)];
+
+ self.nameField.leftView = namePaddingView;
+ self.nameField.leftViewMode = UITextFieldViewModeAlways;
+
+ self.emailField.leftView = emailPaddingView;
+ self.emailField.leftViewMode = UITextFieldViewModeAlways;
+
+ for (UITextField *f in fields) {
+ f.layer.borderColor = [[UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0 alpha:1.0] CGColor];
+ f.layer.borderWidth = 1.0f;
+ f.layer.cornerRadius = 4.0f;
+ f.layer.masksToBounds = YES;
+ }
+
+ self.messageField.layer.borderColor = [[UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0 alpha:1.0] CGColor];
+ self.messageField.layer.borderWidth = 1.0f;
+ self.messageField.layer.cornerRadius = 4.0f;
+ self.messageField.layer.masksToBounds = YES;
+}
+
+- (void)sendFeedback
+{
+ NSURL *url = [NSURL URLWithString:[AppConfig getConfigValue:@"GitosHost"]];
+
+ NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+ self.nameField.text, @"name",
+ self.emailField.text, @"from",
+ self.messageField.text, @"text",
+ nil];
+
+ AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
+
+ NSMutableURLRequest *postRequest = [httpClient requestWithMethod:@"POST" path:@"/feedback" parameters:params];
+
+ AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:postRequest];
+
+ [operation setCompletionBlockWithSuccess:
+ ^(AFHTTPRequestOperation *operation, id responseObject) {
+ [self.hud setHidden:YES];
+ NSString *response = [operation responseString];
+
+ NSDictionary *json = [NSJSONSerialization JSONObjectWithData:[response dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:nil];
+
+ if ([[json valueForKey:@"success"] intValue] == 1) {
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Feedback sent successfully" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+
+ [alert show];
+ }
+ }
+ failure:^(AFHTTPRequestOperation *operation, NSError *error) {
+ [self.hud setHidden:YES];
+ NSLog(@"%@", error);
+ }];
+
+ [operation start];
+ [self.hud setHidden:NO];
}
-- (void)loadFeedbackForm
+- (void)didReceiveMemoryWarning
{
- NSString *feedbackFormPath = [[NSBundle mainBundle] pathForResource:@"feedback" ofType:@"html"];
- NSString *feedbackFormHtml = [NSString stringWithContentsOfFile:feedbackFormPath encoding:NSUTF8StringEncoding error:nil];
- NSURL *baseUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
- [self.formWebView loadHTMLString:feedbackFormHtml baseURL:baseUrl];
+ [super didReceiveMemoryWarning];
+ // Dispose of any resources that can be recreated.
}
@end
View
172 Gitos-iPad/Controllers/FeedbackViewController.xib
@@ -12,8 +12,9 @@
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBProxyObject</string>
+ <string>IBUITextField</string>
+ <string>IBUITextView</string>
<string>IBUIView</string>
- <string>IBUIWebView</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
@@ -35,31 +36,108 @@
<reference key="NSNextResponder"/>
<int key="NSvFlags">292</int>
<array class="NSMutableArray" key="NSSubviews">
- <object class="IBUIWebView" id="477550196">
+ <object class="IBUITextField" id="699852808">
<reference key="NSNextResponder" ref="766721923"/>
- <int key="NSvFlags">274</int>
- <string key="NSFrameSize">{703, 748}</string>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{28, 20}, {646, 36}}</string>
+ <reference key="NSSuperview" ref="766721923"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="1009432364"/>
+ <string key="NSReuseIdentifierKey">_NS:9</string>
+ <bool key="IBUIOpaque">NO</bool>
+ <bool key="IBUIClipsSubviews">YES</bool>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ <int key="IBUIContentVerticalAlignment">0</int>
+ <string key="IBUIText"/>
+ <int key="IBUIBorderStyle">1</int>
+ <string key="IBUIPlaceholder">Name</string>
+ <object class="NSColor" key="IBUITextColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MAA</bytes>
+ <object class="NSColorSpace" key="NSCustomColorSpace" id="627722621">
+ <int key="NSID">2</int>
+ </object>
+ </object>
+ <bool key="IBUIAdjustsFontSizeToFit">YES</bool>
+ <float key="IBUIMinimumFontSize">17</float>
+ <object class="IBUITextInputTraits" key="IBUITextInputTraits">
+ <int key="IBUIAutocorrectionType">1</int>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ <object class="IBUIFontDescription" key="IBUIFontDescription" id="437837318">
+ <string key="name">ArialMT</string>
+ <string key="family">Arial</string>
+ <int key="traits">0</int>
+ <double key="pointSize">14</double>
+ </object>
+ <object class="NSFont" key="IBUIFont" id="642471603">
+ <string key="NSName">ArialMT</string>
+ <double key="NSSize">14</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ </object>
+ <object class="IBUITextField" id="1009432364">
+ <reference key="NSNextResponder" ref="766721923"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{28, 70}, {646, 36}}</string>
+ <reference key="NSSuperview" ref="766721923"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="425938859"/>
+ <string key="NSReuseIdentifierKey">_NS:9</string>
+ <bool key="IBUIOpaque">NO</bool>
+ <bool key="IBUIClipsSubviews">YES</bool>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ <int key="IBUIContentVerticalAlignment">0</int>
+ <string key="IBUIText"/>
+ <int key="IBUIBorderStyle">1</int>
+ <string key="IBUIPlaceholder">Email</string>
+ <object class="NSColor" key="IBUITextColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MAA</bytes>
+ <reference key="NSCustomColorSpace" ref="627722621"/>
+ </object>
+ <bool key="IBUIAdjustsFontSizeToFit">YES</bool>
+ <float key="IBUIMinimumFontSize">17</float>
+ <object class="IBUITextInputTraits" key="IBUITextInputTraits">
+ <int key="IBUIAutocorrectionType">1</int>
+ <int key="IBUIKeyboardType">7</int>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ <reference key="IBUIFontDescription" ref="437837318"/>
+ <reference key="IBUIFont" ref="642471603"/>
+ </object>
+ <object class="IBUITextView" id="425938859">
+ <reference key="NSNextResponder" ref="766721923"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{28, 121}, {646, 128}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MSAxIDEAA</bytes>
</object>
+ <bool key="IBUIClipsSubviews">YES</bool>
+ <bool key="IBUIMultipleTouchEnabled">YES</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
- <int key="IBUIDataDetectorTypes">1</int>
- <bool key="IBUIDetectsPhoneNumbers">YES</bool>
+ <bool key="IBUIShowsHorizontalScrollIndicator">NO</bool>
+ <string key="IBUIText"/>
+ <object class="IBUITextInputTraits" key="IBUITextInputTraits">
+ <int key="IBUIAutocorrectionType">1</int>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ <reference key="IBUIFontDescription" ref="437837318"/>
+ <reference key="IBUIFont" ref="642471603"/>
</object>
</array>
<string key="NSFrame">{{0, 20}, {703, 748}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="699852808"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
- <object class="NSColorSpace" key="NSCustomColorSpace">
- <int key="NSID">2</int>
- </object>
+ <reference key="NSCustomColorSpace" ref="627722621"/>
</object>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics">
@@ -105,19 +183,27 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
- <string key="label">formWebView</string>
+ <string key="label">nameField</string>
<reference key="source" ref="841351856"/>
- <reference key="destination" ref="477550196"/>
+ <reference key="destination" ref="699852808"/>
</object>
- <int key="connectionID">6</int>
+ <int key="connectionID">11</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
- <string key="label">delegate</string>
- <reference key="source" ref="477550196"/>
- <reference key="destination" ref="841351856"/>
+ <string key="label">messageField</string>
+ <reference key="source" ref="841351856"/>
+ <reference key="destination" ref="425938859"/>
</object>
- <int key="connectionID">5</int>
+ <int key="connectionID">13</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">emailField</string>
+ <reference key="source" ref="841351856"/>
+ <reference key="destination" ref="1009432364"/>
+ </object>
+ <int key="connectionID">14</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
@@ -143,13 +229,25 @@
<int key="objectID">2</int>
<reference key="object" ref="766721923"/>
<array class="NSMutableArray" key="children">
- <reference ref="477550196"/>
+ <reference ref="699852808"/>
+ <reference ref="1009432364"/>
+ <reference ref="425938859"/>
</array>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">4</int>
- <reference key="object" ref="477550196"/>
+ <int key="objectID">7</int>
+ <reference key="object" ref="699852808"/>
+ <reference key="parent" ref="766721923"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">8</int>
+ <reference key="object" ref="1009432364"/>
+ <reference key="parent" ref="766721923"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">9</int>
+ <reference key="object" ref="425938859"/>
<reference key="parent" ref="766721923"/>
</object>
</array>
@@ -160,30 +258,42 @@
<string key="-2.CustomClassName">UIResponder</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <dictionary class="NSMutableDictionary" key="7.IBAttributePlaceholdersKey"/>
+ <string key="7.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <dictionary class="NSMutableDictionary" key="8.IBAttributePlaceholdersKey"/>
+ <string key="8.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="9.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
- <int key="maxID">6</int>
+ <int key="maxID">14</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">FeedbackViewController</string>
<string key="superclassName">UIViewController</string>
- <object class="NSMutableDictionary" key="outlets">
- <string key="NS.key.0">formWebView</string>
- <string key="NS.object.0">UIWebView</string>
- </object>
- <object class="NSMutableDictionary" key="toOneOutletInfosByName">
- <string key="NS.key.0">formWebView</string>
- <object class="IBToOneOutletInfo" key="NS.object.0">
- <string key="name">formWebView</string>
- <string key="candidateClassName">UIWebView</string>
+ <dictionary class="NSMutableDictionary" key="outlets">
+ <string key="emailField">UITextField</string>
+ <string key="messageField">UITextView</string>
+ <string key="nameField">UITextField</string>
+ </dictionary>
+ <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
+ <object class="IBToOneOutletInfo" key="emailField">
+ <string key="name">emailField</string>
+ <string key="candidateClassName">UITextField</string>
</object>
- </object>
+ <object class="IBToOneOutletInfo" key="messageField">
+ <string key="name">messageField</string>
+ <string key="candidateClassName">UITextView</string>
+ </object>
+ <object class="IBToOneOutletInfo" key="nameField">
+ <string key="name">nameField</string>
+ <string key="candidateClassName">UITextField</string>
+ </object>
+ </dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/FeedbackViewController.h</string>
View
0 default.css
No changes.

0 comments on commit 7eab5d6

Please sign in to comment.