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
|
#### 1. Minimum iOS version
|
||||||
|
|
||||||
Make sure you minimum iOS version is 9.0.
|
Make sure you minimum iOS version is 10.0.
|
||||||
Select *Runner* from left pane > *General* tab > *Deployment Info* > *Target*: set 9.0 or higher
|
Select *Runner* from left pane > *General* tab > *Deployment Info* > *Target*: set 10.0 or higher
|
||||||
|
|
||||||
#### 2. Install iOS dependencies
|
#### 2. Install iOS dependencies
|
||||||
|
|
||||||
|
|
@ -85,7 +85,7 @@ cd ios && pod install
|
||||||
|
|
||||||
#### 3. Open project in Xcode
|
#### 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. Chromecast SDK setup
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,12 @@ import 'SessionManager.dart';
|
||||||
|
|
||||||
class CastContext {
|
class CastContext {
|
||||||
final ValueNotifier<CastState> state = ValueNotifier(CastState.unavailable);
|
final ValueNotifier<CastState> state = ValueNotifier(CastState.unavailable);
|
||||||
final CastHostApi hostApi;
|
final CastHostApi _hostApi;
|
||||||
|
|
||||||
CastContext(this.hostApi);
|
CastContext(this._hostApi);
|
||||||
|
|
||||||
void showCastChooserDialog() {
|
void showCastChooserDialog() {
|
||||||
hostApi.showCastDialog();
|
_hostApi.showCastDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onCastStateChanged(int castState) {
|
void onCastStateChanged(int castState) {
|
||||||
|
|
@ -20,7 +20,7 @@ class CastContext {
|
||||||
SessionManager get sessionManager {
|
SessionManager get sessionManager {
|
||||||
var result = _sessionManager;
|
var result = _sessionManager;
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
_sessionManager = result = SessionManager(hostApi);
|
_sessionManager = result = SessionManager(_hostApi);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ import '../PlatformBridgeApis.dart';
|
||||||
import 'RemoteMediaClient.dart';
|
import 'RemoteMediaClient.dart';
|
||||||
|
|
||||||
class SessionManager {
|
class SessionManager {
|
||||||
final CastHostApi hostApi;
|
final CastHostApi _hostApi;
|
||||||
|
|
||||||
SessionManager(this.hostApi);
|
SessionManager(this._hostApi);
|
||||||
|
|
||||||
final ValueNotifier<SessionState> state = ValueNotifier(SessionState.idle);
|
final ValueNotifier<SessionState> state = ValueNotifier(SessionState.idle);
|
||||||
|
|
||||||
|
|
@ -44,14 +44,14 @@ class SessionManager {
|
||||||
final castMessage = CastMessage();
|
final castMessage = CastMessage();
|
||||||
castMessage.namespace = namespace;
|
castMessage.namespace = namespace;
|
||||||
castMessage.message = message;
|
castMessage.message = message;
|
||||||
hostApi.sendMessage(castMessage);
|
_hostApi.sendMessage(castMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteMediaClient? _remoteMediaClient;
|
RemoteMediaClient? _remoteMediaClient;
|
||||||
RemoteMediaClient get remoteMediaClient {
|
RemoteMediaClient get remoteMediaClient {
|
||||||
var result = _remoteMediaClient;
|
var result = _remoteMediaClient;
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
_remoteMediaClient = result = RemoteMediaClient(hostApi);
|
_remoteMediaClient = result = RemoteMediaClient(_hostApi);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import '../../flutter_cast_framework.dart';
|
||||||
import '../CastContext.dart';
|
import '../CastContext.dart';
|
||||||
|
|
||||||
const Color _defaultIconColor = Color.fromARGB(255, 255, 255, 255); // white
|
const Color _defaultIconColor = Color.fromARGB(255, 255, 255, 255); // white
|
||||||
|
const Color _disabledIconColor = Color.fromARGB(255, 201, 201, 201); // gray
|
||||||
|
|
||||||
class CastIcon extends StatefulWidget {
|
class CastIcon extends StatefulWidget {
|
||||||
final Color color;
|
final Color color;
|
||||||
|
|
@ -58,7 +59,7 @@ class _CastIconState extends State<CastIcon> with TickerProviderStateMixin {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
switch (_castState) {
|
switch (_castState) {
|
||||||
case CastState.unavailable:
|
case CastState.unavailable:
|
||||||
return _getEmpty();
|
return _getButton("assets/ic_cast_24dp.svg", _disabledIconColor);
|
||||||
|
|
||||||
case CastState.unconnected:
|
case CastState.unconnected:
|
||||||
return _getButton("assets/ic_cast_24dp.svg", widget.color);
|
return _getButton("assets/ic_cast_24dp.svg", widget.color);
|
||||||
|
|
@ -72,7 +73,7 @@ class _CastIconState extends State<CastIcon> with TickerProviderStateMixin {
|
||||||
case CastState.idle:
|
case CastState.idle:
|
||||||
default:
|
default:
|
||||||
debugPrint("State not handled: $_castState");
|
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
|
//region Session State handling
|
||||||
@override
|
@override
|
||||||
void onSessionEnded() {
|
void onSessionEnded() {
|
||||||
castContext.sessionManager.onSessionStateChanged(SessionState.session_ended);
|
castContext.sessionManager
|
||||||
|
.onSessionStateChanged(SessionState.session_ended);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onSessionEnding() {
|
void onSessionEnding() {
|
||||||
castContext.sessionManager.onSessionStateChanged(SessionState.session_ending);
|
castContext.sessionManager
|
||||||
|
.onSessionStateChanged(SessionState.session_ending);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onSessionResumeFailed() {
|
void onSessionResumeFailed() {
|
||||||
castContext.sessionManager.onSessionStateChanged(SessionState.session_resume_failed);
|
castContext.sessionManager
|
||||||
|
.onSessionStateChanged(SessionState.session_resume_failed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onSessionResumed() {
|
void onSessionResumed() {
|
||||||
castContext.sessionManager.onSessionStateChanged(SessionState.session_resumed);
|
castContext.sessionManager
|
||||||
|
.onSessionStateChanged(SessionState.session_resumed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onSessionResuming() {
|
void onSessionResuming() {
|
||||||
castContext.sessionManager.onSessionStateChanged(SessionState.session_resuming);
|
castContext.sessionManager
|
||||||
|
.onSessionStateChanged(SessionState.session_resuming);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onSessionStartFailed() {
|
void onSessionStartFailed() {
|
||||||
castContext.sessionManager.onSessionStateChanged(SessionState.session_start_failed);
|
castContext.sessionManager
|
||||||
|
.onSessionStateChanged(SessionState.session_start_failed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onSessionStarted() {
|
void onSessionStarted() {
|
||||||
castContext.sessionManager.onSessionStateChanged(SessionState.session_started);
|
castContext.sessionManager
|
||||||
|
.onSessionStateChanged(SessionState.session_started);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onSessionStarting() {
|
void onSessionStarting() {
|
||||||
castContext.sessionManager.onSessionStateChanged(SessionState.session_starting);
|
castContext.sessionManager
|
||||||
|
.onSessionStateChanged(SessionState.session_starting);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onSessionSuspended() {
|
void onSessionSuspended() {
|
||||||
castContext.sessionManager.onSessionStateChanged(SessionState.session_suspended);
|
castContext.sessionManager
|
||||||
|
.onSessionStateChanged(SessionState.session_suspended);
|
||||||
}
|
}
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue