CastIcon color handling
This commit is contained in:
parent
41d543c343
commit
b718f290fb
3 changed files with 35 additions and 9 deletions
|
|
@ -74,7 +74,9 @@ class _MyAppState extends State<MyApp> {
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
CastButton(),
|
CastButton(
|
||||||
|
color: Colors.blue,
|
||||||
|
),
|
||||||
Text(
|
Text(
|
||||||
'States',
|
'States',
|
||||||
style: Theme.of(context).textTheme.title,
|
style: Theme.of(context).textTheme.title,
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,18 @@ import '../../flutter_cast_framework.dart';
|
||||||
import 'CastIcon.dart';
|
import 'CastIcon.dart';
|
||||||
|
|
||||||
class CastButton extends StatelessWidget {
|
class CastButton extends StatelessWidget {
|
||||||
|
final Color color;
|
||||||
|
|
||||||
|
CastButton({
|
||||||
|
this.color,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
child: CastIcon(),
|
child: CastIcon(
|
||||||
|
color: color,
|
||||||
|
),
|
||||||
onTap: () => FlutterCastFramework.castContext.showCastChooserDialog());
|
onTap: () => FlutterCastFramework.castContext.showCastChooserDialog());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,26 @@
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import '../CastContext.dart';
|
|
||||||
import '../../flutter_cast_framework.dart';
|
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
|
||||||
|
import '../../flutter_cast_framework.dart';
|
||||||
|
import '../CastContext.dart';
|
||||||
|
|
||||||
|
const Color _defaultIconColor = Color.fromARGB(255, 255, 255, 255); // white
|
||||||
|
|
||||||
class CastIcon extends StatefulWidget {
|
class CastIcon extends StatefulWidget {
|
||||||
|
final Color color;
|
||||||
|
|
||||||
|
CastIcon({
|
||||||
|
this.color = _defaultIconColor,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_CastIconState createState() => _CastIconState();
|
_CastIconState createState() => _CastIconState();
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _getButton(String assetName) {
|
Widget _getButton(String assetName, Color color) {
|
||||||
return SvgPicture.asset(
|
return SvgPicture.asset(
|
||||||
assetName,
|
assetName,
|
||||||
|
color: color,
|
||||||
package: 'flutter_cast_framework',
|
package: 'flutter_cast_framework',
|
||||||
semanticsLabel: 'Cast Button',
|
semanticsLabel: 'Cast Button',
|
||||||
);
|
);
|
||||||
|
|
@ -36,7 +46,7 @@ class _CastIconState extends State<CastIcon> with TickerProviderStateMixin {
|
||||||
|
|
||||||
Widget _getEmpty() => Container();
|
Widget _getEmpty() => Container();
|
||||||
|
|
||||||
Widget _getAnimatedButton() => _ConnectingIcon();
|
Widget _getAnimatedButton() => _ConnectingIcon(color: widget.color);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
@ -45,13 +55,13 @@ class _CastIconState extends State<CastIcon> with TickerProviderStateMixin {
|
||||||
return _getEmpty();
|
return _getEmpty();
|
||||||
|
|
||||||
case CastState.unconnected:
|
case CastState.unconnected:
|
||||||
return _getButton("assets/ic_cast_24dp.svg");
|
return _getButton("assets/ic_cast_24dp.svg", widget.color);
|
||||||
|
|
||||||
case CastState.connecting:
|
case CastState.connecting:
|
||||||
return _getAnimatedButton();
|
return _getAnimatedButton();
|
||||||
|
|
||||||
case CastState.connected:
|
case CastState.connected:
|
||||||
return _getButton("assets/ic_cast_connected_24dp.svg");
|
return _getButton("assets/ic_cast_connected_24dp.svg", widget.color);
|
||||||
|
|
||||||
case CastState.idle:
|
case CastState.idle:
|
||||||
default:
|
default:
|
||||||
|
|
@ -62,6 +72,12 @@ class _CastIconState extends State<CastIcon> with TickerProviderStateMixin {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ConnectingIcon extends StatefulWidget {
|
class _ConnectingIcon extends StatefulWidget {
|
||||||
|
final Color color;
|
||||||
|
|
||||||
|
_ConnectingIcon({
|
||||||
|
this.color = _defaultIconColor,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_ConnectingIconState createState() => _ConnectingIconState();
|
_ConnectingIconState createState() => _ConnectingIconState();
|
||||||
}
|
}
|
||||||
|
|
@ -122,6 +138,6 @@ class _ConnectingIconState extends State<_ConnectingIcon> {
|
||||||
_nextFrame();
|
_nextFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _getButton(frame);
|
return _getButton(frame, widget.color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue