-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25971e2
commit 333515d
Showing
61 changed files
with
1,426 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
DemoProjects/NowPlayingView/NowPlayingView/Assets.xcassets/skipback15.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "skipback15.png", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "[email protected]", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "[email protected]", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Binary file added
BIN
+791 Bytes
...owPlayingView/NowPlayingView/Assets.xcassets/skipback15.imageset/skipback15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.75 KB
...layingView/NowPlayingView/Assets.xcassets/skipback15.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.77 KB
...layingView/NowPlayingView/Assets.xcassets/skipback15.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions
23
...ojects/NowPlayingView/NowPlayingView/Assets.xcassets/skipforward15.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "skipforward15.png", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "[email protected]", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "[email protected]", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Binary file added
BIN
+751 Bytes
...ingView/NowPlayingView/Assets.xcassets/skipforward15.imageset/skipforward15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.7 KB
...View/NowPlayingView/Assets.xcassets/skipforward15.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.8 KB
...View/NowPlayingView/Assets.xcassets/skipforward15.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 55 additions & 11 deletions
66
DemoProjects/NowPlayingView/NowPlayingView/Base.lproj/Main.storyboard
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
DemoProjects/NowPlayingView/NowPlayingView/SpeedPickerViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
|
||
protocol SpeedPickerViewControllerDelegate { | ||
func speedPicker(viewController: SpeedPickerViewController, didChoose speed:SPTAppRemotePodcastPlaybackSpeed) | ||
func speedPickerDidCancel(viewController: SpeedPickerViewController) | ||
} | ||
|
||
|
||
class SpeedPickerViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { | ||
|
||
var delegate: SpeedPickerViewControllerDelegate? | ||
fileprivate let podcastSpeeds: [SPTAppRemotePodcastPlaybackSpeed] | ||
fileprivate var selectedSpeed: SPTAppRemotePodcastPlaybackSpeed | ||
fileprivate var selectedIndex: Int = 0 | ||
fileprivate let cellIdentifier = "SpeedCell" | ||
|
||
lazy var tableView: UITableView = { | ||
let tableView = UITableView(frame: self.view.bounds) | ||
tableView.delegate = self | ||
tableView.dataSource = self | ||
tableView.register(UITableViewCell.self, forCellReuseIdentifier: self.cellIdentifier) | ||
return tableView | ||
}() | ||
|
||
init(podcastSpeeds: [SPTAppRemotePodcastPlaybackSpeed], selectedSpeed: SPTAppRemotePodcastPlaybackSpeed) { | ||
self.podcastSpeeds = podcastSpeeds | ||
self.selectedSpeed = selectedSpeed | ||
super.init(nibName: nil, bundle: nil) | ||
updateSelectedindex() | ||
view.addSubview(tableView) | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
navigationItem.title = "Podcast Playback Speed" | ||
navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Cancel", style: .done, target: self, action: #selector(didPressCancel)) | ||
} | ||
|
||
fileprivate func updateSelectedindex() { | ||
let values = podcastSpeeds.map { $0.value } | ||
selectedIndex = values.distance(from: values.startIndex, to:values.index(of: self.selectedSpeed.value)!) | ||
} | ||
|
||
@objc func didPressCancel() { | ||
delegate?.speedPickerDidCancel(viewController: self) | ||
} | ||
|
||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ||
delegate?.speedPicker(viewController: self, didChoose: podcastSpeeds[indexPath.row]) | ||
selectedSpeed = podcastSpeeds[indexPath.row] | ||
selectedIndex = indexPath.row | ||
tableView.reloadData() | ||
} | ||
|
||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return podcastSpeeds.count | ||
} | ||
|
||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) | ||
cell.textLabel?.text = String(format: "%.1fx", podcastSpeeds[indexPath.row].value.floatValue) | ||
if indexPath.row == selectedIndex { | ||
cell.accessoryType = .checkmark | ||
} else { | ||
cell.accessoryType = .none | ||
} | ||
return cell | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.