Skip to content

Commit e1f21e9

Browse files
authored
Merge pull request #204 from analogcode/dev
Improve station tap behavior and bump to 3.0.0
2 parents 5af4ce2 + 34698be commit e1f21e9

File tree

6 files changed

+23
-19
lines changed

6 files changed

+23
-19
lines changed

SwiftRadio.xcodeproj/project.pbxproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
CA58087D2D40BAC000F8082B /* CarPlaySceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA58087B2D40BAC000F8082B /* CarPlaySceneDelegate.swift */; };
5151
CA5F00022F40A00000000002 /* GradientBackgroundView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA5F00012F40A00000000001 /* GradientBackgroundView.swift */; };
5252
CA5F00032F40A00000000003 /* GradientBackgroundView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA5F00012F40A00000000001 /* GradientBackgroundView.swift */; };
53+
CA5F00042F41000000000001 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = CA5F00062F41000000000003 /* Localizable.xcstrings */; };
54+
CA5F00052F41000000000002 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = CA5F00062F41000000000003 /* Localizable.xcstrings */; };
5355
CA900001200000000000000A /* MarqueeLabel in Frameworks */ = {isa = PBXBuildFile; productRef = CA900002200000000000000A /* MarqueeLabel */; };
5456
CAB4E8292D3D7DC7001282E9 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAB4E8282D3D7DC7001282E9 /* SceneDelegate.swift */; };
5557
CAB4E82A2D3D7DC7001282E9 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAB4E8282D3D7DC7001282E9 /* SceneDelegate.swift */; };
@@ -103,8 +105,6 @@
103105
CEE9A27C2B535C780018FE68 /* AlbumArtworkView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEE9A27A2B535C780018FE68 /* AlbumArtworkView.swift */; };
104106
CEE9A27E2B54A5520018FE68 /* ControlsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEE9A27D2B54A5520018FE68 /* ControlsView.swift */; };
105107
CEE9A27F2B54A5520018FE68 /* ControlsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEE9A27D2B54A5520018FE68 /* ControlsView.swift */; };
106-
CA5F00042F41000000000001 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = CA5F00062F41000000000003 /* Localizable.xcstrings */; };
107-
CA5F00052F41000000000002 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = CA5F00062F41000000000003 /* Localizable.xcstrings */; };
108108
/* End PBXBuildFile section */
109109

110110
/* Begin PBXContainerItemProxy section */
@@ -173,6 +173,7 @@
173173
CA3A11032D4E000000111002 /* Content.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Content.swift; sourceTree = "<group>"; };
174174
CA58087B2D40BAC000F8082B /* CarPlaySceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarPlaySceneDelegate.swift; sourceTree = "<group>"; };
175175
CA5F00012F40A00000000001 /* GradientBackgroundView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GradientBackgroundView.swift; sourceTree = "<group>"; };
176+
CA5F00062F41000000000003 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
176177
CAB4E8282D3D7DC7001282E9 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
177178
CE0A4994291F3A220071C0CC /* SwiftRadio.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SwiftRadio.entitlements; sourceTree = "<group>"; };
178179
CE321FF229371140001572BD /* Bundle+appName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundle+appName.swift"; sourceTree = "<group>"; };
@@ -193,7 +194,6 @@
193194
CEE9A2772B5345C30018FE68 /* NowPlayingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NowPlayingViewController.swift; sourceTree = "<group>"; };
194195
CEE9A27A2B535C780018FE68 /* AlbumArtworkView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumArtworkView.swift; sourceTree = "<group>"; };
195196
CEE9A27D2B54A5520018FE68 /* ControlsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ControlsView.swift; sourceTree = "<group>"; };
196-
CA5F00062F41000000000003 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
197197
/* End PBXFileReference section */
198198

