Browse Source

Add Share button and fix Load More action

master
Dwayne Harris 6 years ago
parent
commit
e691601fd9
  1. 14
      elpha-ios/AccountTableViewController.swift
  2. 12
      elpha-ios/Assets.xcassets/Icons/Share White.imageset/Contents.json
  3. BIN
      elpha-ios/Assets.xcassets/Icons/Share White.imageset/share-white.pdf
  4. BIN
      elpha-ios/Assets.xcassets/Icons/Share.imageset/share.pdf
  5. 61
      elpha-ios/Base.lproj/Main.storyboard
  6. 28
      elpha-ios/StatusTableViewController.swift
  7. 14
      elpha-ios/TimelineTableViewController.swift

14
elpha-ios/AccountTableViewController.swift

@ -175,25 +175,23 @@ class AccountTableViewController: AbstractStatusTableViewController {
}
override func loadMoreTapped(status: StatusMO, direction: PaginationDirection) {
func removeMarker(at: Int) {
status.markers?.remove(at: at)
CoreDataManager.shared.saveContext()
}
if let markers = status.markers {
var removeAt = -1
for (index, marker) in markers.enumerated() {
if marker.context == self.currentPaginationContext && marker.item.direction == direction {
fetchStatuses(withPagination: marker.item) { error in
if error == nil {
removeAt = index
removeMarker(at: index)
} else {
AlertManager.shared.show(message: error!.localizedDescription, category: .error)
}
}
}
}
if removeAt > -1 {
status.markers?.remove(at: removeAt)
CoreDataManager.shared.saveContext()
}
}
}

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

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

BIN
elpha-ios/Assets.xcassets/Icons/Share White.imageset/share-white.pdf

BIN
elpha-ios/Assets.xcassets/Icons/Share.imageset/share.pdf

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

