diff --git a/Resources/Localizations/en.lproj/Localizable.strings b/Resources/Localizations/en.lproj/Localizable.strings index c0ae626e3f..56c6c958b7 100644 --- a/Resources/Localizations/en.lproj/Localizable.strings +++ b/Resources/Localizations/en.lproj/Localizable.strings @@ -2361,7 +2361,7 @@ "date_of_creation" = "Date of creation"; "altitud_and_elevation" = "Altitude & Elevation"; -"max_altitude" = "Max altitude"; +"max_altitude" = "Max. altitude"; "shared_string_sensors" = "Sensors"; "max_sensor_speed" = "Sensor speed, max"; "avg_sensor_speed" = "Sensor speed, average"; diff --git a/Sources/Controllers/MyPlaces/TracksFilterDetailsViewController.swift b/Sources/Controllers/MyPlaces/TracksFilterDetailsViewController.swift index ba2ffdf89f..02a18efca5 100644 --- a/Sources/Controllers/MyPlaces/TracksFilterDetailsViewController.swift +++ b/Sources/Controllers/MyPlaces/TracksFilterDetailsViewController.swift @@ -215,7 +215,6 @@ final class TracksFilterDetailsViewController: OABaseNavbarViewController { addCell(OADatePickerTableViewCell.reuseIdentifier) addCell(OARangeSliderFilterTableViewCell.reuseIdentifier) addCell(OAValueTableViewCell.reuseIdentifier) - addCell(OASimpleTableViewCell.reuseIdentifier) } override func viewDidLoad() { @@ -340,11 +339,19 @@ final class TracksFilterDetailsViewController: OABaseNavbarViewController { if !isSearchActive { let allFoldersSection = tableData.createNewSection() let allFoldersRow = allFoldersSection.createNewRow() - allFoldersRow.cellType = OASimpleTableViewCell.reuseIdentifier + allFoldersRow.cellType = OAValueTableViewCell.reuseIdentifier allFoldersRow.key = Self.allFoldersRowKey allFoldersRow.title = localizedString("all_folders") allFoldersRow.icon = .icCustomFolderOpen allFoldersRow.iconTintColor = .iconColorSelected + if let folderTracks = TracksSearchFilter.getTrackFolderByPath("")?.getFlattenedTrackItems() { + let filteredTracks = baseFilters.getFilteredTrackItems() + let matchingTracksCount = folderTracks.filter { trackItem in + filteredTracks.contains(where: { $0.path == trackItem.path }) + }.count + let totalTracksCount = folderTracks.count + allFoldersRow.descr = "\(matchingTracksCount)/\(totalTracksCount)" + } } func displayFolder(_ folderItem: DisplayFolderItem, in section: OATableSectionData, isRootFolder: Bool) { @@ -441,29 +448,12 @@ final class TracksFilterDetailsViewController: OABaseNavbarViewController { cell.leftIconView.backgroundColor = isKeyNotEmpty ? item.iconTintColor : nil cell.leftIconView.layer.cornerRadius = isKeyNotEmpty ? cell.leftIconView.frame.height / 2 : 0 } - if let key = item.key, selectedItems.contains(key) { + if let key = item.key, (selectedItems.contains(key) || (key == Self.allFoldersRowKey && listFilterType?.isSelectAllItemsSelected == true)) { tableView.selectRow(at: indexPath, animated: false, scrollPosition: .none) } else { tableView.deselectRow(at: indexPath, animated: false) } return cell - } else if item.cellType == OASimpleTableViewCell.reuseIdentifier { - let cell = tableView.dequeueReusableCell(withIdentifier: OASimpleTableViewCell.reuseIdentifier) as! OASimpleTableViewCell - cell.descriptionVisibility(false) - cell.selectedBackgroundView = UIView() - cell.selectedBackgroundView?.backgroundColor = UIColor.groupBg - cell.accessoryType = .none - cell.titleLabel.text = item.title - cell.leftIconView.image = item.icon - cell.leftIconView.tintColor = item.iconTintColor - if item.key == Self.allFoldersRowKey { - if listFilterType?.isSelectAllItemsSelected == true { - tableView.selectRow(at: indexPath, animated: false, scrollPosition: .none) - } else { - tableView.deselectRow(at: indexPath, animated: false) - } - } - return cell } return nil @@ -511,6 +501,11 @@ final class TracksFilterDetailsViewController: OABaseNavbarViewController { override func onRightNavbarButtonPressed() { view.endEditing(true) + if isSearchActive { + searchController?.isActive = false + isSearchActive = false + } + switch filterType { case .length, .duration, .timeInMotion, .averageSpeed, .maxSpeed, .averageAltitude, .maxAltitude, .uphill, .downhill, .maxSensorSpeed, .averageSensorSpeed, .maxSensorHeartRate, .averageSensorHeartRate, .maxSensorCadence, .averageSensorCadence, .maxSensorBicyclePower, .averageSensorBicyclePower, .maxSensorTemperature, .averageSensorTemperature: rangeFilterType?.setValueFrom(from: String(Int(currentValueFrom)), updateListeners_: false) @@ -696,6 +691,7 @@ final class TracksFilterDetailsViewController: OABaseNavbarViewController { extension TracksFilterDetailsViewController: TTRangeSliderDelegate { func didStartTouches(in sender: TTRangeSlider) { + view.endEditing(true) isSliderDragging = true } @@ -763,6 +759,31 @@ extension TracksFilterDetailsViewController: UITextFieldDelegate { } } + func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { + let currentText = textField.text ?? "" + let newText = (currentText as NSString).replacingCharacters(in: range, with: string) + if newText.count > 6 { + return false + } + + if let newValue = Int(newText), !newText.isEmpty { + if textField.tag == .min && newValue < Int(currentValueTo) { + currentValueFrom = Float(newValue) + } else if textField.tag == .max && newValue > Int(currentValueFrom) { + currentValueTo = Float(newValue) + } else { + return true + } + + if let cell = tableView.cellForRow(at: IndexPath(row: 0, section: 0)) as? OARangeSliderFilterTableViewCell { + cell.rangeSlider.selectedMinimum = currentValueFrom + cell.rangeSlider.selectedMaximum = currentValueTo + } + } + + return true + } + func textFieldDidEndEditing(_ textField: UITextField) { guard let text = textField.text, !text.isEmpty, let newValue = Float(text) else { return } switch textField.tag { diff --git a/Sources/Controllers/MyPlaces/TracksFiltersViewController.swift b/Sources/Controllers/MyPlaces/TracksFiltersViewController.swift index 49d8e7381a..c96a197ebd 100644 --- a/Sources/Controllers/MyPlaces/TracksFiltersViewController.swift +++ b/Sources/Controllers/MyPlaces/TracksFiltersViewController.swift @@ -107,7 +107,7 @@ final class TracksFiltersViewController: OABaseButtonsViewController { } override func getLeftNavbarButtonTitle() -> String? { - localizedString("shared_string_cancel") + localizedString("shared_string_close") } override func getBottomAxisMode() -> NSLayoutConstraint.Axis {