@neoskola/auto-play 0.3.13 → 0.3.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -57,23 +57,25 @@ class NowPlayingTemplate: NSObject, AutoPlayTemplate, CPMapTemplateDelegate {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
// MARK: - CPMapButton Controls
|
|
60
|
+
// MARK: - CPMapButton Controls
|
|
61
61
|
|
|
62
62
|
private static func buildMapButtons(isPlaying: Bool, owner: NowPlayingTemplate) -> [CPMapButton] {
|
|
63
|
-
|
|
64
|
-
let renderer = UIGraphicsImageRenderer(size: CGSize(width: 1, height: 1))
|
|
65
|
-
let clearImage = renderer.image { ctx in
|
|
66
|
-
UIColor.clear.setFill()
|
|
67
|
-
ctx.fill(CGRect(x: 0, y: 0, width: 1, height: 1))
|
|
68
|
-
}
|
|
63
|
+
let buttonSize = CPButtonMaximumImageSize
|
|
69
64
|
|
|
70
65
|
// Previous track button
|
|
71
|
-
let
|
|
66
|
+
let prevImage = UIImage(systemName: "backward.end.fill")?
|
|
67
|
+
.withTintColor(.white, renderingMode: .alwaysOriginal)
|
|
68
|
+
.resized(to: buttonSize)
|
|
69
|
+
let prevButton = CPMapButton(image: prevImage ?? UIImage()) { [weak owner] _ in
|
|
72
70
|
owner?.config.onPreviousTrack?()
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
// Play/Pause button
|
|
76
|
-
let
|
|
74
|
+
let playPauseIconName = isPlaying ? "pause.circle.fill" : "play.circle.fill"
|
|
75
|
+
let playPauseImage = UIImage(systemName: playPauseIconName)?
|
|
76
|
+
.withTintColor(.white, renderingMode: .alwaysOriginal)
|
|
77
|
+
.resized(to: buttonSize)
|
|
78
|
+
let playPauseButton = CPMapButton(image: playPauseImage ?? UIImage()) { [weak owner] _ in
|
|
77
79
|
guard let owner = owner else { return }
|
|
78
80
|
DispatchQueue.main.async {
|
|
79
81
|
if owner.config.isPlaying {
|
|
@@ -87,7 +89,10 @@ class NowPlayingTemplate: NSObject, AutoPlayTemplate, CPMapTemplateDelegate {
|
|
|
87
89
|
}
|
|
88
90
|
|
|
89
91
|
// Next track button
|
|
90
|
-
let
|
|
92
|
+
let nextImage = UIImage(systemName: "forward.end.fill")?
|
|
93
|
+
.withTintColor(.white, renderingMode: .alwaysOriginal)
|
|
94
|
+
.resized(to: buttonSize)
|
|
95
|
+
let nextButton = CPMapButton(image: nextImage ?? UIImage()) { [weak owner] _ in
|
|
91
96
|
owner?.config.onNextTrack?()
|
|
92
97
|
}
|
|
93
98
|
|
|
@@ -12,12 +12,6 @@ class NeoSkolaNowPlayingViewController: UIViewController {
|
|
|
12
12
|
private let durationLabel = UILabel()
|
|
13
13
|
private let timeStack = UIStackView()
|
|
14
14
|
|
|
15
|
-
// MARK: - Button Controls (visual only, touch handled by CPMapButton)
|
|
16
|
-
private let buttonStack = UIStackView()
|
|
17
|
-
private let previousButton = UIButton(type: .custom)
|
|
18
|
-
private let playPauseButton = UIButton(type: .custom)
|
|
19
|
-
private let nextButton = UIButton(type: .custom)
|
|
20
|
-
|
|
21
15
|
// MARK: - Lifecycle
|
|
22
16
|
|
|
23
17
|
override func viewDidLoad() {
|
|
@@ -72,45 +66,6 @@ class NeoSkolaNowPlayingViewController: UIViewController {
|
|
|
72
66
|
timeStack.addArrangedSubview(currentTimeLabel)
|
|
73
67
|
timeStack.addArrangedSubview(durationLabel)
|
|
74
68
|
|
|
75
|
-
// Previous Button
|
|
76
|
-
previousButton.setImage(
|
|
77
|
-
UIImage(systemName: "backward.end.fill",
|
|
78
|
-
withConfiguration: UIImage.SymbolConfiguration(pointSize: 28, weight: .medium))?
|
|
79
|
-
.withTintColor(.white, renderingMode: .alwaysOriginal),
|
|
80
|
-
for: .normal
|
|
81
|
-
)
|
|
82
|
-
previousButton.backgroundColor = .clear
|
|
83
|
-
previousButton.isUserInteractionEnabled = false
|
|
84
|
-
|
|
85
|
-
// Play/Pause Button
|
|
86
|
-
playPauseButton.setImage(
|
|
87
|
-
UIImage(systemName: "play.circle.fill",
|
|
88
|
-
withConfiguration: UIImage.SymbolConfiguration(pointSize: 44, weight: .medium))?
|
|
89
|
-
.withTintColor(.white, renderingMode: .alwaysOriginal),
|
|
90
|
-
for: .normal
|
|
91
|
-
)
|
|
92
|
-
playPauseButton.backgroundColor = .clear
|
|
93
|
-
playPauseButton.isUserInteractionEnabled = false
|
|
94
|
-
|
|
95
|
-
// Next Button
|
|
96
|
-
nextButton.setImage(
|
|
97
|
-
UIImage(systemName: "forward.end.fill",
|
|
98
|
-
withConfiguration: UIImage.SymbolConfiguration(pointSize: 28, weight: .medium))?
|
|
99
|
-
.withTintColor(.white, renderingMode: .alwaysOriginal),
|
|
100
|
-
for: .normal
|
|
101
|
-
)
|
|
102
|
-
nextButton.backgroundColor = .clear
|
|
103
|
-
nextButton.isUserInteractionEnabled = false
|
|
104
|
-
|
|
105
|
-
// Button Stack (horizontal)
|
|
106
|
-
buttonStack.axis = .horizontal
|
|
107
|
-
buttonStack.alignment = .center
|
|
108
|
-
buttonStack.distribution = .equalSpacing
|
|
109
|
-
buttonStack.spacing = 40
|
|
110
|
-
buttonStack.addArrangedSubview(previousButton)
|
|
111
|
-
buttonStack.addArrangedSubview(playPauseButton)
|
|
112
|
-
buttonStack.addArrangedSubview(nextButton)
|
|
113
|
-
|
|
114
69
|
// Main container stack (vertical)
|
|
115
70
|
containerStack.axis = .vertical
|
|
116
71
|
containerStack.alignment = .fill
|
|
@@ -137,14 +92,6 @@ class NeoSkolaNowPlayingViewController: UIViewController {
|
|
|
137
92
|
containerStack.addArrangedSubview(progressView)
|
|
138
93
|
containerStack.addArrangedSubview(timeStack)
|
|
139
94
|
|
|
140
|
-
// Spacer between time and buttons
|
|
141
|
-
let spacer3 = UIView()
|
|
142
|
-
spacer3.translatesAutoresizingMaskIntoConstraints = false
|
|
143
|
-
spacer3.heightAnchor.constraint(equalToConstant: 16).isActive = true
|
|
144
|
-
containerStack.addArrangedSubview(spacer3)
|
|
145
|
-
|
|
146
|
-
containerStack.addArrangedSubview(buttonStack)
|
|
147
|
-
|
|
148
95
|
view.addSubview(containerStack)
|
|
149
96
|
}
|
|
150
97
|
|
|
@@ -170,14 +117,6 @@ class NeoSkolaNowPlayingViewController: UIViewController {
|
|
|
170
117
|
func updatePlaybackState(isPlaying: Bool) {
|
|
171
118
|
statusLabel.text = isPlaying ? "OYNATILIYOR" : "DURAKLATILDI"
|
|
172
119
|
statusLabel.textColor = isPlaying ? UIColor.systemGreen : UIColor.systemGray
|
|
173
|
-
|
|
174
|
-
let iconName = isPlaying ? "pause.circle.fill" : "play.circle.fill"
|
|
175
|
-
playPauseButton.setImage(
|
|
176
|
-
UIImage(systemName: iconName,
|
|
177
|
-
withConfiguration: UIImage.SymbolConfiguration(pointSize: 44, weight: .medium))?
|
|
178
|
-
.withTintColor(.white, renderingMode: .alwaysOriginal),
|
|
179
|
-
for: .normal
|
|
180
|
-
)
|
|
181
120
|
}
|
|
182
121
|
|
|
183
122
|
func updateTime(elapsed: Double, duration: Double) {
|