@neoskola/auto-play 0.3.9 → 0.3.10
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.
|
@@ -10,11 +10,14 @@ class NeoSkolaNowPlayingViewController: UIViewController {
|
|
|
10
10
|
weak var delegate: NowPlayingViewDelegate?
|
|
11
11
|
|
|
12
12
|
// MARK: - UI Elements
|
|
13
|
-
|
|
13
|
+
// Left side: artwork + info
|
|
14
|
+
private let leftColumn = UIView()
|
|
15
|
+
private let artworkImageView = UIImageView()
|
|
14
16
|
private let courseNameLabel = UILabel()
|
|
15
17
|
private let lessonNameLabel = UILabel()
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
|
|
19
|
+
// Right side: controls + progress
|
|
20
|
+
private let rightColumn = UIView()
|
|
18
21
|
private let statusLabel = UILabel()
|
|
19
22
|
private let controlsStack = UIStackView()
|
|
20
23
|
private let prevButton = UIButton(type: .system)
|
|
@@ -39,56 +42,53 @@ class NeoSkolaNowPlayingViewController: UIViewController {
|
|
|
39
42
|
// MARK: - Setup
|
|
40
43
|
|
|
41
44
|
private func setupUI() {
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
// Left Column
|
|
46
|
+
leftColumn.translatesAutoresizingMaskIntoConstraints = false
|
|
47
|
+
view.addSubview(leftColumn)
|
|
44
48
|
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
// Artwork
|
|
50
|
+
artworkImageView.contentMode = .scaleAspectFill
|
|
51
|
+
artworkImageView.clipsToBounds = true
|
|
52
|
+
artworkImageView.layer.cornerRadius = 10
|
|
53
|
+
artworkImageView.backgroundColor = UIColor(white: 0.15, alpha: 1.0)
|
|
54
|
+
artworkImageView.translatesAutoresizingMaskIntoConstraints = false
|
|
55
|
+
leftColumn.addSubview(artworkImageView)
|
|
56
|
+
|
|
57
|
+
let placeholderConfig = UIImage.SymbolConfiguration(pointSize: 28, weight: .light)
|
|
58
|
+
artworkImageView.image = UIImage(systemName: "music.note", withConfiguration: placeholderConfig)
|
|
59
|
+
artworkImageView.tintColor = UIColor(white: 0.3, alpha: 1.0)
|
|
60
|
+
|
|
61
|
+
// Course Name
|
|
62
|
+
courseNameLabel.font = .systemFont(ofSize: 11, weight: .medium)
|
|
63
|
+
courseNameLabel.textColor = UIColor(white: 0.5, alpha: 1.0)
|
|
48
64
|
courseNameLabel.textAlignment = .center
|
|
49
65
|
courseNameLabel.numberOfLines = 1
|
|
66
|
+
courseNameLabel.adjustsFontSizeToFitWidth = true
|
|
67
|
+
courseNameLabel.minimumScaleFactor = 0.8
|
|
50
68
|
courseNameLabel.translatesAutoresizingMaskIntoConstraints = false
|
|
51
|
-
|
|
69
|
+
leftColumn.addSubview(courseNameLabel)
|
|
52
70
|
|
|
53
|
-
// Lesson Name
|
|
54
|
-
lessonNameLabel.font = .systemFont(ofSize:
|
|
71
|
+
// Lesson Name
|
|
72
|
+
lessonNameLabel.font = .systemFont(ofSize: 13, weight: .bold)
|
|
55
73
|
lessonNameLabel.textColor = .white
|
|
56
74
|
lessonNameLabel.textAlignment = .center
|
|
57
75
|
lessonNameLabel.numberOfLines = 2
|
|
58
76
|
lessonNameLabel.adjustsFontSizeToFitWidth = true
|
|
59
77
|
lessonNameLabel.minimumScaleFactor = 0.7
|
|
60
78
|
lessonNameLabel.translatesAutoresizingMaskIntoConstraints = false
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// Artwork Container (golge ve yuvarlak koseler)
|
|
64
|
-
artworkContainer.translatesAutoresizingMaskIntoConstraints = false
|
|
65
|
-
artworkContainer.layer.cornerRadius = 14
|
|
66
|
-
artworkContainer.layer.shadowColor = UIColor.black.cgColor
|
|
67
|
-
artworkContainer.layer.shadowOpacity = 0.5
|
|
68
|
-
artworkContainer.layer.shadowOffset = CGSize(width: 0, height: 4)
|
|
69
|
-
artworkContainer.layer.shadowRadius = 12
|
|
70
|
-
containerView.addSubview(artworkContainer)
|
|
71
|
-
|
|
72
|
-
// Artwork Image
|
|
73
|
-
artworkImageView.contentMode = .scaleAspectFill
|
|
74
|
-
artworkImageView.clipsToBounds = true
|
|
75
|
-
artworkImageView.layer.cornerRadius = 14
|
|
76
|
-
artworkImageView.backgroundColor = UIColor(white: 0.15, alpha: 1.0)
|
|
77
|
-
artworkImageView.translatesAutoresizingMaskIntoConstraints = false
|
|
78
|
-
artworkContainer.addSubview(artworkImageView)
|
|
79
|
+
leftColumn.addSubview(lessonNameLabel)
|
|
79
80
|
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
artworkImageView.tintColor = UIColor(white: 0.3, alpha: 1.0)
|
|
81
|
+
// Right Column
|
|
82
|
+
rightColumn.translatesAutoresizingMaskIntoConstraints = false
|
|
83
|
+
view.addSubview(rightColumn)
|
|
84
84
|
|
|
85
85
|
// Status Label
|
|
86
|
-
statusLabel.font = .systemFont(ofSize:
|
|
86
|
+
statusLabel.font = .systemFont(ofSize: 10, weight: .semibold)
|
|
87
87
|
statusLabel.textColor = UIColor.systemGreen
|
|
88
88
|
statusLabel.textAlignment = .center
|
|
89
89
|
statusLabel.text = "OYNATILIYOR"
|
|
90
90
|
statusLabel.translatesAutoresizingMaskIntoConstraints = false
|
|
91
|
-
|
|
91
|
+
rightColumn.addSubview(statusLabel)
|
|
92
92
|
|
|
93
93
|
// Controls
|
|
94
94
|
setupControls()
|
|
@@ -98,15 +98,15 @@ class NeoSkolaNowPlayingViewController: UIViewController {
|
|
|
98
98
|
progressView.trackTintColor = UIColor(white: 0.2, alpha: 1.0)
|
|
99
99
|
progressView.progress = 0
|
|
100
100
|
progressView.translatesAutoresizingMaskIntoConstraints = false
|
|
101
|
-
|
|
101
|
+
rightColumn.addSubview(progressView)
|
|
102
102
|
|
|
103
103
|
// Time Labels
|
|
104
|
-
currentTimeLabel.font = .monospacedDigitSystemFont(ofSize:
|
|
104
|
+
currentTimeLabel.font = .monospacedDigitSystemFont(ofSize: 10, weight: .medium)
|
|
105
105
|
currentTimeLabel.textColor = UIColor(white: 0.45, alpha: 1.0)
|
|
106
106
|
currentTimeLabel.text = "0:00"
|
|
107
107
|
currentTimeLabel.translatesAutoresizingMaskIntoConstraints = false
|
|
108
108
|
|
|
109
|
-
durationLabel.font = .monospacedDigitSystemFont(ofSize:
|
|
109
|
+
durationLabel.font = .monospacedDigitSystemFont(ofSize: 10, weight: .medium)
|
|
110
110
|
durationLabel.textColor = UIColor(white: 0.45, alpha: 1.0)
|
|
111
111
|
durationLabel.text = "--:--"
|
|
112
112
|
durationLabel.textAlignment = .right
|
|
@@ -117,102 +117,96 @@ class NeoSkolaNowPlayingViewController: UIViewController {
|
|
|
117
117
|
timeStack.addArrangedSubview(currentTimeLabel)
|
|
118
118
|
timeStack.addArrangedSubview(durationLabel)
|
|
119
119
|
timeStack.translatesAutoresizingMaskIntoConstraints = false
|
|
120
|
-
|
|
120
|
+
rightColumn.addSubview(timeStack)
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
private func setupControls() {
|
|
124
|
-
|
|
125
|
-
let prevConfig = UIImage.SymbolConfiguration(pointSize: 24, weight: .medium)
|
|
124
|
+
let prevConfig = UIImage.SymbolConfiguration(pointSize: 20, weight: .medium)
|
|
126
125
|
prevButton.setImage(UIImage(systemName: "backward.end.fill", withConfiguration: prevConfig), for: .normal)
|
|
127
126
|
prevButton.tintColor = .white
|
|
128
127
|
prevButton.addTarget(self, action: #selector(prevTapped), for: .touchUpInside)
|
|
129
128
|
prevButton.translatesAutoresizingMaskIntoConstraints = false
|
|
130
129
|
|
|
131
|
-
|
|
132
|
-
let playConfig = UIImage.SymbolConfiguration(pointSize: 42, weight: .medium)
|
|
130
|
+
let playConfig = UIImage.SymbolConfiguration(pointSize: 36, weight: .medium)
|
|
133
131
|
playPauseButton.setImage(UIImage(systemName: "play.circle.fill", withConfiguration: playConfig), for: .normal)
|
|
134
132
|
playPauseButton.tintColor = UIColor.systemGreen
|
|
135
133
|
playPauseButton.addTarget(self, action: #selector(playPauseTapped), for: .touchUpInside)
|
|
136
134
|
playPauseButton.translatesAutoresizingMaskIntoConstraints = false
|
|
137
135
|
|
|
138
|
-
|
|
139
|
-
let nextConfig = UIImage.SymbolConfiguration(pointSize: 24, weight: .medium)
|
|
136
|
+
let nextConfig = UIImage.SymbolConfiguration(pointSize: 20, weight: .medium)
|
|
140
137
|
nextButton.setImage(UIImage(systemName: "forward.end.fill", withConfiguration: nextConfig), for: .normal)
|
|
141
138
|
nextButton.tintColor = .white
|
|
142
139
|
nextButton.addTarget(self, action: #selector(nextTapped), for: .touchUpInside)
|
|
143
140
|
nextButton.translatesAutoresizingMaskIntoConstraints = false
|
|
144
141
|
|
|
145
|
-
// Stack
|
|
146
142
|
controlsStack.axis = .horizontal
|
|
147
143
|
controlsStack.alignment = .center
|
|
148
144
|
controlsStack.distribution = .equalCentering
|
|
149
|
-
controlsStack.spacing =
|
|
145
|
+
controlsStack.spacing = 28
|
|
150
146
|
controlsStack.addArrangedSubview(prevButton)
|
|
151
147
|
controlsStack.addArrangedSubview(playPauseButton)
|
|
152
148
|
controlsStack.addArrangedSubview(nextButton)
|
|
153
149
|
controlsStack.translatesAutoresizingMaskIntoConstraints = false
|
|
154
|
-
|
|
150
|
+
rightColumn.addSubview(controlsStack)
|
|
155
151
|
}
|
|
156
152
|
|
|
157
153
|
private func setupConstraints() {
|
|
158
154
|
let safeArea = view.safeAreaLayoutGuide
|
|
159
155
|
|
|
160
156
|
NSLayoutConstraint.activate([
|
|
161
|
-
//
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
//
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
//
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
// Status
|
|
190
|
-
statusLabel.topAnchor.constraint(equalTo:
|
|
191
|
-
statusLabel.centerXAnchor.constraint(equalTo:
|
|
192
|
-
|
|
193
|
-
// Controls
|
|
194
|
-
controlsStack.
|
|
195
|
-
controlsStack.centerXAnchor.constraint(equalTo:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
progressView.
|
|
208
|
-
progressView.leadingAnchor.constraint(equalTo: containerView.leadingAnchor),
|
|
209
|
-
progressView.trailingAnchor.constraint(equalTo: containerView.trailingAnchor),
|
|
157
|
+
// Left Column — sol taraf, artwork + text
|
|
158
|
+
leftColumn.topAnchor.constraint(equalTo: safeArea.topAnchor, constant: 8),
|
|
159
|
+
leftColumn.leadingAnchor.constraint(equalTo: safeArea.leadingAnchor, constant: 16),
|
|
160
|
+
leftColumn.bottomAnchor.constraint(lessThanOrEqualTo: safeArea.bottomAnchor, constant: -8),
|
|
161
|
+
leftColumn.widthAnchor.constraint(equalTo: safeArea.widthAnchor, multiplier: 0.35),
|
|
162
|
+
|
|
163
|
+
// Artwork — sol column ustunde, kare
|
|
164
|
+
artworkImageView.topAnchor.constraint(equalTo: leftColumn.topAnchor),
|
|
165
|
+
artworkImageView.centerXAnchor.constraint(equalTo: leftColumn.centerXAnchor),
|
|
166
|
+
artworkImageView.widthAnchor.constraint(equalTo: leftColumn.widthAnchor, constant: -8),
|
|
167
|
+
artworkImageView.heightAnchor.constraint(equalTo: artworkImageView.widthAnchor),
|
|
168
|
+
|
|
169
|
+
// Course Name — artwork altinda
|
|
170
|
+
courseNameLabel.topAnchor.constraint(equalTo: artworkImageView.bottomAnchor, constant: 6),
|
|
171
|
+
courseNameLabel.leadingAnchor.constraint(equalTo: leftColumn.leadingAnchor),
|
|
172
|
+
courseNameLabel.trailingAnchor.constraint(equalTo: leftColumn.trailingAnchor),
|
|
173
|
+
|
|
174
|
+
// Lesson Name — course altinda
|
|
175
|
+
lessonNameLabel.topAnchor.constraint(equalTo: courseNameLabel.bottomAnchor, constant: 2),
|
|
176
|
+
lessonNameLabel.leadingAnchor.constraint(equalTo: leftColumn.leadingAnchor),
|
|
177
|
+
lessonNameLabel.trailingAnchor.constraint(equalTo: leftColumn.trailingAnchor),
|
|
178
|
+
|
|
179
|
+
// Right Column — sag taraf, kontroller + progress
|
|
180
|
+
rightColumn.topAnchor.constraint(equalTo: safeArea.topAnchor, constant: 8),
|
|
181
|
+
rightColumn.leadingAnchor.constraint(equalTo: leftColumn.trailingAnchor, constant: 12),
|
|
182
|
+
rightColumn.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor, constant: -16),
|
|
183
|
+
rightColumn.bottomAnchor.constraint(lessThanOrEqualTo: safeArea.bottomAnchor, constant: -8),
|
|
184
|
+
|
|
185
|
+
// Status — sag column ust
|
|
186
|
+
statusLabel.topAnchor.constraint(equalTo: rightColumn.topAnchor, constant: 8),
|
|
187
|
+
statusLabel.centerXAnchor.constraint(equalTo: rightColumn.centerXAnchor),
|
|
188
|
+
|
|
189
|
+
// Controls — dikey merkez
|
|
190
|
+
controlsStack.centerYAnchor.constraint(equalTo: rightColumn.centerYAnchor, constant: -4),
|
|
191
|
+
controlsStack.centerXAnchor.constraint(equalTo: rightColumn.centerXAnchor),
|
|
192
|
+
|
|
193
|
+
prevButton.widthAnchor.constraint(greaterThanOrEqualToConstant: 40),
|
|
194
|
+
prevButton.heightAnchor.constraint(greaterThanOrEqualToConstant: 40),
|
|
195
|
+
playPauseButton.widthAnchor.constraint(greaterThanOrEqualToConstant: 48),
|
|
196
|
+
playPauseButton.heightAnchor.constraint(greaterThanOrEqualToConstant: 48),
|
|
197
|
+
nextButton.widthAnchor.constraint(greaterThanOrEqualToConstant: 40),
|
|
198
|
+
nextButton.heightAnchor.constraint(greaterThanOrEqualToConstant: 40),
|
|
199
|
+
|
|
200
|
+
// Progress Bar — controls altinda
|
|
201
|
+
progressView.topAnchor.constraint(equalTo: controlsStack.bottomAnchor, constant: 10),
|
|
202
|
+
progressView.leadingAnchor.constraint(equalTo: rightColumn.leadingAnchor),
|
|
203
|
+
progressView.trailingAnchor.constraint(equalTo: rightColumn.trailingAnchor),
|
|
210
204
|
progressView.heightAnchor.constraint(equalToConstant: 3),
|
|
211
205
|
|
|
212
|
-
// Time Stack
|
|
213
|
-
timeStack.topAnchor.constraint(equalTo: progressView.bottomAnchor, constant:
|
|
214
|
-
timeStack.leadingAnchor.constraint(equalTo:
|
|
215
|
-
timeStack.trailingAnchor.constraint(equalTo:
|
|
206
|
+
// Time Stack — progress altinda
|
|
207
|
+
timeStack.topAnchor.constraint(equalTo: progressView.bottomAnchor, constant: 3),
|
|
208
|
+
timeStack.leadingAnchor.constraint(equalTo: rightColumn.leadingAnchor),
|
|
209
|
+
timeStack.trailingAnchor.constraint(equalTo: rightColumn.trailingAnchor),
|
|
216
210
|
])
|
|
217
211
|
}
|
|
218
212
|
|
|
@@ -226,7 +220,7 @@ class NeoSkolaNowPlayingViewController: UIViewController {
|
|
|
226
220
|
func updatePlaybackState(isPlaying: Bool) {
|
|
227
221
|
self.isPlaying = isPlaying
|
|
228
222
|
|
|
229
|
-
let config = UIImage.SymbolConfiguration(pointSize:
|
|
223
|
+
let config = UIImage.SymbolConfiguration(pointSize: 36, weight: .medium)
|
|
230
224
|
let iconName = isPlaying ? "pause.circle.fill" : "play.circle.fill"
|
|
231
225
|
playPauseButton.setImage(UIImage(systemName: iconName, withConfiguration: config), for: .normal)
|
|
232
226
|
playPauseButton.tintColor = isPlaying ? UIColor.systemOrange : UIColor.systemGreen
|