Restrict build button on iOS so that it only appears if Twitter is enabled

This commit is contained in:
Maurice Parker
2020-05-02 17:21:01 -05:00
parent b6a0057439
commit 41a17dfb06
4 changed files with 18 additions and 3 deletions

View File

@@ -407,7 +407,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
guard !isDisplayingSheet && !AccountManager.shared.activeAccounts.isEmpty else {
return false
}
return ExtensionPointManager.shared.activeExtensionPoints.values.contains(where: { $0 is TwitterFeedProvider })
return ExtensionPointManager.shared.isTwitterEnabled
}
#if !MAC_APP_STORE
if item.action == #selector(toggleWebInspectorEnabled(_:)) {

View File

@@ -49,6 +49,10 @@ final class ExtensionPointManager: FeedProviderManagerDelegate {
return activeExtensionPoints.values.compactMap({ return $0 as? FeedProvider })
}
var isTwitterEnabled: Bool {
return activeExtensionPoints.values.contains(where: { $0 is TwitterFeedProvider })
}
init() {
#if os(macOS)
#if DEBUG

View File

@@ -26,7 +26,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="URL" textAlignment="natural" adjustsFontForContentSizeCategory="YES" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="eRp-AP-WFq">
<rect key="frame" x="20" y="4" width="269.66666666666669" height="36"/>
<rect key="frame" x="20" y="4" width="323" height="36"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<textInputTraits key="textInputTraits" keyboardType="URL"/>
</textField>
@@ -41,7 +41,7 @@
<constraints>
<constraint firstItem="eRp-AP-WFq" firstAttribute="top" secondItem="eNS-Rp-w0A" secondAttribute="top" constant="4" id="80p-a2-3NC"/>
<constraint firstItem="f0N-Iy-ZFD" firstAttribute="centerY" secondItem="eRp-AP-WFq" secondAttribute="centerY" id="Ci9-Fe-KrJ"/>
<constraint firstItem="f0N-Iy-ZFD" firstAttribute="leading" secondItem="eRp-AP-WFq" secondAttribute="trailing" constant="8" id="ZNi-6o-A6w"/>
<constraint firstAttribute="trailing" secondItem="eRp-AP-WFq" secondAttribute="trailing" id="Xue-v3-aqR"/>
<constraint firstAttribute="trailing" secondItem="f0N-Iy-ZFD" secondAttribute="trailing" constant="20" symbolic="YES" id="aHH-ef-7dH"/>
<constraint firstItem="eRp-AP-WFq" firstAttribute="leading" secondItem="eNS-Rp-w0A" secondAttribute="leading" constant="20" symbolic="YES" id="bHJ-7l-Pl3"/>
<constraint firstAttribute="bottom" secondItem="eRp-AP-WFq" secondAttribute="bottom" constant="4" id="fs0-iw-zTo"/>
@@ -118,7 +118,9 @@
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<connections>
<outlet property="nameTextField" destination="u7n-VL-Ho9" id="YQV-Xq-f9q"/>
<outlet property="urlBuilderButton" destination="f0N-Iy-ZFD" id="HlB-Cu-Dak"/>
<outlet property="urlTextField" destination="eRp-AP-WFq" id="FG3-pH-2Fh"/>
<outlet property="urlTextFieldToSuperViewConstraint" destination="Xue-v3-aqR" id="ZcO-5b-g08"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="TO9-rb-MQ7" userLabel="First Responder" sceneMemberID="firstResponder"/>

View File

@@ -15,6 +15,8 @@ import RSParser
class AddWebFeedViewController: UITableViewController, AddContainerViewControllerChild {
@IBOutlet private weak var urlTextField: UITextField!
@IBOutlet weak var urlTextFieldToSuperViewConstraint: NSLayoutConstraint!
@IBOutlet weak var urlBuilderButton: UIButton!
@IBOutlet private weak var nameTextField: UITextField!
private var folderLabel = ""
@@ -41,6 +43,13 @@ class AddWebFeedViewController: UITableViewController, AddContainerViewControlle
urlTextField.text = initialFeed
urlTextField.delegate = self
if ExtensionPointManager.shared.isTwitterEnabled {
urlTextFieldToSuperViewConstraint.isActive = false
urlTextField.trailingAnchor.constraint(equalTo: urlBuilderButton.leadingAnchor, constant: -8).isActive = true
} else {
urlBuilderButton.isHidden = true
}
if initialFeed != nil {
delegate?.readyToAdd(state: true)
}