Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the shared now playing implementation #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ios/Classes/FCPEnums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ enum FCPChannelTypes {
static let onPresentStateChanged = "onPresentStateChanged"
static let popTemplate = "popTemplate"
static let pushTemplate = "pushTemplate"
static let showNowPlaying = "showNowPlaying"
static let closePresent = "closePresent"
static let onGridButtonPressed = "onGridButtonPressed"
static let setActionSheet = "setActionSheet"
Expand Down
8 changes: 8 additions & 0 deletions ios/Classes/SwiftFlutterCarplayPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ public class SwiftFlutterCarplayPlugin: NSObject, FlutterPlugin {
self.objcPresentTemplate = nil
result(true)
break
case FCPChannelTypes.showNowPlaying:
guard let animated = call.arguments as? Bool else {
result(false)
return
}
FlutterCarPlaySceneDelegate.push(template: CPNowPlayingTemplate.shared, animated: animated)
result(true)
break
case FCPChannelTypes.pushTemplate:
guard let args = call.arguments as? [String : Any] else {
result(false)
Expand Down
13 changes: 13 additions & 0 deletions lib/carplay_worker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,17 @@ class FlutterCarplay {
throw TypeError();
}
}

/// Navigate to the shared instance of the NowPlaying Template
///
/// - If animated is true, CarPlay animates the transition between templates.
static Future<bool> showSharedNowPlaying({
bool animated = true,
}) async {
bool isCompleted = await _carPlayController.reactToNativeModule(
FCPChannelTypes.showNowPlaying,
animated,
);
return isCompleted;
}
}
1 change: 1 addition & 0 deletions lib/constants/private_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum FCPChannelTypes {
popTemplate,
closePresent,
pushTemplate,
showNowPlaying,
onGridButtonPressed,
setActionSheet,
onBarButtonPressed,
Expand Down