Browse Source

Fix spoiler text functionality

master
Dwayne Harris 6 years ago
parent
commit
ab08c5b6d3
  1. 4
      elpha-ios.xcodeproj/project.pbxproj
  2. 12
      elpha-ios/Assets.xcassets/Icons/Alert.imageset/Contents.json
  3. BIN
      elpha-ios/Assets.xcassets/Icons/Alert.imageset/alert-octagon.pdf
  4. 49
      elpha-ios/StatusView.swift
  5. 59
      elpha-ios/StatusView.xib

4
elpha-ios.xcodeproj/project.pbxproj

@ -927,6 +927,7 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = R9PMLQGTGZ;
INFOPLIST_FILE = "elpha-ios/Info.plist";
@ -937,6 +938,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "xyz.elpha.elpha-ios";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 1;
};
@ -947,6 +949,7 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = R9PMLQGTGZ;
INFOPLIST_FILE = "elpha-ios/Info.plist";
@ -957,6 +960,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "xyz.elpha.elpha-ios";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 1;
};

12
elpha-ios/Assets.xcassets/Icons/Alert.imageset/Contents.json

@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "alert-octagon.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

BIN
elpha-ios/Assets.xcassets/Icons/Alert.imageset/alert-octagon.pdf

49
elpha-ios/StatusView.swift

