diff options
author | Vitaly Takmazov | 2023-05-13 04:51:09 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-05-13 04:51:09 +0300 |
commit | 37f8fb16c6ce16ca601c386b62f65a48e31642fc (patch) | |
tree | 7530ccc48db78903edb7d3fbd0ed13f46df712d9 /Juick/Views | |
parent | 0e2dee0cdb3082880180697a16c1d696852ceb58 (diff) |
Message layout updates and clickable images
Diffstat (limited to 'Juick/Views')
-rw-r--r-- | Juick/Views/MessageCell.h | 2 | ||||
-rw-r--r-- | Juick/Views/MessageCell.m | 15 | ||||
-rw-r--r-- | Juick/Views/MessageCell.xib | 112 |
3 files changed, 70 insertions, 59 deletions
diff --git a/Juick/Views/MessageCell.h b/Juick/Views/MessageCell.h index d50751b..f568bdc 100644 --- a/Juick/Views/MessageCell.h +++ b/Juick/Views/MessageCell.h @@ -11,6 +11,8 @@ @protocol MessageCellDelegate -(void) avatarClicked:(NSString *)uname; +-(void) linkClicked:(NSString *)url; + @end @interface MessageCell : UITableViewCell diff --git a/Juick/Views/MessageCell.m b/Juick/Views/MessageCell.m index ceb2ac5..9b1b593 100644 --- a/Juick/Views/MessageCell.m +++ b/Juick/Views/MessageCell.m @@ -16,6 +16,7 @@ @property(nonatomic, readonly) UIFont *boldFont; @property(nonatomic, readonly) UIFont *italicFont; - (void) updateAvatarWithUrl:(NSString *)avatarUrl; +@property(nonatomic, strong) NSString *attachment; @end @implementation MessageCell @@ -72,14 +73,15 @@ const NSString *unreadMarker = @"●"; }]; } if ([msg.attach length] > 0) { - CGFloat imageHeight = [msg.attachment.small.height floatValue] / [[UIScreen mainScreen] scale]; - CGFloat imageWidth = [msg.attachment.small.width floatValue] / [[UIScreen mainScreen] scale]; + self.attachment = msg.attachment.url; + CGFloat imageHeight = [msg.attachment.medium.height floatValue] / [[UIScreen mainScreen] scale]; + CGFloat imageWidth = [msg.attachment.medium.width floatValue] / [[UIScreen mainScreen] scale]; self.attach.image = [UIImage placeholderImageWithColor:[UIColor colorNamed:@"Muted"] size:CGSizeMake(imageWidth, imageHeight)]; self.attachmentHeight.constant = imageHeight; self.attachmentWidth.constant = imageWidth; __weak UIImageView *weakAttach = self.attach; - [[AppDelegate shared].api fetchImageWithURL:[NSURL URLWithString:msg.attachment.small.url] callback:^(NSData *data) { + [[AppDelegate shared].api fetchImageWithURL:[NSURL URLWithString:msg.attachment.medium.url] callback:^(NSData *data) { [UIView transitionWithView:weakAttach duration:0.3 options:UIViewAnimationOptionTransitionCrossDissolve @@ -88,6 +90,10 @@ const NSString *unreadMarker = @"●"; } completion:nil]; }]; + UITapGestureRecognizer *attachmentTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(linkClicked:)]; + [attachmentTapGestureRecognizer setEnabled:YES]; + [self.attach addGestureRecognizer:attachmentTapGestureRecognizer]; + [self.attach setUserInteractionEnabled:YES]; } else { self.attachmentHeight.constant = 0; self.attach.image = nil; @@ -174,5 +180,8 @@ const NSString *unreadMarker = @"●"; -(void) avatarClicked:(UIGestureRecognizer *)gestureRecognizer { [self.delegate avatarClicked:self.title.text]; } +-(void) linkClicked:(UIGestureRecognizer *)gestureRecognizer { + [self.delegate linkClicked:self.attachment]; +} @end diff --git a/Juick/Views/MessageCell.xib b/Juick/Views/MessageCell.xib index 53a2408..5d35561 100644 --- a/Juick/Views/MessageCell.xib +++ b/Juick/Views/MessageCell.xib @@ -18,68 +18,71 @@ <rect key="frame" x="0.0" y="0.0" width="572" height="604"/> <autoresizingMask key="autoresizingMask"/> <subviews> - <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="Azj-pa-GEC"> - <rect key="frame" x="20" y="20" width="532" height="564"/> + <stackView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="252" verticalCompressionResistancePriority="751" distribution="fillProportionally" alignment="center" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="7FT-kJ-84d" userLabel="Item header"> + <rect key="frame" x="20" y="20" width="532" height="76"/> <subviews> - <stackView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="252" verticalCompressionResistancePriority="751" distribution="fillProportionally" alignment="center" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="7FT-kJ-84d"> - <rect key="frame" x="0.0" y="0.0" width="532" height="76"/> - <subviews> - <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="751" verticalCompressionResistancePriority="751" translatesAutoresizingMaskIntoConstraints="NO" id="CZk-Q8-JqS"> - <rect key="frame" x="0.0" y="14" width="48" height="48"/> - <constraints> - <constraint firstAttribute="height" priority="999" constant="48" id="ZnT-UD-xga"/> - <constraint firstAttribute="width" constant="48" id="khZ-DB-qfq"/> - </constraints> - </imageView> - <stackView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="252" axis="vertical" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="o3h-ci-LWF"> - <rect key="frame" x="56" y="16" width="476" height="44.5"/> - <subviews> - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="CHd-h0-hPk"> - <rect key="frame" x="0.0" y="0.0" width="476" height="20.5"/> - <fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/> - <nil key="textColor"/> - <nil key="highlightedColor"/> - </label> - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" verticalCompressionResistancePriority="751" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AVu-qV-q84"> - <rect key="frame" x="0.0" y="28.5" width="476" height="16"/> - <fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/> - <nil key="textColor"/> - <nil key="highlightedColor"/> - </label> - </subviews> - </stackView> - </subviews> - </stackView> - <textView clipsSubviews="YES" multipleTouchEnabled="YES" userInteractionEnabled="NO" contentMode="scaleToFill" verticalHuggingPriority="1000" verticalCompressionResistancePriority="749" scrollEnabled="NO" editable="NO" textAlignment="natural" adjustsFontForContentSizeCategory="YES" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nZn-a4-oSt"> - <rect key="frame" x="0.0" y="84" width="532" height="192"/> - <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> - <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> - <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/> - <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/> - </textView> - <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Uha-ow-kFJ"> - <rect key="frame" x="0.0" y="284" width="532" height="256"/> + <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="751" verticalCompressionResistancePriority="751" translatesAutoresizingMaskIntoConstraints="NO" id="CZk-Q8-JqS"> + <rect key="frame" x="0.0" y="14" width="48" height="48"/> <constraints> - <constraint firstAttribute="height" priority="999" constant="256" identifier="attachHeight" id="Cuq-dQ-VYU"/> - <constraint firstAttribute="width" priority="999" constant="256" identifier="attachWidth" id="oJg-1R-jp3"/> + <constraint firstAttribute="height" priority="999" constant="48" id="ZnT-UD-xga"/> + <constraint firstAttribute="width" constant="48" id="khZ-DB-qfq"/> </constraints> </imageView> - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aJE-mZ-MCS"> - <rect key="frame" x="0.0" y="548" width="532" height="16"/> - <fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/> - <nil key="textColor"/> - <nil key="highlightedColor"/> - </label> + <stackView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="252" axis="vertical" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="o3h-ci-LWF"> + <rect key="frame" x="56" y="16" width="476" height="44.5"/> + <subviews> + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="CHd-h0-hPk"> + <rect key="frame" x="0.0" y="0.0" width="476" height="20.5"/> + <fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/> + <nil key="textColor"/> + <nil key="highlightedColor"/> + </label> + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" verticalCompressionResistancePriority="751" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AVu-qV-q84"> + <rect key="frame" x="0.0" y="28.5" width="476" height="16"/> + <fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/> + <nil key="textColor"/> + <nil key="highlightedColor"/> + </label> + </subviews> + </stackView> </subviews> - <color key="backgroundColor" name="TextBackground"/> </stackView> + <textView clipsSubviews="YES" multipleTouchEnabled="YES" userInteractionEnabled="NO" contentMode="scaleToFill" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" scrollEnabled="NO" editable="NO" textAlignment="natural" adjustsFontForContentSizeCategory="YES" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nZn-a4-oSt"> + <rect key="frame" x="20" y="104" width="532" height="192"/> + <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> + <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> + <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/> + <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/> + </textView> + <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Uha-ow-kFJ"> + <rect key="frame" x="0.0" y="304" width="572" height="256"/> + <constraints> + <constraint firstAttribute="height" priority="999" constant="256" identifier="attachHeight" id="Cuq-dQ-VYU"/> + <constraint firstAttribute="width" priority="999" constant="256" identifier="attachWidth" id="oJg-1R-jp3"/> + </constraints> + </imageView> + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aJE-mZ-MCS"> + <rect key="frame" x="20" y="568" width="532" height="16"/> + <fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/> + <nil key="textColor"/> + <nil key="highlightedColor"/> + </label> </subviews> <color key="backgroundColor" name="Background"/> <constraints> - <constraint firstAttribute="bottom" secondItem="Azj-pa-GEC" secondAttribute="bottom" constant="20" symbolic="YES" id="OWY-DI-0dv"/> - <constraint firstItem="Azj-pa-GEC" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="20" symbolic="YES" id="Ohz-6B-bYr"/> - <constraint firstItem="Azj-pa-GEC" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="20" symbolic="YES" id="biD-O8-Mwb"/> - <constraint firstAttribute="trailing" secondItem="Azj-pa-GEC" secondAttribute="trailing" constant="20" symbolic="YES" id="ymN-qs-0pB"/> + <constraint firstItem="nZn-a4-oSt" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="20" symbolic="YES" id="0zm-OK-XwQ"/> + <constraint firstItem="nZn-a4-oSt" firstAttribute="top" secondItem="7FT-kJ-84d" secondAttribute="bottom" constant="8" symbolic="YES" id="4aL-eh-Hr1"/> + <constraint firstAttribute="trailing" secondItem="Uha-ow-kFJ" secondAttribute="trailing" id="53k-cb-1Id"/> + <constraint firstItem="aJE-mZ-MCS" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="20" symbolic="YES" id="7ly-7o-0Hz"/> + <constraint firstAttribute="trailing" secondItem="7FT-kJ-84d" secondAttribute="trailing" constant="20" symbolic="YES" id="ISb-j0-2qS"/> + <constraint firstAttribute="bottom" secondItem="aJE-mZ-MCS" secondAttribute="bottom" constant="20" symbolic="YES" id="SVc-7q-7cq"/> + <constraint firstItem="7FT-kJ-84d" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="20" symbolic="YES" id="U1q-JA-Kje"/> + <constraint firstItem="7FT-kJ-84d" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="20" symbolic="YES" id="aQq-kz-fa6"/> + <constraint firstAttribute="trailing" secondItem="nZn-a4-oSt" secondAttribute="trailing" constant="20" symbolic="YES" id="mA7-MH-CBn"/> + <constraint firstItem="aJE-mZ-MCS" firstAttribute="top" secondItem="Uha-ow-kFJ" secondAttribute="bottom" constant="8" symbolic="YES" id="ukt-qs-QTa"/> + <constraint firstItem="Uha-ow-kFJ" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="y52-pJ-8lj"/> + <constraint firstItem="Uha-ow-kFJ" firstAttribute="top" secondItem="nZn-a4-oSt" secondAttribute="bottom" constant="8" symbolic="YES" id="y6Y-nI-bRW"/> + <constraint firstAttribute="trailing" secondItem="aJE-mZ-MCS" secondAttribute="trailing" constant="20" symbolic="YES" id="zly-DV-unc"/> </constraints> </tableViewCellContentView> <connections> @@ -99,8 +102,5 @@ <namedColor name="Background"> <color red="0.99215686274509807" green="0.99215686274509807" blue="0.99607843137254903" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> </namedColor> - <namedColor name="TextBackground"> - <color red="1" green="1" blue="1" alpha="0.75" colorSpace="custom" customColorSpace="sRGB"/> - </namedColor> </resources> </document> |