summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2021-03-20 00:13:49 +0300
committerGravatar Vitaly Takmazov2021-03-20 00:13:49 +0300
commit767a762f2c220527762f3c59fd0aeb12ccd474ec (patch)
tree23c1715e685a05d144d80ab60750bedc88ea358d
parent7a969d40babccbb8bdddb254d03e74c638b354a8 (diff)
Fix text input view in chat on Mac
-rw-r--r--Juick/Main.storyboard92
-rw-r--r--Juick/ViewControllers/ChatViewController.h4
-rw-r--r--Juick/ViewControllers/ChatViewController.m23
3 files changed, 70 insertions, 49 deletions
diff --git a/Juick/Main.storyboard b/Juick/Main.storyboard
index 5d99c97..fae7c7e 100644
--- a/Juick/Main.storyboard
+++ b/Juick/Main.storyboard
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Rbr-km-xhI">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Rbr-km-xhI">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
+ <capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
@@ -74,6 +75,43 @@
</objects>
<point key="canvasLocation" x="-135.19999999999999" y="-169.56521739130437"/>
</scene>
+ <!--Chat View Controller-->
+ <scene sceneID="gXi-Rc-5Tr">
+ <objects>
+ <viewController id="NJ0-eV-xFG" customClass="ChatViewController" sceneMemberID="viewController">
+ <view key="view" contentMode="scaleToFill" id="urU-0K-b02">
+ <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <subviews>
+ <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="ypj-S8-a0N">
+ <rect key="frame" x="0.0" y="44" width="375" height="623"/>
+ <subviews>
+ <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="XSR-ku-71h">
+ <rect key="frame" x="0.0" y="0.0" width="375" height="623"/>
+ <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+ </tableView>
+ </subviews>
+ </stackView>
+ </subviews>
+ <viewLayoutGuide key="safeArea" id="hMv-Fe-KsO"/>
+ <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+ <constraints>
+ <constraint firstItem="ypj-S8-a0N" firstAttribute="leading" secondItem="hMv-Fe-KsO" secondAttribute="leading" id="Y6Q-pa-ZIY"/>
+ <constraint firstItem="hMv-Fe-KsO" firstAttribute="trailing" secondItem="ypj-S8-a0N" secondAttribute="trailing" id="ozx-gm-ecN"/>
+ <constraint firstItem="ypj-S8-a0N" firstAttribute="top" secondItem="hMv-Fe-KsO" secondAttribute="top" id="vSP-kM-XxT"/>
+ <constraint firstItem="hMv-Fe-KsO" firstAttribute="bottom" secondItem="ypj-S8-a0N" secondAttribute="bottom" id="we7-9y-GcE"/>
+ </constraints>
+ </view>
+ <navigationItem key="navigationItem" id="8cn-fV-rqO"/>
+ <connections>
+ <outlet property="stack" destination="ypj-S8-a0N" id="Ywj-FB-Wqf"/>
+ <outlet property="tableView" destination="XSR-ku-71h" id="dDA-yH-aHj"/>
+ </connections>
+ </viewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="H8z-L4-Fon" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
+ </objects>
+ <point key="canvasLocation" x="1144.8" y="-117.39130434782609"/>
+ </scene>
<!--Navigation Controller-->
<scene sceneID="fTm-5S-xsb">
<objects>
@@ -96,7 +134,7 @@
<objects>
<viewController id="4g9-hM-bzq" customClass="LoginViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="ak5-5Q-P4e">
- <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+ <rect key="frame" x="0.0" y="0.0" width="375" height="647"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" axis="vertical" spacing="24" translatesAutoresizingMaskIntoConstraints="NO" id="axR-g5-sfd">
@@ -127,7 +165,7 @@
<userDefinedRuntimeAttribute type="string" keyPath="placeholder" value="Password..."/>
</userDefinedRuntimeAttributes>
</textField>
- <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gPQ-xI-b5J">
+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gPQ-xI-b5J">
<rect key="frame" x="0.0" y="280.5" width="351" height="33"/>
<color key="backgroundColor" name="Chat"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
@@ -141,13 +179,13 @@
</subviews>
</stackView>
</subviews>
+ <viewLayoutGuide key="safeArea" id="fue-ZI-ech"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="fue-ZI-ech" firstAttribute="trailing" secondItem="axR-g5-sfd" secondAttribute="trailing" constant="12" id="CP5-In-mwY"/>
<constraint firstItem="axR-g5-sfd" firstAttribute="leading" secondItem="fue-ZI-ech" secondAttribute="leading" constant="12" id="YIV-CU-Vyy"/>
<constraint firstItem="axR-g5-sfd" firstAttribute="top" secondItem="fue-ZI-ech" secondAttribute="top" constant="12" id="ZUC-uk-RH7"/>
</constraints>
- <viewLayoutGuide key="safeArea" id="fue-ZI-ech"/>
</view>
<navigationItem key="navigationItem" id="QaM-45-gms"/>
<connections>
@@ -207,9 +245,6 @@
<rect key="frame" x="0.0" y="0.0" width="348" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
- <connections>
- <segue destination="jVt-4s-14k" kind="push" identifier="chatSegue" id="YUK-fh-DMd"/>
- </connections>
</tableViewCell>
</prototypes>
<connections>
@@ -221,6 +256,9 @@
<offsetWrapper key="titlePositionAdjustment" horizontal="0.0" vertical="0.0"/>
</tabBarItem>
<navigationItem key="navigationItem" title="Chats" id="hVh-CA-hQo"/>
+ <connections>
+ <segue destination="NJ0-eV-xFG" kind="push" identifier="chatSegue" id="2fL-Ga-5Tg"/>
+ </connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="8ge-Xf-wBN" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
@@ -231,7 +269,7 @@
<objects>
<viewController title="New post" hidesBottomBarWhenPushed="YES" id="rr1-jx-MLx" customClass="NewPostViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="7ep-bO-aeZ">
- <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+ <rect key="frame" x="0.0" y="0.0" width="375" height="647"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="XYj-Y4-lfM">
@@ -241,6 +279,7 @@
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
</subviews>
+ <viewLayoutGuide key="safeArea" id="UJz-7C-l1q"/>
<color key="backgroundColor" name="TextBackground"/>
<constraints>
<constraint firstItem="UJz-7C-l1q" firstAttribute="top" secondItem="XYj-Y4-lfM" secondAttribute="top" constant="4" id="5aN-lI-YBC"/>
@@ -248,7 +287,6 @@
<constraint firstItem="XYj-Y4-lfM" firstAttribute="leading" secondItem="UJz-7C-l1q" secondAttribute="leading" constant="4" id="aw6-Uf-tSS"/>
<constraint firstItem="UJz-7C-l1q" firstAttribute="trailing" secondItem="XYj-Y4-lfM" secondAttribute="trailing" constant="4" id="gTz-QO-1CL"/>
</constraints>
- <viewLayoutGuide key="safeArea" id="UJz-7C-l1q"/>
</view>
<navigationItem key="navigationItem" id="Yd6-Yh-gtd">
<barButtonItem key="leftBarButtonItem" systemItem="cancel" id="pNy-rM-fck">
@@ -271,35 +309,6 @@
</objects>
<point key="canvasLocation" x="2087.1999999999998" y="-889.20539730134942"/>
</scene>
- <!--Chat View Controller-->
- <scene sceneID="pvH-EU-EhQ">
- <objects>
- <tableViewController storyboardIdentifier="chatViewController" hidesBottomBarWhenPushed="YES" id="jVt-4s-14k" customClass="ChatViewController" sceneMemberID="viewController">
- <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" keyboardDismissMode="interactive" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="CGw-ia-Afb">
- <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
- <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
- <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
- <prototypes>
- <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="bubbleMessageCell" id="LzB-jF-bmj" customClass="BubbleMessageCell">
- <rect key="frame" x="0.0" y="28" width="375" height="43.5"/>
- <autoresizingMask key="autoresizingMask"/>
- <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="LzB-jF-bmj" id="GOC-84-YKd">
- <rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
- <autoresizingMask key="autoresizingMask"/>
- </tableViewCellContentView>
- </tableViewCell>
- </prototypes>
- <connections>
- <outlet property="dataSource" destination="jVt-4s-14k" id="AmJ-8N-KSz"/>
- <outlet property="delegate" destination="jVt-4s-14k" id="oAC-v1-Xqi"/>
- </connections>
- </tableView>
- <navigationItem key="navigationItem" id="bwh-ES-OoM"/>
- </tableViewController>
- <placeholder placeholderIdentifier="IBFirstResponder" id="a3c-tt-waA" userLabel="First Responder" sceneMemberID="firstResponder"/>
- </objects>
- <point key="canvasLocation" x="1408.8" y="-162.3688155922039"/>
- </scene>
<!--Discover-->
<scene sceneID="g01-td-y6A">
<objects>
@@ -443,10 +452,13 @@
<color red="0.97254901960784312" green="0.97254901960784312" blue="0.97254901960784312" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="TextBackground">
- <color red="0.99215686274509807" green="0.99215686274509807" blue="0.99607843137254903" alpha="0.75" colorSpace="custom" customColorSpace="sRGB"/>
+ <color red="0.99199998378753662" green="0.99199998378753662" blue="0.99599999189376831" alpha="0.75" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="Title">
<color red="0.23529411764705882" green="0.46666666666666667" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
+ <systemColor name="systemBackgroundColor">
+ <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+ </systemColor>
</resources>
</document>
diff --git a/Juick/ViewControllers/ChatViewController.h b/Juick/ViewControllers/ChatViewController.h
index bfd63e7..f21eb10 100644
--- a/Juick/ViewControllers/ChatViewController.h
+++ b/Juick/ViewControllers/ChatViewController.h
@@ -10,9 +10,11 @@
#import "User.h"
#import "MessageInputView.h"
-@interface ChatViewController : UITableViewController<MessageInputDelegate>
+@interface ChatViewController : UIViewController<MessageInputDelegate, UITableViewDelegate, UITableViewDataSource>
@property(nonatomic, strong) NSMutableArray *messages;
@property(nonatomic, strong) NSString *uname;
+@property (weak, nonatomic) IBOutlet UIStackView *stack;
+@property (strong, nonatomic) IBOutlet UITableView *tableView;
-(void) reloadChat;
@end
diff --git a/Juick/ViewControllers/ChatViewController.m b/Juick/ViewControllers/ChatViewController.m
index 695d7ec..9493155 100644
--- a/Juick/ViewControllers/ChatViewController.m
+++ b/Juick/ViewControllers/ChatViewController.m
@@ -23,6 +23,8 @@
- (void)viewDidLoad {
[super viewDidLoad];
[self.navigationController.visibleViewController setTitle:self.uname];
+ self.tableView.delegate = self;
+ self.tableView.dataSource = self;
[self.tableView registerNib:[UINib nibWithNibName:@"BubbleMessageCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"bubbleMessageCell"];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive;
@@ -30,9 +32,12 @@
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
[self reloadChat];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
- self.refreshControl = [UIRefreshControl new];
- [self.refreshControl addTarget:self action:@selector(reloadChat) forControlEvents:UIControlEventValueChanged];
+ self.tableView.refreshControl = [UIRefreshControl new];
+ [self.tableView.refreshControl addTarget:self action:@selector(reloadChat) forControlEvents:UIControlEventValueChanged];
[self addObserver:self forKeyPath:@"uname" options:0 context:nil];
+#if TARGET_OS_MACCATALYST
+ [self.stack addArrangedSubview:[self inputAccessoryView]];
+#endif
}
-(void) reloadChat {
@@ -42,18 +47,20 @@
if (err == nil) {
[self.messages addObjectsFromArray:[[messages reverseObjectEnumerator] allObjects]];
NSMutableArray *indexPaths = [NSMutableArray new];
- for (NSUInteger index = 0; index < [messages count]; index++) {
+ NSInteger messagesCount = [self.messages count];
+ for (NSUInteger index = 0; index < messagesCount; index++) {
[indexPaths addObject:[NSIndexPath indexPathForRow:index inSection: 0]];
}
- [self.tableView beginUpdates];
- [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:YES];
- [self.tableView endUpdates];
- NSInteger messagesCount = [self.messages count];
+ if (indexPaths > 0) {
+ [self.tableView beginUpdates];
+ [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:YES];
+ [self.tableView endUpdates];
+ }
if (messagesCount > 0) {
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[self.messages count]-1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:NO];
}
}
- [self.refreshControl endRefreshing];
+ [self.tableView.refreshControl endRefreshing];
}];
}