forked from organicmaps/organicmaps
[ios] category settings screen
This commit is contained in:
parent
7206ae61b4
commit
c0f21a6619
11 changed files with 442 additions and 0 deletions
|
@ -80,6 +80,18 @@ final class BMCViewController: MWMViewController {
|
|||
MapViewController.topViewController().navigationController?.pushViewController(shareController,
|
||||
animated: true)
|
||||
}
|
||||
|
||||
private func openCategorySettings(category: BMCCategory) {
|
||||
let storyboard = UIStoryboard.instance(.categorySettings)
|
||||
let settingsController = storyboard.instantiateInitialViewController() as! CategorySettingsViewController
|
||||
settingsController.categoryId = category.identifier
|
||||
settingsController.maxCategoryNameLength = viewModel.maxCategoryNameLength
|
||||
settingsController.minCategoryNameLength = viewModel.minCategoryNameLength
|
||||
settingsController.delegate = self
|
||||
|
||||
MapViewController.topViewController().navigationController?.pushViewController(settingsController,
|
||||
animated: true)
|
||||
}
|
||||
|
||||
private func openCategory(category: BMCCategory) {
|
||||
let bmViewController = BookmarksVC(category: category.identifier)!
|
||||
|
@ -98,6 +110,10 @@ final class BMCViewController: MWMViewController {
|
|||
actionSheet.addAction(UIAlertAction(title: rename, style: .default, handler: { _ in
|
||||
self.updateCategoryName(category: category)
|
||||
}))
|
||||
let settings = L("settings").capitalized
|
||||
actionSheet.addAction(UIAlertAction(title: settings, style: .default, handler: { _ in
|
||||
self.openCategorySettings(category: category)
|
||||
}))
|
||||
let showHide = L(category.isVisible ? "hide" : "show").capitalized
|
||||
actionSheet.addAction(UIAlertAction(title: showHide, style: .default, handler: { _ in
|
||||
self.visibilityAction(category: category)
|
||||
|
@ -298,3 +314,17 @@ extension BMCViewController: BMCCategoriesHeaderDelegate {
|
|||
categoriesHeader.isShowAll = viewModel.areAllCategoriesHidden()
|
||||
}
|
||||
}
|
||||
|
||||
extension BMCViewController: CategorySettingsViewControllerDelegate {
|
||||
func categorySettingsController(_ viewController: CategorySettingsViewController,
|
||||
didEndEditing categoryId: MWMMarkGroupID) {
|
||||
navigationController?.popViewController(animated: true)
|
||||
viewModel?.reloadData()
|
||||
}
|
||||
|
||||
func categorySettingsController(_ viewController: CategorySettingsViewController,
|
||||
didDelete categoryId: MWMMarkGroupID) {
|
||||
navigationController?.popViewController(animated: true)
|
||||
viewModel?.reloadData()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,10 @@ final class BMCDefaultViewModel: NSObject {
|
|||
private func setNotifications() {
|
||||
notifications.append(.load)
|
||||
}
|
||||
|
||||
func reloadData() {
|
||||
loadData()
|
||||
}
|
||||
|
||||
private func loadData() {
|
||||
sections = []
|
||||
|
|
|
@ -52,4 +52,6 @@ protocol BMCViewModel: AnyObject {
|
|||
func requestRestoring()
|
||||
func applyRestoring()
|
||||
func cancelRestoring()
|
||||
|
||||
func reloadData()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,204 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="tgw-vx-qJ3">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Category Settings View Controller-->
|
||||
<scene sceneID="eBM-OB-XT9">
|
||||
<objects>
|
||||
<tableViewController id="tgw-vx-qJ3" customClass="CategorySettingsViewController" customModule="maps_me" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="uHY-BM-YSP">
|
||||
<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"/>
|
||||
<sections>
|
||||
<tableViewSection id="jeV-o1-epf">
|
||||
<cells>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" rowHeight="48" id="LjQ-0n-eLM">
|
||||
<rect key="frame" x="0.0" y="35" width="375" height="48"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="LjQ-0n-eLM" id="hTk-4S-Yxd">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="47.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="Bars in Saint-Petersburg" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="cbH-NH-2Hd">
|
||||
<rect key="frame" x="16" y="14" width="343" height="20"/>
|
||||
<color key="textColor" white="0.0" alpha="0.87" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular16"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackPrimaryText"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="localizedPlaceholder" value="ugc_route_edit_list_name"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="tgw-vx-qJ3" id="CUQ-LZ-Zxa"/>
|
||||
</connections>
|
||||
</textField>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="cbH-NH-2Hd" firstAttribute="centerY" secondItem="hTk-4S-Yxd" secondAttribute="centerY" id="4Aq-WF-Dgv"/>
|
||||
<constraint firstAttribute="trailing" secondItem="cbH-NH-2Hd" secondAttribute="trailing" constant="16" id="fy4-PC-J2J"/>
|
||||
<constraint firstItem="cbH-NH-2Hd" firstAttribute="leading" secondItem="hTk-4S-Yxd" secondAttribute="leading" constant="16" id="i3e-o0-1X5"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" rowHeight="48" id="D4f-KS-vQs">
|
||||
<rect key="frame" x="0.0" y="83" width="375" height="48"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="D4f-KS-vQs" id="0jc-u2-nKr">
|
||||
<rect key="frame" x="0.0" y="0.0" width="341" height="47.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Sharing options" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rM4-Nu-8WD">
|
||||
<rect key="frame" x="16" y="14" width="114" height="20"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" white="0.0" alpha="0.87" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="sharing_options"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular16"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackPrimaryText"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Not shared" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hwp-Cw-qHJ">
|
||||
<rect key="frame" x="260" y="14" width="81" height="20"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" red="0.5607843137254902" green="0.55686274509803924" blue="0.58039215686274503" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular16"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</label>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="hwp-Cw-qHJ" secondAttribute="trailing" id="9UI-T2-6P2"/>
|
||||
<constraint firstItem="rM4-Nu-8WD" firstAttribute="leading" secondItem="0jc-u2-nKr" secondAttribute="leadingMargin" id="Bn3-If-XN5"/>
|
||||
<constraint firstItem="hwp-Cw-qHJ" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="rM4-Nu-8WD" secondAttribute="trailing" constant="10" id="ENS-hs-qEL"/>
|
||||
<constraint firstItem="rM4-Nu-8WD" firstAttribute="centerY" secondItem="0jc-u2-nKr" secondAttribute="centerY" id="YvA-Kx-Bs8"/>
|
||||
<constraint firstItem="hwp-Cw-qHJ" firstAttribute="centerY" secondItem="0jc-u2-nKr" secondAttribute="centerY" id="vtW-Xg-w0U"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<segue destination="R3j-2J-zLq" kind="show" id="rev-2E-hOm"/>
|
||||
<segue destination="R3j-2J-zLq" kind="show" trigger="accessoryAction" id="1o0-KH-pCo"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
<tableViewSection id="WFB-XH-2pJ">
|
||||
<cells>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="TopLeft" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" rowHeight="96" id="MI7-01-a5u">
|
||||
<rect key="frame" x="0.0" y="167" width="375" height="96"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="TopLeft" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="MI7-01-a5u" id="Ahn-rC-HXu">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="95.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" text="Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu" translatesAutoresizingMaskIntoConstraints="NO" id="2hT-xL-Vpf" customClass="MWMTextView">
|
||||
<rect key="frame" x="16" y="12" width="343" height="71.5"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="71" id="y1P-L7-Lg2"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="localizedPlaceholder" value="ugc_route_edit_description_hint"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular16"/>
|
||||
<userDefinedRuntimeAttribute type="number" keyPath="textContainer.lineFragmentPadding">
|
||||
<integer key="value" value="0"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackPrimaryText"/>
|
||||
<userDefinedRuntimeAttribute type="rect" keyPath="textContainerInset">
|
||||
<rect key="value" x="0.0" y="0.0" width="0.0" height="0.0"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="tgw-vx-qJ3" id="Qxk-m9-jcG"/>
|
||||
</connections>
|
||||
</textView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="2hT-xL-Vpf" secondAttribute="trailing" constant="16" id="B8z-hn-G7j"/>
|
||||
<constraint firstItem="2hT-xL-Vpf" firstAttribute="top" secondItem="Ahn-rC-HXu" secondAttribute="top" constant="12" id="BtZ-2k-Jkg"/>
|
||||
<constraint firstAttribute="bottom" secondItem="2hT-xL-Vpf" secondAttribute="bottom" constant="12" id="Eyb-iY-0Tg"/>
|
||||
<constraint firstItem="2hT-xL-Vpf" firstAttribute="leading" secondItem="Ahn-rC-HXu" secondAttribute="leading" constant="16" id="pmG-bp-8X9"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
<tableViewSection id="LeZ-S5-Rxs">
|
||||
<cells>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" id="WjK-j0-RKa">
|
||||
<rect key="frame" x="0.0" y="299" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="WjK-j0-RKa" id="5HB-S5-Pl2">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="u56-Jh-ACU">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<state key="normal" title="Delete List">
|
||||
<color key="titleColor" red="0.95686274510000002" green="0.26274509800000001" blue="0.21176470589999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</state>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular17"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="red"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<action selector="deleteListButtonPressed:" destination="tgw-vx-qJ3" eventType="touchUpInside" id="hEg-uB-1pl"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
</sections>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="tgw-vx-qJ3" id="cij-qD-O59"/>
|
||||
<outlet property="delegate" destination="tgw-vx-qJ3" id="FFI-DX-Gfg"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<toolbarItems/>
|
||||
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
|
||||
<connections>
|
||||
<outlet property="accessStatusLabel" destination="hwp-Cw-qHJ" id="FFA-EU-pHx"/>
|
||||
<outlet property="descriptionCell" destination="WFB-XH-2pJ" id="gBu-qU-6AM"/>
|
||||
<outlet property="descriptionTextView" destination="2hT-xL-Vpf" id="ZGf-vb-TFO"/>
|
||||
<outlet property="nameTextField" destination="cbH-NH-2Hd" id="NoV-HY-TxN"/>
|
||||
<outlet property="saveButton" destination="rLB-UA-24H" id="ifT-3k-Jvo"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="WNJ-iX-bm4" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
<barButtonItem systemItem="save" id="rLB-UA-24H">
|
||||
<connections>
|
||||
<action selector="onSave:" destination="tgw-vx-qJ3" id="Dm0-hF-uaC"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="847.20000000000005" y="-135.38230884557723"/>
|
||||
</scene>
|
||||
<!--BookmarksSharingFlow-->
|
||||
<scene sceneID="9SR-5u-fx9">
|
||||
<objects>
|
||||
<viewControllerPlaceholder storyboardName="BookmarksSharingFlow" id="R3j-2J-zLq" sceneMemberID="viewController"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="tGW-R4-7DO" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1498.4000000000001" y="-134.03298350824588"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<inferredMetricsTieBreakers>
|
||||
<segue reference="rev-2E-hOm"/>
|
||||
</inferredMetricsTieBreakers>
|
||||
</document>
|
|
@ -0,0 +1,141 @@
|
|||
protocol CategorySettingsViewControllerDelegate: AnyObject {
|
||||
func categorySettingsController(_ viewController: CategorySettingsViewController,
|
||||
didEndEditing categoryId: MWMMarkGroupID)
|
||||
func categorySettingsController(_ viewController: CategorySettingsViewController,
|
||||
didDelete categoryId: MWMMarkGroupID)
|
||||
}
|
||||
|
||||
class CategorySettingsViewController: MWMTableViewController {
|
||||
|
||||
var categoryId: MWMMarkGroupID?
|
||||
var maxCategoryNameLength: UInt?
|
||||
var minCategoryNameLength: UInt?
|
||||
|
||||
var manager: MWMBookmarksManager {
|
||||
return MWMBookmarksManager.shared()
|
||||
}
|
||||
|
||||
weak var delegate: CategorySettingsViewControllerDelegate?
|
||||
|
||||
@IBOutlet private weak var accessStatusLabel: UILabel!
|
||||
@IBOutlet private weak var nameTextField: UITextField!
|
||||
@IBOutlet private weak var descriptionTextView: UITextView!
|
||||
@IBOutlet private weak var descriptionCell: UITableViewCell!
|
||||
@IBOutlet private weak var saveButton: UIBarButtonItem!
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
title = L("settings")
|
||||
|
||||
assert(categoryId != nil && minCategoryNameLength != nil && maxCategoryNameLength != nil,
|
||||
"must provide category info")
|
||||
|
||||
nameTextField.text = manager.getCategoryName(categoryId!)
|
||||
descriptionTextView.text = manager.getCategoryDescription(categoryId!)
|
||||
configureAccessStatus()
|
||||
|
||||
navigationItem.rightBarButtonItem = saveButton
|
||||
}
|
||||
|
||||
func configureAccessStatus() {
|
||||
switch MWMBookmarksManager.shared().getCategoryAccessStatus(categoryId!) {
|
||||
case .local:
|
||||
accessStatusLabel.text = "Not shared"
|
||||
case .public:
|
||||
accessStatusLabel.text = "Public"
|
||||
case .private:
|
||||
accessStatusLabel.text = "Private"
|
||||
case .other:
|
||||
assert(false, "it's not ok that this category has such access status")
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func deleteListButtonPressed(_ sender: Any) {
|
||||
guard let category = categoryId else {
|
||||
assert(false)
|
||||
return
|
||||
}
|
||||
|
||||
manager.deleteCategory(category)
|
||||
delegate?.categorySettingsController(self, didDelete: category)
|
||||
}
|
||||
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
if let destinationVC = segue.destination as? BookmarksSharingViewController {
|
||||
destinationVC.categoryId = categoryId
|
||||
destinationVC.delegate = self
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func onSave(_ sender: Any) {
|
||||
guard let category = categoryId,
|
||||
let newName = nameTextField.text,
|
||||
!newName.isEmpty else {
|
||||
assert(false)
|
||||
return
|
||||
}
|
||||
|
||||
manager.setCategory(category, name: newName)
|
||||
manager.setCategory(category, description: descriptionTextView.text)
|
||||
delegate?.categorySettingsController(self, didEndEditing: category)
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
||||
return UITableViewAutomaticDimension
|
||||
}
|
||||
}
|
||||
|
||||
extension CategorySettingsViewController: BookmarksSharingViewControllerDelegate {
|
||||
func didShareCategory() {
|
||||
configureAccessStatus()
|
||||
}
|
||||
}
|
||||
|
||||
extension CategorySettingsViewController: UITextViewDelegate {
|
||||
func textViewDidChange(_ textView: UITextView) {
|
||||
let size = textView.bounds.size
|
||||
let newSize = textView.sizeThatFits(CGSize(width: size.width,
|
||||
height: CGFloat.greatestFiniteMagnitude))
|
||||
|
||||
// Resize the cell only when cell's size is changed
|
||||
if abs(size.height - newSize.height) >= 1 {
|
||||
UIView.setAnimationsEnabled(false)
|
||||
tableView.beginUpdates()
|
||||
tableView.endUpdates()
|
||||
UIView.setAnimationsEnabled(true)
|
||||
|
||||
if let thisIndexPath = tableView.indexPath(for: descriptionCell) {
|
||||
tableView?.scrollToRow(at: thisIndexPath, at: .bottom, animated: false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension CategorySettingsViewController: UITextFieldDelegate {
|
||||
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange,
|
||||
replacementString string: String) -> Bool {
|
||||
let currentText = textField.text ?? ""
|
||||
|
||||
guard let stringRange = Range(range, in: currentText) else { return false }
|
||||
let updatedText = currentText.replacingCharacters(in: stringRange, with: string)
|
||||
|
||||
guard let maxAvailableLength = maxCategoryNameLength,
|
||||
let minAvailableLength = minCategoryNameLength else {
|
||||
assert(false)
|
||||
return true
|
||||
}
|
||||
|
||||
saveButton.isEnabled = updatedText.count > minAvailableLength
|
||||
|
||||
if updatedText.count > maxAvailableLength {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func textFieldShouldClear(_ textField: UITextField) -> Bool {
|
||||
saveButton.isEnabled = false
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -1,10 +1,15 @@
|
|||
import SafariServices
|
||||
|
||||
protocol BookmarksSharingViewControllerDelegate: AnyObject {
|
||||
func didShareCategory()
|
||||
}
|
||||
|
||||
final class BookmarksSharingViewController: MWMTableViewController {
|
||||
typealias ViewModel = MWMAuthorizationViewModel
|
||||
|
||||
var categoryId: MWMMarkGroupID?
|
||||
var categoryUrl: URL?
|
||||
weak var delegate: BookmarksSharingViewControllerDelegate?
|
||||
|
||||
@IBOutlet weak var uploadAndPublishCell: UploadActionCell!
|
||||
@IBOutlet weak var getDirectLinkCell: UploadActionCell!
|
||||
|
@ -98,6 +103,7 @@ final class BookmarksSharingViewController: MWMTableViewController {
|
|||
} else {
|
||||
self?.getDirectLinkCell.cellState = .completed
|
||||
self?.categoryUrl = url
|
||||
self?.delegate?.didShareCategory()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -27,3 +27,10 @@ typedef NS_ENUM(NSUInteger, MWMBookmarksShareStatus) {
|
|||
MWMBookmarksShareStatusArchiveError,
|
||||
MWMBookmarksShareStatusFileError
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, MWMCategoryAccessStatus) {
|
||||
MWMCategoryAccessStatusLocal,
|
||||
MWMCategoryAccessStatusPublic,
|
||||
MWMCategoryAccessStatusPrivate,
|
||||
MWMCategoryAccessStatusOther
|
||||
};
|
||||
|
|
|
@ -21,9 +21,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
- (NSString *)getCategoryName:(MWMMarkGroupID)groupId;
|
||||
- (uint64_t)getCategoryMarksCount:(MWMMarkGroupID)groupId;
|
||||
- (uint64_t)getCategoryTracksCount:(MWMMarkGroupID)groupId;
|
||||
- (MWMCategoryAccessStatus)getCategoryAccessStatus:(MWMMarkGroupID)groupId;
|
||||
- (NSString *)getCategoryDescription:(MWMMarkGroupID)groupId;
|
||||
|
||||
- (MWMMarkGroupID)createCategoryWithName:(NSString *)name;
|
||||
- (void)setCategory:(MWMMarkGroupID)groupId name:(NSString *)name;
|
||||
- (void)setCategory:(MWMMarkGroupID)groupId description:(NSString *)name;
|
||||
- (BOOL)isCategoryVisible:(MWMMarkGroupID)groupId;
|
||||
- (void)setCategory:(MWMMarkGroupID)groupId isVisible:(BOOL)isVisible;
|
||||
- (void)setUserCategoriesVisible:(BOOL)isVisible;
|
||||
|
|
|
@ -307,6 +307,28 @@ NSString * const CloudErrorToString(Cloud::SynchronizationResult result)
|
|||
return self.bm.GetTrackIds(groupId).size();
|
||||
}
|
||||
|
||||
- (MWMCategoryAccessStatus)getCategoryAccessStatus:(MWMMarkGroupID)groupId
|
||||
{
|
||||
switch (self.bm.GetCategoryData(groupId).m_accessRules)
|
||||
{
|
||||
case kml::AccessRules::Local:
|
||||
return MWMCategoryAccessStatusLocal;
|
||||
case kml::AccessRules::Public:
|
||||
return MWMCategoryAccessStatusPublic;
|
||||
case kml::AccessRules::DirectLink:
|
||||
return MWMCategoryAccessStatusPrivate;
|
||||
case kml::AccessRules::P2P:
|
||||
case kml::AccessRules::Paid:
|
||||
case kml::AccessRules::Count:
|
||||
return MWMCategoryAccessStatusOther;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)getCategoryDescription:(MWMMarkGroupID)groupId
|
||||
{
|
||||
return @(kml::GetDefaultStr(self.bm.GetCategoryData(groupId).m_description).c_str());
|
||||
}
|
||||
|
||||
- (MWMMarkGroupID)createCategoryWithName:(NSString *)name
|
||||
{
|
||||
auto groupId = self.bm.CreateBookmarkCategory(name.UTF8String);
|
||||
|
@ -319,6 +341,11 @@ NSString * const CloudErrorToString(Cloud::SynchronizationResult result)
|
|||
self.bm.GetEditSession().SetCategoryName(groupId, name.UTF8String);
|
||||
}
|
||||
|
||||
- (void)setCategory:(MWMMarkGroupID)groupId description:(NSString *)name
|
||||
{
|
||||
self.bm.GetEditSession().SetCategoryDescription(groupId, name.UTF8String);
|
||||
}
|
||||
|
||||
- (BOOL)isCategoryVisible:(MWMMarkGroupID)groupId
|
||||
{
|
||||
return self.bm.IsVisible(groupId);
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
/* Begin PBXBuildFile section */
|
||||
1DA7908820762CEB008BDD6B /* libopen_location_code.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DA7908920762CEB008BDD6B /* libopen_location_code.a */; };
|
||||
1DFA2F6A20D3B57400FB2C66 /* UIColor+PartnerColor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1DFA2F6920D3B57400FB2C66 /* UIColor+PartnerColor.mm */; };
|
||||
33046832219C57180041F3A8 /* CategorySettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33046831219C57180041F3A8 /* CategorySettingsViewController.swift */; };
|
||||
33046836219C5A4E0041F3A8 /* CategorySettings.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 33046835219C5A4E0041F3A8 /* CategorySettings.storyboard */; };
|
||||
3358607E217632A2006D11F2 /* BookmarksSharingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3358607D217632A2006D11F2 /* BookmarksSharingViewController.swift */; };
|
||||
33BCD61621777A7400CA30B4 /* BookmarksSharingFlow.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 33BCD61521777A7400CA30B4 /* BookmarksSharingFlow.storyboard */; };
|
||||
33C558E3217F6CF100299E70 /* UploadActionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33C558E2217F6CF100299E70 /* UploadActionCell.swift */; };
|
||||
|
@ -782,6 +784,8 @@
|
|||
1DFA2F6E20D3CA9200FB2C66 /* UIColorRoutines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIColorRoutines.h; sourceTree = "<group>"; };
|
||||
28A0AB4B0D9B1048005BE974 /* Maps_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = Maps_Prefix.pch; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
|
||||
29B97316FDCFA39411CA2CEA /* main.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = main.mm; sourceTree = "<group>"; };
|
||||
33046831219C57180041F3A8 /* CategorySettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategorySettingsViewController.swift; sourceTree = "<group>"; };
|
||||
33046835219C5A4E0041F3A8 /* CategorySettings.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = CategorySettings.storyboard; sourceTree = "<group>"; };
|
||||
3358607D217632A2006D11F2 /* BookmarksSharingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarksSharingViewController.swift; sourceTree = "<group>"; };
|
||||
33BCD61521777A7400CA30B4 /* BookmarksSharingFlow.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = BookmarksSharingFlow.storyboard; sourceTree = "<group>"; };
|
||||
33C558E2217F6CF100299E70 /* UploadActionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadActionCell.swift; sourceTree = "<group>"; };
|
||||
|
@ -2152,6 +2156,15 @@
|
|||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
33046837219C605E0041F3A8 /* Category settings */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
33046831219C57180041F3A8 /* CategorySettingsViewController.swift */,
|
||||
33046835219C5A4E0041F3A8 /* CategorySettings.storyboard */,
|
||||
);
|
||||
path = "Category settings";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
33C49D5C21774222000F8B6A /* Sharing */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -2384,6 +2397,7 @@
|
|||
3404F4A02028A6C00090E401 /* Categories */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
33046837219C605E0041F3A8 /* Category settings */,
|
||||
33C49D5C21774222000F8B6A /* Sharing */,
|
||||
343D7B6D202AF4CA007D56A8 /* Actions */,
|
||||
3404F48F202898CC0090E401 /* BMCModels.swift */,
|
||||
|
@ -4595,6 +4609,7 @@
|
|||
F6E2FE8E1E097BA00083EBEC /* MWMPlacePageLinkCell.xib in Resources */,
|
||||
F6E2FE7F1E097BA00083EBEC /* MWMPlacePageOpeningHoursCell.xib in Resources */,
|
||||
34AB66711FC5AA330078E451 /* TransportTransitTrain.xib in Resources */,
|
||||
33046836219C5A4E0041F3A8 /* CategorySettings.storyboard in Resources */,
|
||||
34BBD6471F82649D0070CA50 /* GoogleSignIn.bundle in Resources */,
|
||||
F6E2FE851E097BA00083EBEC /* MWMPlacePageOpeningHoursWeekDayView.xib in Resources */,
|
||||
F6E2FE941E097BA00083EBEC /* PlacePageTaxiCell.xib in Resources */,
|
||||
|
@ -5114,6 +5129,7 @@
|
|||
33C558E3217F6CF100299E70 /* UploadActionCell.swift in Sources */,
|
||||
347E039A1FAC5F1D00426032 /* UIWindow+InputLanguage.swift in Sources */,
|
||||
340475711E081A4600C92850 /* MWMSettings.mm in Sources */,
|
||||
33046832219C57180041F3A8 /* CategorySettingsViewController.swift in Sources */,
|
||||
3404165C1E7C29AE00E2B6D6 /* PhotosInteractionAnimator.swift in Sources */,
|
||||
34E50DE01F6FCBA1008EED49 /* UGCAddReviewCell.swift in Sources */,
|
||||
34D4FA631E26572D003F53EF /* FirstLaunchController.swift in Sources */,
|
||||
|
|
|
@ -10,6 +10,7 @@ enum Storyboard: Int {
|
|||
case settings
|
||||
case welcome
|
||||
case sharing
|
||||
case categorySettings
|
||||
}
|
||||
|
||||
extension UIStoryboard {
|
||||
|
@ -23,6 +24,7 @@ extension UIStoryboard {
|
|||
case .settings: name = "Settings"
|
||||
case .welcome: name = "Welcome"
|
||||
case .sharing: name = "BookmarksSharingFlow"
|
||||
case .categorySettings: name = "CategorySettings"
|
||||
}
|
||||
return UIStoryboard(name: name, bundle: nil)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue