diff options
Diffstat (limited to 'Juick')
-rw-r--r-- | Juick/AppDelegate.m | 5 | ||||
-rw-r--r-- | Juick/Main.storyboard | 11 | ||||
-rw-r--r-- | Juick/ViewControllers/DiscoverViewController.m | 4 | ||||
-rw-r--r-- | Juick/ViewControllers/LoginViewController.h | 1 | ||||
-rw-r--r-- | Juick/ViewControllers/LoginViewController.m | 16 |
5 files changed, 32 insertions, 5 deletions
diff --git a/Juick/AppDelegate.m b/Juick/AppDelegate.m index 5f76145..4fa1f92 100644 --- a/Juick/AppDelegate.m +++ b/Juick/AppDelegate.m @@ -32,6 +32,11 @@ [[UIToolbar appearance] setTintColor:[ColorScheme linkColor]]; [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault; + if ([[NSUserDefaults standardUserDefaults] objectForKey:@"FirstRun"] == nil) { + [[PDKeychainBindings sharedKeychainBindings] setObject:nil forKey:@"com.juick.username"]; + [[PDKeychainBindings sharedKeychainBindings] setObject:nil forKey:@"com.juick.password"]; + [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"FirstRun"]; + } [self registerForRemoteNotifications]; NSDictionary *userInfo = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]; diff --git a/Juick/Main.storyboard b/Juick/Main.storyboard index 2a274d9..8042f4b 100644 --- a/Juick/Main.storyboard +++ b/Juick/Main.storyboard @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="zgP-bN-c50"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="zgP-bN-c50"> <device id="retina4_7" orientation="portrait"> <adaptation id="fullscreen"/> </device> <dependencies> <deployment identifier="iOS"/> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> @@ -106,7 +106,7 @@ <navigationItem key="navigationItem" id="M2f-nV-K0C"> <barButtonItem key="rightBarButtonItem" title="Item" image="settings_icon" style="plain" id="Sd1-hN-fdS"> <connections> - <segue destination="4g9-hM-bzq" kind="push" id="6ha-6h-L0E"/> + <segue destination="4g9-hM-bzq" kind="push" identifier="loginSegue" id="6ha-6h-L0E"/> </connections> </barButtonItem> </navigationItem> @@ -139,7 +139,7 @@ <rect key="frame" x="0.0" y="120" width="339" height="30"/> <nil key="textColor"/> <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/> - <textInputTraits key="textInputTraits" textContentType="username"/> + <textInputTraits key="textInputTraits" returnKeyType="next" textContentType="username"/> <userDefinedRuntimeAttributes> <userDefinedRuntimeAttribute type="string" keyPath="placeholder" value="Username..."/> </userDefinedRuntimeAttributes> @@ -151,7 +151,7 @@ <rect key="frame" x="0.0" y="174" width="339" height="30"/> <nil key="textColor"/> <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/> - <textInputTraits key="textInputTraits" secureTextEntry="YES" textContentType="password"/> + <textInputTraits key="textInputTraits" returnKeyType="go" secureTextEntry="YES" textContentType="password"/> <userDefinedRuntimeAttributes> <userDefinedRuntimeAttribute type="string" keyPath="placeholder" value="Password..."/> </userDefinedRuntimeAttributes> @@ -183,6 +183,7 @@ </view> <navigationItem key="navigationItem" id="QaM-45-gms"/> <connections> + <outlet property="bottomConstraint" destination="TyY-LG-msW" id="pwp-vP-jtH"/> <outlet property="passwordField" destination="xGs-fu-6K0" id="zY6-lx-9PQ"/> <outlet property="usernameField" destination="BMn-5D-Cqa" id="DQU-Fb-Q4e"/> <outlet property="visualEffectView" destination="iqI-7F-B8z" id="oBZ-aP-B0n"/> diff --git a/Juick/ViewControllers/DiscoverViewController.m b/Juick/ViewControllers/DiscoverViewController.m index c874c25..fde23ee 100644 --- a/Juick/ViewControllers/DiscoverViewController.m +++ b/Juick/ViewControllers/DiscoverViewController.m @@ -74,6 +74,10 @@ AppDelegate *appDelegate; } } - (IBAction)filterAction:(id)sender { + if (![User isAuthenticated]) { + [self performSegueWithIdentifier:@"loginSegue" sender:self]; + return; + } UIAlertController *filterAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; [filterAlert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; [filterAlert addAction:[UIAlertAction actionWithTitle:@"My feed" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { diff --git a/Juick/ViewControllers/LoginViewController.h b/Juick/ViewControllers/LoginViewController.h index baf71db..18ca4a4 100644 --- a/Juick/ViewControllers/LoginViewController.h +++ b/Juick/ViewControllers/LoginViewController.h @@ -13,4 +13,5 @@ @property (weak, nonatomic) IBOutlet UITextField *usernameField; @property (weak, nonatomic) IBOutlet UITextField *passwordField; @property (weak, nonatomic) IBOutlet UIVisualEffectView *visualEffectView; +@property (strong, nonatomic) IBOutlet NSLayoutConstraint *bottomConstraint; @end diff --git a/Juick/ViewControllers/LoginViewController.m b/Juick/ViewControllers/LoginViewController.m index 4f63e44..fd3c2b0 100644 --- a/Juick/ViewControllers/LoginViewController.m +++ b/Juick/ViewControllers/LoginViewController.m @@ -12,6 +12,10 @@ #import "AppDelegate.h" #import "APIClient.h" +@interface LoginViewController() +@property (nonatomic, assign) int paddingValue; +@end + @implementation LoginViewController - (void) awakeFromNib { @@ -26,6 +30,18 @@ target:self action:@selector(doneSignIn)]; self.usernameField.text = [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"]; self.passwordField.text = [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.password"]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil]; +} + +-(void) keyboardDidShow:(NSNotification *)sender { + CGRect keyboardRect = [sender.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; + self.bottomConstraint.constant = keyboardRect.size.height - self.view.safeAreaInsets.bottom + self.paddingValue; + [self.view layoutIfNeeded]; +} +-(void) keyboardWillHide:(NSNotification *)sender { + self.bottomConstraint.constant = self.paddingValue; + [self.view layoutIfNeeded]; } |