Skip to content

Commit

Permalink
Fix comments on testing 1 (#4229)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitrySvetlichny authored Dec 20, 2024
1 parent 435f9b8 commit 2cf4cd6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Resources/Localizations/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ final class TracksFilterDetailsViewController: OABaseNavbarViewController {
addCell(OADatePickerTableViewCell.reuseIdentifier)
addCell(OARangeSliderFilterTableViewCell.reuseIdentifier)
addCell(OAValueTableViewCell.reuseIdentifier)
addCell(OASimpleTableViewCell.reuseIdentifier)
}

override func viewDidLoad() {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -696,6 +691,7 @@ final class TracksFilterDetailsViewController: OABaseNavbarViewController {

extension TracksFilterDetailsViewController: TTRangeSliderDelegate {
func didStartTouches(in sender: TTRangeSlider) {
view.endEditing(true)
isSliderDragging = true
}

Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2cf4cd6

Please sign in to comment.