@ -38,9 +38,12 @@ class StatusView: UIView {
@IBOutlet var topDividerView: UIView!
@IBOutlet var bottomDividerView: UIView!
@IBOutlet var attachmentsView: UIView!
@IBOutlet var detailsView: UIView!
@IBOutlet var spoilerImageView: UIImageView!
var status: StatusMO? = nil
var delegate: StatusViewDelegate? = nil
var spoilerView: UIVisualEffectView? = nil
@IBAction func boostViewTapped(_ sender: Any) {
if let delegate = delegate, let status = status {
@ -77,6 +80,20 @@ class StatusView: UIView {
}
}
@IBAction func spoilerImageTapped(_ sender: Any) {
if let status = status {
status.hidden = true
CoreDataManager.shared.saveContext()
}
}
@objc func reveal(sender: UITapGestureRecognizer) {
if let status = status {
status.hidden = false
CoreDataManager.shared.saveContext()
}
}
override init(frame: CGRect) {
super.init(frame: frame)
@ -92,7 +109,6 @@ class StatusView: UIView {
Bundle.main.loadNibNamed("StatusView", owner: self, options: nil)
addSubview(contentView)
contentView.frame = self.bounds
// contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
}
public func update(withStatus status: StatusMO) {
@ -106,6 +122,8 @@ class StatusView: UIView {
attachmentsView.backgroundColor = UIColor.white
attachmentsView.isHidden = true
spoilerImageView.isHidden = true
let avatarFilter = AspectScaledToFillSizeWithRoundedCornersFilter(
size: CGSize(width: 40.0, height: 40.0),
radius: 20.0,
@ -135,14 +153,15 @@ class StatusView: UIView {
contentLabel.attributedText = attributedText
if status.hidden {
if status.hidden && spoilerView == nil {
let spoilerText = UILabel(frame: contentLabel.frame)
spoilerText.textColor = UIColor(named: "Text")
spoilerText.textColor = UIColor(named: "Primary")
spoilerText.font = UIFont.systemFont(ofSize: 15, weight: .bold)
spoilerText.textAlignment = .center
spoilerText.text = status.spoilerText
spoilerText.translatesAutoresizingMaskIntoConstraints = false
let blurEffectView = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffect.Style.prominent))
let blurEffectView = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffect.Style.light))
blurEffectView.translatesAutoresizingMaskIntoConstraints = false
blurEffectView.contentView.addSubview(spoilerText)
@ -152,14 +171,30 @@ class StatusView: UIView {
spoilerText.centerYAnchor.constraint(equalTo: blurEffectView.centerYAnchor),
])
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.reveal))
tapGesture.numberOfTapsRequired = 1
tapGesture.numberOfTouchesRequired = 1
blurEffectView.addGestureRecognizer(tapGesture)
blurEffectView.isUserInteractionEnabled = true
self.spoilerView = blurEffectView
self.contentView.addSubview(blurEffectView)
NSLayoutConstraint.activate([
blurEffectView.leadingAnchor.constraint(equalTo: contentLabel.trailingAnchor),
blurEffectView.trailingAnchor.constraint(equalTo: contentLabel.trailingAnchor),
blurEffectView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
blurEffectView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
blurEffectView.topAnchor.constraint(equalTo: contentLabel.topAnchor),
blurEffectView.bottomAnchor.constraint(equalTo: contentLabel.bottomAnchor),
blurEffectView.bottomAnchor.constraint(equalTo: detailsView.topAnchor),
])
} else {
if let spoilerView = spoilerView {
spoilerView.removeFromSuperview()
self.spoilerView = nil
}
if let spoilerText = status.spoilerText, !spoilerText.isEmpty {
spoilerImageView.isHidden = false
}
}
} catch {
print("\(error)")

59
elpha-ios/StatusView.xib

@ -23,6 +23,7 @@
<outlet property="bottomDividerView" destination="m4t-ve-E78" id="fEE-Uh-2qq"/>
<outlet property="contentLabel" destination="WPF-Oe-N2r" id="Gw6-2e-SDE"/>
<outlet property="contentView" destination="iN0-l3-epB" id="BBM-O7-PHb"/>
<outlet property="detailsView" destination="y5N-A7-27p" id="10T-HF-Veu"/>
<outlet property="displayNameLabel" destination="a9Z-2P-cZT" id="9w7-9G-cp3"/>
<outlet property="favoritesImageView" destination="EID-tt-v32" id="nxH-Fm-sb8"/>
<outlet property="favoritesLabel" destination="MHw-QN-ZwH" id="cNY-nH-fIO"/>
@ -32,6 +33,7 @@
<outlet property="replyDisplayNameLabel" destination="nfb-4h-YH9" id="Sqp-dR-U0N"/>
<outlet property="replyUsernameLabel" destination="odK-vM-y2x" id="HC4-1Q-aSP"/>
<outlet property="replyView" destination="v8x-tf-zFb" id="MkC-Dz-5Cw"/>
<outlet property="spoilerImageView" destination="08K-bv-mOd" id="n67-gw-nMR"/>
<outlet property="timestampLabel" destination="8et-mR-yd2" id="VW6-9b-k6T"/>
<outlet property="topDividerView" destination="bg1-Q4-Ru5" id="hCA-Qw-9OZ"/>
<outlet property="usernameLabel" destination="1xI-cX-lcs" id="IaM-0W-3dg"/>
@ -189,10 +191,10 @@
</connections>
</view>
<view contentMode="scaleToFill" verticalHuggingPriority="249" translatesAutoresizingMaskIntoConstraints="NO" id="cAR-YB-u2k">
<rect key="frame" x="0.0" y="205" width="375" height="173"/>
<rect key="frame" x="0.0" y="205" width="375" height="183"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="249" text="Content" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WPF-Oe-N2r">
<rect key="frame" x="8" y="93" width="359" height="72"/>
<rect key="frame" x="8" y="86" width="359" height="89"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" name="Text"/>
<nil key="highlightedColor"/>
@ -245,7 +247,7 @@
<constraint firstAttribute="trailing" secondItem="50m-cW-QIF" secondAttribute="trailing" constant="8" id="FxM-Hx-2Do"/>
<constraint firstItem="50m-cW-QIF" firstAttribute="top" secondItem="cAR-YB-u2k" secondAttribute="top" constant="8" id="dNY-jH-OpT"/>
<constraint firstItem="50m-cW-QIF" firstAttribute="leading" secondItem="cAR-YB-u2k" secondAttribute="leading" id="diD-1N-0MJ"/>
<constraint firstItem="WPF-Oe-N2r" firstAttribute="top" secondItem="50m-cW-QIF" secondAttribute="bottom" constant="15" id="sAS-TY-p0y"/>
<constraint firstItem="WPF-Oe-N2r" firstAttribute="top" secondItem="50m-cW-QIF" secondAttribute="bottom" constant="8" id="sAS-TY-p0y"/>
<constraint firstAttribute="trailing" secondItem="WPF-Oe-N2r" secondAttribute="trailing" constant="8" id="vxV-3b-ytI"/>
<constraint firstItem="WPF-Oe-N2r" firstAttribute="leading" secondItem="cAR-YB-u2k" secondAttribute="leading" constant="8" id="wqO-6z-tPD"/>
</constraints>
@ -254,24 +256,18 @@
</connections>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XuS-iF-YYL">
<rect key="frame" x="0.0" y="378" width="375" height="375"/>
<rect key="frame" x="0.0" y="388" width="375" height="375"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" secondItem="XuS-iF-YYL" secondAttribute="height" multiplier="1:1" priority="999" id="8CQ-GM-Un6"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="y5N-A7-27p">
<rect key="frame" x="0.0" y="753" width="375" height="60"/>
<rect key="frame" x="0.0" y="763" width="375" height="50"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="pJk-g2-yyR">
<rect key="frame" x="8" y="15" width="155" height="30"/>
<rect key="frame" x="8" y="10" width="155" height="30"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Timestamp" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8et-mR-yd2">
<rect key="frame" x="20" y="7" width="127" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" name="Primary"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Clock" translatesAutoresizingMaskIntoConstraints="NO" id="RIE-8X-Pwy">
<rect key="frame" x="0.0" y="7.5" width="15" height="15"/>
<constraints>
@ -282,16 +278,13 @@
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="8et-mR-yd2" secondAttribute="trailing" constant="8" id="Ef0-g6-O5k"/>
<constraint firstItem="8et-mR-yd2" firstAttribute="centerY" secondItem="pJk-g2-yyR" secondAttribute="centerY" id="kQC-AV-EAl"/>
<constraint firstAttribute="height" constant="30" id="lBc-f9-l5n"/>
<constraint firstItem="RIE-8X-Pwy" firstAttribute="leading" secondItem="pJk-g2-yyR" secondAttribute="leading" id="p7F-pf-Sks"/>
<constraint firstItem="RIE-8X-Pwy" firstAttribute="centerY" secondItem="pJk-g2-yyR" secondAttribute="centerY" id="s4a-hc-DRW"/>
<constraint firstItem="8et-mR-yd2" firstAttribute="leading" secondItem="RIE-8X-Pwy" secondAttribute="trailing" constant="5" id="xdH-yK-kCQ"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="P6f-0v-SWB">
<rect key="frame" x="307" y="15" width="60" height="30"/>
<rect key="frame" x="307" y="10" width="60" height="30"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="100" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MHw-QN-ZwH">
<rect key="frame" x="26" y="6.5" width="26" height="17"/>
@ -318,7 +311,7 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="cfJ-cH-ci5">
<rect key="frame" x="239" y="15" width="60" height="30"/>
<rect key="frame" x="239" y="10" width="60" height="30"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="100" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rq6-p2-tL4">
<rect key="frame" x="34" y="6.5" width="26" height="17"/>
@ -345,7 +338,7 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ZKM-hs-NVu">
<rect key="frame" x="171" y="15" width="60" height="30"/>
<rect key="frame" x="171" y="10" width="60" height="30"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="100" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Uog-Tq-elS">
<rect key="frame" x="34" y="6.5" width="26" height="17"/>
@ -371,18 +364,40 @@
<constraint firstItem="mRG-vF-1Ur" firstAttribute="centerY" secondItem="ZKM-hs-NVu" secondAttribute="centerY" id="xMG-H7-qbH"/>
</constraints>
</view>
<imageView contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Alert" translatesAutoresizingMaskIntoConstraints="NO" id="08K-bv-mOd">
<rect key="frame" x="130" y="17" width="16" height="16"/>
<gestureRecognizers/>
<constraints>
<constraint firstAttribute="width" constant="16" id="bi8-gE-iFl"/>
<constraint firstAttribute="height" constant="16" id="e2J-ux-POY"/>
</constraints>
<connections>
<outletCollection property="gestureRecognizers" destination="7Bx-xz-zOf" appends="YES" id="JjH-FW-hp1"/>
</connections>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Timestamp" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8et-mR-yd2">
<rect key="frame" x="28" y="17" width="102" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" name="Primary"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="08K-bv-mOd" firstAttribute="leading" secondItem="8et-mR-yd2" secondAttribute="trailing" id="2cy-GJ-MWR"/>
<constraint firstItem="ZKM-hs-NVu" firstAttribute="centerY" secondItem="y5N-A7-27p" secondAttribute="centerY" id="2wb-g9-MnU"/>
<constraint firstAttribute="trailing" secondItem="P6f-0v-SWB" secondAttribute="trailing" constant="8" id="7l6-9R-zXM"/>
<constraint firstAttribute="height" priority="999" constant="60" id="CSD-OT-KeH"/>
<constraint firstAttribute="height" priority="999" constant="50" id="CSD-OT-KeH"/>
<constraint firstItem="8et-mR-yd2" firstAttribute="leading" secondItem="RIE-8X-Pwy" secondAttribute="trailing" constant="5" id="N83-Wl-ZvS"/>
<constraint firstItem="P6f-0v-SWB" firstAttribute="centerY" secondItem="y5N-A7-27p" secondAttribute="centerY" id="S34-vg-5Qz"/>
<constraint firstItem="pJk-g2-yyR" firstAttribute="centerY" secondItem="y5N-A7-27p" secondAttribute="centerY" id="STf-J7-ymf"/>
<constraint firstItem="cfJ-cH-ci5" firstAttribute="centerY" secondItem="y5N-A7-27p" secondAttribute="centerY" id="ZT4-Fj-yNI"/>
<constraint firstItem="pJk-g2-yyR" firstAttribute="leading" secondItem="y5N-A7-27p" secondAttribute="leading" constant="8" id="aPb-pb-D3s"/>
<constraint firstItem="8et-mR-yd2" firstAttribute="centerY" secondItem="y5N-A7-27p" secondAttribute="centerY" id="eJg-DO-LK8"/>
<constraint firstItem="cfJ-cH-ci5" firstAttribute="leading" secondItem="ZKM-hs-NVu" secondAttribute="trailing" constant="8" id="hXF-W4-P8y"/>
<constraint firstItem="P6f-0v-SWB" firstAttribute="leading" secondItem="cfJ-cH-ci5" secondAttribute="trailing" constant="8" id="kcy-tq-hcb"/>
<constraint firstItem="08K-bv-mOd" firstAttribute="centerY" secondItem="y5N-A7-27p" secondAttribute="centerY" id="mv2-hf-g49"/>
<constraint firstItem="ZKM-hs-NVu" firstAttribute="leading" secondItem="08K-bv-mOd" secondAttribute="trailing" constant="25" id="pyF-wf-PTZ"/>
<constraint firstItem="ZKM-hs-NVu" firstAttribute="leading" secondItem="pJk-g2-yyR" secondAttribute="trailing" constant="8" id="s4k-Oq-Qhh"/>
</constraints>
</view>
@ -433,8 +448,14 @@
<action selector="mainViewTapped:" destination="-1" id="tEa-rG-C4L"/>
</connections>
</tapGestureRecognizer>
<tapGestureRecognizer id="7Bx-xz-zOf">
<connections>
<action selector="spoilerImageTapped:" destination="-1" id="3mz-UA-QEJ"/>
</connections>
</tapGestureRecognizer>
</objects>
<resources>
<image name="Alert" width="22" height="22"/>
<image name="Boost Regular" width="20" height="24"/>
<image name="Clock" width="22" height="22"/>
<image name="Message" width="20" height="20"/>

Loading…
Cancel
Save