Further sizing improvements on iPad. Only show add feed / folder pickers when there is more than 1 item to display.
This commit is contained in:
parent
2f82f05721
commit
34c6341b4c
@ -14,7 +14,7 @@
|
||||
<scene sceneID="2Tc-JN-edX">
|
||||
<objects>
|
||||
<tableViewController storyboardIdentifier="AddFeedViewController" id="7aE-6a-iP7" customClass="AddFeedViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="1" sectionFooterHeight="5" id="D0S-TM-mtm">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" scrollEnabled="NO" dataMode="static" style="grouped" separatorStyle="default" allowsSelection="NO" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="1" sectionFooterHeight="5" id="D0S-TM-mtm">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||
@ -100,15 +100,15 @@
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" rowHeight="200" id="PiN-2i-6Dj">
|
||||
<rect key="frame" x="0.0" y="173" width="375" height="200"/>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" rowHeight="140" id="PiN-2i-6Dj">
|
||||
<rect key="frame" x="0.0" y="173" width="375" height="140"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="PiN-2i-6Dj" id="sZ4-hj-gua">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="199.66666666666666"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="139.66666666666666"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<pickerView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="v2n-nX-8jq">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="199.66666666666666"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="139.66666666666666"/>
|
||||
</pickerView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
@ -242,7 +242,7 @@
|
||||
<scene sceneID="m7L-uI-ghq">
|
||||
<objects>
|
||||
<tableViewController storyboardIdentifier="AddFolderViewController" id="3dI-34-ljo" customClass="AddFolderViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="1" sectionFooterHeight="5" id="7xa-gZ-zHA">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" scrollEnabled="NO" dataMode="static" style="grouped" separatorStyle="default" allowsSelection="NO" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="1" sectionFooterHeight="5" id="7xa-gZ-zHA">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||
@ -305,15 +305,15 @@
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" rowHeight="200" id="zRi-p6-4KU">
|
||||
<rect key="frame" x="0.0" y="129" width="375" height="200"/>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" rowHeight="140" id="zRi-p6-4KU">
|
||||
<rect key="frame" x="0.0" y="129" width="375" height="140"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="zRi-p6-4KU" id="wek-Qh-OXr">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="199.66666666666666"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="139.66666666666666"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<pickerView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="eGY-V8-gzJ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="199.66666666666666"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="139.66666666666666"/>
|
||||
</pickerView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
|
@ -14,12 +14,15 @@ import RSParser
|
||||
|
||||
class AddFeedViewController: UITableViewController, AddContainerViewControllerChild {
|
||||
|
||||
@IBOutlet weak var urlTextField: UITextField!
|
||||
@IBOutlet weak var nameTextField: UITextField!
|
||||
@IBOutlet weak var folderPickerView: UIPickerView!
|
||||
@IBOutlet weak var folderLabel: UILabel!
|
||||
@IBOutlet private weak var urlTextField: UITextField!
|
||||
@IBOutlet private weak var nameTextField: UITextField!
|
||||
@IBOutlet private weak var folderPickerView: UIPickerView!
|
||||
@IBOutlet private weak var folderLabel: UILabel!
|
||||
|
||||
private var pickerData: AddFeedFolderPickerData!
|
||||
private lazy var pickerData: AddFeedFolderPickerData = AddFeedFolderPickerData()
|
||||
private var shouldDisplayPicker: Bool {
|
||||
return pickerData.containerNames.count > 1
|
||||
}
|
||||
|
||||
private var userCancelled = false
|
||||
|
||||
@ -42,13 +45,16 @@ class AddFeedViewController: UITableViewController, AddContainerViewControllerCh
|
||||
|
||||
nameTextField.text = initialFeedName
|
||||
nameTextField.delegate = self
|
||||
folderLabel.text = pickerData.containerNames.first
|
||||
|
||||
if shouldDisplayPicker {
|
||||
folderPickerView.dataSource = self
|
||||
folderPickerView.delegate = self
|
||||
folderPickerView.showsSelectionIndicator = true
|
||||
} else {
|
||||
folderPickerView.isHidden = true
|
||||
}
|
||||
|
||||
pickerData = AddFeedFolderPickerData()
|
||||
folderPickerView.dataSource = self
|
||||
folderPickerView.delegate = self
|
||||
folderPickerView.showsSelectionIndicator = true
|
||||
folderLabel.text = pickerData.containerNames[0]
|
||||
|
||||
// I couldn't figure out the gap at the top of the UITableView, so I took a hammer to it.
|
||||
tableView.contentInset = UIEdgeInsets(top: -28, left: 0, bottom: 0, right: 0)
|
||||
|
||||
@ -119,6 +125,15 @@ class AddFeedViewController: UITableViewController, AddContainerViewControllerCh
|
||||
delegate?.readyToAdd(state: urlTextField.text?.rs_stringMayBeURL() ?? false)
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
if section == 1 {
|
||||
return shouldDisplayPicker ? 2 : 1
|
||||
}
|
||||
|
||||
return super.tableView(tableView, numberOfRowsInSection: section)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
extension AddFeedViewController: UIPickerViewDataSource, UIPickerViewDelegate {
|
||||
|
@ -12,9 +12,13 @@ import RSCore
|
||||
|
||||
class AddFolderViewController: UITableViewController, AddContainerViewControllerChild {
|
||||
|
||||
@IBOutlet weak var nameTextField: UITextField!
|
||||
@IBOutlet weak var accountLabel: UILabel!
|
||||
@IBOutlet weak var accountPickerView: UIPickerView!
|
||||
@IBOutlet private weak var nameTextField: UITextField!
|
||||
@IBOutlet private weak var accountLabel: UILabel!
|
||||
@IBOutlet private weak var accountPickerView: UIPickerView!
|
||||
|
||||
private var shouldDisplayPicker: Bool {
|
||||
return accounts.count > 1
|
||||
}
|
||||
|
||||
private var accounts: [Account]!
|
||||
|
||||
@ -25,10 +29,16 @@ class AddFolderViewController: UITableViewController, AddContainerViewController
|
||||
super.viewDidLoad()
|
||||
|
||||
accounts = AccountManager.shared.sortedActiveAccounts
|
||||
|
||||
nameTextField.delegate = self
|
||||
accountLabel.text = (accounts[0] as DisplayNameProvider).nameForDisplay
|
||||
|
||||
accountPickerView.dataSource = self
|
||||
accountPickerView.delegate = self
|
||||
if shouldDisplayPicker {
|
||||
accountPickerView.dataSource = self
|
||||
accountPickerView.delegate = self
|
||||
} else {
|
||||
accountPickerView.isHidden = true
|
||||
}
|
||||
|
||||
// I couldn't figure out the gap at the top of the UITableView, so I took a hammer to it.
|
||||
tableView.contentInset = UIEdgeInsets(top: -28, left: 0, bottom: 0, right: 0)
|
||||
@ -53,6 +63,13 @@ class AddFolderViewController: UITableViewController, AddContainerViewController
|
||||
delegate?.readyToAdd(state: !(nameTextField.text?.isEmpty ?? false))
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
if section == 1 && !shouldDisplayPicker {
|
||||
return 1
|
||||
}
|
||||
|
||||
return super.tableView(tableView, numberOfRowsInSection: section)
|
||||
}
|
||||
}
|
||||
|
||||
extension AddFolderViewController: UIPickerViewDataSource, UIPickerViewDelegate {
|
||||
@ -74,3 +91,12 @@ extension AddFolderViewController: UIPickerViewDataSource, UIPickerViewDelegate
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension AddFolderViewController: UITextFieldDelegate {
|
||||
|
||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
textField.resignFirstResponder()
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user