Hide the account field for Popular and All reddit types
This commit is contained in:
parent
775a69a295
commit
a6b58beac7
|
@ -16,6 +16,7 @@
|
|||
<outlet property="subredditTextField" destination="cEh-Wt-f5D" id="bnp-Zp-1fe"/>
|
||||
<outlet property="typeDescriptionLabel" destination="f4Z-B8-HHm" id="jZ2-gz-Zr2"/>
|
||||
<outlet property="typePopupButton" destination="j18-w8-wsH" id="KFC-K4-0tG"/>
|
||||
<outlet property="typeToSortLayoutConstraint" destination="cWU-ae-ETO" id="wrj-j7-L7F"/>
|
||||
<outlet property="window" destination="QvC-M9-y7g" id="7rH-S2-LF4"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
|
@ -132,7 +133,7 @@ DQ
|
|||
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="f4Z-B8-HHm">
|
||||
<rect key="frame" x="85" y="118" width="203" height="14"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="5AA-um-oEb">
|
||||
<font key="font" metaFont="menu" size="11"/>
|
||||
<font key="font" metaFont="message" size="11"/>
|
||||
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
|
@ -206,15 +207,16 @@ DQ
|
|||
<constraint firstItem="6vt-DL-mVR" firstAttribute="top" secondItem="TzV-3k-fXd" secondAttribute="bottom" constant="10" id="Sjo-Bv-alZ"/>
|
||||
<constraint firstAttribute="trailing" secondItem="TzV-3k-fXd" secondAttribute="trailing" constant="20" symbolic="YES" id="V1s-JA-hA8"/>
|
||||
<constraint firstItem="6vt-DL-mVR" firstAttribute="leading" secondItem="dNV-oD-vzR" secondAttribute="trailing" constant="8" id="WNy-vn-p8M"/>
|
||||
<constraint firstItem="70f-O6-cwn" firstAttribute="top" secondItem="cEh-Wt-f5D" secondAttribute="bottom" constant="8" id="Z4e-I2-h5w"/>
|
||||
<constraint firstAttribute="trailing" secondItem="cEh-Wt-f5D" secondAttribute="trailing" constant="20" id="ZSt-ga-a8N"/>
|
||||
<constraint firstItem="dtI-Hu-rFb" firstAttribute="leading" secondItem="hXq-IS-19x" secondAttribute="trailing" constant="12" symbolic="YES" id="ahD-oU-iFu"/>
|
||||
<constraint firstItem="70f-O6-cwn" firstAttribute="top" secondItem="j18-w8-wsH" secondAttribute="bottom" constant="39" id="cWU-ae-ETO"/>
|
||||
<constraint firstItem="Acr-Ig-NVG" firstAttribute="leading" secondItem="EiT-Mj-1SZ" secondAttribute="leading" constant="20" id="dhv-D0-aPe"/>
|
||||
<constraint firstAttribute="trailing" secondItem="j18-w8-wsH" secondAttribute="trailing" constant="20" id="eQ9-hw-PXg"/>
|
||||
<constraint firstItem="j18-w8-wsH" firstAttribute="top" secondItem="EiT-Mj-1SZ" secondAttribute="top" constant="20" symbolic="YES" id="fK6-IW-NhJ"/>
|
||||
<constraint firstItem="j18-w8-wsH" firstAttribute="leading" secondItem="X1H-Vv-1CJ" secondAttribute="leading" id="gSv-gG-TLd"/>
|
||||
<constraint firstItem="6vt-DL-mVR" firstAttribute="leading" secondItem="TzV-3k-fXd" secondAttribute="leading" id="hMP-wG-fsP"/>
|
||||
<constraint firstItem="cEh-Wt-f5D" firstAttribute="top" secondItem="j18-w8-wsH" secondAttribute="bottom" constant="10" id="hxS-Z9-dWU"/>
|
||||
<constraint firstItem="dtI-Hu-rFb" firstAttribute="top" secondItem="6vt-DL-mVR" secondAttribute="bottom" constant="15" id="iRc-pH-8jE"/>
|
||||
<constraint firstItem="j18-w8-wsH" firstAttribute="firstBaseline" secondItem="ddC-6D-Tvd" secondAttribute="firstBaseline" id="iz7-4p-NWj"/>
|
||||
<constraint firstAttribute="trailing" secondItem="dtI-Hu-rFb" secondAttribute="trailing" constant="20" symbolic="YES" id="kEo-af-SUe"/>
|
||||
<constraint firstItem="j18-w8-wsH" firstAttribute="leading" secondItem="ddC-6D-Tvd" secondAttribute="trailing" constant="8" id="n9D-4Y-HXk"/>
|
||||
|
|
|
@ -21,6 +21,8 @@ class AddRedditFeedWindowController : NSWindowController, AddFeedWindowControlle
|
|||
@IBOutlet weak var accountPopupButton: NSPopUpButton!
|
||||
@IBOutlet weak var subredditTextField: NSTextField!
|
||||
|
||||
@IBOutlet weak var typeToSortLayoutConstraint: NSLayoutConstraint!
|
||||
|
||||
@IBOutlet weak var sortPopupButton: NSPopUpButton!
|
||||
|
||||
@IBOutlet var nameTextField: NSTextField!
|
||||
|
@ -143,47 +145,63 @@ private extension AddRedditFeedWindowController {
|
|||
switch typePopupButton.selectedItem?.tag ?? 0 {
|
||||
case 0:
|
||||
|
||||
accountLabel.isHidden = false
|
||||
accountPopupButton.isHidden = false
|
||||
typeDescriptionLabel.stringValue = NSLocalizedString("Your personal Reddit frontpage", comment: "Home")
|
||||
subredditTextField.isHidden = true
|
||||
addButton.isEnabled = true
|
||||
animateShowHideFields(collapsed: false) {
|
||||
self.accountLabel.isHidden = false
|
||||
self.accountPopupButton.isHidden = false
|
||||
self.typeDescriptionLabel.stringValue = NSLocalizedString("Your personal Reddit frontpage", comment: "Home")
|
||||
self.subredditTextField.isHidden = true
|
||||
self.addButton.isEnabled = true
|
||||
}
|
||||
|
||||
case 1:
|
||||
|
||||
accountLabel.isHidden = false
|
||||
accountPopupButton.isHidden = false
|
||||
accountLabel.isHidden = true
|
||||
accountPopupButton.isHidden = true
|
||||
typeDescriptionLabel.stringValue = NSLocalizedString("The best posts on Reddit for you", comment: "Popular")
|
||||
subredditTextField.isHidden = true
|
||||
addButton.isEnabled = true
|
||||
|
||||
animateShowHideFields(collapsed: true)
|
||||
|
||||
case 2:
|
||||
|
||||
accountLabel.isHidden = false
|
||||
accountPopupButton.isHidden = false
|
||||
typeDescriptionLabel.stringValue = NSLocalizedString("The most active posts", comment: "All")
|
||||
subredditTextField.isHidden = true
|
||||
addButton.isEnabled = true
|
||||
|
||||
default:
|
||||
|
||||
accountLabel.isHidden = true
|
||||
accountPopupButton.isHidden = true
|
||||
typeDescriptionLabel.stringValue = NSLocalizedString("The most active posts", comment: "All")
|
||||
subredditTextField.isHidden = true
|
||||
addButton.isEnabled = true
|
||||
animateShowHideFields(collapsed: true)
|
||||
|
||||
default:
|
||||
|
||||
if !subredditTextField.stringValue.isEmpty {
|
||||
typeDescriptionLabel.stringValue = NSLocalizedString("Posts from r/\(subredditTextField.stringValue)", comment: "Subreddit")
|
||||
} else {
|
||||
typeDescriptionLabel.stringValue = ""
|
||||
animateShowHideFields(collapsed: false) {
|
||||
self.accountLabel.isHidden = true
|
||||
self.accountPopupButton.isHidden = true
|
||||
|
||||
if !self.subredditTextField.stringValue.isEmpty {
|
||||
self.typeDescriptionLabel.stringValue = NSLocalizedString("Posts from r/\(self.subredditTextField.stringValue)", comment: "Subreddit")
|
||||
} else {
|
||||
self.typeDescriptionLabel.stringValue = ""
|
||||
}
|
||||
|
||||
self.subredditTextField.placeholderString = NSLocalizedString("Subreddit", comment: "Search Term")
|
||||
self.subredditTextField.isHidden = false
|
||||
self.addButton.isEnabled = !self.subredditTextField.stringValue.isEmpty
|
||||
}
|
||||
|
||||
subredditTextField.placeholderString = NSLocalizedString("Subreddit", comment: "Search Term")
|
||||
subredditTextField.isHidden = false
|
||||
addButton.isEnabled = !subredditTextField.stringValue.isEmpty
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
func animateShowHideFields(collapsed: Bool, completion: (() -> Void)? = nil) {
|
||||
let constant: CGFloat = collapsed ? 8 : 39
|
||||
|
||||
NSAnimationContext.beginGrouping()
|
||||
NSAnimationContext.current.duration = 0.2
|
||||
NSAnimationContext.current.completionHandler = completion
|
||||
typeToSortLayoutConstraint.animator().constant = constant
|
||||
NSAnimationContext.endGrouping()
|
||||
}
|
||||
|
||||
func cancelSheet() {
|
||||
delegate?.addFeedWindowControllerUserDidCancel(self)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue