summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-12-04 00:20:02 +0300
committerGravatar Vitaly Takmazov2017-12-04 00:20:02 +0300
commit3c680cfe8c1e6cfbce16f787fbf01fdb3f7c40ae (patch)
tree51c90370eae5c622ab305bc4bd7eb0a34fd96f2a
parentccf06c2af74f63e5276e15f3e10acf74bf4174f7 (diff)
WIP
-rw-r--r--Juick.xcodeproj/project.pbxproj10
-rw-r--r--Juick/APIClient.h1
-rw-r--r--Juick/APIClient.m15
-rw-r--r--Juick/ViewControllers/MessagesViewController.m2
-rw-r--r--Juick/ViewControllers/ThreadViewController.h3
-rw-r--r--Juick/ViewControllers/ThreadViewController.m31
-rw-r--r--Juick/Views/MessageInputView.h15
-rw-r--r--Juick/Views/MessageInputView.m13
-rw-r--r--Juick/Views/MessageInputView.xib82
9 files changed, 161 insertions, 11 deletions
diff --git a/Juick.xcodeproj/project.pbxproj b/Juick.xcodeproj/project.pbxproj
index 38a14a7..2708a64 100644
--- a/Juick.xcodeproj/project.pbxproj
+++ b/Juick.xcodeproj/project.pbxproj
@@ -46,6 +46,8 @@
77C6ADDE1F770EB2000AEA8C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 77C6ADDD1F770EB2000AEA8C /* Main.storyboard */; };
77C6ADE41F7717BC000AEA8C /* ThreadViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77C6ADE31F7717BC000AEA8C /* ThreadViewController.m */; };
77E35A82189A5B5A00B2D216 /* LoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77E35A81189A5B5A00B2D216 /* LoginViewController.m */; };
+ 77E61A5B1FD467FC00B4E304 /* MessageInputView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 77E61A5A1FD467FC00B4E304 /* MessageInputView.xib */; };
+ 77E61A5E1FD4682B00B4E304 /* MessageInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = 77E61A5D1FD4682B00B4E304 /* MessageInputView.m */; };
77FCADDF1D6A50DA00CBA649 /* APIClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 77FCADDE1D6A50DA00CBA649 /* APIClient.m */; };
/* End PBXBuildFile section */
@@ -119,6 +121,9 @@
77C6ADE31F7717BC000AEA8C /* ThreadViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ThreadViewController.m; sourceTree = "<group>"; };
77E35A80189A5B5A00B2D216 /* LoginViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginViewController.h; sourceTree = "<group>"; };
77E35A81189A5B5A00B2D216 /* LoginViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginViewController.m; sourceTree = "<group>"; };
+ 77E61A5A1FD467FC00B4E304 /* MessageInputView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MessageInputView.xib; sourceTree = "<group>"; };
+ 77E61A5C1FD4682B00B4E304 /* MessageInputView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessageInputView.h; sourceTree = "<group>"; };
+ 77E61A5D1FD4682B00B4E304 /* MessageInputView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MessageInputView.m; sourceTree = "<group>"; };
77FCADDE1D6A50DA00CBA649 /* APIClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APIClient.m; sourceTree = "<group>"; };
77FCADE01D6A50EC00CBA649 /* APIClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = APIClient.h; sourceTree = "<group>"; };
9FF4AA695CB46B0E7AED628D /* Pods_JuickTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_JuickTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -303,6 +308,9 @@
776C41BA1FD3EF180063B82E /* MessageCell.h */,
776C41BB1FD3EF180063B82E /* MessageCell.m */,
776C41BC1FD3EF180063B82E /* MessageCell.xib */,
+ 77E61A5A1FD467FC00B4E304 /* MessageInputView.xib */,
+ 77E61A5C1FD4682B00B4E304 /* MessageInputView.h */,
+ 77E61A5D1FD4682B00B4E304 /* MessageInputView.m */,
);
path = Views;
sourceTree = "<group>";
@@ -414,6 +422,7 @@
773F231C1F76DD0B00B5B0DF /* SerpentineBoldItalic.ttf in Resources */,
77317BB6181BBE8500D60005 /* InfoPlist.strings in Resources */,
773F23331F76ECAC00B5B0DF /* LaunchScreen.storyboard in Resources */,
+ 77E61A5B1FD467FC00B4E304 /* MessageInputView.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -516,6 +525,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 77E61A5E1FD4682B00B4E304 /* MessageInputView.m in Sources */,
77317BBC181BBE8500D60005 /* AppDelegate.m in Sources */,
776C41C11FD3FF6E0063B82E /* DiscoverViewController.m in Sources */,
77FCADDF1D6A50DA00CBA649 /* APIClient.m in Sources */,
diff --git a/Juick/APIClient.h b/Juick/APIClient.h
index 8c6e024..ca511a5 100644
--- a/Juick/APIClient.h
+++ b/Juick/APIClient.h
@@ -14,6 +14,7 @@
+(APIClient *) sharedClient;
-(void) pullNextFromPath:(NSString *)path params:(NSDictionary *)params callback:(void(^)(NSArray *, NSError *))callback;
+-(void) postReplyToThread:(NSNumber *)mid inReplyTo:(NSNumber *)rid text:(NSString *)text;
+(NSString *) messagesUrl;
+(NSString *) threadUrl;
diff --git a/Juick/APIClient.m b/Juick/APIClient.m
index beace7c..ca894d4 100644
--- a/Juick/APIClient.m
+++ b/Juick/APIClient.m
@@ -52,6 +52,21 @@
});
}
+-(void) postReplyToThread:(NSNumber *)mid inReplyTo:(NSNumber *)rid text:(NSString *)text {
+ AFHTTPSessionManager *manager = [APIClient sharedClient].manager;
+ NSOperationQueue *operationQueue = [NSOperationQueue new];
+ [operationQueue addOperationWithBlock:^{
+ [manager POST:@"/post" parameters:
+ @{
+ @"mid": mid,
+ @"rid": rid,
+ @"body": text
+ } progress:nil success:nil failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
+ NSLog(@"Errrorrr: %@", [error localizedDescription]);
+ }];
+ }];
+}
+
+(NSString *) messagesUrl {
return @"/messages";
diff --git a/Juick/ViewControllers/MessagesViewController.m b/Juick/ViewControllers/MessagesViewController.m
index 5a5a794..71f4271 100644
--- a/Juick/ViewControllers/MessagesViewController.m
+++ b/Juick/ViewControllers/MessagesViewController.m
@@ -117,7 +117,7 @@
if (lastMsg != nil) {
NSNumber *lastMid = lastMsg.mid;
if (![self.path isEqualToString:[APIClient threadUrl]]) {
- [self.params setObject:lastMid forKey:@"before_mid"];
+ self.params = [@{@"before_mid":lastMid} mutableCopy];
}
[self refreshData];
}
diff --git a/Juick/ViewControllers/ThreadViewController.h b/Juick/ViewControllers/ThreadViewController.h
index 484e2fb..a9c5259 100644
--- a/Juick/ViewControllers/ThreadViewController.h
+++ b/Juick/ViewControllers/ThreadViewController.h
@@ -8,7 +8,6 @@
#import <UIKit/UIKit.h>
#include "MessagesViewController.h"
-@import PHFComposeBarView;
-@interface ThreadViewController : MessagesViewController<PHFComposeBarViewDelegate>
+@interface ThreadViewController : MessagesViewController
@end
diff --git a/Juick/ViewControllers/ThreadViewController.m b/Juick/ViewControllers/ThreadViewController.m
index 4de0cab..2b0d3c4 100644
--- a/Juick/ViewControllers/ThreadViewController.m
+++ b/Juick/ViewControllers/ThreadViewController.m
@@ -9,13 +9,15 @@
#import "ThreadViewController.h"
#import "ColorScheme.h"
#import "MessageCell.h"
-@import PHFComposeBarView;
+#import "MessageInputView.h"
+#import "APIClient.h"
@interface ThreadViewController ()
@property (nonatomic, readwrite, retain) UIView *inputAccessoryView;
-(void) updateQuoteText:(Message *)message;
+@property NSNumber *replyTo;
@end
@@ -23,6 +25,9 @@
- (void)viewDidLoad {
[super viewDidLoad];
+ self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive;
+
+ _replyTo = @(0);
}
@@ -32,26 +37,36 @@
- (UIView *)inputAccessoryView {
if (!_inputAccessoryView) {
- CGRect viewBounds = self.view.bounds;
- CGRect frame = CGRectMake(0, viewBounds.size.height - PHFComposeBarViewInitialHeight - self.view.safeAreaInsets.top + self.view.safeAreaInsets.bottom, viewBounds.size.width, PHFComposeBarViewInitialHeight);
- PHFComposeBarView *inputView = [[PHFComposeBarView alloc] initWithFrame:frame];
- inputView.backgroundColor = [UIColor whiteColor];
+ MessageInputView *inputView = (MessageInputView *)[[[NSBundle mainBundle] loadNibNamed:@"MessageInputView" owner:self options:nil] firstObject];
+ /*inputView.backgroundColor = [UIColor whiteColor];
inputView.buttonTintColor = [ColorScheme linkColor];
inputView.maxLinesCount = 4;
inputView.utilityButtonImage = [UIImage imageNamed:@"Camera"];
- inputView.delegate = self;
+ inputView.delegate = self;*/
+ inputView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
+ [inputView.sendButton addTarget:self action:@selector(sendReply) forControlEvents:UIControlEventTouchUpInside];
_inputAccessoryView = inputView;
}
return _inputAccessoryView;
}
-(void) updateQuoteText:(Message *)message {
- /*MessageInputView *inputView = (MessageInputView *)self.inputAccessoryView;
- inputView.quoteText.text = message.text;*/
+ MessageInputView *inputView = (MessageInputView *)self.inputAccessoryView;
+ inputView.quoteText.text = message.text;
+ [inputView.contentView setNeedsUpdateConstraints];
+ [inputView.contentView updateConstraintsIfNeeded];
+ [inputView.contentView setNeedsLayout];
+ [inputView.contentView layoutIfNeeded];
+}
+-(void) sendReply {
+ MessageInputView *inputView = (MessageInputView *)self.inputAccessoryView;
+ Message *msg = [self.messages firstObject];
+ [[APIClient sharedClient] postReplyToThread:msg.mid inReplyTo:self.replyTo text:inputView.textContent.text];
}
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Message * selectedMessage = [self.messages objectAtIndex:indexPath.row];
+ _replyTo = selectedMessage.rid;
[self updateQuoteText:selectedMessage];
}
diff --git a/Juick/Views/MessageInputView.h b/Juick/Views/MessageInputView.h
new file mode 100644
index 0000000..46919b4
--- /dev/null
+++ b/Juick/Views/MessageInputView.h
@@ -0,0 +1,15 @@
+//
+// MessageInputView.h
+// Juick
+//
+// Created by Vitaly Takmazov on 03/12/2017.
+// Copyright © 2017 com.juick. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface MessageInputView : UIVisualEffectView
+@property (weak, nonatomic) IBOutlet UILabel *quoteText;
+@property (weak, nonatomic) IBOutlet UIButton *sendButton;
+@property (weak, nonatomic) IBOutlet UITextView *textContent;
+@end
diff --git a/Juick/Views/MessageInputView.m b/Juick/Views/MessageInputView.m
new file mode 100644
index 0000000..147a508
--- /dev/null
+++ b/Juick/Views/MessageInputView.m
@@ -0,0 +1,13 @@
+//
+// MessageInputView.m
+// Juick
+//
+// Created by Vitaly Takmazov on 03/12/2017.
+// Copyright © 2017 com.juick. All rights reserved.
+//
+
+#import "MessageInputView.h"
+@implementation MessageInputView
+
+
+@end
diff --git a/Juick/Views/MessageInputView.xib b/Juick/Views/MessageInputView.xib
new file mode 100644
index 0000000..54ba547
--- /dev/null
+++ b/Juick/Views/MessageInputView.xib
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+ <device id="retina4_7" orientation="portrait">
+ <adaptation id="fullscreen"/>
+ </device>
+ <dependencies>
+ <deployment identifier="iOS"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
+ <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+ </dependencies>
+ <objects>
+ <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+ <visualEffectView opaque="NO" contentMode="scaleToFill" id="8gV-Bq-kOk" customClass="MessageInputView">
+ <rect key="frame" x="0.0" y="0.0" width="604" height="87"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="imu-GT-9JL">
+ <rect key="frame" x="0.0" y="0.0" width="604" height="87"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <subviews>
+ <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="6" translatesAutoresizingMaskIntoConstraints="NO" id="3Wb-84-dcd">
+ <rect key="frame" x="6" y="6" width="592" height="75"/>
+ <subviews>
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" verticalCompressionResistancePriority="248" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Swn-59-jWb">
+ <rect key="frame" x="0.0" y="0.0" width="592" height="31"/>
+ <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
+ <nil key="textColor"/>
+ <nil key="highlightedColor"/>
+ </label>
+ <stackView opaque="NO" contentMode="scaleToFill" verticalCompressionResistancePriority="749" spacing="12" translatesAutoresizingMaskIntoConstraints="NO" id="e2q-59-qlo">
+ <rect key="frame" x="0.0" y="37" width="592" height="38"/>
+ <subviews>
+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="infoLight" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ZXm-ce-xjB">
+ <rect key="frame" x="0.0" y="0.0" width="44" height="38"/>
+ <constraints>
+ <constraint firstAttribute="width" constant="44" id="chf-2p-LxF"/>
+ </constraints>
+ </button>
+ <textView multipleTouchEnabled="YES" contentMode="scaleToFill" horizontalHuggingPriority="252" horizontalCompressionResistancePriority="749" scrollEnabled="NO" keyboardDismissMode="interactive" textAlignment="natural" adjustsFontForContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="alc-Oi-DBv">
+ <rect key="frame" x="56" y="0.0" width="480" height="38"/>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+ <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
+ <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
+ <userDefinedRuntimeAttributes>
+ <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
+ <integer key="value" value="5"/>
+ </userDefinedRuntimeAttribute>
+ <userDefinedRuntimeAttribute type="boolean" keyPath="layer.clipsToBounds" value="YES"/>
+ </userDefinedRuntimeAttributes>
+ </textView>
+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="9h3-lP-1PC">
+ <rect key="frame" x="548" y="0.0" width="44" height="38"/>
+ <constraints>
+ <constraint firstAttribute="width" constant="44" id="QvX-xP-ypC"/>
+ </constraints>
+ <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
+ <state key="normal" title="Send"/>
+ </button>
+ </subviews>
+ </stackView>
+ </subviews>
+ </stackView>
+ </subviews>
+ <constraints>
+ <constraint firstItem="ZiU-Ll-9jB" firstAttribute="bottom" secondItem="3Wb-84-dcd" secondAttribute="bottom" constant="6" id="6la-q5-7Uo"/>
+ <constraint firstItem="3Wb-84-dcd" firstAttribute="top" secondItem="ZiU-Ll-9jB" secondAttribute="top" constant="6" id="ibK-wT-80X"/>
+ <constraint firstItem="ZiU-Ll-9jB" firstAttribute="trailing" secondItem="3Wb-84-dcd" secondAttribute="trailing" constant="6" id="wBb-3j-nHr"/>
+ <constraint firstItem="3Wb-84-dcd" firstAttribute="leading" secondItem="ZiU-Ll-9jB" secondAttribute="leading" constant="6" id="wM0-uw-QAg"/>
+ </constraints>
+ <viewLayoutGuide key="safeArea" id="ZiU-Ll-9jB"/>
+ </view>
+ <blurEffect style="light"/>
+ <connections>
+ <outlet property="quoteText" destination="Swn-59-jWb" id="tky-lv-tWn"/>
+ <outlet property="sendButton" destination="9h3-lP-1PC" id="9a8-ZV-jcJ"/>
+ <outlet property="textContent" destination="alc-Oi-DBv" id="PqQ-aJ-Unr"/>
+ </connections>
+ <point key="canvasLocation" x="213" y="82.5"/>
+ </visualEffectView>
+ </objects>
+</document>