Commit c03c4cca authored by Ian Hickson's avatar Ian Hickson

Activity clean-up

Turns out Android crashes if the colour is not opaque, so we enforce
that at the Dart level.

Also, since label and colour are both actually optional, make them
named arguments.
parent 5fdb0749
...@@ -121,6 +121,6 @@ Pancetta meatball tongue tenderloin rump tail jowl boudin."""; ...@@ -121,6 +121,6 @@ Pancetta meatball tongue tenderloin rump tail jowl boudin.""";
child: row child: row
); );
updateTaskDescription('Interactive Flex', topColor); updateTaskDescription(label: 'Interactive Flex', color: topColor);
new DemoBinding(root: root); new DemoBinding(root: root);
} }
...@@ -11,7 +11,7 @@ import 'shell.dart'; ...@@ -11,7 +11,7 @@ import 'shell.dart';
export 'package:sky_services/activity/activity.mojom.dart'; export 'package:sky_services/activity/activity.mojom.dart';
/// Dart wrapper around Activity mojo service available in Sky on Android. /// Dart wrapper around Activity mojo service available in Flutter on Android.
/// ///
/// Most clients will want to use these methods instead of the activity service /// Most clients will want to use these methods instead of the activity service
/// directly. /// directly.
...@@ -50,8 +50,10 @@ final PathService pathService = _pathServiceProxy.ptr; ...@@ -50,8 +50,10 @@ final PathService pathService = _pathServiceProxy.ptr;
Color _cachedPrimaryColor; Color _cachedPrimaryColor;
String _cachedLabel; String _cachedLabel;
/// Sets the TaskDescription for the current Activity /// Sets the TaskDescription for the current Activity.
void updateTaskDescription(String label, Color color) { /// The color, if provided, must be opaque.
void updateTaskDescription({ String label, Color color }) {
assert(color == null || color.alpha == 0xFF);
if (_cachedPrimaryColor == color && _cachedLabel == label) if (_cachedPrimaryColor == color && _cachedLabel == label)
return; return;
......
...@@ -7,7 +7,9 @@ import 'package:flutter/widgets.dart'; ...@@ -7,7 +7,9 @@ import 'package:flutter/widgets.dart';
/// Controls the description of this app in the operating system. /// Controls the description of this app in the operating system.
class Title extends StatelessComponent { class Title extends StatelessComponent {
Title({ this.title, this.child, this.color }); Title({ this.title, this.child, this.color }) {
assert(color == null || color.alpha == 0xFF);
}
final Widget child; final Widget child;
...@@ -18,13 +20,15 @@ class Title extends StatelessComponent { ...@@ -18,13 +20,15 @@ class Title extends StatelessComponent {
final Color color; final Color color;
Widget build(BuildContext context) { Widget build(BuildContext context) {
updateTaskDescription(title, color); updateTaskDescription(label: title, color: color);
return child; return child;
} }
void debugFillDescription(List<String> description) { void debugFillDescription(List<String> description) {
super.debugFillDescription(description); super.debugFillDescription(description);
description.add('"$title"'); if (title != null)
description.add('color: $color'); description.add('"$title"');
if (color != null)
description.add('color: $color');
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment