summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Juick/Views/MessageInputView.h9
-rw-r--r--Juick/Views/MessageInputView.m20
-rw-r--r--Juick/Views/MessageInputView.xib63
3 files changed, 67 insertions, 25 deletions
diff --git a/Juick/Views/MessageInputView.h b/Juick/Views/MessageInputView.h
index c78f498..9cf3652 100644
--- a/Juick/Views/MessageInputView.h
+++ b/Juick/Views/MessageInputView.h
@@ -14,9 +14,14 @@
@end
-@interface MessageInputView : UIVisualEffectView
+@interface MessageInputView : UIVisualEffectView<UITextViewDelegate>
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *bottomConstraint;
-@property (strong, nonatomic) IBOutlet UITextField *textView;
+@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textHeightConstraint;
+@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topMarginConstraint;
+@property (strong, nonatomic) IBOutlet UITextView *textView;
+
+@property (weak, nonatomic) IBOutlet UIButton *sendButton;
+
- (IBAction)sendPressed:(id)sender;
@property (nonatomic, weak) id<MessageInputDelegate> delegate;
diff --git a/Juick/Views/MessageInputView.m b/Juick/Views/MessageInputView.m
index c4d96de..054ded7 100644
--- a/Juick/Views/MessageInputView.m
+++ b/Juick/Views/MessageInputView.m
@@ -10,9 +10,23 @@
@implementation MessageInputView
--(void) awakeFromNib {
- [super awakeFromNib];
- [self setTintColor:[UIColor colorNamed:@"Title"]];
+- (CGSize) textSize {
+ CGSize size = CGSizeMake(self.textView.bounds.size.width, FLT_MAX);
+ return [self.textView sizeThatFits:size];
+}
+
+- (CGSize) intrinsicContentSize {
+ CGSize viewSize = [self textSize];
+ viewSize.height = viewSize.height + self.bottomConstraint.constant + self.topMarginConstraint.constant;
+ return viewSize;
+}
+
+- (void)textViewDidChange:(UITextView *)textView {
+ if ([self textSize].height != self.textHeightConstraint.constant) {
+ self.textHeightConstraint.constant = [self textSize].height;
+ [self layoutIfNeeded];
+ }
+ [self.sendButton setEnabled:[self.textView.text length] > 0];
}
- (IBAction)sendPressed:(id)sender {
diff --git a/Juick/Views/MessageInputView.xib b/Juick/Views/MessageInputView.xib
index 9cb8bd4..525d888 100644
--- a/Juick/Views/MessageInputView.xib
+++ b/Juick/Views/MessageInputView.xib
@@ -4,33 +4,42 @@
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
+ <capability name="Named colors" minToolsVersion="9.0"/>
+ <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="2Ze-bx-tgN" customClass="MessageInputView">
- <rect key="frame" x="0.0" y="0.0" width="320" height="58"/>
- <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2Ze-bx-tgN" customClass="MessageInputView">
+ <rect key="frame" x="0.0" y="0.0" width="320" height="55"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="Jo1-Go-4dO">
- <rect key="frame" x="0.0" y="0.0" width="320" height="58"/>
+ <rect key="frame" x="0.0" y="0.0" width="320" height="55"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
- <stackView opaque="NO" contentMode="scaleToFill" spacing="6" translatesAutoresizingMaskIntoConstraints="NO" id="OCM-7q-caQ">
- <rect key="frame" x="4" y="4" width="300" height="38"/>
+ <stackView opaque="NO" contentMode="scaleToFill" alignment="center" spacing="6" translatesAutoresizingMaskIntoConstraints="NO" id="OCM-7q-caQ">
+ <rect key="frame" x="8" y="8" width="296" height="39"/>
<subviews>
- <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="112-Yb-83a">
- <rect key="frame" x="0.0" y="0.0" width="30" height="38"/>
+ <button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="999" horizontalCompressionResistancePriority="999" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="112-Yb-83a">
+ <rect key="frame" x="0.0" y="3" width="30" height="33"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<state key="normal" title="@"/>
</button>
- <textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="249" horizontalCompressionResistancePriority="751" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" adjustsFontForContentSizeCategory="YES" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Dkb-8O-5u6">
- <rect key="frame" x="36" y="0.0" width="218" height="38"/>
+ <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" textAlignment="natural" adjustsFontForContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tWq-jg-tXW">
+ <rect key="frame" x="36" y="0.0" width="214" height="39"/>
+ <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
+ <constraints>
+ <constraint firstAttribute="height" constant="39" id="Dhd-rY-QS9"/>
+ </constraints>
+ <color key="textColor" name="Text"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
- <textInputTraits key="textInputTraits"/>
- </textField>
- <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="iUb-5g-Btb">
- <rect key="frame" x="260" y="0.0" width="40" height="38"/>
+ <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
+ <connections>
+ <outlet property="delegate" destination="2Ze-bx-tgN" id="Csx-Qg-lYh"/>
+ </connections>
+ </textView>
+ <button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="999" horizontalCompressionResistancePriority="999" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="iUb-5g-Btb">
+ <rect key="frame" x="256" y="3" width="40" height="33"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<state key="normal" title="Send"/>
<connections>
@@ -41,18 +50,32 @@
</stackView>
</subviews>
<constraints>
- <constraint firstAttribute="trailingMargin" secondItem="OCM-7q-caQ" secondAttribute="trailing" constant="8" id="70a-kb-HZp"/>
- <constraint firstItem="OCM-7q-caQ" firstAttribute="topMargin" secondItem="Jo1-Go-4dO" secondAttribute="top" constant="4" id="Voz-db-iEt"/>
- <constraint firstItem="OCM-7q-caQ" firstAttribute="leadingMargin" secondItem="Jo1-Go-4dO" secondAttribute="leading" constant="4" id="epV-Pa-CnX"/>
- <constraint firstAttribute="bottomMargin" secondItem="OCM-7q-caQ" secondAttribute="bottom" constant="8" id="hsT-4s-U3s"/>
+ <constraint firstItem="5tZ-ZX-uO1" firstAttribute="trailing" secondItem="OCM-7q-caQ" secondAttribute="trailing" constant="16" id="70a-kb-HZp"/>
+ <constraint firstItem="OCM-7q-caQ" firstAttribute="topMargin" secondItem="5tZ-ZX-uO1" secondAttribute="top" constant="8" id="Voz-db-iEt"/>
+ <constraint firstItem="OCM-7q-caQ" firstAttribute="leadingMargin" secondItem="5tZ-ZX-uO1" secondAttribute="leading" constant="8" id="epV-Pa-CnX"/>
+ <constraint firstItem="5tZ-ZX-uO1" firstAttribute="bottom" secondItem="OCM-7q-caQ" secondAttribute="bottom" constant="8" id="hsT-4s-U3s"/>
</constraints>
+ <viewLayoutGuide key="safeArea" id="5tZ-ZX-uO1"/>
</view>
+ <color key="tintColor" name="Title"/>
+ <viewLayoutGuide key="safeArea" id="cMG-PD-wrX"/>
<blurEffect style="light"/>
<connections>
<outlet property="bottomConstraint" destination="hsT-4s-U3s" id="b1V-Gk-1At"/>
- <outlet property="textView" destination="Dkb-8O-5u6" id="6YC-Bn-7P6"/>
+ <outlet property="sendButton" destination="iUb-5g-Btb" id="nZW-5X-H6K"/>
+ <outlet property="textHeightConstraint" destination="Dhd-rY-QS9" id="qcD-mT-90j"/>
+ <outlet property="textView" destination="tWq-jg-tXW" id="6og-aj-ZrO"/>
+ <outlet property="topMarginConstraint" destination="Voz-db-iEt" id="IcV-qc-hOJ"/>
</connections>
- <point key="canvasLocation" x="-387" y="95"/>
+ <point key="canvasLocation" x="-387.19999999999999" y="92.203898050974516"/>
</visualEffectView>
</objects>
+ <resources>
+ <namedColor name="Text">
+ <color red="0.13333333333333333" green="0.13333333333333333" blue="0.13333333333333333" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+ </namedColor>
+ <namedColor name="Title">
+ <color red="0.0" green="0.40000000000000002" blue="0.59999999999999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+ </namedColor>
+ </resources>
</document>