forked from shadowfacts/Tusker
Cleanup visibility selection
This commit is contained in:
parent
ba55540712
commit
82d4fe22cf
|
@ -80,7 +80,6 @@
|
|||
D641C77B213CB017004B4513 /* FollowNotificationTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D641C77A213CB017004B4513 /* FollowNotificationTableViewCell.xib */; };
|
||||
D641C77D213CB024004B4513 /* FollowNotificationTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D641C77C213CB024004B4513 /* FollowNotificationTableViewCell.swift */; };
|
||||
D641C77F213DC78A004B4513 /* InlineTextAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = D641C77E213DC78A004B4513 /* InlineTextAttachment.swift */; };
|
||||
D641C78F213DF2AA004B4513 /* VisibilityTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D641C78E213DF2AA004B4513 /* VisibilityTableViewController.swift */; };
|
||||
D6434EB3215B1856001A919A /* XCBRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6434EB2215B1856001A919A /* XCBRequest.swift */; };
|
||||
D646C956213B365700269FB5 /* LargeImageExpandAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D646C955213B365700269FB5 /* LargeImageExpandAnimationController.swift */; };
|
||||
D646C958213B367000269FB5 /* LargeImageShrinkAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D646C957213B367000269FB5 /* LargeImageShrinkAnimationController.swift */; };
|
||||
|
@ -115,6 +114,7 @@
|
|||
D67E051521643C77000E0927 /* Tab.swift in Sources */ = {isa = PBXBuildFile; fileRef = D67E051421643C77000E0927 /* Tab.swift */; };
|
||||
D6A5FAF1217B7E05003DB2D9 /* ComposeViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D6A5FAF0217B7E05003DB2D9 /* ComposeViewController.xib */; };
|
||||
D6A5FAFB217B86CE003DB2D9 /* OnboardingViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D6A5FAFA217B86CE003DB2D9 /* OnboardingViewController.xib */; };
|
||||
D6B8DB342182A59300424AF7 /* UIAlertController+Visibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6B8DB332182A59300424AF7 /* UIAlertController+Visibility.swift */; };
|
||||
D6BED170212663DA00F02DA0 /* SwiftSoup.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D6BED16E212663DA00F02DA0 /* SwiftSoup.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
D6BED174212667E900F02DA0 /* StatusTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BED173212667E900F02DA0 /* StatusTableViewCell.swift */; };
|
||||
D6C693CA2161253F007D6A6D /* SilentActionPermissionsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693C92161253F007D6A6D /* SilentActionPermissionsTableViewController.swift */; };
|
||||
|
@ -274,7 +274,6 @@
|
|||
D641C77A213CB017004B4513 /* FollowNotificationTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FollowNotificationTableViewCell.xib; sourceTree = "<group>"; };
|
||||
D641C77C213CB024004B4513 /* FollowNotificationTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FollowNotificationTableViewCell.swift; sourceTree = "<group>"; };
|
||||
D641C77E213DC78A004B4513 /* InlineTextAttachment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InlineTextAttachment.swift; sourceTree = "<group>"; };
|
||||
D641C78E213DF2AA004B4513 /* VisibilityTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VisibilityTableViewController.swift; sourceTree = "<group>"; };
|
||||
D6434EB2215B1856001A919A /* XCBRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCBRequest.swift; sourceTree = "<group>"; };
|
||||
D646C955213B365700269FB5 /* LargeImageExpandAnimationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LargeImageExpandAnimationController.swift; sourceTree = "<group>"; };
|
||||
D646C957213B367000269FB5 /* LargeImageShrinkAnimationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LargeImageShrinkAnimationController.swift; sourceTree = "<group>"; };
|
||||
|
@ -308,6 +307,7 @@
|
|||
D67E051421643C77000E0927 /* Tab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tab.swift; sourceTree = "<group>"; };
|
||||
D6A5FAF0217B7E05003DB2D9 /* ComposeViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ComposeViewController.xib; sourceTree = "<group>"; };
|
||||
D6A5FAFA217B86CE003DB2D9 /* OnboardingViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = OnboardingViewController.xib; sourceTree = "<group>"; };
|
||||
D6B8DB332182A59300424AF7 /* UIAlertController+Visibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIAlertController+Visibility.swift"; sourceTree = "<group>"; };
|
||||
D6BED16E212663DA00F02DA0 /* SwiftSoup.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = SwiftSoup.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D6BED173212667E900F02DA0 /* StatusTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusTableViewCell.swift; sourceTree = "<group>"; };
|
||||
D6C693C92161253F007D6A6D /* SilentActionPermissionsTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SilentActionPermissionsTableViewController.swift; sourceTree = "<group>"; };
|
||||
|
@ -608,7 +608,6 @@
|
|||
D67E0512216438A7000E0927 /* AppearanceTableViewController.swift */,
|
||||
D621544721682A9D0003D87D /* TabsTableViewController.swift */,
|
||||
D627FF80217FE8F400CC0648 /* BehaviorTableViewController.swift */,
|
||||
D641C78E213DF2AA004B4513 /* VisibilityTableViewController.swift */,
|
||||
D6C693C92161253F007D6A6D /* SilentActionPermissionsTableViewController.swift */,
|
||||
);
|
||||
path = Preferences;
|
||||
|
@ -733,6 +732,7 @@
|
|||
D6C693FD2162FEEA007D6A6D /* UIViewController+Children.swift */,
|
||||
D6E0DC8D216EDF1E00369478 /* Previewing.swift */,
|
||||
D6538944214D6D7500E3CEFC /* TableViewSwipeActionProvider.swift */,
|
||||
D6B8DB332182A59300424AF7 /* UIAlertController+Visibility.swift */,
|
||||
);
|
||||
path = Utilities;
|
||||
sourceTree = "<group>";
|
||||
|
@ -1164,12 +1164,12 @@
|
|||
D663626221360B1900C9CBA2 /* Preferences.swift in Sources */,
|
||||
D6333B792139AEFD00CE884A /* Date+TimeAgo.swift in Sources */,
|
||||
D621544821682A9D0003D87D /* TabsTableViewController.swift in Sources */,
|
||||
D641C78F213DF2AA004B4513 /* VisibilityTableViewController.swift in Sources */,
|
||||
D641C77F213DC78A004B4513 /* InlineTextAttachment.swift in Sources */,
|
||||
04496BD721625361001F1B23 /* ContentLabel.swift in Sources */,
|
||||
D663626C21361C6700C9CBA2 /* Account+Preferences.swift in Sources */,
|
||||
D6C693CA2161253F007D6A6D /* SilentActionPermissionsTableViewController.swift in Sources */,
|
||||
D6333B372137838300CE884A /* AttributedString+Trim.swift in Sources */,
|
||||
D6B8DB342182A59300424AF7 /* UIAlertController+Visibility.swift in Sources */,
|
||||
D641C777213CAA9E004B4513 /* ActionNotificationTableViewCell.swift in Sources */,
|
||||
D627FF74217BBC9700CC0648 /* AppRouter.swift in Sources */,
|
||||
D6C693FE2162FEEA007D6A6D /* UIViewController+Children.swift in Sources */,
|
||||
|
|
|
@ -186,20 +186,13 @@ class ComposeViewController: UIViewController {
|
|||
// MARK: - Interaction
|
||||
|
||||
@IBAction func visibilityPressed(_ sender: Any) {
|
||||
let alertController = UIAlertController(title: "Post Visibility", message: nil, preferredStyle: .actionSheet)
|
||||
for visibility in Status.Visibility.allCases {
|
||||
let action = UIAlertAction(title: visibility.displayName, style: .default, handler: { _ in
|
||||
UIView.performWithoutAnimation {
|
||||
self.visibility = visibility
|
||||
self.visibilityButton.layoutIfNeeded()
|
||||
}
|
||||
})
|
||||
if visibility == self.visibility {
|
||||
action.setValue(true, forKey: "checked")
|
||||
let alertController = UIAlertController(currentVisibility: self.visibility) { (visibility) in
|
||||
guard let visibility = visibility else { return }
|
||||
UIView.performWithoutAnimation {
|
||||
self.visibility = visibility
|
||||
self.visibilityButton.layoutIfNeeded()
|
||||
}
|
||||
alertController.addAction(action)
|
||||
}
|
||||
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
|
||||
present(alertController, animated: true)
|
||||
}
|
||||
|
||||
|
|
|
@ -16,17 +16,31 @@ class BehaviorTableViewController: UITableViewController {
|
|||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
automaticallySaveDraftsSwitch.setOn(Preferences.shared.automaticallySaveDrafts, animated: false)
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
defaultPostVisibilityLabel.text = Preferences.shared.defaultPostVisibility.displayName
|
||||
automaticallySaveDraftsSwitch.setOn(Preferences.shared.automaticallySaveDrafts, animated: false)
|
||||
}
|
||||
|
||||
@IBAction func automaticallySaveDraftsChanged(_ sender: Any) {
|
||||
Preferences.shared.automaticallySaveDrafts = automaticallySaveDraftsSwitch.isOn
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
|
||||
if indexPath.row == 0 {
|
||||
return indexPath
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
tableView.deselectRow(at: indexPath, animated: true)
|
||||
|
||||
let alertController = UIAlertController(currentVisibility: Preferences.shared.defaultPostVisibility) { (visibility) in
|
||||
guard let visibility = visibility else { return }
|
||||
Preferences.shared.defaultPostVisibility = visibility
|
||||
self.defaultPostVisibilityLabel.text = visibility.displayName
|
||||
}
|
||||
present(alertController, animated: true)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -252,11 +252,11 @@
|
|||
<sections>
|
||||
<tableViewSection id="aBH-nA-3uG">
|
||||
<cells>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" id="d0B-9U-ZkB">
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" id="d0B-9U-ZkB">
|
||||
<rect key="frame" x="0.0" y="35" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="d0B-9U-ZkB" id="GI8-Xu-bhJ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="341" height="43.5"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Default Post Visibility" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xrH-fX-mdk">
|
||||
|
@ -266,7 +266,7 @@
|
|||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Public" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OBq-tA-USG">
|
||||
<rect key="frame" x="286" y="11.5" width="47" height="21"/>
|
||||
<rect key="frame" x="312" y="11.5" width="47" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
|
@ -279,9 +279,6 @@
|
|||
<constraint firstItem="xrH-fX-mdk" firstAttribute="leading" secondItem="GI8-Xu-bhJ" secondAttribute="leadingMargin" id="vwm-LF-b6v"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<segue destination="50Z-Q7-qIn" kind="show" id="i02-r2-FnL"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" id="T41-nS-8UI">
|
||||
<rect key="frame" x="0.0" y="79" width="375" height="44"/>
|
||||
|
@ -348,45 +345,6 @@
|
|||
</objects>
|
||||
<point key="canvasLocation" x="1" y="1280"/>
|
||||
</scene>
|
||||
<!--Default Post Visibility-->
|
||||
<scene sceneID="z9g-ND-zkU">
|
||||
<objects>
|
||||
<tableViewController id="50Z-Q7-qIn" customClass="VisibilityTableViewController" customModule="Tusker" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="jrt-1S-2QW">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||
<prototypes>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="visibilityCell" textLabel="KUX-fK-ZYf" style="IBUITableViewCellStyleDefault" id="f76-x5-8Ze">
|
||||
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="f76-x5-8Ze" id="2wP-9N-jJQ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="KUX-fK-ZYf">
|
||||
<rect key="frame" x="16" y="0.0" width="343" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<sections/>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="50Z-Q7-qIn" id="ons-RO-joK"/>
|
||||
<outlet property="delegate" destination="50Z-Q7-qIn" id="L9X-TN-yXa"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<navigationItem key="navigationItem" title="Default Post Visibility" id="vGy-Fn-uqI"/>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="JNY-yb-Efi" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="825" y="1280"/>
|
||||
</scene>
|
||||
<!--Advanced-->
|
||||
<scene sceneID="xgj-Fx-53j">
|
||||
<objects>
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
//
|
||||
// VisibilityTableViewController.swift
|
||||
// Tusker
|
||||
//
|
||||
// Created by Shadowfacts on 9/3/18.
|
||||
// Copyright © 2018 Shadowfacts. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Pachyderm
|
||||
|
||||
class VisibilityTableViewController: UITableViewController {
|
||||
|
||||
// todo: description of visibility types
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
}
|
||||
|
||||
// MARK: - Table view data source
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return Status.Visibility.allCases.count
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let visibility = Status.Visibility.allCases[indexPath.row]
|
||||
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "visibilityCell", for: indexPath)
|
||||
cell.textLabel!.text = visibility.displayName
|
||||
cell.accessoryType = visibility == Preferences.shared.defaultPostVisibility ? .checkmark : .none
|
||||
return cell
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
let oldVisibility = Preferences.shared.defaultPostVisibility
|
||||
let oldIndexPath = IndexPath(row: Status.Visibility.allCases.firstIndex(of: oldVisibility)!, section: 0)
|
||||
|
||||
let visibility = Status.Visibility.allCases[indexPath.row]
|
||||
Preferences.shared.defaultPostVisibility = visibility
|
||||
|
||||
tableView.reloadRows(at: [indexPath], with: .automatic)
|
||||
tableView.reloadRows(at: [oldIndexPath], with: .none)
|
||||
}
|
||||
|
||||
/*
|
||||
// MARK: - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
// Get the new view controller using segue.destination.
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
//
|
||||
// UIAlertController+Visibility.swift
|
||||
// Tusker
|
||||
//
|
||||
// Created by Shadowfacts on 10/25/18.
|
||||
// Copyright © 2018 Shadowfacts. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Pachyderm
|
||||
|
||||
extension UIAlertController {
|
||||
|
||||
convenience init(currentVisibility: Status.Visibility?, completion: @escaping (Status.Visibility?) -> Void) {
|
||||
self.init(title: "Post Visibility", message: nil, preferredStyle: .actionSheet)
|
||||
|
||||
for visibility in Status.Visibility.allCases {
|
||||
let action = UIAlertAction(title: visibility.displayName, style: .default) { (_) in
|
||||
completion(visibility)
|
||||
}
|
||||
if visibility == currentVisibility {
|
||||
action.setValue(true, forKey: "checked")
|
||||
}
|
||||
addAction(action)
|
||||
}
|
||||
|
||||
addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (_) in
|
||||
completion(nil)
|
||||
}))
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue