Skip to content

fixed up styling, added icons, improved keyboard dismissal #102

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

Open
wants to merge 2 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "btn_close_gray_up.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "[email protected]"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 15 additions & 5 deletions MAF/MAF/PostDetailViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ @interface PostDetailViewController () <UICollectionViewDataSource, UICollection
@property (weak, nonatomic) IBOutlet UICollectionView *_collectionView;
@property (weak, nonatomic) IBOutlet UITextField *_commentContentTextField;
@property (weak, nonatomic) IBOutlet UIView *_postView;
@property (nonatomic, strong) UITapGestureRecognizer *tapGesture;
@property (nonatomic, assign) CGPoint originalCenter;


- (IBAction)_addComment:(id)sender;
- (IBAction)dismiss:(id)sender;
Expand All @@ -32,22 +35,26 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
if (self) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil];

self.tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard:)];
[self.view addGestureRecognizer:self.tapGesture];
}
return self;
}

- (void)keyboardDidShow:(NSNotification *)notification
{
// Get the size of the keyboard.
self.tapGesture.enabled = YES;
CGRect keyboardRect = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGFloat diffY = keyboardRect.origin.y - (self.view.frame.origin.y + self.view.frame.size.height + keyboardRect.size.height/2);
[self.view moveToPoint:CGPointMake(self.view.center.x, self.view.center.y + 10 - diffY) withBeginTime:CACurrentMediaTime() onCompletion:nil];
CGFloat diffY = keyboardRect.origin.y - (self.view.center.y + self.view.frame.size.height/2);
self.originalCenter = self.view.center;
[self.view moveToPoint:CGPointMake(self.view.center.x, self.view.center.y - diffY) withBeginTime:CACurrentMediaTime() onCompletion:nil];
}

-(void)keyboardDidHide:(NSNotification *)notification
{
[self.view moveToPoint:CGPointMake(self.view.center.x, self.view.center.y) withBeginTime:CACurrentMediaTime() onCompletion:nil];
[self.view moveToPoint:self.originalCenter withBeginTime:CACurrentMediaTime() onCompletion:nil];
self.tapGesture.enabled = NO;
}

- (void)viewDidLoad {
Expand All @@ -57,7 +64,6 @@ - (void)viewDidLoad {
self._collectionView.delegate = self;
self._collectionView.dataSource = self;
self._commentContentTextField.delegate = self;
self.title = @"Comment";

MessageCollectionViewCell *postView = [[[NSBundle mainBundle] loadNibNamed:@"MessageCollectionViewCell" owner:nil options:nil] firstObject];
postView.post = self.post;
Expand Down Expand Up @@ -128,6 +134,10 @@ - (IBAction)_addComment:(id)sender {
[[ViewManager instance] clearCache];
}

- (void)dismissKeyboard:(id)sender {
[self._commentContentTextField resignFirstResponder];
}

- (IBAction)dismiss:(id)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
Expand Down
18 changes: 13 additions & 5 deletions MAF/MAF/PostDetailViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,30 @@
<constraint firstAttribute="width" constant="28" id="Cin-lJ-ouQ"/>
<constraint firstAttribute="height" constant="28" id="NlJ-xl-8Bn"/>
</constraints>
<state key="normal" image="btn_close_white_up"/>
<state key="normal" image="btn_close_gray_up"/>
<connections>
<action selector="dismiss:" destination="-1" eventType="touchUpInside" id="OUe-bT-Lea"/>
</connections>
</button>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="GNh-M0-U9I">
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="GNh-M0-U9I" userLabel="Divider">
<rect key="frame" x="0.0" y="27" width="320" height="1"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="0.95294117647058818" green="0.95294117647058818" blue="0.95294117647058818" alpha="1" colorSpace="calibratedRGB"/>
</view>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Post" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Qey-KZ-XlL" customClass="OpenSansRegularLabel">
<rect key="frame" x="145" y="5" width="30" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="oJ5-Ws-L9z" secondAttribute="trailing" id="Aye-8V-i4e"/>
<constraint firstItem="oJ5-Ws-L9z" firstAttribute="top" secondItem="VLj-Y4-39R" secondAttribute="top" id="QKz-kc-H8b"/>
<constraint firstAttribute="centerX" secondItem="Qey-KZ-XlL" secondAttribute="centerX" id="TrB-wp-bfb"/>
<constraint firstAttribute="bottom" secondItem="oJ5-Ws-L9z" secondAttribute="bottom" id="Yeq-Sw-KA2"/>
<constraint firstAttribute="centerY" secondItem="Qey-KZ-XlL" secondAttribute="centerY" id="bES-Od-rhY"/>
<constraint firstAttribute="height" constant="28" id="hJW-pw-OeG"/>
</constraints>
</view>
Expand Down Expand Up @@ -101,6 +109,6 @@
</view>
</objects>
<resources>
<image name="btn_close_white_up" width="10" height="10"/>
<image name="btn_close_gray_up" width="11" height="11"/>
</resources>
</document>
7 changes: 4 additions & 3 deletions MAF/MAF/PresentingAnimator.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ - (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionC
fromView.userInteractionEnabled = NO;

UIView *dimmingView = [[UIView alloc] initWithFrame:fromView.bounds];
dimmingView.backgroundColor = [UIColor customGrayColor];
dimmingView.backgroundColor = [UIColor blackColor];
dimmingView.layer.opacity = 0.0;

UIView *toView = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey].view;
CGFloat sizeReductionRatio = (float)3/7;
CGFloat heightRatio = (float)4/7;
// CGFloat widthRatio = (float)6/7;
toView.frame = CGRectMake(0,
0,
CGRectGetWidth(transitionContext.containerView.bounds),
sizeReductionRatio*CGRectGetHeight(transitionContext.containerView.bounds));
heightRatio*CGRectGetHeight(transitionContext.containerView.bounds));
toView.center = CGPointMake(transitionContext.containerView.center.x, -transitionContext.containerView.center.y);

[transitionContext.containerView addSubview:dimmingView];
Expand Down