Browse Source

Fix compose accessory view and add some visibility support

master
Dwayne Harris 6 years ago
parent
commit
f1dd615f1c
  1. 12
      elpha-ios/Assets.xcassets/Icons/Direct.imageset/Contents.json
  2. BIN
      elpha-ios/Assets.xcassets/Icons/Direct.imageset/send.pdf
  3. 12
      elpha-ios/Assets.xcassets/Icons/Private.imageset/Contents.json
  4. BIN
      elpha-ios/Assets.xcassets/Icons/Private.imageset/eye-off.pdf
  5. 24
      elpha-ios/Base.lproj/Main.storyboard
  6. 19
      elpha-ios/ComposeAccessoryView.swift
  7. 62
      elpha-ios/ComposeAccessoryView.xib
  8. 13
      elpha-ios/ComposeViewController.swift
  9. 10
      elpha-ios/FLAnimatedImageView+SetImage.swift
  10. 24
      elpha-ios/StatusView.swift
  11. 6
      elpha-ios/TimelineTableViewController.swift

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

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

BIN
elpha-ios/Assets.xcassets/Icons/Direct.imageset/send.pdf

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

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

BIN
elpha-ios/Assets.xcassets/Icons/Private.imageset/eye-off.pdf

24
elpha-ios/Base.lproj/Main.storyboard

@ -1075,35 +1075,35 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="160"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Replying To" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="co5-cA-nTI">
<rect key="frame" x="20" y="8" width="335" height="30"/>
<rect key="frame" x="20" y="8" width="335" height="25"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="YlZ-hK-ikz"/>
<constraint firstAttribute="height" constant="25" id="YlZ-hK-ikz"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="16"/>
<color key="textColor" name="Primary"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="DBM-gJ-bmW" customClass="FLAnimatedImageView">
<rect key="frame" x="20" y="48" width="40" height="40"/>
<rect key="frame" x="20" y="43" width="40" height="40"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="Odb-PW-C0m"/>
<constraint firstAttribute="width" constant="40" id="eJR-OK-tSg"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Display Name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="htY-mN-l6s">
<rect key="frame" x="68" y="48" width="287" height="18"/>
<rect key="frame" x="68" y="43" width="287" height="18"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<color key="textColor" name="Text"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Username" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="P5v-hq-2Ee">
<rect key="frame" x="68" y="68" width="287" height="15.666666666666671"/>
<rect key="frame" x="68" y="62.999999999999993" width="287" height="15.666666666666664"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" name="Primary"/>
<nil key="highlightedColor"/>
</label>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" text="Content" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="wi5-07-ou8" customClass="UITextViewFixed" customModule="elpha_ios" customModuleProvider="target">
<rect key="frame" x="20" y="98" width="335" height="54"/>
<rect key="frame" x="20" y="93" width="335" height="59"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" name="Primary"/>
<color key="textColor" name="Text"/>
@ -1136,7 +1136,7 @@
<rect key="frame" x="0.0" y="160" width="375" height="548"/>
<subviews>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Content Warning" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="D8y-nm-aIL">
<rect key="frame" x="20" y="439.33333333333337" width="335" height="35"/>
<rect key="frame" x="20" y="469.33333333333337" width="335" height="35"/>
<constraints>
<constraint firstAttribute="height" constant="35" id="Pja-qP-5Hb"/>
</constraints>
@ -1145,19 +1145,19 @@
<textInputTraits key="textInputTraits"/>
</textField>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="500" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lj5-34-gkN">
<rect key="frame" x="20" y="402.33333333333337" width="335" height="17"/>
<rect key="frame" x="20" y="432.33333333333337" width="335" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" name="Primary"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Description of content warnings." lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="L6c-Q0-xOK">
<rect key="frame" x="20" y="482.33333333333337" width="335" height="15.666666666666686"/>
<rect key="frame" x="20" y="512.33333333333337" width="335" height="15.666666666666629"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" cocoaTouchSystemColor="scrollViewTexturedBackgroundColor"/>
<nil key="highlightedColor"/>
</label>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="9BJ-55-1nh">
<rect key="frame" x="20" y="8" width="335" height="386.33333333333331"/>
<rect key="frame" x="20" y="8" width="335" height="416.33333333333331"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" name="Primary"/>
<color key="textColor" name="Text"/>
@ -1174,7 +1174,7 @@
<constraint firstAttribute="trailing" secondItem="D8y-nm-aIL" secondAttribute="trailing" constant="20" id="Ghs-6F-hzK"/>
<constraint firstItem="L6c-Q0-xOK" firstAttribute="top" secondItem="D8y-nm-aIL" secondAttribute="bottom" constant="8" id="IIM-Kg-fbe"/>
<constraint firstItem="D8y-nm-aIL" firstAttribute="leading" secondItem="LeJ-qN-f3j" secondAttribute="leading" constant="20" id="Tdy-Mo-HPS"/>
<constraint firstAttribute="bottom" secondItem="L6c-Q0-xOK" secondAttribute="bottom" constant="50" id="XkQ-Ab-eUM"/>
<constraint firstAttribute="bottom" secondItem="L6c-Q0-xOK" secondAttribute="bottom" constant="20" id="XkQ-Ab-eUM"/>
<constraint firstItem="D8y-nm-aIL" firstAttribute="top" secondItem="lj5-34-gkN" secondAttribute="bottom" constant="20" id="ZTP-bY-fRh"/>
<constraint firstItem="lj5-34-gkN" firstAttribute="leading" secondItem="LeJ-qN-f3j" secondAttribute="leading" constant="20" id="bAc-FO-r0d"/>
<constraint firstAttribute="trailing" secondItem="9BJ-55-1nh" secondAttribute="trailing" constant="20" id="fuN-h0-TiZ"/>
@ -1218,7 +1218,7 @@
<constraint firstItem="TaE-kM-jSH" firstAttribute="top" secondItem="7bB-Lp-9yL" secondAttribute="bottom" constant="8" id="v75-Uk-r4i"/>
</constraints>
</view>
<blurEffect style="extraLight"/>
<blurEffect style="light"/>
</visualEffectView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>