199199
/* Begin PBXFrameworksBuildPhase section */
@@ -856,7 +856,7 @@
856856
"$(inherited)",
857857
"@executable_path/Frameworks",
858858
);
859-
MARKETING_VERSION = 2.0.8;
859+
MARKETING_VERSION = 3.0.0;
860860
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11";
861861
PRODUCT_BUNDLE_IDENTIFIER = com.matthewfecher.SwiftRadio;
862862
PRODUCT_NAME = SwiftRadio;
@@ -888,7 +888,7 @@
888888
"$(inherited)",
889889
"@executable_path/Frameworks",
890890
);
891-
MARKETING_VERSION = 2.0.8;
891+
MARKETING_VERSION = 3.0.0;
892892
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11";
893893
PRODUCT_BUNDLE_IDENTIFIER = com.matthewfecher.SwiftRadio;
894894
PRODUCT_NAME = SwiftRadio;
@@ -923,7 +923,7 @@
923923
"$(inherited)",
924924
"@executable_path/Frameworks",
925925
);
926-
MARKETING_VERSION = 2.0.8;
926+
MARKETING_VERSION = 3.0.0;
927927
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11";
928928
OTHER_SWIFT_FLAGS = "-D CarPlay";
929929
PRODUCT_BUNDLE_IDENTIFIER = com.fethica.SwiftRadio;
@@ -960,7 +960,7 @@
960960
"$(inherited)",
961961
"@executable_path/Frameworks",
962962
);
963-
MARKETING_VERSION = 2.0.8;
963+
MARKETING_VERSION = 3.0.0;
964964
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11";
965965
OTHER_SWIFT_FLAGS = "-D CarPlay";
966966
PRODUCT_BUNDLE_IDENTIFIER = com.fethica.SwiftRadio;

SwiftRadio/Coordinators/MainCoordinator.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import UIKit
1010
import MessageUI
1111
import SafariServices
1212
import LNPopupController
13+
import FRadioPlayer
1314

1415
class MainCoordinator: NavigationCoordinator {
1516
var childCoordinators: [Coordinator] = []
@@ -21,6 +22,7 @@ class MainCoordinator: NavigationCoordinator {
2122
return vc
2223
}()
2324

25+
private let player = FRadioPlayer.shared
2426
private var isPopupBarPresented = false
2527

2628
func start() {
@@ -101,8 +103,10 @@ extension MainCoordinator: StationsViewControllerDelegate {
101103
if isNewStation {
102104
StationsManager.shared.set(station: station)
103105
presentPopupBarIfNeeded()
104-
} else {
106+
} else if player.isPlaying {
105107
navigationController.openPopup(animated: true)
108+
} else {
109+
player.togglePlaying()
106110
}
107111
}
108112

50.3 KB
Loading
218 KB
Loading
498 KB
Loading

SwiftRadio/ViewControllers/StationsViewController.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ class StationsViewController: BaseController, Handoffable {
5454
return view
5555
}()
5656

57+
private lazy var nowPlayingBarButton: UIBarButtonItem = {
58+
let barButton = UIBarButtonItem(customView: nowPlayingIndicator)
59+
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(nowPlayingBarButtonPressed))
60+
nowPlayingIndicator.addGestureRecognizer(tapGesture)
61+
nowPlayingIndicator.isUserInteractionEnabled = true
62+
return barButton
63+
}()
64+
5765
private lazy var nowPlayingIndicator: UIView = {
5866
let container = UIView()
5967
container.addSubview(equalizerView)
@@ -136,30 +144,22 @@ class StationsViewController: BaseController, Handoffable {
136144
navigationItem.rightBarButtonItem = nil
137145
return
138146
}
139-
140-
guard navigationItem.rightBarButtonItem == nil else { return }
141-
let barButton = UIBarButtonItem(customView: nowPlayingIndicator)
142-
barButton.target = self
143-
barButton.action = #selector(nowPlayingBarButtonPressed)
144-
145-
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(nowPlayingBarButtonPressed))
146-
nowPlayingIndicator.addGestureRecognizer(tapGesture)
147-
nowPlayingIndicator.isUserInteractionEnabled = true
148-
149-
navigationItem.rightBarButtonItem = barButton
150147
updateNowPlayingAnimation()
151148
}
152149

153150
private func updateNowPlayingAnimation() {
154151
if isBuffering {
155152
equalizerView.stopAnimating()
156153
bufferingView.startAnimating()
154+
navigationItem.rightBarButtonItem = nowPlayingBarButton
157155
} else if player.isPlaying {
158156
bufferingView.stopAnimating()
159157
equalizerView.startAnimating()
158+
navigationItem.rightBarButtonItem = nowPlayingBarButton
160159
} else {
161160
equalizerView.stopAnimating()
162161
bufferingView.stopAnimating()
162+
navigationItem.rightBarButtonItem = nil
163163
}
164164
}
165165

0 commit comments

Comments
 (0)