@ -1348,19 +1348,19 @@
<objects>
<tableViewController storyboardIdentifier="StatusTableViewController" id="RAJ-ub-len" customClass="StatusTableViewController" customModule="elpha_ios" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="3Kx-zr-iiy">
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="1000"/>
<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="none" indentationWidth="10" reuseIdentifier="MainStatusTableViewCell" rowHeight="675" id="8ys-Fm-1Yg" customClass="MainStatusTableViewCell" customModule="elpha_ios" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="375" height="675"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="MainStatusTableViewCell" rowHeight="750" id="8ys-Fm-1Yg" customClass="MainStatusTableViewCell" customModule="elpha_ios" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="375" height="750"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="8ys-Fm-1Yg" id="Hj7-kC-H7L">
<rect key="frame" x="0.0" y="0.0" width="375" height="675"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="750"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="hBh-J5-s0Y">
<rect key="frame" x="0.0" y="0.0" width="375" height="675"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="750"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="D1b-xI-QXf">
<rect key="frame" x="0.0" y="0.0" width="375" height="60"/>
@ -1422,10 +1422,10 @@
</connections>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bsb-4z-qCl">
<rect key="frame" x="0.0" y="150" width="375" height="30"/>
<rect key="frame" x="0.0" y="150" width="375" height="55"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" editable="NO" text="Content" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="Qno-L9-nUh" customClass="UITextViewFixed" customModule="elpha_ios" customModuleProvider="target">
<rect key="frame" x="8" y="8" width="359" height="14"/>
<rect key="frame" x="8" y="8" width="359" height="39"/>
<color key="backgroundColor" name="Background Primary"/>
<color key="tintColor" name="Primary"/>
<color key="textColor" name="Text"/>
@ -1444,14 +1444,14 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7SO-v5-Rfd">
<rect key="frame" x="0.0" y="180" width="375" height="375"/>
<rect key="frame" x="0.0" y="205" width="375" height="375"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" secondItem="7SO-v5-Rfd" secondAttribute="height" multiplier="1:1" id="OxV-Aa-cex"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="HzB-eP-8UY">
<rect key="frame" x="0.0" y="555" width="375" height="60"/>
<rect key="frame" x="0.0" y="580" width="375" height="60"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="C8A-x8-8TG">
<rect key="frame" x="8" y="13.666666666666629" width="160" height="33"/>
@ -1508,6 +1508,7 @@
</imageView>
</subviews>
<color key="backgroundColor" name="Background Primary"/>
<gestureRecognizers/>
<constraints>
<constraint firstAttribute="trailing" secondItem="3Ew-31-ZWY" secondAttribute="trailing" id="3Jq-Ho-6AR"/>
<constraint firstAttribute="height" constant="30" id="FpV-XH-nDq"/>
@ -1516,6 +1517,9 @@
<constraint firstItem="3Ew-31-ZWY" firstAttribute="centerY" secondItem="Iqe-xC-DYy" secondAttribute="centerY" id="MhK-X2-0ah"/>
<constraint firstAttribute="width" constant="60" id="zXz-Dr-CWl"/>
</constraints>
<connections>
<outletCollection property="gestureRecognizers" destination="dVp-l7-qxz" appends="YES" id="KSk-XK-AB1"/>
</connections>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9oD-Y0-ilp">
<rect key="frame" x="307" y="15" width="60" height="30"/>
@ -1577,7 +1581,6 @@
</constraints>
<connections>
<outletCollection property="gestureRecognizers" destination="IYd-yl-Al5" appends="YES" id="G65-E0-qae"/>
<outletCollection property="gestureRecognizers" destination="dVp-l7-qxz" appends="YES" id="37g-LW-Ne9"/>
</connections>
</view>
</subviews>
@ -1595,8 +1598,28 @@
<constraint firstItem="C8A-x8-8TG" firstAttribute="leading" secondItem="HzB-eP-8UY" secondAttribute="leading" constant="8" id="xFd-Du-UwS"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lfq-fs-5DV">
<rect key="frame" x="0.0" y="640" width="375" height="50"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mux-Se-p9C">
<rect key="frame" x="178.66666666666666" y="14" width="18" height="22"/>
<state key="normal" image="Share">
<color key="titleColor" name="Text"/>
</state>
<connections>
<action selector="shareTapped:" destination="RAJ-ub-len" eventType="touchUpInside" id="QKA-aN-NLx"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" name="Secondary"/>
<constraints>
<constraint firstItem="mux-Se-p9C" firstAttribute="centerX" secondItem="lfq-fs-5DV" secondAttribute="centerX" id="Qd2-Cj-swd"/>
<constraint firstItem="mux-Se-p9C" firstAttribute="centerY" secondItem="lfq-fs-5DV" secondAttribute="centerY" id="QxH-8e-6T2"/>
<constraint firstAttribute="height" constant="50" id="cWT-Qc-ikf"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="mSb-NY-H82">
<rect key="frame" x="0.0" y="615" width="375" height="60"/>
<rect key="frame" x="0.0" y="690" width="375" height="60"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Replies" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LcE-Gx-SAh">
<rect key="frame" x="15" y="8" width="352" height="52"/>
@ -1644,7 +1667,7 @@
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="StatusTableViewCell" rowHeight="120" id="cLF-Rc-b4K" customClass="StatusTableViewCell" customModule="elpha_ios" customModuleProvider="target">
<rect key="frame" x="0.0" y="703" width="375" height="120"/>
<rect key="frame" x="0.0" y="778" width="375" height="120"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="cLF-Rc-b4K" id="jhE-cB-Cj1">
<rect key="frame" x="0.0" y="0.0" width="375" height="120"/>
@ -1672,6 +1695,7 @@
<outlet property="delegate" destination="RAJ-ub-len" id="P31-wp-SuL"/>
</connections>
</tableView>
<size key="freeformSize" width="375" height="1000"/>
<refreshControl key="refreshControl" opaque="NO" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" id="1F2-ct-Zy0">
<rect key="frame" x="0.0" y="0.0" width="1000" height="1000"/>
<autoresizingMask key="autoresizingMask"/>
@ -1691,11 +1715,6 @@
<action selector="accountViewTapped:" destination="RAJ-ub-len" id="8BS-4Z-ZQz"/>
</connections>
</tapGestureRecognizer>
<tapGestureRecognizer id="dVp-l7-qxz">
<connections>
<action selector="boostTapped:" destination="RAJ-ub-len" id="gBv-xx-8fA"/>
</connections>
</tapGestureRecognizer>
<tapGestureRecognizer id="uBg-bz-egu">
<connections>
<action selector="favoriteTapped:" destination="RAJ-ub-len" id="JNI-Rd-xSW"/>
@ -1706,6 +1725,11 @@
<action selector="replyTapped:" destination="RAJ-ub-len" id="uWr-ZP-fyf"/>
</connections>
</tapGestureRecognizer>
<tapGestureRecognizer id="dVp-l7-qxz">
<connections>
<action selector="boostTapped:" destination="RAJ-ub-len" id="gBv-xx-8fA"/>
</connections>
</tapGestureRecognizer>
</objects>
<point key="canvasLocation" x="2701.5999999999999" y="-22.167487684729064"/>
</scene>
@ -1773,7 +1797,7 @@
<outletCollection property="gestureRecognizers" destination="9Gi-hE-TEp" appends="YES" id="Wyp-Na-DYj"/>
</connections>
</imageView>
<imageView contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Share" translatesAutoresizingMaskIntoConstraints="NO" id="vZ9-hY-vNA">
<imageView contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Share White" translatesAutoresizingMaskIntoConstraints="NO" id="vZ9-hY-vNA">
<rect key="frame" x="344" y="50" width="16" height="20"/>
<gestureRecognizers/>
<constraints>
@ -1895,6 +1919,7 @@
<image name="Logo" width="180" height="180"/>
<image name="Message" width="20" height="20"/>
<image name="Share" width="18" height="22"/>
<image name="Share White" width="18" height="22"/>
<image name="Star Regular" width="22" height="22"/>
<image name="Timelines" width="20" height="21"/>
<namedColor name="Background Primary">

