This repository has been archived by the owner on Aug 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
#import "SettingsColorView.h" | ||
#import "AppDelegate.h" | ||
#import "NSString+Utilities.h" | ||
#import "MFMailComposeViewController+BlocksKit.h" | ||
|
||
@interface SettingsViewController () <UITextFieldDelegate, ToxIdViewDelegate, SettingsColorViewDelegate> | ||
|
||
|
@@ -27,6 +28,8 @@ @interface SettingsViewController () <UITextFieldDelegate, ToxIdViewDelegate, Se | |
|
||
@property (strong, nonatomic) SettingsColorView *colorView; | ||
|
||
@property (strong, nonatomic) UIButton *feedbackButton; | ||
|
||
@end | ||
|
||
@implementation SettingsViewController | ||
|
@@ -53,6 +56,7 @@ - (void)loadView | |
[self createStatusMessageField]; | ||
[self createToxIdView]; | ||
[self createColorView]; | ||
[self createFeedbackButton]; | ||
} | ||
|
||
- (void)viewDidLayoutSubviews | ||
|
@@ -62,6 +66,32 @@ - (void)viewDidLayoutSubviews | |
[self adjustSubviews]; | ||
} | ||
|
||
#pragma mark - Actions | ||
|
||
- (void)feedbackButtonPressed | ||
{ | ||
if (! [MFMailComposeViewController canSendMail]) { | ||
[[[UIAlertView alloc] initWithTitle:nil | ||
message:NSLocalizedString(@"Please configure your mail settings", @"Settings") | ||
delegate:nil | ||
cancelButtonTitle:NSLocalizedString(@"OK", @"Settings") | ||
otherButtonTitles:nil] show]; | ||
|
||
return; | ||
} | ||
|
||
MFMailComposeViewController *vc = [MFMailComposeViewController new]; | ||
vc.navigationBar.tintColor = [AppearanceManager textMainColor]; | ||
[vc setSubject:@"Feedback"]; | ||
[vc setToRecipients:@[@"[email protected]"]]; | ||
|
||
vc.bk_completionBlock = ^(MFMailComposeViewController *vc, MFMailComposeResult result, NSError *error) { | ||
[self dismissViewControllerAnimated:YES completion:nil]; | ||
}; | ||
|
||
[self presentViewController:vc animated:YES completion:nil]; | ||
} | ||
|
||
#pragma mark - UITextFieldDelegate | ||
|
||
- (BOOL) textField:(UITextField *)textField | ||
|
@@ -177,11 +207,22 @@ - (void)createColorView | |
[self.scrollView addSubview:self.colorView]; | ||
} | ||
|
||
- (void)createFeedbackButton | ||
{ | ||
self.feedbackButton = [UIButton buttonWithType:UIButtonTypeSystem]; | ||
[self.feedbackButton setTitle:NSLocalizedString(@"Feedback", @"Settings") forState:UIControlStateNormal]; | ||
[self.feedbackButton addTarget:self | ||
action:@selector(feedbackButtonPressed) | ||
forControlEvents:UIControlEventTouchUpInside]; | ||
|
||
[self.scrollView addSubview:self.feedbackButton]; | ||
} | ||
|
||
- (void)adjustSubviews | ||
{ | ||
self.scrollView.frame = self.view.bounds; | ||
|
||
CGFloat currentOriginY = 0.0; | ||
__unused CGFloat currentOriginY = 0.0; | ||
const CGFloat yIndentation = 10.0; | ||
|
||
CGRect frame = CGRectZero; | ||
|
@@ -224,6 +265,16 @@ - (void)adjustSubviews | |
} | ||
currentOriginY = CGRectGetMaxY(frame); | ||
|
||
{ | ||
[self.feedbackButton sizeToFit]; | ||
frame = self.feedbackButton.frame; | ||
frame.origin.x = (self.view.frame.size.width - frame.size.width) / 2; | ||
frame.origin.y = self.scrollView.frame.size.height - frame.size.height - yIndentation - | ||
self.scrollView.contentInset.top - self.scrollView.contentInset.bottom; | ||
self.feedbackButton.frame = frame; | ||
} | ||
currentOriginY = CGRectGetMaxY(frame); | ||
|
||
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.origin.x, currentOriginY + yIndentation); | ||
} | ||
|
||
|