Add default post visibility preference UI

This commit is contained in:
Shadowfacts 2018-09-03 19:11:37 -04:00
parent e821004238
commit 3a40287776
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
4 changed files with 149 additions and 3 deletions

View File

@ -20,6 +20,7 @@
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 */; };
D646C956213B365700269FB5 /* LargeImageExpandAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D646C955213B365700269FB5 /* LargeImageExpandAnimationController.swift */; };
D646C958213B367000269FB5 /* LargeImageShrinkAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D646C957213B367000269FB5 /* LargeImageShrinkAnimationController.swift */; };
D646C95A213B5D0500269FB5 /* LargeImageInteractionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D646C959213B5D0500269FB5 /* LargeImageInteractionController.swift */; };
@ -114,6 +115,7 @@
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>"; };
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>"; };
D646C959213B5D0500269FB5 /* LargeImageInteractionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LargeImageInteractionController.swift; sourceTree = "<group>"; };
@ -276,8 +278,8 @@
isa = PBXGroup;
children = (
D646C954213B364600269FB5 /* Transitions */,
D6C94D862139E62700CB5196 /* LargeImageViewController.swift */,
D6C94D842139DFD800CB5196 /* LargeImage.storyboard */,
D6C94D862139E62700CB5196 /* LargeImageViewController.swift */,
);
path = "Large Image";
sourceTree = "<group>";
@ -285,8 +287,9 @@
D641C789213DD87E004B4513 /* Preferences */ = {
isa = PBXGroup;
children = (
D663626721360E2C00C9CBA2 /* PreferencesTableViewController.swift */,
D663626521360DD700C9CBA2 /* Preferences.storyboard */,
D663626721360E2C00C9CBA2 /* PreferencesTableViewController.swift */,
D641C78E213DF2AA004B4513 /* VisibilityTableViewController.swift */,
);
path = Preferences;
sourceTree = "<group>";
@ -600,6 +603,7 @@
D6C94D872139E62700CB5196 /* LargeImageViewController.swift in Sources */,
D663626221360B1900C9CBA2 /* Preferences.swift in Sources */,
D6333B792139AEFD00CE884A /* Date+TimeAgo.swift in Sources */,
D641C78F213DF2AA004B4513 /* VisibilityTableViewController.swift in Sources */,
D641C77F213DC78A004B4513 /* InlineTextAttachment.swift in Sources */,
D663626C21361C6700C9CBA2 /* Account+Preferences.swift in Sources */,
D6333B372137838300CE884A /* AttributedString+Trim.swift in Sources */,

View File

@ -105,6 +105,41 @@
</tableViewCell>
</cells>
</tableViewSection>
<tableViewSection id="1m2-cM-16u">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" id="8Y3-if-FhA">
<rect key="frame" x="0.0" y="203" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="8Y3-if-FhA" id="ZpZ-BB-0Ti">
<rect key="frame" x="0.0" y="0.0" width="341" 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="VIi-n0-FBN">
<rect key="frame" x="16" y="11.5" width="159" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<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="RXt-HZ-X6X">
<rect key="frame" x="294" 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"/>
</label>
</subviews>
<constraints>
<constraint firstItem="VIi-n0-FBN" firstAttribute="centerY" secondItem="ZpZ-BB-0Ti" secondAttribute="centerY" id="7qF-Va-DIX"/>
<constraint firstAttribute="trailing" secondItem="RXt-HZ-X6X" secondAttribute="trailing" id="8Y3-1J-Y5y"/>
<constraint firstItem="RXt-HZ-X6X" firstAttribute="centerY" secondItem="ZpZ-BB-0Ti" secondAttribute="centerY" id="8vB-O3-3p8"/>
<constraint firstItem="VIi-n0-FBN" firstAttribute="leading" secondItem="ZpZ-BB-0Ti" secondAttribute="leadingMargin" id="y3v-9l-ECZ"/>
</constraints>
</tableViewCellContentView>
<connections>
<segue destination="50Z-Q7-qIn" kind="show" id="Nns-Fe-keu"/>
</connections>
</tableViewCell>
</cells>
</tableViewSection>
</sections>
<connections>
<outlet property="dataSource" destination="ArB-e7-yko" id="Kxa-qc-mae"/>
@ -114,6 +149,7 @@
<navigationItem key="navigationItem" title="Preferences" id="dN7-yl-voz"/>
<connections>
<outlet property="circularAvatarsSwitch" destination="EGF-Yh-zaU" id="jAS-4F-WwG"/>
<outlet property="defaultPostVisibilityLabel" destination="RXt-HZ-X6X" id="KEB-sg-UNE"/>
<outlet property="hideCustomEmojiInUsernamesSwitch" destination="vWi-fm-tjV" id="8zA-bD-SE3"/>
<outlet property="showRepliesInProfilesSwitch" destination="iCG-F0-6ZK" id="p5E-oK-ZYl"/>
</connections>
@ -122,6 +158,45 @@
</objects>
<point key="canvasLocation" x="826" y="-234"/>
</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="1654" y="-234"/>
</scene>
<!--Preferences-->
<scene sceneID="3UV-H1-kd4">
<objects>
@ -138,7 +213,7 @@
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Otz-oe-r9y" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-126" y="-234"/>
<point key="canvasLocation" x="-23" y="-234"/>
</scene>
</scenes>
</document>

View File

@ -18,6 +18,7 @@ class PreferencesTableViewController: UITableViewController {
@IBOutlet weak var showRepliesInProfilesSwitch: UISwitch!
@IBOutlet weak var circularAvatarsSwitch: UISwitch!
@IBOutlet weak var hideCustomEmojiInUsernamesSwitch: UISwitch!
@IBOutlet weak var defaultPostVisibilityLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
@ -26,6 +27,12 @@ class PreferencesTableViewController: UITableViewController {
circularAvatarsSwitch.setOn(Preferences.shared.avatarStyle == .circle, animated: false)
hideCustomEmojiInUsernamesSwitch.setOn(Preferences.shared.hideCustomEmojiInUsernames, animated: false)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
defaultPostVisibilityLabel.text = Preferences.shared.defaultPostVisibility.displayName
}
/*
// MARK: - Navigation

View File

@ -0,0 +1,60 @@
//
// VisibilityTableViewController.swift
// Tusker
//
// Created by Shadowfacts on 9/3/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import UIKit
import MastodonKit
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 Visibility.allCases.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let visibility = 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: Visibility.allCases.firstIndex(of: oldVisibility)!, section: 0)
let visibility = 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.
}
*/
}