2025-08-21 12:10:43 +08:00
|
|
|
//
|
2026-01-27 22:12:31 +08:00
|
|
|
// TimelineCustomizerCell.swift
|
2025-08-21 12:10:43 +08:00
|
|
|
// NetNewsWire-iOS
|
|
|
|
|
//
|
|
|
|
|
// Created by Stuart Breckenridge on 21/08/2025.
|
|
|
|
|
// Copyright © 2025 Ranchero Software. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import UIKit
|
2026-05-29 10:46:00 -07:00
|
|
|
import Images
|
2025-08-21 12:10:43 +08:00
|
|
|
|
|
|
|
|
enum SliderConfiguration {
|
|
|
|
|
case numberOfLines
|
|
|
|
|
case iconSize
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-27 22:12:31 +08:00
|
|
|
final class TimelineCustomizerCell: UICollectionViewCell {
|
2026-03-31 15:02:12 -07:00
|
|
|
@IBOutlet var slider: TickMarkSlider!
|
2026-01-31 21:04:11 -08:00
|
|
|
|
2025-08-21 12:10:43 +08:00
|
|
|
var sliderConfiguration: SliderConfiguration! {
|
|
|
|
|
didSet {
|
|
|
|
|
switch sliderConfiguration {
|
|
|
|
|
case .numberOfLines:
|
|
|
|
|
slider.minimumValue = 1
|
|
|
|
|
slider.maximumValue = 6
|
2026-03-29 21:31:02 -07:00
|
|
|
if #available(iOS 26, *) {
|
|
|
|
|
slider.trackConfiguration = .init(allowsTickValuesOnly: true, numberOfTicks: 6)
|
|
|
|
|
}
|
2026-10-22 13:46:32 -07:00
|
|
|
slider.value = Float(AppDefaults.timelineNumberOfLines)
|
2026-03-31 15:02:12 -07:00
|
|
|
slider.addTickMarks()
|
2025-08-21 12:10:43 +08:00
|
|
|
case .iconSize:
|
|
|
|
|
slider.minimumValue = 1
|
|
|
|
|
slider.maximumValue = 3
|
2026-03-29 21:31:02 -07:00
|
|
|
if #available(iOS 26, *) {
|
|
|
|
|
slider.trackConfiguration = .init(allowsTickValuesOnly: true, numberOfTicks: 3)
|
|
|
|
|
}
|
2026-10-22 13:46:32 -07:00
|
|
|
slider.value = Float(AppDefaults.timelineIconSize.rawValue)
|
2026-03-31 15:02:12 -07:00
|
|
|
slider.addTickMarks()
|
2025-08-21 12:10:43 +08:00
|
|
|
case .none:
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-31 21:04:11 -08:00
|
|
|
|
2025-08-21 12:10:43 +08:00
|
|
|
@IBAction func sliderValueChanges(_ sender: Any) {
|
|
|
|
|
switch sliderConfiguration {
|
|
|
|
|
case .numberOfLines:
|
2026-10-22 13:46:32 -07:00
|
|
|
AppDefaults.timelineNumberOfLines = Int(slider.value.rounded())
|
2025-08-21 12:10:43 +08:00
|
|
|
case .iconSize:
|
|
|
|
|
guard let iconSize = IconSize(rawValue: Int(slider.value.rounded())) else { return }
|
2026-10-22 13:46:32 -07:00
|
|
|
AppDefaults.timelineIconSize = iconSize
|
2025-08-21 12:10:43 +08:00
|
|
|
case .none:
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-31 21:04:11 -08:00
|
|
|
|
2026-01-27 22:12:31 +08:00
|
|
|
override func updateConfiguration(using state: UICellConfigurationState) {
|
2026-10-21 19:05:11 -07:00
|
|
|
var backgroundConfig = UIBackgroundConfiguration.listCell().updated(for: state)
|
2026-01-27 22:32:01 +08:00
|
|
|
backgroundConfig.backgroundColor = traitCollection.userInterfaceStyle == .dark ? .secondarySystemBackground : .white
|
2026-01-27 22:12:31 +08:00
|
|
|
backgroundConfig.cornerRadius = 20
|
|
|
|
|
self.backgroundConfiguration = backgroundConfig
|
|
|
|
|
}
|
2026-01-31 21:04:11 -08:00
|
|
|
|
2025-08-21 12:10:43 +08:00
|
|
|
}
|