@neoskola/auto-play 0.3.11 → 0.3.13
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,26 +57,23 @@ class NowPlayingTemplate: NSObject, AutoPlayTemplate, CPMapTemplateDelegate {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
// MARK: - CPMapButton Controls
|
|
60
|
+
// MARK: - CPMapButton Controls (transparent touch handlers)
|
|
61
61
|
|
|
62
62
|
private static func buildMapButtons(isPlaying: Bool, owner: NowPlayingTemplate) -> [CPMapButton] {
|
|
63
|
-
|
|
63
|
+
// 1x1 transparent image for invisible buttons
|
|
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
|
+
}
|
|
64
69
|
|
|
65
70
|
// Previous track button
|
|
66
|
-
let
|
|
67
|
-
.withTintColor(.systemBlue, renderingMode: .alwaysOriginal)
|
|
68
|
-
.resized(to: buttonSize)
|
|
69
|
-
let prevButton = CPMapButton(image: prevImage ?? UIImage()) { [weak owner] _ in
|
|
71
|
+
let prevButton = CPMapButton(image: clearImage) { [weak owner] _ in
|
|
70
72
|
owner?.config.onPreviousTrack?()
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
// Play/Pause button
|
|
74
|
-
let
|
|
75
|
-
let playPauseColor: UIColor = isPlaying ? .systemOrange : .systemGreen
|
|
76
|
-
let playPauseImage = UIImage(systemName: playPauseIconName)?
|
|
77
|
-
.withTintColor(playPauseColor, renderingMode: .alwaysOriginal)
|
|
78
|
-
.resized(to: buttonSize)
|
|
79
|
-
let playPauseButton = CPMapButton(image: playPauseImage ?? UIImage()) { [weak owner] _ in
|
|
76
|
+
let playPauseButton = CPMapButton(image: clearImage) { [weak owner] _ in
|
|
80
77
|
guard let owner = owner else { return }
|
|
81
78
|
DispatchQueue.main.async {
|
|
82
79
|
if owner.config.isPlaying {
|
|
@@ -90,10 +87,7 @@ class NowPlayingTemplate: NSObject, AutoPlayTemplate, CPMapTemplateDelegate {
|
|
|
90
87
|
}
|
|
91
88
|
|
|
92
89
|
// Next track button
|
|
93
|
-
let
|
|
94
|
-
.withTintColor(.systemBlue, renderingMode: .alwaysOriginal)
|
|
95
|
-
.resized(to: buttonSize)
|
|
96
|
-
let nextButton = CPMapButton(image: nextImage ?? UIImage()) { [weak owner] _ in
|
|
90
|
+
let nextButton = CPMapButton(image: clearImage) { [weak owner] _ in
|
|
97
91
|
owner?.config.onNextTrack?()
|
|
98
92
|
}
|
|
99
93
|
|
|
@@ -2,7 +2,7 @@ import UIKit
|
|
|
2
2
|
|
|
3
3
|
class NeoSkolaNowPlayingViewController: UIViewController {
|
|
4
4
|
|
|
5
|
-
// MARK: - UI Elements
|
|
5
|
+
// MARK: - UI Elements
|
|
6
6
|
private let containerStack = UIStackView()
|
|
7
7
|
private let courseNameLabel = UILabel()
|
|
8
8
|
private let lessonNameLabel = UILabel()
|
|
@@ -12,6 +12,12 @@ 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
|
+
|
|
15
21
|
// MARK: - Lifecycle
|
|
16
22
|
|
|
17
23
|
override func viewDidLoad() {
|
|
@@ -66,6 +72,45 @@ class NeoSkolaNowPlayingViewController: UIViewController {
|
|
|
66
72
|
timeStack.addArrangedSubview(currentTimeLabel)
|
|
67
73
|
timeStack.addArrangedSubview(durationLabel)
|
|
68
74
|
|
|
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
|
+
|
|
69
114
|
// Main container stack (vertical)
|
|
70
115
|
containerStack.axis = .vertical
|
|
71
116
|
containerStack.alignment = .fill
|
|
@@ -92,6 +137,14 @@ class NeoSkolaNowPlayingViewController: UIViewController {
|
|
|
92
137
|
containerStack.addArrangedSubview(progressView)
|
|
93
138
|
containerStack.addArrangedSubview(timeStack)
|
|
94
139
|
|
|
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
|
+
|
|
95
148
|
view.addSubview(containerStack)
|
|
96
149
|
}
|
|
97
150
|
|
|
@@ -117,6 +170,14 @@ class NeoSkolaNowPlayingViewController: UIViewController {
|
|
|
117
170
|
func updatePlaybackState(isPlaying: Bool) {
|
|
118
171
|
statusLabel.text = isPlaying ? "OYNATILIYOR" : "DURAKLATILDI"
|
|
119
172
|
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
|
+
)
|
|
120
181
|
}
|
|
121
182
|
|
|
122
183
|
func updateTime(elapsed: Double, duration: Double) {
|
|
@@ -137,4 +198,5 @@ class NeoSkolaNowPlayingViewController: UIViewController {
|
|
|
137
198
|
let secs = Int(seconds) % 60
|
|
138
199
|
return String(format: "%d:%02d", mins, secs)
|
|
139
200
|
}
|
|
201
|
+
|
|
140
202
|
}
|