19
elpha-ios/ComposeAccessoryView.swift

@ -22,6 +22,12 @@ class ComposeAccessoryView: UIView {
var delegate: ComposeAccessoryViewDelegate? = nil
var selectedVisibility: StatusVisibility = .public {
didSet {
visibilityButton.setTitle(" \(selectedVisibility.rawValue.capitalized)", for: .normal)
}
}
override init(frame: CGRect) {
super.init(frame: frame)
setup()
@ -36,19 +42,22 @@ class ComposeAccessoryView: UIView {
Bundle.main.loadNibNamed("ComposeAccessoryView", owner: self, options: nil)
addSubview(contentView)
contentView.frame = self.bounds
contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
attachmentButton.addTarget(self, action: #selector(attachmentTapped), for: .touchUpInside)
visibilityButton.addTarget(self, action: #selector(visibilityTapped), for: .touchUpInside)
tootButton.addTarget(self, action: #selector(tootTapped), for: .touchUpInside)
}
@IBAction func attachmentTapped(_ sender: Any) {
print("Attachment tapped 1")
@objc func attachmentTapped() {
delegate?.attachmentTapped()
}
@IBAction func visibilityTapped(_ sender: Any) {
print("Visibility tapped 1")
@objc func visibilityTapped() {
delegate?.visibilityTapped()
}
@IBAction func tootTapped(_ sender: Any) {
@objc func tootTapped() {
delegate?.tootTapped()
}
}

62
elpha-ios/ComposeAccessoryView.xib

@ -13,10 +13,10 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ComposeAccessoryView" customModule="elpha_ios" customModuleProvider="target">
<connections>
<outlet property="attachmentButton" destination="p9E-dV-blq" id="PGC-qB-cmp"/>
<outlet property="attachmentButton" destination="9e6-LL-Q5S" id="1Ap-3d-xiD"/>
<outlet property="contentView" destination="iN0-l3-epB" id="RRP-dz-Q9f"/>
<outlet property="tootButton" destination="f6o-l1-yXR" id="9rx-wt-RGB"/>
<outlet property="visibilityButton" destination="ZLh-n0-Jkb" id="rhj-Rh-j8C"/>
<outlet property="tootButton" destination="6ye-Mc-D0N" id="XrS-ws-QDP"/>
<outlet property="visibilityButton" destination="ZKF-NE-Feb" id="Tmp-j2-vhf"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
@ -24,54 +24,35 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="55"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="p9E-dV-blq">
<rect key="frame" x="20" y="17" width="22" height="23"/>
<constraints>
<constraint firstAttribute="width" constant="22" id="FYE-si-fNa"/>
<constraint firstAttribute="height" constant="23" id="XFq-lD-Puo"/>
</constraints>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="9e6-LL-Q5S">
<rect key="frame" x="20" y="16" width="22" height="23"/>
<state key="normal" image="Attachment">
<color key="titleColor" name="Primary"/>
</state>
<connections>
<action selector="attachmentTapped:" destination="-1" eventType="touchUpInside" id="qNg-9t-ZlU"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="f6o-l1-yXR">
<rect key="frame" x="284" y="17" width="71" height="23"/>
<constraints>
<constraint firstAttribute="height" constant="23" id="TKB-N5-qlj"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
<state key="normal" title=" Toot!" image="Compose">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ZKF-NE-Feb">
<rect key="frame" x="52" y="18.5" width="82" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<state key="normal" title=" Visibility" image="Visibility">
<color key="titleColor" name="Primary"/>
</state>
<connections>
<action selector="tootTapped:" destination="-1" eventType="touchUpInside" id="Pke-RH-QSD"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ZLh-n0-Jkb">
<rect key="frame" x="57" y="18" width="79" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="22" id="gTK-Rc-C4r"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<state key="normal" title=" Visibility" image="Visibility">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6ye-Mc-D0N">
<rect key="frame" x="284" y="16" width="71" height="23"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
<state key="normal" title=" Toot!" image="Compose">
<color key="titleColor" name="Primary"/>
</state>
<connections>
<action selector="visibilityTapped:" destination="-1" eventType="touchUpInside" id="f3p-KD-4Z7"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" name="Secondary"/>
<constraints>
<constraint firstItem="ZLh-n0-Jkb" firstAttribute="leading" secondItem="p9E-dV-blq" secondAttribute="trailing" constant="15" id="5pc-4Y-ZhS"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="p9E-dV-blq" secondAttribute="bottom" constant="15" id="HUF-cO-ElL"/>
<constraint firstAttribute="bottom" secondItem="ZLh-n0-Jkb" secondAttribute="bottom" constant="15" id="UkW-u6-WMg"/>
<constraint firstItem="p9E-dV-blq" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="20" id="jVv-Cj-aR0"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="f6o-l1-yXR" secondAttribute="bottom" constant="15" id="pJj-50-4rA"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="f6o-l1-yXR" secondAttribute="trailing" constant="20" id="rjA-c3-AEe"/>
<constraint firstItem="9e6-LL-Q5S" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="20" id="1C4-Zu-jaB"/>
<constraint firstItem="ZKF-NE-Feb" firstAttribute="leading" secondItem="9e6-LL-Q5S" secondAttribute="trailing" constant="10" id="7qu-Ze-wUG"/>
<constraint firstItem="6ye-Mc-D0N" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="B48-lC-JWt"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="6ye-Mc-D0N" secondAttribute="trailing" constant="20" id="SkH-tt-60l"/>
<constraint firstItem="9e6-LL-Q5S" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="Ssm-Gb-M63"/>
<constraint firstItem="ZKF-NE-Feb" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="h9A-7c-eed"/>
</constraints>
<nil key="simulatedTopBarMetrics"/>
<nil key="simulatedBottomBarMetrics"/>
@ -87,5 +68,8 @@
<namedColor name="Primary">
<color red="0.32549019607843138" green="0.20392156862745098" blue="0.55686274509803924" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="Secondary">
<color red="0.792156862745098" green="0.68627450980392157" blue="0.99215686274509807" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
</resources>
</document>

13
elpha-ios/ComposeViewController.swift

@ -21,6 +21,7 @@ class ComposeViewController: UIViewController {
@IBOutlet var bottomConstraint: NSLayoutConstraint!
let characterLimit = 500
let composeAccessoryViewHeight: CGFloat = 55.0
var feedbackGenerator: UINotificationFeedbackGenerator? = nil
var replyToStatus: StatusMO? = nil
var composeAccessoryView: ComposeAccessoryView? = nil
@ -36,8 +37,9 @@ class ComposeViewController: UIViewController {
statusTextView.layer.cornerRadius = 10
statusTextView.layer.masksToBounds = true
composeAccessoryView = ComposeAccessoryView()
composeAccessoryView = ComposeAccessoryView(frame: CGRect(x: 0.0, y: 0.0, width: self.view.bounds.size.width, height: composeAccessoryViewHeight))
composeAccessoryView!.delegate = self
composeAccessoryView!.selectedVisibility = .public
statusTextView.delegate = self
statusTextView.inputAccessoryView = composeAccessoryView
@ -82,17 +84,14 @@ class ComposeViewController: UIViewController {
let endFrameY = endFrame?.origin.y ?? 0
if endFrameY >= UIScreen.main.bounds.size.height {
bottomConstraint.constant = 50.0
bottomConstraint.constant = 0
} else {
bottomConstraint.constant = (endFrame?.size.height ?? 0.0) + 15
bottomConstraint.constant = (endFrame?.size.height ?? 0.0) - 15
}
}
}
@IBAction func dismissTapped(_ sender: Any) {
statusTextView.inputAccessoryView = nil
statusTextView.reloadInputViews()
dismiss(animated: true)
}
}
@ -106,7 +105,7 @@ extension ComposeViewController: UITextViewDelegate {
extension ComposeViewController: ComposeAccessoryViewDelegate {
func attachmentTapped() {
print("Attachment tapped")
AlertManager.shared.show(message: "Attachment support coming soon", category: .normal)
}
func visibilityTapped() {

10
elpha-ios/FLAnimatedImageView+SetImage.swift

@ -52,8 +52,8 @@ extension FLAnimatedImageView {
func setImage(withURL url: URL, withShadow shadow: Bool = false, withContentMode contentMode: UIView.ContentMode = .scaleAspectFill) {
func setShadow() {
if shadow {
self.layer.shadowColor = UIColor.black.cgColor
self.layer.shadowOpacity = 0.8
self.layer.shadowColor = UIColor(white: 0.0, alpha: 0.5).cgColor
self.layer.shadowOpacity = 1
self.layer.shadowOffset = CGSize.zero
self.layer.shadowRadius = 10
}
@ -61,13 +61,14 @@ extension FLAnimatedImageView {
if let data = ImageCache.get(url: url) {
self.contentMode = contentMode
setShadow()
if url.absoluteString.hasSuffix(".gif") {
self.animatedImage = FLAnimatedImage(animatedGIFData: data)
} else {
self.image = UIImage(data: data)
}
setShadow()
} else {
setPlaceholder()
@ -77,13 +78,14 @@ extension FLAnimatedImageView {
ImageCache.set(url: url, data: data)
self.contentMode = contentMode
setShadow()
if url.absoluteString.hasSuffix(".gif") {
self.animatedImage = FLAnimatedImage(animatedGIFData: data)
} else {
self.image = UIImage(data: data)
}
setShadow()
}
}
}

24
elpha-ios/StatusView.swift

@ -125,6 +125,13 @@ class StatusView: UIView {
@IBAction func boostTapped(_ sender: Any) {
if let status = status {
let allowedVisibility = [StatusVisibility.public, StatusVisibility.unlisted]
let visibility = StatusVisibility(rawValue: status.visibility!)
guard allowedVisibility.contains(visibility!) else {
return
}
feedbackGenerator?.prepare()
if status.reblogged {
@ -314,10 +321,19 @@ class StatusView: UIView {
boostsLabel.text = NumberFormatter.localizedString(from: NSNumber(value: status.reblogsCount), number: .decimal)
favoritesLabel.text = NumberFormatter.localizedString(from: NSNumber(value: status.favoritesCount), number: .decimal)
if status.reblogged {
boostsImageView.image = UIImage(named: "Boost Bold")
} else {
boostsImageView.image = UIImage(named: "Boost Regular")
let visibility = StatusVisibility(rawValue: status.visibility!)
switch visibility! {
case .private:
boostsImageView.image = UIImage(named: "Private")
case .direct:
boostsImageView.image = UIImage(named: "Direct")
default:
if status.reblogged {
boostsImageView.image = UIImage(named: "Boost Bold")
} else {
boostsImageView.image = UIImage(named: "Boost Regular")
}
}
if status.favorited {

6
elpha-ios/TimelineTableViewController.swift

@ -77,12 +77,6 @@ class TimelineTableViewController: AbstractStatusTableViewController {
if fetchedResultsController?.fetchedObjects?.count ?? 0 == 0 {
initializeFetchedResultsController()
}
fetchTimeline { error in
if error != nil {
AlertManager.shared.show(message: error!.localizedDescription, category: .error)
}
}
}
override func loadMoreTapped(status: StatusMO, direction: PaginationDirection) {

Loading…
Cancel
Save