Skip to content

Commit b8c5b98

Browse files
committed
WaitingQueue: postpone feature
1 parent 1163e8a commit b8c5b98

File tree

22 files changed

+18
-92
lines changed

22 files changed

+18
-92
lines changed

Amperfy/Assets.xcassets/Contents.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"info" : {
3-
"version" : 1,
4-
"author" : "xcode"
3+
"author" : "xcode",
4+
"version" : 1
55
}
6-
}
6+
}

Amperfy/Assets.xcassets/main_insert.imageset/Contents.json Amperfy/Assets.xcassets/context_queue_append.imageset/Contents.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"scale" : "2x"
1010
},
1111
{
12-
"filename" : "main_insert.png",
12+
"filename" : "context_queue_append.png",
1313
"idiom" : "universal",
1414
"scale" : "3x"
1515
}
Loading

Amperfy/Assets.xcassets/waiting_insert.imageset/Contents.json Amperfy/Assets.xcassets/context_queue_insert.imageset/Contents.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"scale" : "2x"
1010
},
1111
{
12-
"filename" : "waiting_insert.png",
12+
"filename" : "context_queue_insert.png",
1313
"idiom" : "universal",
1414
"scale" : "3x"
1515
}
Loading
Binary file not shown.
Binary file not shown.

Amperfy/Assets.xcassets/main_append.imageset/Contents.json Amperfy/Assets.xcassets/user_queue_append.imageset/Contents.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"scale" : "2x"
1010
},
1111
{
12-
"filename" : "main_append.png",
12+
"filename" : "user_queue_append.png",
1313
"idiom" : "universal",
1414
"scale" : "3x"
1515
}
Loading

Amperfy/Assets.xcassets/waiting_append.imageset/Contents.json Amperfy/Assets.xcassets/user_queue_insert.imageset/Contents.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"scale" : "2x"
1010
},
1111
{
12-
"filename" : "waiting_append.png",
12+
"filename" : "user_queue_insert.png",
1313
"idiom" : "universal",
1414
"scale" : "3x"
1515
}
Loading
Binary file not shown.
Binary file not shown.

Amperfy/Player/PlayerUtil.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ enum PlayerQueueType: Int, CaseIterable {
4141

4242
var description : String {
4343
switch self {
44-
case .prev: return "Previous in Main Queue"
44+
case .prev: return "Previous"
4545
case .waitingQueue: return "Next in Waiting Queue"
46-
case .next: return "Next in Main Queue"
46+
case .next: return "Next"
4747
}
4848
}
4949
}

Amperfy/Screens/ViewController/BasicTableViewController.swift

