mirror of
https://github.com/samsonjs/samhuri.net-ios.git
synced 2026-04-04 11:05:49 +00:00
rename posts
This commit is contained in:
parent
1420b53285
commit
ef19a90da1
6 changed files with 136 additions and 3 deletions
|
|
@ -7,6 +7,7 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
1BCFCC3709A3C3783E180815 /* ChangeTitleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BCFCE26B630D546311BB715 /* ChangeTitleViewController.m */; };
|
||||
1BCFCC637C63C780248D685E /* PostCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BCFCB5C36F301B2B93F8069 /* PostCell.m */; };
|
||||
1BCFCD7E8EEBFAA97226B0BF /* UIColor+Hex.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BCFC23988387A5CAE551C90 /* UIColor+Hex.m */; };
|
||||
1BCFCF6DB93786CC2EDB8F69 /* PostCollection.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BCFC3B62AA92DB07923F7C1 /* PostCollection.m */; };
|
||||
|
|
@ -49,6 +50,8 @@
|
|||
1BCFCB18C8C8304D67E6462E /* PostCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PostCollection.h; sourceTree = "<group>"; };
|
||||
1BCFCB5C36F301B2B93F8069 /* PostCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PostCell.m; sourceTree = "<group>"; };
|
||||
1BCFCCF30594E0E2DCC32116 /* PostCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PostCell.h; sourceTree = "<group>"; };
|
||||
1BCFCDD73D4AE8F16A9C9E3D /* ChangeTitleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChangeTitleViewController.h; sourceTree = "<group>"; };
|
||||
1BCFCE26B630D546311BB715 /* ChangeTitleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChangeTitleViewController.m; sourceTree = "<group>"; };
|
||||
1BCFCFA1E7D4AFDA984693E1 /* UIColor+Hex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+Hex.h"; sourceTree = "<group>"; };
|
||||
7B4070521AE46BC9000C2E43 /* auth.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = auth.json; sourceTree = "<group>"; };
|
||||
7B5C4BD919F2606900667D48 /* Blog.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Blog.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
|
@ -164,6 +167,8 @@
|
|||
1BCFCCF30594E0E2DCC32116 /* PostCell.h */,
|
||||
1BCFC3B62AA92DB07923F7C1 /* PostCollection.m */,
|
||||
1BCFCB18C8C8304D67E6462E /* PostCollection.h */,
|
||||
1BCFCE26B630D546311BB715 /* ChangeTitleViewController.m */,
|
||||
1BCFCDD73D4AE8F16A9C9E3D /* ChangeTitleViewController.h */,
|
||||
);
|
||||
path = Blog;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -428,6 +433,7 @@
|
|||
1BCFCC637C63C780248D685E /* PostCell.m in Sources */,
|
||||
1BCFCD7E8EEBFAA97226B0BF /* UIColor+Hex.m in Sources */,
|
||||
1BCFCF6DB93786CC2EDB8F69 /* PostCollection.m in Sources */,
|
||||
1BCFCC3709A3C3783E180815 /* ChangeTitleViewController.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
</toolbar>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" translatesAutoresizingMaskIntoConstraints="NO" id="wrG-1y-ZY3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="492"/>
|
||||
<color key="backgroundColor" red="0.1333333333" green="0.1333333333" blue="0.1333333333" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color key="backgroundColor" red="0.26666666666666666" green="0.26666666666666666" blue="0.26666666666666666" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
|
||||
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
|
|
@ -117,6 +117,43 @@
|
|||
</objects>
|
||||
<point key="canvasLocation" x="709" y="129"/>
|
||||
</scene>
|
||||
<!--Change Title View Controller-->
|
||||
<scene sceneID="j4l-wz-jyJ">
|
||||
<objects>
|
||||
<viewController storyboardIdentifier="Change Title View Controller" useStoryboardIdentifierAsRestorationIdentifier="YES" id="iGU-Zs-0by" customClass="ChangeTitleViewController" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="TvQ-ee-aa5"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="UG3-LY-P0T"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="B66-2b-lYL">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="G2v-XU-V16">
|
||||
<rect key="frame" x="16" y="285" width="568" height="30"/>
|
||||
<color key="backgroundColor" red="0.2666666667" green="0.2666666667" blue="0.2666666667" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color key="textColor" red="0.96862745100000003" green="0.96862745100000003" blue="0.96862745100000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="iGU-Zs-0by" id="22s-mb-pJM"/>
|
||||
</connections>
|
||||
</textField>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="centerX" secondItem="G2v-XU-V16" secondAttribute="centerX" id="1bq-IE-HrD"/>
|
||||
<constraint firstItem="G2v-XU-V16" firstAttribute="width" secondItem="B66-2b-lYL" secondAttribute="width" constant="-32" id="7ms-ZC-kzo"/>
|
||||
<constraint firstAttribute="centerY" secondItem="G2v-XU-V16" secondAttribute="centerY" id="Jnq-JZ-918"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="titleField" destination="G2v-XU-V16" id="jgw-Ix-HzP"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="wDc-x2-2jN" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="709" y="884"/>
|
||||
</scene>
|
||||
<!--Preview-->
|
||||
<scene sceneID="MEA-t1-FD6">
|
||||
<objects>
|
||||
|
|
|
|||
12
Blog/ChangeTitleViewController.h
Normal file
12
Blog/ChangeTitleViewController.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
//
|
||||
// Created by Sami Samhuri on 15-04-24.
|
||||
// Copyright (c) 2015 Guru Logic Inc. All rights reserved.
|
||||
//
|
||||
@import UIKit;
|
||||
|
||||
@interface ChangeTitleViewController : UIViewController
|
||||
|
||||
@property (nonatomic, copy) NSString *articleTitle;
|
||||
@property (nonatomic, copy) dispatch_block_t dismissBlock;
|
||||
|
||||
@end
|
||||
44
Blog/ChangeTitleViewController.m
Normal file
44
Blog/ChangeTitleViewController.m
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
// Created by Sami Samhuri on 15-04-24.
|
||||
// Copyright (c) 2015 Guru Logic Inc. All rights reserved.
|
||||
//
|
||||
#import "ChangeTitleViewController.h"
|
||||
|
||||
@interface ChangeTitleViewController () <UITextFieldDelegate>
|
||||
|
||||
@property (nonatomic, weak) IBOutlet UITextField *titleField;
|
||||
|
||||
@end
|
||||
|
||||
@implementation ChangeTitleViewController
|
||||
|
||||
@synthesize articleTitle = _articleTitle;
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.titleField.text = _articleTitle;
|
||||
[self.titleField becomeFirstResponder];
|
||||
}
|
||||
|
||||
- (NSString *)articleTitle {
|
||||
if (self.titleField) {
|
||||
return self.titleField.text;
|
||||
}
|
||||
return _articleTitle;
|
||||
}
|
||||
|
||||
- (void)setArticleTitle:(NSString *)articleTitle {
|
||||
_articleTitle = [articleTitle copy];
|
||||
if (self.titleField) {
|
||||
self.titleField.text = articleTitle;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
|
||||
if (self.dismissBlock) {
|
||||
self.dismissBlock();
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -11,8 +11,9 @@
|
|||
#import "BlogController.h"
|
||||
#import "Post.h"
|
||||
#import "PreviewViewController.h"
|
||||
#import "ChangeTitleViewController.h"
|
||||
|
||||
@interface EditorViewController () <UITextViewDelegate>
|
||||
@interface EditorViewController () <UITextViewDelegate, UIPopoverPresentationControllerDelegate>
|
||||
|
||||
@property (nonatomic, weak) IBOutlet UILabel *titleView;
|
||||
@property (nonatomic, weak) IBOutlet UITextView *textView;
|
||||
|
|
@ -57,6 +58,7 @@
|
|||
|
||||
- (void)configureTitleView {
|
||||
self.titleView.text = self.modifiedPost.title.length ? self.modifiedPost.title : @"Untitled";
|
||||
[self.titleView sizeToFit];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
|
|
@ -149,4 +151,36 @@
|
|||
self.modifiedPost = [self.modifiedPost copyWithURL:url];
|
||||
}
|
||||
|
||||
- (IBAction)presentChangeTitle:(id)sender {
|
||||
if (self.presentedViewController) {
|
||||
return;
|
||||
}
|
||||
|
||||
ChangeTitleViewController *changeTitleViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Change Title View Controller"];
|
||||
changeTitleViewController.modalPresentationStyle = UIModalPresentationPopover;
|
||||
changeTitleViewController.preferredContentSize = CGSizeMake(320, 60);
|
||||
changeTitleViewController.articleTitle = self.modifiedPost.title;
|
||||
UIPopoverPresentationController *presentationController = changeTitleViewController.popoverPresentationController;
|
||||
presentationController.delegate = self;
|
||||
presentationController.sourceView = self.view;
|
||||
presentationController.sourceRect = CGRectMake(CGRectGetWidth(self.view.bounds) / 2, 0, 1, 1);
|
||||
presentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
|
||||
changeTitleViewController.dismissBlock = ^{
|
||||
NSString *title = changeTitleViewController.articleTitle;
|
||||
[self updatePostTitle:title];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
};
|
||||
[self presentViewController:changeTitleViewController animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {
|
||||
return UIModalPresentationNone;
|
||||
}
|
||||
|
||||
- (void)popoverPresentationControllerDidDismissPopover:(UIPopoverPresentationController *)popoverPresentationController {
|
||||
ChangeTitleViewController *changeTitleViewController = (ChangeTitleViewController *)popoverPresentationController.presentedViewController;
|
||||
NSString *title = changeTitleViewController.articleTitle;
|
||||
[self updatePostTitle:title];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@
|
|||
@"url" : url ?: [NSNull null],
|
||||
@"draft" : @(self.draft),
|
||||
@"new" : @(self.new),
|
||||
} error:nil];
|
||||
} error:nil];
|
||||
}
|
||||
|
||||
- (BOOL)isEqualToPost:(Post *)other {
|
||||
|
|
|
|||
Loading…
Reference in a new issue