| 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:math' as math; | 5 import 'dart:math' as math; |
| 6 | 6 |
| 7 import 'package:sky/animation/scroll_behavior.dart'; | 7 import 'package:sky/animation/scroll_behavior.dart'; |
| 8 import 'package:sky/widgets/basic.dart'; | 8 import 'package:sky/widgets/basic.dart'; |
| 9 import 'package:sky/widgets/scrollable.dart'; | 9 import 'package:sky/widgets/scrollable.dart'; |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 double drawStart = scrollOffset + alignmentDelta; | 78 double drawStart = scrollOffset + alignmentDelta; |
| 79 itemShowIndex = math.max(0, (drawStart / itemHeight).floor()); | 79 itemShowIndex = math.max(0, (drawStart / itemHeight).floor()); |
| 80 | 80 |
| 81 offsetY = -alignmentDelta; | 81 offsetY = -alignmentDelta; |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 List<Widget> items = buildItems(itemShowIndex, itemShowCount); | 85 List<Widget> items = buildItems(itemShowIndex, itemShowCount); |
| 86 assert(items.every((item) => item.key != null)); | 86 assert(items.every((item) => item.key != null)); |
| 87 | 87 |
| 88 // TODO(ianh): Refactor this so that it does the building in the |
| 89 // same frame as the size observing, similar to BlockViewport, but |
| 90 // keeping the fixed-height optimisations. |
| 88 return new SizeObserver( | 91 return new SizeObserver( |
| 89 callback: _handleSizeChanged, | 92 callback: _handleSizeChanged, |
| 90 child: new Viewport( | 93 child: new Viewport( |
| 91 offset: offsetY, | 94 offset: offsetY, |
| 92 child: new Container( | 95 child: new Container( |
| 93 padding: padding, | 96 padding: padding, |
| 94 child: new Block(items) | 97 child: new Block(items) |
| 95 ) | 98 ) |
| 96 ) | 99 ) |
| 97 ); | 100 ); |
| 98 } | 101 } |
| 99 | 102 |
| 100 List<Widget> buildItems(int start, int count); | 103 List<Widget> buildItems(int start, int count); |
| 101 | 104 |
| 102 } | 105 } |
| OLD | NEW |