CastIcon always visible
- Fix indentation - Fix private var visibility
This commit is contained in:
parent
db0855c37c
commit
a4714dfb1b
5 changed files with 33 additions and 23 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ import 'SessionManager.dart';
|
|||
|
||||
class CastContext {
|
||||
final ValueNotifier<CastState> 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<SessionState> 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<CastIcon> 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<CastIcon> with TickerProviderStateMixin {
|
|||
case CastState.idle:
|
||||
default:
|
||||
debugPrint("State not handled: $_castState");
|
||||
return _getEmpty();
|
||||
return _getButton("assets/ic_cast_24dp.svg", _disabledIconColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,47 +37,56 @@ 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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue