Skip to content

Commit

Permalink
refactor: carplay pigeon api refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
illuminati1911 committed Nov 14, 2024
1 parent 8add516 commit 523d66b
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ class GoogleMapsAutoViewMessageHandler(private val viewRegistry: GoogleMapsViewR
}
}

override fun awaitMapReady(callback: (Result<Unit>) -> Unit) {
return getView().awaitMapReady(callback)
}

override fun isMyLocationEnabled(): Boolean {
return getView().isMyLocationEnabled()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6240,8 +6240,6 @@ private object AutoMapViewApiCodec : StandardMessageCodec() {

/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
interface AutoMapViewApi {
fun awaitMapReady(callback: (Result<Unit>) -> Unit)

fun isMyLocationEnabled(): Boolean

fun setMyLocationEnabled(enabled: Boolean)
Expand Down Expand Up @@ -6420,28 +6418,6 @@ interface AutoMapViewApi {
/** Sets up an instance of `AutoMapViewApi` to handle messages through the `binaryMessenger`. */
@Suppress("UNCHECKED_CAST")
fun setUp(binaryMessenger: BinaryMessenger, api: AutoMapViewApi?) {
run {
val channel =
BasicMessageChannel<Any?>(
binaryMessenger,
"dev.flutter.pigeon.google_navigation_flutter.AutoMapViewApi.awaitMapReady",
codec,
)
if (api != null) {
channel.setMessageHandler { _, reply ->
api.awaitMapReady() { result: Result<Unit> ->
val error = result.exceptionOrNull()
if (error != null) {
reply.reply(wrapError(error))
} else {
reply.reply(wrapResult(null))
}
}
}
} else {
channel.setMessageHandler(null)
}
}
run {
val channel =
BasicMessageChannel<Any?>(
Expand Down
3 changes: 1 addition & 2 deletions ios/Classes/GoogleMapsNavigationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ class GoogleMapsNavigationView: NSObject, FlutterPlatformView, ViewSettledDelega
mapConfiguration: MapConfiguration,
imageRegistry: ImageRegistry,
isCarPlayView: Bool) {

if (!isCarPlayView && (viewId == nil || viewEventApi == nil)) {
if !isCarPlayView, viewId == nil || viewEventApi == nil {
fatalError("For non-carplay map view viewId and viewEventApi is required")
}

Expand Down
20 changes: 0 additions & 20 deletions ios/Classes/messages.g.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5737,7 +5737,6 @@ class AutoMapViewApiCodec: FlutterStandardMessageCodec {

/// Generated protocol from Pigeon that represents a handler of messages from Flutter.
protocol AutoMapViewApi {
func awaitMapReady(completion: @escaping (Result<Void, Error>) -> Void)
func isMyLocationEnabled() throws -> Bool
func setMyLocationEnabled(enabled: Bool) throws
func getMyLocation() throws -> LatLngDto?
Expand Down Expand Up @@ -5826,25 +5825,6 @@ enum AutoMapViewApiSetup {
static var codec: FlutterStandardMessageCodec { AutoMapViewApiCodec.shared }
/// Sets up an instance of `AutoMapViewApi` to handle messages through the `binaryMessenger`.
static func setUp(binaryMessenger: FlutterBinaryMessenger, api: AutoMapViewApi?) {
let awaitMapReadyChannel = FlutterBasicMessageChannel(
name: "dev.flutter.pigeon.google_navigation_flutter.AutoMapViewApi.awaitMapReady",
binaryMessenger: binaryMessenger,
codec: codec
)
if let api {
awaitMapReadyChannel.setMessageHandler { _, reply in
api.awaitMapReady { result in
switch result {
case .success:
reply(wrapResult(nil))
case let .failure(error):
reply(wrapError(error))
}
}
}
} else {
awaitMapReadyChannel.setMessageHandler(nil)
}
let isMyLocationEnabledChannel = FlutterBasicMessageChannel(
name: "dev.flutter.pigeon.google_navigation_flutter.AutoMapViewApi.isMyLocationEnabled",
binaryMessenger: binaryMessenger,
Expand Down
3 changes: 0 additions & 3 deletions lib/src/google_navigation_flutter_platform_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,6 @@ abstract mixin class MapViewAPIInterface {
}

abstract mixin class AutoMapViewAPIInterface {
/// Awaits the auto view to be ready for communication.
Future<void> awaitMapReadyForAuto();

/// Get the preference for whether the my location should be enabled or disabled.
Future<bool> isMyLocationEnabledForAuto();

Expand Down
5 changes: 0 additions & 5 deletions lib/src/method_channel/common_auto_view_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ mixin CommonAutoMapViewAPI on AutoMapViewAPIInterface {
}
}

@override
Future<void> awaitMapReadyForAuto() {
return _viewApi.awaitMapReady();
}

@override
Future<bool> isMyLocationEnabledForAuto() {
return _viewApi.isMyLocationEnabled();
Expand Down
24 changes: 0 additions & 24 deletions lib/src/method_channel/messages.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6628,30 +6628,6 @@ class AutoMapViewApi {
static const MessageCodec<Object?> pigeonChannelCodec =
_AutoMapViewApiCodec();

Future<void> awaitMapReady() async {
const String __pigeon_channelName =
'dev.flutter.pigeon.google_navigation_flutter.AutoMapViewApi.awaitMapReady';
final BasicMessageChannel<Object?> __pigeon_channel =
BasicMessageChannel<Object?>(
__pigeon_channelName,
pigeonChannelCodec,
binaryMessenger: __pigeon_binaryMessenger,
);
final List<Object?>? __pigeon_replyList =
await __pigeon_channel.send(null) as List<Object?>?;
if (__pigeon_replyList == null) {
throw _createConnectionError(__pigeon_channelName);
} else if (__pigeon_replyList.length > 1) {
throw PlatformException(
code: __pigeon_replyList[0]! as String,
message: __pigeon_replyList[1] as String?,
details: __pigeon_replyList[2],
);
} else {
return;
}
}

Future<bool> isMyLocationEnabled() async {
const String __pigeon_channelName =
'dev.flutter.pigeon.google_navigation_flutter.AutoMapViewApi.isMyLocationEnabled';
Expand Down
3 changes: 0 additions & 3 deletions pigeons/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1256,9 +1256,6 @@ abstract class NavigationSessionEventApi {

@HostApi()
abstract class AutoMapViewApi {
@async
void awaitMapReady();

bool isMyLocationEnabled();
void setMyLocationEnabled(bool enabled);
LatLngDto? getMyLocation();
Expand Down

0 comments on commit 523d66b

Please sign in to comment.