28
elpha-ios/StatusTableViewController.swift

@ -27,9 +27,11 @@ class StatusTableViewController: AbstractStatusTableViewController, UIGestureRec
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
fetchStatuses { error in
if error != nil {
AlertManager.shared.show(message: error!.localizedDescription, category: .error)
if SettingsManager.automaticallyRefreshTimelines {
fetchStatuses { error in
if error != nil {
AlertManager.shared.show(message: error!.localizedDescription, category: .error)
}
}
}
}
@ -118,6 +120,13 @@ class StatusTableViewController: AbstractStatusTableViewController, UIGestureRec
self.replyTapped(status: status!)
}
@IBAction func shareTapped(_ sender: Any) {
if let status = status {
let controller = UIActivityViewController(activityItems: [status.uri!], applicationActivities: nil)
present(controller, animated: true)
}
}
func fetchStatuses(completion: @escaping (Error?) -> Void) {
if let status = status {
loading = true
@ -296,12 +305,13 @@ extension StatusTableViewController: NSFetchedResultsControllerDelegate {
case NSFetchedResultsChangeType.delete:
tableView.deleteRows(at: [indexPath!], with: UITableView.RowAnimation.none)
case NSFetchedResultsChangeType.update:
if let cell = tableView.cellForRow(at: indexPath!) as? StatusTableViewCell {
updateCell(cell, withStatusAt: indexPath!)
}
if let cell = tableView.cellForRow(at: indexPath!) as? MainStatusTableViewCell {
updateMainCell(cell, withStatus: anObject as! StatusMO)
switch tableView.cellForRow(at: indexPath!) {
case let cell as StatusTableViewCell:
updateCell(cell, withStatusAt: indexPath!)
case let cell as MainStatusTableViewCell:
updateMainCell(cell, withStatus: anObject as! StatusMO)
default:
return
}
case NSFetchedResultsChangeType.move:
tableView.deleteRows(at: [indexPath!], with: UITableView.RowAnimation.fade)

14
elpha-ios/TimelineTableViewController.swift

@ -83,25 +83,23 @@ class TimelineTableViewController: AbstractStatusTableViewController {
}
override func loadMoreTapped(status: StatusMO, direction: PaginationDirection) {
func removeMarker(at: Int) {
status.markers?.remove(at: at)
CoreDataManager.shared.saveContext()
}
if let markers = status.markers {
var removeAt = -1
for (index, marker) in markers.enumerated() {
if marker.context == self.currentPaginationContext && marker.item.direction == direction {
fetchTimeline(withPagination: marker.item) { error in
if error == nil {
removeAt = index
removeMarker(at: index)
} else {
AlertManager.shared.show(message: error!.localizedDescription, category: .error)
}
}
}
}
if removeAt > -1 {
status.markers?.remove(at: removeAt)
CoreDataManager.shared.saveContext()
}
}
}

Loading…
Cancel
Save