Merge branch 'master' of github.com:domokit/sky_engine
Conflicts: sky/sdk/example/game/lib/particle_system.dart
This commit is contained in:
@@ -2,157 +2,33 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("//mojo/public/dart/rules.gni")
|
||||
action("sky") {
|
||||
script = "//sky/build/symlink.py"
|
||||
|
||||
dart_pkg("sky") {
|
||||
sources = [
|
||||
"CHANGELOG.md",
|
||||
"bin/init.dart",
|
||||
"lib/animation/animated_simulation.dart",
|
||||
"lib/animation/animated_value.dart",
|
||||
"lib/animation/animation_performance.dart",
|
||||
"lib/animation/curves.dart",
|
||||
"lib/animation/forces.dart",
|
||||
"lib/animation/scroll_behavior.dart",
|
||||
"lib/animation/timeline.dart",
|
||||
"lib/assets/.gitignore",
|
||||
"lib/assets/material-design-icons.sha1",
|
||||
"lib/base/debug.dart",
|
||||
"lib/base/hit_test.dart",
|
||||
"lib/base/lerp.dart",
|
||||
"lib/base/node.dart",
|
||||
"lib/base/scheduler.dart",
|
||||
"lib/download_material_design_icons",
|
||||
"lib/editing/editable_string.dart",
|
||||
"lib/editing/editable_text.dart",
|
||||
"lib/editing/input.dart",
|
||||
"lib/mojo/activity.dart",
|
||||
"lib/mojo/asset_bundle.dart",
|
||||
"lib/mojo/embedder.dart",
|
||||
"lib/mojo/keyboard.dart",
|
||||
"lib/mojo/net/fetch.dart",
|
||||
"lib/mojo/net/image_cache.dart",
|
||||
"lib/mojo/shell.dart",
|
||||
"lib/painting/box_painter.dart",
|
||||
"lib/painting/shadows.dart",
|
||||
"lib/painting/text_style.dart",
|
||||
"lib/rendering/auto_layout.dart",
|
||||
"lib/rendering/block.dart",
|
||||
"lib/rendering/box.dart",
|
||||
"lib/rendering/flex.dart",
|
||||
"lib/rendering/object.dart",
|
||||
"lib/rendering/paragraph.dart",
|
||||
"lib/rendering/sky_binding.dart",
|
||||
"lib/rendering/stack.dart",
|
||||
"lib/sky_tool",
|
||||
"lib/theme/colors.dart",
|
||||
"lib/theme/shadows.dart",
|
||||
"lib/theme/theme_data.dart",
|
||||
"lib/theme/typography.dart",
|
||||
"lib/theme/view_configuration.dart",
|
||||
"lib/widgets/animated_component.dart",
|
||||
"lib/widgets/animated_container.dart",
|
||||
"lib/widgets/basic.dart",
|
||||
"lib/widgets/block_viewport.dart",
|
||||
"lib/widgets/button_base.dart",
|
||||
"lib/widgets/card.dart",
|
||||
"lib/widgets/checkbox.dart",
|
||||
"lib/widgets/default_text_style.dart",
|
||||
"lib/widgets/dialog.dart",
|
||||
"lib/widgets/dismissable.dart",
|
||||
"lib/widgets/drawer.dart",
|
||||
"lib/widgets/drawer_divider.dart",
|
||||
"lib/widgets/drawer_header.dart",
|
||||
"lib/widgets/drawer_item.dart",
|
||||
"lib/widgets/fixed_height_scrollable.dart",
|
||||
"lib/widgets/flat_button.dart",
|
||||
"lib/widgets/floating_action_button.dart",
|
||||
"lib/widgets/focus.dart",
|
||||
"lib/widgets/icon.dart",
|
||||
"lib/widgets/icon_button.dart",
|
||||
"lib/widgets/ink_well.dart",
|
||||
"lib/widgets/material.dart",
|
||||
"lib/widgets/material_button.dart",
|
||||
"lib/widgets/modal_overlay.dart",
|
||||
"lib/widgets/navigator.dart",
|
||||
"lib/widgets/popup_menu.dart",
|
||||
"lib/widgets/popup_menu_item.dart",
|
||||
"lib/widgets/radio.dart",
|
||||
"lib/widgets/raised_button.dart",
|
||||
"lib/widgets/scaffold.dart",
|
||||
"lib/widgets/scrollable.dart",
|
||||
"lib/widgets/scrollable_list.dart",
|
||||
"lib/widgets/scrollable_viewport.dart",
|
||||
"lib/widgets/snack_bar.dart",
|
||||
"lib/widgets/switch.dart",
|
||||
"lib/widgets/tabs.dart",
|
||||
"lib/widgets/task_description.dart",
|
||||
"lib/widgets/theme.dart",
|
||||
"lib/widgets/toggleable.dart",
|
||||
"lib/widgets/tool_bar.dart",
|
||||
"lib/widgets/variable_height_scrollable.dart",
|
||||
"lib/widgets/widget.dart",
|
||||
"pubspec.yaml",
|
||||
stamp_file = "$target_gen_dir/symlink.stamp"
|
||||
|
||||
sources = [ "pubspec.yaml" ]
|
||||
outputs = [ stamp_file ]
|
||||
|
||||
args = [
|
||||
rebase_path("lib", root_build_dir),
|
||||
rebase_path("$root_gen_dir/dart-pkg/packages/sky", root_build_dir),
|
||||
"--touch",
|
||||
rebase_path(stamp_file, root_build_dir)
|
||||
]
|
||||
|
||||
# List of mojom targets that the sky pkg exports
|
||||
deps = [
|
||||
"//mojo/services/asset_bundle/public/interfaces",
|
||||
"//mojo/services/keyboard/public/interfaces",
|
||||
"//sky/services/activity:interfaces",
|
||||
"//sky/services/engine:interfaces",
|
||||
]
|
||||
|
||||
datadeps = [
|
||||
"//mojo/dart/mojo_services",
|
||||
"//mojo/dart/mojom",
|
||||
"//mojo/public/dart:mojo",
|
||||
"//sky/engine/bindings",
|
||||
"//sky/services/testing:interfaces",
|
||||
"//sky/services/media:interfaces",
|
||||
"//sky/packages/sky_engine",
|
||||
"//sky/packages/sky_services",
|
||||
"//third_party/dart-pkg",
|
||||
]
|
||||
|
||||
sdk_ext_directory = "$root_gen_dir/sky/bindings"
|
||||
sdk_ext_files = [
|
||||
"//sky/engine/bindings/sky_internals.dart",
|
||||
"//sky/engine/bindings/builtin_natives.dart",
|
||||
]
|
||||
sdk_ext_mappings = [
|
||||
"dart:sky,dart_sky.dart",
|
||||
"dart:sky.internals,sky_internals.dart",
|
||||
"dart:sky_builtin_natives,builtin_natives.dart",
|
||||
]
|
||||
}
|
||||
|
||||
action("material_design_icons") {
|
||||
source_file = "lib/assets/material-design-icons"
|
||||
target_file = "$root_gen_dir/dart-pkg/sky/lib/assets/material-design-icons"
|
||||
stamp = "$target_gen_dir/material_design_icons_linked"
|
||||
|
||||
sources = [
|
||||
"lib/assets/material-design-icons.sha1",
|
||||
]
|
||||
outputs = [
|
||||
stamp,
|
||||
]
|
||||
|
||||
script = "//sky/build/symlink.py"
|
||||
args = [
|
||||
rebase_path(source_file, root_build_dir),
|
||||
rebase_path(target_file, root_build_dir),
|
||||
"--touch",
|
||||
rebase_path(stamp, root_build_dir),
|
||||
]
|
||||
|
||||
deps = [
|
||||
":sky",
|
||||
]
|
||||
}
|
||||
|
||||
group("sdk") {
|
||||
deps = [
|
||||
":sky",
|
||||
":material_design_icons",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -7,11 +7,14 @@ import 'package:sky/theme/colors.dart' as colors;
|
||||
import 'package:sky/theme/typography.dart' as typography;
|
||||
import 'package:sky/widgets/basic.dart';
|
||||
import 'package:sky/widgets/default_text_style.dart';
|
||||
import 'package:sky/widgets/dialog.dart';
|
||||
import 'package:sky/widgets/floating_action_button.dart';
|
||||
import 'package:sky/widgets/flat_button.dart';
|
||||
import 'package:sky/widgets/focus.dart';
|
||||
import 'package:sky/widgets/icon.dart';
|
||||
import 'package:sky/widgets/icon_button.dart';
|
||||
import 'package:sky/widgets/material.dart';
|
||||
import 'package:sky/widgets/navigator.dart';
|
||||
import 'package:sky/widgets/scaffold.dart';
|
||||
import 'package:sky/widgets/scrollable_viewport.dart';
|
||||
import 'package:sky/widgets/task_description.dart';
|
||||
@@ -51,17 +54,23 @@ class Field extends Component {
|
||||
|
||||
class AddressBookApp extends App {
|
||||
|
||||
Widget buildToolBar() {
|
||||
Widget buildToolBar(Navigator navigator) {
|
||||
return new ToolBar(
|
||||
left: new IconButton(icon: "navigation/arrow_back"),
|
||||
right: [new IconButton(icon: "navigation/check")]
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildFloatingActionButton() {
|
||||
Widget buildFloatingActionButton(Navigator navigator) {
|
||||
return new FloatingActionButton(
|
||||
child: new Icon(type: 'image/photo_camera', size: 24),
|
||||
backgroundColor: Theme.of(this).accentColor
|
||||
backgroundColor: Theme.of(this).accentColor,
|
||||
onPressed: () {
|
||||
showDialog = true;
|
||||
navigator.pushState(this, (_) {
|
||||
showDialog = false;
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -71,8 +80,10 @@ class AddressBookApp extends App {
|
||||
static final GlobalKey addressKey = new GlobalKey();
|
||||
static final GlobalKey ringtoneKey = new GlobalKey();
|
||||
static final GlobalKey noteKey = new GlobalKey();
|
||||
static final GlobalKey fillKey = new GlobalKey();
|
||||
static final GlobalKey emoticonKey = new GlobalKey();
|
||||
|
||||
Widget buildBody() {
|
||||
Widget buildBody(Navigator navigator) {
|
||||
return new Material(
|
||||
child: new ScrollableBlock([
|
||||
new AspectRatio(
|
||||
@@ -91,12 +102,59 @@ class AddressBookApp extends App {
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildMain() {
|
||||
return new Scaffold(
|
||||
toolbar: buildToolBar(),
|
||||
body: buildBody(),
|
||||
floatingActionButton: buildFloatingActionButton()
|
||||
);
|
||||
bool showDialog = false;
|
||||
|
||||
Widget buildMain(Navigator navigator) {
|
||||
List<Widget> layers = [
|
||||
new Focus(
|
||||
initialFocus: nameKey,
|
||||
child: new Scaffold(
|
||||
toolbar: buildToolBar(navigator),
|
||||
body: buildBody(navigator),
|
||||
floatingActionButton: buildFloatingActionButton(navigator)
|
||||
)
|
||||
)
|
||||
];
|
||||
if (showDialog) {
|
||||
layers.add(new Focus(
|
||||
initialFocus: fillKey,
|
||||
child: new Dialog(
|
||||
title: new Text("Describe your picture"),
|
||||
content: new ScrollableBlock([
|
||||
new Field(inputKey: fillKey, icon: "editor/format_color_fill", placeholder: "Color"),
|
||||
new Field(inputKey: emoticonKey, icon: "editor/insert_emoticon", placeholder: "Emotion"),
|
||||
]),
|
||||
onDismiss: navigator.pop,
|
||||
actions: [
|
||||
new FlatButton(
|
||||
child: new Text('DISCARD'),
|
||||
onPressed: () {
|
||||
navigator.pop();
|
||||
}
|
||||
),
|
||||
new FlatButton(
|
||||
child: new Text('SAVE'),
|
||||
onPressed: () {
|
||||
navigator.pop();
|
||||
}
|
||||
),
|
||||
]
|
||||
)
|
||||
));
|
||||
}
|
||||
return new Stack(layers);
|
||||
}
|
||||
|
||||
NavigationState _navigationState;
|
||||
|
||||
void initState() {
|
||||
_navigationState = new NavigationState([
|
||||
new Route(
|
||||
name: '/',
|
||||
builder: (navigator, route) => buildMain(navigator)
|
||||
),
|
||||
]);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Widget build() {
|
||||
@@ -111,10 +169,7 @@ class AddressBookApp extends App {
|
||||
style: typography.error, // if you see this, you've forgotten to correctly configure the text style!
|
||||
child: new TaskDescription(
|
||||
label: 'Address Book',
|
||||
child: new Focus(
|
||||
initialFocus: nameKey,
|
||||
child: buildMain()
|
||||
)
|
||||
child: new Navigator(_navigationState)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import 'package:sky/painting/text_style.dart';
|
||||
import 'package:sky/widgets/basic.dart';
|
||||
import 'package:sky/widgets/button_base.dart';
|
||||
import 'package:sky/widgets/dialog.dart';
|
||||
import 'package:sky/widgets/drawer.dart';
|
||||
import 'package:sky/widgets/drawer_divider.dart';
|
||||
@@ -13,10 +14,13 @@ import 'package:sky/widgets/flat_button.dart';
|
||||
import 'package:sky/widgets/floating_action_button.dart';
|
||||
import 'package:sky/widgets/icon_button.dart';
|
||||
import 'package:sky/widgets/icon.dart';
|
||||
import 'package:sky/widgets/ink_well.dart';
|
||||
import 'package:sky/widgets/material.dart';
|
||||
import 'package:sky/widgets/navigator.dart';
|
||||
import 'package:sky/widgets/radio.dart';
|
||||
import 'package:sky/widgets/scaffold.dart';
|
||||
import 'package:sky/widgets/scrollable_list.dart';
|
||||
import 'package:sky/widgets/scrollable_viewport.dart';
|
||||
import 'package:sky/widgets/snack_bar.dart';
|
||||
import 'package:sky/widgets/theme.dart';
|
||||
import 'package:sky/widgets/tool_bar.dart';
|
||||
@@ -27,7 +31,10 @@ import 'fitness_item.dart';
|
||||
import 'measurement.dart';
|
||||
|
||||
class FitnessItemList extends Component {
|
||||
FitnessItemList({ Key key, this.items, this.onDismissed }) : super(key: key);
|
||||
FitnessItemList({ Key key, this.items, this.onDismissed }) : super(key: key) {
|
||||
assert(items != null);
|
||||
assert(onDismissed != null);
|
||||
}
|
||||
|
||||
final List<FitnessItem> items;
|
||||
final FitnessItemHandler onDismissed;
|
||||
@@ -36,11 +43,40 @@ class FitnessItemList extends Component {
|
||||
return new Material(
|
||||
type: MaterialType.canvas,
|
||||
child: new ScrollableList<FitnessItem>(
|
||||
padding: const EdgeDims.all(4.0),
|
||||
items: items,
|
||||
itemHeight: kFitnessItemHeight,
|
||||
itemBuilder: (item) => new MeasurementRow(
|
||||
measurement: item as Measurement,
|
||||
onDismissed: onDismissed
|
||||
itemBuilder: (item) => item.toRow(onDismissed: onDismissed)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DialogMenuItem extends ButtonBase {
|
||||
DialogMenuItem(this.children, { Key key, this.onPressed }) : super(key: key);
|
||||
|
||||
List<Widget> children;
|
||||
Function onPressed;
|
||||
|
||||
void syncFields(DialogMenuItem source) {
|
||||
children = source.children;
|
||||
onPressed = source.onPressed;
|
||||
super.syncFields(source);
|
||||
}
|
||||
|
||||
Widget buildContent() {
|
||||
return new Listener(
|
||||
onGestureTap: (_) {
|
||||
if (onPressed != null)
|
||||
onPressed();
|
||||
},
|
||||
child: new Container(
|
||||
height: 48.0,
|
||||
child: new InkWell(
|
||||
child: new Padding(
|
||||
padding: const EdgeDims.symmetric(horizontal: 16.0),
|
||||
child: new Flex(children)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -204,11 +240,30 @@ class FeedFragment extends StatefulComponent {
|
||||
}
|
||||
|
||||
bool _isShowingDialog = false;
|
||||
String _addItemRoute;
|
||||
|
||||
void _handleAddItemRouteChanged(String routeName) {
|
||||
setState(() {
|
||||
_addItemRoute = routeName;
|
||||
});
|
||||
}
|
||||
|
||||
Widget buildDialog() {
|
||||
// TODO(jackson): Internationalize
|
||||
Map<String, String> labels = {
|
||||
'/meals/new': 'Eat',
|
||||
'/measurements/new': 'Measure',
|
||||
};
|
||||
List<Widget> menuItems = [];
|
||||
for(String routeName in labels.keys) {
|
||||
menuItems.add(new DialogMenuItem([
|
||||
new Flexible(child: new Text(labels[routeName])),
|
||||
new Radio(value: routeName, groupValue: _addItemRoute, onChanged: _handleAddItemRouteChanged),
|
||||
], onPressed: () => _handleAddItemRouteChanged(routeName)));
|
||||
}
|
||||
return new Dialog(
|
||||
title: new Text("New item"),
|
||||
content: new Text("What are you trying to do?"),
|
||||
title: new Text("What are you doing?"),
|
||||
content: new ScrollableBlock(menuItems),
|
||||
onDismiss: navigator.pop,
|
||||
actions: [
|
||||
new FlatButton(
|
||||
@@ -216,17 +271,10 @@ class FeedFragment extends StatefulComponent {
|
||||
onPressed: navigator.pop
|
||||
),
|
||||
new FlatButton(
|
||||
child: new Text('EAT'),
|
||||
child: new Text('ADD'),
|
||||
onPressed: () {
|
||||
navigator.pop();
|
||||
navigator.pushNamed("/meals/new");
|
||||
}
|
||||
),
|
||||
new FlatButton(
|
||||
child: new Text('MEASURE'),
|
||||
onPressed: () {
|
||||
navigator.pop();
|
||||
navigator.pushNamed("/measurements/new");
|
||||
navigator.pushNamed(_addItemRoute);
|
||||
}
|
||||
),
|
||||
]
|
||||
@@ -236,6 +284,9 @@ class FeedFragment extends StatefulComponent {
|
||||
void _handleActionButtonPressed() {
|
||||
setState(() {
|
||||
_isShowingDialog = true;
|
||||
navigator.pushState(this, (_) {
|
||||
_isShowingDialog = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ typedef void FitnessItemHandler(FitnessItem item);
|
||||
|
||||
const double kFitnessItemHeight = 79.0;
|
||||
|
||||
class FitnessItem {
|
||||
abstract class FitnessItem {
|
||||
FitnessItem({ this.when }) {
|
||||
assert(when != null);
|
||||
}
|
||||
@@ -18,13 +18,17 @@ class FitnessItem {
|
||||
|
||||
// TODO(jackson): Internationalize
|
||||
String get displayDate => "${when.year.toString()}-${when.month.toString().padLeft(2,'0')}-${when.day.toString().padLeft(2,'0')}";
|
||||
|
||||
FitnessItemRow toRow({ FitnessItemHandler onDismissed });
|
||||
}
|
||||
|
||||
abstract class FitnessItemRow extends Component {
|
||||
|
||||
FitnessItemRow({ FitnessItem item, this.onDismissed })
|
||||
: this.item = item,
|
||||
super(key: new Key(item.when.toString()));
|
||||
super(key: new Key(item.when.toString())) {
|
||||
assert(onDismissed != null);
|
||||
}
|
||||
|
||||
final FitnessItem item;
|
||||
final FitnessItemHandler onDismissed;
|
||||
|
||||
@@ -21,6 +21,10 @@ class Meal extends FitnessItem {
|
||||
Meal({ DateTime when, this.description }) : super(when: when);
|
||||
|
||||
final String description;
|
||||
|
||||
FitnessItemRow toRow({ FitnessItemHandler onDismissed }) {
|
||||
return new MealRow(meal: this, onDismissed: onDismissed);
|
||||
}
|
||||
}
|
||||
|
||||
class MealRow extends FitnessItemRow {
|
||||
@@ -91,6 +95,8 @@ class MealFragment extends StatefulComponent {
|
||||
});
|
||||
}
|
||||
|
||||
static final GlobalKey descriptionKey = new GlobalKey();
|
||||
|
||||
Widget buildBody() {
|
||||
Meal meal = new Meal(when: new DateTime.now());
|
||||
return new Material(
|
||||
@@ -101,7 +107,7 @@ class MealFragment extends StatefulComponent {
|
||||
child: new Block([
|
||||
new Text(meal.displayDate),
|
||||
new Input(
|
||||
focused: false,
|
||||
key: descriptionKey,
|
||||
placeholder: 'Describe meal',
|
||||
onChanged: _handleDescriptionChanged
|
||||
),
|
||||
|
||||
@@ -25,6 +25,10 @@ class Measurement extends FitnessItem {
|
||||
|
||||
// TODO(jackson): Internationalize
|
||||
String get displayWeight => "${weight.toStringAsFixed(2)} lbs";
|
||||
|
||||
FitnessItemRow toRow({ FitnessItemHandler onDismissed }) {
|
||||
return new MeasurementRow(measurement: this, onDismissed: onDismissed);
|
||||
}
|
||||
}
|
||||
|
||||
class MeasurementRow extends FitnessItemRow {
|
||||
@@ -105,6 +109,8 @@ class MeasurementFragment extends StatefulComponent {
|
||||
});
|
||||
}
|
||||
|
||||
static final GlobalKey weightKey = new GlobalKey();
|
||||
|
||||
Widget buildBody() {
|
||||
Measurement measurement = new Measurement(when: new DateTime.now());
|
||||
return new Material(
|
||||
@@ -115,7 +121,7 @@ class MeasurementFragment extends StatefulComponent {
|
||||
child: new Block([
|
||||
new Text(measurement.displayDate),
|
||||
new Input(
|
||||
focused: false,
|
||||
key: weightKey,
|
||||
placeholder: 'Enter weight',
|
||||
onChanged: _handleWeightChanged
|
||||
),
|
||||
|
||||
@@ -271,43 +271,10 @@ class ParticleSystem extends Node {
|
||||
colors.add(particleColor);
|
||||
}
|
||||
|
||||
// TODO(viktork): Verify that the C++ version looks right and is faster!
|
||||
Paint paint = new Paint()..setTransferMode(transferMode)
|
||||
..setFilterQuality(FilterQuality.low) // All Skia examples do this.
|
||||
..isAntiAlias = false; // Antialiasing breaks SkCanvas.drawAtlas?
|
||||
return canvas.drawAtlas(texture.image, transforms, rects, colors,
|
||||
canvas.drawAtlas(texture.image, transforms, rects, colors,
|
||||
TransferMode.modulate, null, paint);
|
||||
|
||||
dartDrawAtlas(canvas, texture.image, transforms, rects, colors,
|
||||
TransferMode.modulate, paint);
|
||||
}
|
||||
}
|
||||
|
||||
void dartDrawAtlas(Canvas canvas, Image image, List<RSTransform> transforms,
|
||||
List<Rect> rects, List<Color> colors, TransferMode transferMode, Paint paint) {
|
||||
assert(transforms.length == rects.length && transforms.length == colors.length);
|
||||
|
||||
Texture mainTexture = new Texture(image);
|
||||
|
||||
for (int i = 0; i < transforms.length; i++) {
|
||||
RSTransform transform = transforms[i];
|
||||
Rect rect = rects[i];
|
||||
Color color = colors[i];
|
||||
|
||||
canvas.save();
|
||||
|
||||
Matrix4 matrix = new Matrix4(transform.scos, transform.ssin, 0.0, 0.0,
|
||||
-transform.ssin, transform.scos, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
transform.tx, transform.ty, 0.0, 1.0);
|
||||
canvas.concat(matrix.storage);
|
||||
|
||||
paint.setColorFilter(new ColorFilter.mode(color, transferMode));
|
||||
paint.color = color;
|
||||
|
||||
Texture texture = mainTexture.textureFromRect(rect);
|
||||
texture.drawTexture(canvas, new Point(-texture.size.width/2.0, -texture.size.height/2.0), paint);
|
||||
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class StockSettings extends StatefulComponent {
|
||||
BackupMode backup;
|
||||
SettingsUpdater updater;
|
||||
|
||||
bool showModeDialog = false;
|
||||
bool _showModeDialog = false;
|
||||
|
||||
void syncFields(StockSettings source) {
|
||||
navigator = source.navigator;
|
||||
@@ -60,9 +60,9 @@ class StockSettings extends StatefulComponent {
|
||||
_handleOptimismChanged(false);
|
||||
break;
|
||||
case StockMode.pessimistic:
|
||||
showModeDialog = true;
|
||||
_showModeDialog = true;
|
||||
navigator.pushState(this, (_) {
|
||||
showModeDialog = false;
|
||||
_showModeDialog = false;
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -123,7 +123,7 @@ class StockSettings extends StatefulComponent {
|
||||
body: buildSettingsPane()
|
||||
)
|
||||
];
|
||||
if (showModeDialog) {
|
||||
if (_showModeDialog) {
|
||||
layers.add(new Dialog(
|
||||
title: new Text("Change mode?"),
|
||||
content: new Text("Optimistic mode means everything is awesome. Are you sure you can handle that?"),
|
||||
|
||||
@@ -9,10 +9,12 @@ import 'package:sky/widgets/basic.dart';
|
||||
import 'package:sky/widgets/block_viewport.dart';
|
||||
import 'package:sky/widgets/card.dart';
|
||||
import 'package:sky/widgets/dismissable.dart';
|
||||
import 'package:sky/widgets/icon.dart';
|
||||
import 'package:sky/widgets/variable_height_scrollable.dart';
|
||||
import 'package:sky/widgets/scaffold.dart';
|
||||
import 'package:sky/widgets/theme.dart';
|
||||
import 'package:sky/widgets/tool_bar.dart';
|
||||
import 'package:sky/theme/typography.dart' as typography;
|
||||
import 'package:sky/widgets/widget.dart';
|
||||
import 'package:sky/widgets/task_description.dart';
|
||||
|
||||
@@ -27,8 +29,11 @@ class CardModel {
|
||||
|
||||
class CardCollectionApp extends App {
|
||||
|
||||
final TextStyle cardLabelStyle =
|
||||
new TextStyle(color: white, fontSize: 18.0, fontWeight: bold);
|
||||
static const TextStyle cardLabelStyle =
|
||||
const TextStyle(color: white, fontSize: 18.0, fontWeight: bold);
|
||||
|
||||
final TextStyle backgroundTextStyle =
|
||||
typography.white.title.copyWith(textAlign: TextAlign.center);
|
||||
|
||||
BlockViewportLayoutState layoutState = new BlockViewportLayoutState();
|
||||
List<CardModel> cardModels;
|
||||
@@ -57,21 +62,50 @@ class CardCollectionApp extends App {
|
||||
Widget builder(int index) {
|
||||
if (index >= cardModels.length)
|
||||
return null;
|
||||
CardModel card = cardModels[index];
|
||||
|
||||
return new Dismissable(
|
||||
key: card.key,
|
||||
CardModel cardModel = cardModels[index];
|
||||
Widget card = new Dismissable(
|
||||
onResized: () { layoutState.invalidate([index]); },
|
||||
onDismissed: () { dismissCard(card); },
|
||||
onDismissed: () { dismissCard(cardModel); },
|
||||
child: new Card(
|
||||
color: card.color,
|
||||
color: cardModel.color,
|
||||
child: new Container(
|
||||
height: card.height,
|
||||
height: cardModel.height,
|
||||
padding: const EdgeDims.all(8.0),
|
||||
child: new Center(child: new Text(card.label, style: cardLabelStyle))
|
||||
child: new Center(child: new Text(cardModel.label, style: cardLabelStyle))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Widget backgroundText = new Center(
|
||||
child: new Text("Swipe in either direction", style: backgroundTextStyle)
|
||||
);
|
||||
|
||||
// The background Widget appears behind the Dismissable card when the card
|
||||
// moves to the left or right. The Positioned widget ensures that the
|
||||
// size of the background,card Stack will be based only on the card. The
|
||||
// Viewport ensures that when the card's resize animation occurs, the
|
||||
// background (text and icons) will just be clipped, not resized.
|
||||
Widget background = new Positioned(
|
||||
top: 0.0,
|
||||
left: 0.0,
|
||||
child: new Container(
|
||||
margin: const EdgeDims.all(4.0),
|
||||
child: new Viewport(
|
||||
child: new Container(
|
||||
height: cardModel.height,
|
||||
decoration: new BoxDecoration(backgroundColor: Theme.of(this).primaryColor),
|
||||
child: new Flex([
|
||||
new Icon(type: 'navigation/arrow_back', size: 36),
|
||||
new Flexible(child: backgroundText),
|
||||
new Icon(type: 'navigation/arrow_forward', size: 36)
|
||||
])
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return new Stack([background, card], key: cardModel.key);
|
||||
}
|
||||
|
||||
Widget build() {
|
||||
@@ -85,17 +119,20 @@ class CardCollectionApp extends App {
|
||||
)
|
||||
);
|
||||
|
||||
return new Theme(
|
||||
data: new ThemeData(
|
||||
brightness: ThemeBrightness.light,
|
||||
primarySwatch: Blue,
|
||||
accentColor: RedAccent[200]
|
||||
),
|
||||
child: new TaskDescription(
|
||||
label: 'Cards',
|
||||
child: new Scaffold(
|
||||
toolbar: new ToolBar(center: new Text('Swipe Away')),
|
||||
body: cardCollection
|
||||
return new IconTheme(
|
||||
data: const IconThemeData(color: IconThemeColor.white),
|
||||
child: new Theme(
|
||||
data: new ThemeData(
|
||||
brightness: ThemeBrightness.light,
|
||||
primarySwatch: Blue,
|
||||
accentColor: RedAccent[200]
|
||||
),
|
||||
child: new TaskDescription(
|
||||
label: 'Cards',
|
||||
child: new Scaffold(
|
||||
toolbar: new ToolBar(center: new Text('Swipe Away')),
|
||||
body: cardCollection
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
1
packages/flutter/lib/assets/.gitignore
vendored
1
packages/flutter/lib/assets/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
material-design-icons
|
||||
@@ -1 +0,0 @@
|
||||
74927f91069e6540e40983acb5eb40072704fd2f
|
||||
@@ -1,55 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright (c) 2015 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import urllib2
|
||||
|
||||
|
||||
def main():
|
||||
sky_lib_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
assets_dir = os.path.join(sky_lib_dir, 'assets')
|
||||
icons_dir = os.path.join(assets_dir, 'material-design-icons')
|
||||
existing_sha1_path = os.path.join(icons_dir, 'material-design-icons.sha1')
|
||||
|
||||
existing_sha1 = None
|
||||
if os.path.isfile(existing_sha1_path):
|
||||
with open(existing_sha1_path, 'r') as f:
|
||||
existing_sha1 = f.read()
|
||||
|
||||
sha1_path = os.path.join(assets_dir, 'material-design-icons.sha1')
|
||||
|
||||
with open(sha1_path, 'r') as f:
|
||||
sha1 = f.read()
|
||||
|
||||
if existing_sha1 == sha1:
|
||||
return
|
||||
|
||||
print "Downloading missing material design icons"
|
||||
|
||||
tgz_path = os.path.join(assets_dir, 'material-design-icons.tgz')
|
||||
url = 'https://storage.googleapis.com/mojo/material-design-icons/%s' % sha1
|
||||
response = urllib2.urlopen(url)
|
||||
|
||||
with open(tgz_path, 'wb') as f:
|
||||
f.write(response.read())
|
||||
|
||||
shutil.rmtree(icons_dir, ignore_errors=True)
|
||||
|
||||
output_path = os.path.join(assets_dir, tgz_path)
|
||||
subprocess.call([
|
||||
'tar', '-xzf', output_path, '-C', assets_dir
|
||||
])
|
||||
|
||||
subprocess.call([
|
||||
'cp', sha1_path, icons_dir
|
||||
])
|
||||
|
||||
os.unlink(tgz_path)
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
@@ -18,6 +18,8 @@ import time
|
||||
# TODO(eseidel): This should be BIN_DIR.
|
||||
LIB_DIR = os.path.realpath(os.path.dirname(os.path.abspath(__file__)))
|
||||
SKY_PACKAGE_ROOT = os.path.realpath(os.path.dirname(LIB_DIR))
|
||||
SKY_ENGINE_PACKAGE_ROOT = os.path.realpath(os.path.join(SKY_PACKAGE_ROOT,
|
||||
os.pardir, 'sky_engine'))
|
||||
|
||||
SKY_SERVER_PORT = 9888
|
||||
OBSERVATORY_PORT = 8181
|
||||
@@ -164,7 +166,7 @@ class StartSky(object):
|
||||
args.install = True
|
||||
|
||||
if args.install:
|
||||
apk_path = os.path.join(SKY_PACKAGE_ROOT, 'apks', APK_NAME)
|
||||
apk_path = os.path.join(SKY_ENGINE_PACKAGE_ROOT, 'apks', APK_NAME)
|
||||
if not os.path.exists(apk_path):
|
||||
print "'%s' does not exist?" % apk_path
|
||||
return 2
|
||||
|
||||
@@ -53,7 +53,6 @@ class Dismissable extends AnimatedComponent {
|
||||
..duration = _kCardDismissFadeout
|
||||
..variable = new AnimatedList([_position, _opacity])
|
||||
..addListener(_handleFadeProgressChanged);
|
||||
watch(_fadePerformance);
|
||||
}
|
||||
|
||||
void _handleFadeProgressChanged() {
|
||||
@@ -85,8 +84,6 @@ class Dismissable extends AnimatedComponent {
|
||||
}
|
||||
|
||||
void _maybeCallOnDismissed() {
|
||||
_resizePerformance.stop();
|
||||
_resizePerformance.removeListener(_handleResizeProgressChanged);
|
||||
if (onDismissed != null)
|
||||
onDismissed();
|
||||
}
|
||||
@@ -96,22 +93,19 @@ class Dismissable extends AnimatedComponent {
|
||||
assert(_fadePerformance != null);
|
||||
assert(_resizePerformance == null);
|
||||
|
||||
// TODO(hansmuller): _fadePerformance is completed; stop shouldn't be needed.
|
||||
_fadePerformance.stop();
|
||||
_fadePerformance.removeListener(_handleFadeProgressChanged);
|
||||
|
||||
_maybeCallOnResized();
|
||||
|
||||
AnimatedValue<double> dismissHeight = new AnimatedValue<double>(_size.height,
|
||||
end: 0.0,
|
||||
curve: ease,
|
||||
interval: new Interval(_kCardDismissResizeDelay, 1.0)
|
||||
end: 0.0,
|
||||
curve: ease,
|
||||
interval: new Interval(_kCardDismissResizeDelay, 1.0)
|
||||
);
|
||||
_resizePerformance = new AnimationPerformance()
|
||||
..variable = dismissHeight
|
||||
..duration = _kCardDismissResize
|
||||
..addListener(_handleResizeProgressChanged)
|
||||
..play();
|
||||
watch(_resizePerformance);
|
||||
}
|
||||
|
||||
void _handleResizeProgressChanged() {
|
||||
|
||||
@@ -41,7 +41,7 @@ class IconTheme extends Inherited {
|
||||
AssetBundle _initIconBundle() {
|
||||
if (rootBundle != null)
|
||||
return rootBundle;
|
||||
const String _kAssetBase = '/packages/sky/assets/material-design-icons/';
|
||||
const String _kAssetBase = '/packages/material_design_icons/icons/';
|
||||
return new NetworkAssetBundle(Uri.base.resolve(_kAssetBase));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
name: sky
|
||||
version: 0.0.21
|
||||
author: Chromium Authors <sky-dev@googlegroups.com>
|
||||
description: A framework for writing Sky applications
|
||||
homepage: https://github.com/domokit/sky_engine/tree/master/sky/sdk
|
||||
dependencies:
|
||||
cassowary: ^0.1.7
|
||||
material_design_icons: ^0.0.1
|
||||
mojo_services: ^0.0.15
|
||||
mojo: ^0.0.17
|
||||
mojom: ^0.0.17
|
||||
newton: ^0.1.0
|
||||
sky_engine: ^0.0.1
|
||||
sky_services: ^0.0.1
|
||||
sky_tools: ^0.0.2
|
||||
vector_math: ^1.4.3
|
||||
description: Dart files to support executing inside Sky
|
||||
environment:
|
||||
sdk: '>=1.8.0 <2.0.0'
|
||||
homepage: https://github.com/domokit/mojo/tree/master/sky
|
||||
name: sky
|
||||
version: 0.0.21
|
||||
|
||||
Reference in New Issue
Block a user