| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:sky' as sky; | 5 import 'dart:sky' as sky; |
| 6 | 6 |
| 7 import 'package:vector_math/vector_math.dart'; | 7 import 'package:vector_math/vector_math.dart'; |
| 8 import 'package:sky/animation/animation_performance.dart'; | 8 import 'package:sky/animation/animation_performance.dart'; |
| 9 import 'package:sky/animation/scroll_behavior.dart'; | 9 import 'package:sky/animation/scroll_behavior.dart'; |
| 10 import 'package:sky/base/lerp.dart'; | 10 import 'package:sky/base/lerp.dart'; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 builder = source.builder; | 40 builder = source.builder; |
| 41 token = source.token; | 41 token = source.token; |
| 42 super.syncFields(source); | 42 super.syncFields(source); |
| 43 } | 43 } |
| 44 | 44 |
| 45 ScrollBehavior createScrollBehavior() => new OverscrollBehavior(); | 45 ScrollBehavior createScrollBehavior() => new OverscrollBehavior(); |
| 46 OverscrollBehavior get scrollBehavior => super.scrollBehavior; | 46 OverscrollBehavior get scrollBehavior => super.scrollBehavior; |
| 47 | 47 |
| 48 void _handleSizeChanged(Size newSize) { | 48 void _handleSizeChanged(Size newSize) { |
| 49 setState(() { | 49 setState(() { |
| 50 scrollBehavior.containerHeight = newSize.height; | 50 scrollBehavior.containerSize = newSize.height; |
| 51 scrollBehavior.contentsHeight = 5000.0; | 51 scrollBehavior.contentsSize = 5000.0; |
| 52 }); | 52 }); |
| 53 } | 53 } |
| 54 | 54 |
| 55 Widget buildContent() { | 55 Widget buildContent() { |
| 56 return new SizeObserver( | 56 return new SizeObserver( |
| 57 callback: _handleSizeChanged, | 57 callback: _handleSizeChanged, |
| 58 child: new BlockViewport( | 58 child: new BlockViewport( |
| 59 builder: builder, | 59 builder: builder, |
| 60 startOffset: scrollOffset, | 60 startOffset: scrollOffset, |
| 61 token: token | 61 token: token |
| 62 ) | 62 ) |
| 63 ); | 63 ); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 class CardCollectionApp extends App { | 67 class CardCollectionApp extends App { |
| 68 | 68 |
| 69 final TextStyle cardLabelStyle = | 69 final TextStyle cardLabelStyle = |
| 70 new TextStyle(color: White, fontSize: 18.0, fontWeight: bold); | 70 new TextStyle(color: White, fontSize: 18.0, fontWeight: bold); |
| 71 | 71 |
| 72 final List<double> cardHeights = [ | 72 final List<double> cardHeights = [ |
| 73 48.0, 64.0, 82.0, 46.0, 60.0, 55.0, 84.0, 96.0, 50.0, | 73 48.0, 64.0, 82.0, 46.0, 60.0, 55.0, 84.0, 96.0, 50.0, |
| 74 48.0, 64.0, 82.0, 46.0, 60.0, 55.0, 84.0, 96.0, 50.0, | 74 48.0, 64.0, 82.0, 46.0, 60.0, 55.0, 84.0, 96.0, 50.0, |
| 75 48.0, 64.0, 82.0, 46.0, 60.0, 55.0, 84.0, 96.0, 50.0 | 75 48.0, 64.0, 82.0, 46.0, 60.0, 55.0, 84.0, 96.0, 50.0 |
| 76 ]; | 76 ]; |
| 77 | 77 |
| 78 List<int> visibleCardIndices; | 78 List<int> visibleCardIndices; |
| 79 | 79 |
| 80 CardCollectionApp() { | 80 CardCollectionApp() { |
| 81 _activeCardTransform = new AnimatedContainer() | 81 _activeCardTransform = new AnimatedContainer() |
| 82 ..position = new AnimatedType<Point>(Point.origin) | 82 ..position = new AnimatedType<Point>(Point.origin) |
| 83 ..opacity = new AnimatedType<double>(1.0, end: 0.0); | 83 ..opacity = new AnimatedType<double>(1.0, end: 0.0); |
| 84 | 84 |
| 85 _activeCardAnimation = _activeCardTransform.createPerformance( | 85 _activeCardAnimation = _activeCardTransform.createPerformance( |
| 86 [_activeCardTransform.position, _activeCardTransform.opacity], | 86 [_activeCardTransform.position, _activeCardTransform.opacity], |
| 87 duration: new Duration(milliseconds: _kCardDismissFadeoutMS)); | 87 duration: new Duration(milliseconds: _kCardDismissFadeoutMS)); |
| 88 _activeCardAnimation.addListener(_handleAnimationProgressChanged); | 88 _activeCardAnimation.addListener(_handleAnimationProgressChanged); |
| 89 | 89 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 return new Scaffold( | 221 return new Scaffold( |
| 222 toolbar: new ToolBar(center: new Text('Swipe Away')), | 222 toolbar: new ToolBar(center: new Text('Swipe Away')), |
| 223 body: new SizeObserver(child: cardCollection, callback: _handleSizeChanged
) | 223 body: new SizeObserver(child: cardCollection, callback: _handleSizeChanged
) |
| 224 ); | 224 ); |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 | 227 |
| 228 void main() { | 228 void main() { |
| 229 runApp(new CardCollectionApp()); | 229 runApp(new CardCollectionApp()); |
| 230 } | 230 } |
| OLD | NEW |