summaryrefslogtreecommitdiff
path: root/Juick
diff options
context:
space:
mode:
Diffstat (limited to 'Juick')
-rw-r--r--Juick/ViewControllers/ChatViewController.h3
-rw-r--r--Juick/ViewControllers/ChatViewController.m2
-rw-r--r--Juick/Views/MessageInputView.h29
-rw-r--r--Juick/Views/MessageInputView.m36
-rw-r--r--Juick/Views/MessageInputView.swift47
-rw-r--r--Juick/Views/MessageInputView.xib16
6 files changed, 58 insertions, 75 deletions
diff --git a/Juick/ViewControllers/ChatViewController.h b/Juick/ViewControllers/ChatViewController.h
index f23ecc8..a1d4739 100644
--- a/Juick/ViewControllers/ChatViewController.h
+++ b/Juick/ViewControllers/ChatViewController.h
@@ -8,7 +8,8 @@
#import <UIKit/UIKit.h>
#import "User.h"
-#import "MessageInputView.h"
+
+@protocol MessageInputDelegate;
@interface ChatViewController : UIViewController<MessageInputDelegate, UITableViewDelegate, UITableViewDataSource>
@property(nonatomic, strong) NSMutableArray *messages;
diff --git a/Juick/ViewControllers/ChatViewController.m b/Juick/ViewControllers/ChatViewController.m
index 9ca024c..86d7b2f 100644
--- a/Juick/ViewControllers/ChatViewController.m
+++ b/Juick/ViewControllers/ChatViewController.m
@@ -9,7 +9,7 @@
#import "ChatViewController.h"
#import "BubbleMessageCell.h"
-#import "MessageInputView.h"
+#import "Juick-Swift.h"
#define kMessageInputInitialHeight 50
diff --git a/Juick/Views/MessageInputView.h b/Juick/Views/MessageInputView.h
deleted file mode 100644
index 9cf3652..0000000
--- a/Juick/Views/MessageInputView.h
+++ /dev/null
@@ -1,29 +0,0 @@
-//
-// MessageInputView.h
-// Juick
-//
-// Created by Vitaly Takmazov on 08/04/2018.
-// Copyright © 2018 com.juick. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-@protocol MessageInputDelegate <NSObject>
-
--(void) textSent:(NSString *)text;
-
-@end
-
-@interface MessageInputView : UIVisualEffectView<UITextViewDelegate>
-@property (strong, nonatomic) IBOutlet NSLayoutConstraint *bottomConstraint;
-@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;
-
-@end
diff --git a/Juick/Views/MessageInputView.m b/Juick/Views/MessageInputView.m
deleted file mode 100644
index 054ded7..0000000
--- a/Juick/Views/MessageInputView.m
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// MessageInputView.m
-// Juick
-//
-// Created by Vitaly Takmazov on 08/04/2018.
-// Copyright © 2018 com.juick. All rights reserved.
-//
-
-#import "MessageInputView.h"
-
-@implementation MessageInputView
-
-- (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 {
- [self.delegate textSent:self.textView.text];
- self.textView.text = nil;
-}
-@end
diff --git a/Juick/Views/MessageInputView.swift b/Juick/Views/MessageInputView.swift
new file mode 100644
index 0000000..2a923e2
--- /dev/null
+++ b/Juick/Views/MessageInputView.swift
@@ -0,0 +1,47 @@
+//
+// MessageInputView.swift
+// Juick
+//
+// Created by Vitaly Takmazov on 13.05.2023.
+// Copyright © 2023 com.juick. All rights reserved.
+//
+
+import UIKit
+
+@objc protocol MessageInputDelegate {
+ @objc func textSent(_ text: String)
+}
+
+@objc
+class MessageInputView: UIVisualEffectView, UITextViewDelegate {
+ @IBOutlet weak var bottomConstraint: NSLayoutConstraint!
+ @IBOutlet weak var textHeightConstraint: NSLayoutConstraint!
+ @IBOutlet weak var topMarginConstraint: NSLayoutConstraint!
+ @IBOutlet weak var textView: UITextView!
+ @IBOutlet weak var sendButton: UIButton!
+
+ @IBAction func sendPressed(_ sender: Any) {
+ self.delegate?.textSent(self.textView.text)
+ self.textView.text = nil
+ }
+ @objc var delegate: MessageInputDelegate?
+
+ func textSize() -> CGSize {
+ let size = CGSizeMake(self.textView.bounds.size.width, CGFloat(Float.greatestFiniteMagnitude))
+ return self.textView.sizeThatFits(size)
+ }
+
+ override var intrinsicContentSize: CGSize {
+ var viewSize = self.textSize()
+ viewSize.height = viewSize.height + self.bottomConstraint.constant + self.topMarginConstraint.constant
+ return viewSize
+ }
+
+ func textViewDidChange(_ textView: UITextView) {
+ if (self.textSize().height != self.textHeightConstraint.constant) {
+ self.textHeightConstraint.constant = self.textSize().height
+ layoutIfNeeded()
+ }
+ self.sendButton.isEnabled = self.textView.text.count > 0
+ }
+}
diff --git a/Juick/Views/MessageInputView.xib b/Juick/Views/MessageInputView.xib
index d7e76df..dc02c17 100644
--- a/Juick/Views/MessageInputView.xib
+++ b/Juick/Views/MessageInputView.xib
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19455" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19454"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
<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"/>
@@ -12,22 +12,22 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
- <visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2Ze-bx-tgN" customClass="MessageInputView">
+ <visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2Ze-bx-tgN" customClass="MessageInputView" customModule="Juick" customModuleProvider="target">
<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="55"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" alignment="bottom" spacing="6" translatesAutoresizingMaskIntoConstraints="NO" id="OCM-7q-caQ">
- <rect key="frame" x="8" y="8" width="296" height="39"/>
+ <rect key="frame" x="8" y="28" width="296" height="19"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="999" horizontalCompressionResistancePriority="999" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="112-Yb-83a">
- <rect key="frame" x="0.0" y="10" width="30" height="29"/>
+ <rect key="frame" x="0.0" y="0.0" width="30" height="19"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<state key="normal" title="@"/>
</button>
<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="220" height="39"/>
+ <rect key="frame" x="36" y="0.0" width="214" height="19"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="height" constant="39" id="Dhd-rY-QS9"/>
@@ -40,11 +40,11 @@
</connections>
</textView>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="999" horizontalCompressionResistancePriority="999" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="iUb-5g-Btb">
- <rect key="frame" x="262" y="10" width="34" height="29"/>
+ <rect key="frame" x="256" y="0.0" width="40" height="19"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<state key="normal" title="Send"/>
<connections>
- <action selector="sendPressed:" destination="2Ze-bx-tgN" eventType="touchUpInside" id="8Nq-cB-tho"/>
+ <action selector="sendPressed:" destination="2Ze-bx-tgN" eventType="touchUpInside" id="Isb-Pi-Qc2"/>
</connections>
</button>
</subviews>