+6-41
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ typealias QueueSwipeCallback = (IndexPath, _ completionHandler: @escaping (_ pla
3535

3636
extension BasicTableViewController {
3737
func createInsertNextQueueSwipeAction(indexPath: IndexPath, actionCallback: @escaping QueueSwipeCallback) -> UIContextualAction {
38-
let action = UIContextualAction(style: .normal, title: "Insert into Next in Main Queue") { (action, view, completionHandler) in
38+
let action = UIContextualAction(style: .normal, title: "Play Next") { (action, view, completionHandler) in
3939
let generator = UINotificationFeedbackGenerator()
4040
generator.notificationOccurred(.success)
4141
actionCallback(indexPath) { playables in
@@ -44,49 +44,21 @@ extension BasicTableViewController {
4444
completionHandler(true)
4545
}
4646
action.backgroundColor = .systemBlue
47-
action.image = UIImage(named: "main_insert")?.invertedImage()
48-
return action
49-
}
50-
51-
func createInsertWaitingQueueSwipeAction(indexPath: IndexPath, actionCallback: @escaping QueueSwipeCallback) -> UIContextualAction {
52-
let action = UIContextualAction(style: .normal, title: "Insert into Next in Waiting Queue") { (action, view, completionHandler) in
53-
let generator = UIImpactFeedbackGenerator(style: .light)
54-
generator.impactOccurred()
55-
actionCallback(indexPath) { playables in
56-
self.appDelegate.player.insertFirstToWaitingQueue(playables: playables.filterCached(dependigOn: self.appDelegate.persistentStorage.settings.isOfflineMode))
57-
}
58-
completionHandler(true)
59-
}
60-
action.backgroundColor = .systemOrange
61-
action.image = UIImage(named: "waiting_insert")?.invertedImage()
47+
action.image = UIImage(named: "context_queue_insert")?.invertedImage()
6248
return action
6349
}
6450

6551
func createAppendNextQueueSwipeAction(indexPath: IndexPath, actionCallback: @escaping QueueSwipeCallback) -> UIContextualAction {
66-
let action = UIContextualAction(style: .normal, title: "Append to Next in Main Queue") { (action, view, completionHandler) in
52+
let action = UIContextualAction(style: .normal, title: "Play Later") { (action, view, completionHandler) in
6753
let generator = UINotificationFeedbackGenerator()
6854
generator.notificationOccurred(.success)
6955
actionCallback(indexPath) { playables in
7056
self.appDelegate.player.appendToNextInMainQueue(playables: playables.filterCached(dependigOn: self.appDelegate.persistentStorage.settings.isOfflineMode))
7157
}
7258
completionHandler(true)
7359
}
74-
action.backgroundColor = .systemBlue
75-
action.image = UIImage(named: "main_append")?.invertedImage()
76-
return action
77-
}
78-
79-
func createAppendWaitingQueueSwipeAction(indexPath: IndexPath, actionCallback: @escaping QueueSwipeCallback) -> UIContextualAction {
80-
let action = UIContextualAction(style: .normal, title: "Append to Next in Waiting Queue") { (action, view, completionHandler) in
81-
let generator = UIImpactFeedbackGenerator(style: .light)
82-
generator.impactOccurred()
83-
actionCallback(indexPath) { playables in
84-
self.appDelegate.player.appendToWaitingQueue(playables: playables.filterCached(dependigOn: self.appDelegate.persistentStorage.settings.isOfflineMode))
85-
}
86-
completionHandler(true)
87-
}
8860
action.backgroundColor = .systemOrange
89-
action.image = UIImage(named: "waiting_append")?.invertedImage()
61+
action.image = UIImage(named: "context_queue_append")?.invertedImage()
9062
return action
9163
}
9264
}
@@ -120,18 +92,11 @@ class BasicTableViewController: UITableViewController {
12092
updateSearchResults(for: searchController)
12193
}
12294

123-
override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
124-
guard let swipeCB = swipeCallback else { return nil }
125-
return UISwipeActionsConfiguration(actions: [
126-
createInsertNextQueueSwipeAction(indexPath: indexPath, actionCallback: swipeCB),
127-
createInsertWaitingQueueSwipeAction(indexPath: indexPath, actionCallback: swipeCB)
128-
])
129-
}
13095
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
13196
guard let swipeCB = swipeCallback else { return nil }
13297
return UISwipeActionsConfiguration(actions: [
133-
createAppendNextQueueSwipeAction(indexPath: indexPath, actionCallback: swipeCB),
134-
createAppendWaitingQueueSwipeAction(indexPath: indexPath, actionCallback: swipeCB)
98+
createInsertNextQueueSwipeAction(indexPath: indexPath, actionCallback: swipeCB),
99+
createAppendNextQueueSwipeAction(indexPath: indexPath, actionCallback: swipeCB)
135100
])
136101
}
137102

Amperfy/Screens/ViewController/DirectoriesVC.swift

+2-17
Original file line numberDiff line numberDiff line change
@@ -80,31 +80,16 @@ class DirectoriesVC: BasicTableViewController {
8080
return 0.0
8181
}
8282
}
83-
84-
override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
85-
guard indexPath.section == 1 else { return nil }
86-
let adjustedIndexPath = IndexPath(row: indexPath.row , section: 0)
87-
return UISwipeActionsConfiguration(actions: [
88-
createInsertNextQueueSwipeAction(indexPath: adjustedIndexPath) { (indexPath, completionHandler) in
89-
let song = self.songsFetchedResultsController.getWrappedEntity(at: indexPath)
90-
completionHandler([song])
91-
},
92-
createInsertWaitingQueueSwipeAction(indexPath: adjustedIndexPath) { (indexPath, completionHandler) in
93-
let song = self.songsFetchedResultsController.getWrappedEntity(at: indexPath)
94-
completionHandler([song])
95-
}
96-
])
97-
}
9883

9984
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
10085
guard indexPath.section == 1 else { return nil }
10186
let adjustedIndexPath = IndexPath(row: indexPath.row , section: 0)
10287
return UISwipeActionsConfiguration(actions: [
103-
createAppendNextQueueSwipeAction(indexPath: adjustedIndexPath) { (indexPath, completionHandler) in
88+
createInsertNextQueueSwipeAction(indexPath: adjustedIndexPath) { (indexPath, completionHandler) in
10489
let song = self.songsFetchedResultsController.getWrappedEntity(at: indexPath)
10590
completionHandler([song])
10691
},
107-
createAppendWaitingQueueSwipeAction(indexPath: adjustedIndexPath) { (indexPath, completionHandler) in
92+
createAppendNextQueueSwipeAction(indexPath: adjustedIndexPath) { (indexPath, completionHandler) in
10893
let song = self.songsFetchedResultsController.getWrappedEntity(at: indexPath)
10994
completionHandler([song])
11095
}

Amperfy/Screens/ViewController/PopupPlayerVC.swift

+1-25
Original file line numberDiff line numberDiff line change
@@ -247,26 +247,7 @@ class PopupPlayerVC: UIViewController, UITableViewDelegate, UITableViewDataSourc
247247

248248
func refreshWaitingQueueSectionHeader() {
249249
let waitingQueueSectionView = sectionViews[1]
250-
if player.waitingQueue.isEmpty {
251-
waitingQueueSectionView.hide()
252-
} else {
253-
waitingQueueSectionView.display(type: .waitingQueue, buttonTitle: "Clear") {
254-
self.clearWaitingQueue()
255-
}
256-
}
257-
}
258-
259-
func clearWaitingQueue() {
260-
tableView.beginUpdates()
261-
var indexPaths = [IndexPath]()
262-
for i in 0...self.player.waitingQueue.count-1 {
263-
indexPaths.append(IndexPath(row: i, section: 1))
264-
}
265-
tableView.deleteRows(at: indexPaths, with: .fade)
266-
appDelegate.player.clearWaitingQueue()
267-
tableView.endUpdates()
268-
refreshWaitingQueueSectionHeader()
269-
playerView?.refreshPlayer()
250+
waitingQueueSectionView.hide()
270251
}
271252

272253
// Override to support conditional rearranging of the table view.
@@ -307,11 +288,6 @@ class PopupPlayerVC: UIViewController, UITableViewDelegate, UITableViewDataSourc
307288
self.reloadData()
308289
self.playerView?.refreshPlayer()
309290
}))
310-
if !player.waitingQueue.isEmpty {
311-
alert.addAction(UIAlertAction(title: "Clear Waiting Queue", style: .default, handler: { _ in
312-
self.clearWaitingQueue()
313-
}))
314-
}
315291
if appDelegate.persistentStorage.settings.isOnlineMode {
316292
alert.addAction(UIAlertAction(title: "Add all songs to playlist", style: .default, handler: { _ in
317293
let selectPlaylistVC = PlaylistSelectorVC.instantiateFromAppStoryboard()

Design/Playlist.xcf

528 Bytes
Binary file not shown.

Design/context_queue_append.png

9.82 KB
Loading

Design/context_queue_insert.png

9.71 KB
Loading

Design/user_queue_append.png

10.7 KB
Loading

Design/user_queue_insert.png

10.6 KB
Loading

0 commit comments

Comments
 (0)