From a4714dfb1bc7b1c98e7ea6ecac82af66ac85160f Mon Sep 17 00:00:00 2001 From: gianlucaparadise Date: Mon, 15 Nov 2021 08:55:49 +0100 Subject: [PATCH] CastIcon always visible - Fix indentation - Fix private var visibility --- README.md | 6 +++--- lib/src/cast/CastContext.dart | 8 ++++---- lib/src/cast/SessionManager.dart | 8 ++++---- lib/src/cast/widgets/CastIcon.dart | 5 +++-- lib/src/flutter_cast_framework.dart | 29 +++++++++++++++++++---------- 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index abdbf5a..405bec0 100644 --- a/README.md +++ b/README.md @@ -72,8 +72,8 @@ Make sure that your application and your activity are using an `AppCompat` theme #### 1. Minimum iOS version -Make sure you minimum iOS version is 9.0. -Select *Runner* from left pane > *General* tab > *Deployment Info* > *Target*: set 9.0 or higher +Make sure you minimum iOS version is 10.0. +Select *Runner* from left pane > *General* tab > *Deployment Info* > *Target*: set 10.0 or higher #### 2. Install iOS dependencies @@ -85,7 +85,7 @@ cd ios && pod install #### 3. Open project in Xcode -To open your flutter project with Xcode running `open ios/Runner.xcworkspace` +To open your flutter project with Xcode, from root folder run `open ios/Runner.xcworkspace` #### 4. Chromecast SDK setup diff --git a/lib/src/cast/CastContext.dart b/lib/src/cast/CastContext.dart index ada6e10..7c48dd8 100644 --- a/lib/src/cast/CastContext.dart +++ b/lib/src/cast/CastContext.dart @@ -4,12 +4,12 @@ import 'SessionManager.dart'; class CastContext { final ValueNotifier state = ValueNotifier(CastState.unavailable); - final CastHostApi hostApi; + final CastHostApi _hostApi; - CastContext(this.hostApi); + CastContext(this._hostApi); void showCastChooserDialog() { - hostApi.showCastDialog(); + _hostApi.showCastDialog(); } void onCastStateChanged(int castState) { @@ -20,7 +20,7 @@ class CastContext { SessionManager get sessionManager { var result = _sessionManager; if (result == null) { - _sessionManager = result = SessionManager(hostApi); + _sessionManager = result = SessionManager(_hostApi); } return result; } diff --git a/lib/src/cast/SessionManager.dart b/lib/src/cast/SessionManager.dart index ed9bf17..b2d5696 100644 --- a/lib/src/cast/SessionManager.dart +++ b/lib/src/cast/SessionManager.dart @@ -3,9 +3,9 @@ import '../PlatformBridgeApis.dart'; import 'RemoteMediaClient.dart'; class SessionManager { - final CastHostApi hostApi; + final CastHostApi _hostApi; - SessionManager(this.hostApi); + SessionManager(this._hostApi); final ValueNotifier state = ValueNotifier(SessionState.idle); @@ -44,14 +44,14 @@ class SessionManager { final castMessage = CastMessage(); castMessage.namespace = namespace; castMessage.message = message; - hostApi.sendMessage(castMessage); + _hostApi.sendMessage(castMessage); } RemoteMediaClient? _remoteMediaClient; RemoteMediaClient get remoteMediaClient { var result = _remoteMediaClient; if (result == null) { - _remoteMediaClient = result = RemoteMediaClient(hostApi); + _remoteMediaClient = result = RemoteMediaClient(_hostApi); } return result; } diff --git a/lib/src/cast/widgets/CastIcon.dart b/lib/src/cast/widgets/CastIcon.dart index 142d89d..c52a4d0 100644 --- a/lib/src/cast/widgets/CastIcon.dart +++ b/lib/src/cast/widgets/CastIcon.dart @@ -5,6 +5,7 @@ import '../../flutter_cast_framework.dart'; import '../CastContext.dart'; const Color _defaultIconColor = Color.fromARGB(255, 255, 255, 255); // white +const Color _disabledIconColor = Color.fromARGB(255, 201, 201, 201); // gray class CastIcon extends StatefulWidget { final Color color; @@ -58,7 +59,7 @@ class _CastIconState extends State with TickerProviderStateMixin { Widget build(BuildContext context) { switch (_castState) { case CastState.unavailable: - return _getEmpty(); + return _getButton("assets/ic_cast_24dp.svg", _disabledIconColor); case CastState.unconnected: return _getButton("assets/ic_cast_24dp.svg", widget.color); @@ -72,7 +73,7 @@ class _CastIconState extends State with TickerProviderStateMixin { case CastState.idle: default: debugPrint("State not handled: $_castState"); - return _getEmpty(); + return _getButton("assets/ic_cast_24dp.svg", _disabledIconColor); } } } diff --git a/lib/src/flutter_cast_framework.dart b/lib/src/flutter_cast_framework.dart index e25496c..d5bc1ac 100644 --- a/lib/src/flutter_cast_framework.dart +++ b/lib/src/flutter_cast_framework.dart @@ -37,49 +37,58 @@ class FlutterCastFramework extends CastFlutterApi { //region Session State handling @override void onSessionEnded() { - castContext.sessionManager.onSessionStateChanged(SessionState.session_ended); + castContext.sessionManager + .onSessionStateChanged(SessionState.session_ended); } @override void onSessionEnding() { - castContext.sessionManager.onSessionStateChanged(SessionState.session_ending); + castContext.sessionManager + .onSessionStateChanged(SessionState.session_ending); } @override void onSessionResumeFailed() { - castContext.sessionManager.onSessionStateChanged(SessionState.session_resume_failed); + castContext.sessionManager + .onSessionStateChanged(SessionState.session_resume_failed); } @override void onSessionResumed() { - castContext.sessionManager.onSessionStateChanged(SessionState.session_resumed); + castContext.sessionManager + .onSessionStateChanged(SessionState.session_resumed); } @override void onSessionResuming() { - castContext.sessionManager.onSessionStateChanged(SessionState.session_resuming); + castContext.sessionManager + .onSessionStateChanged(SessionState.session_resuming); } @override void onSessionStartFailed() { - castContext.sessionManager.onSessionStateChanged(SessionState.session_start_failed); + castContext.sessionManager + .onSessionStateChanged(SessionState.session_start_failed); } @override void onSessionStarted() { - castContext.sessionManager.onSessionStateChanged(SessionState.session_started); + castContext.sessionManager + .onSessionStateChanged(SessionState.session_started); } @override void onSessionStarting() { - castContext.sessionManager.onSessionStateChanged(SessionState.session_starting); + castContext.sessionManager + .onSessionStateChanged(SessionState.session_starting); } @override void onSessionSuspended() { - castContext.sessionManager.onSessionStateChanged(SessionState.session_suspended); + castContext.sessionManager + .onSessionStateChanged(SessionState.session_suspended); } //endregion //endregion -} \ No newline at end of file +}