| 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 '../animation/scroll_behavior.dart'; | 5 import '../animation/scroll_behavior.dart'; |
| 6 import '../fn2.dart'; | 6 import '../fn2.dart'; |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
| 9 import 'dart:sky' as sky; | |
| 10 import 'package:vector_math/vector_math.dart'; | 9 import 'package:vector_math/vector_math.dart'; |
| 11 import 'scrollable.dart'; | 10 import 'scrollable.dart'; |
| 12 | 11 |
| 13 abstract class FixedHeightScrollable extends Scrollable { | 12 abstract class FixedHeightScrollable extends Scrollable { |
| 14 FixedHeightScrollable({ this.itemHeight, Object key }) : super(key: key) { | 13 FixedHeightScrollable({ this.itemHeight, Object key }) : super(key: key) { |
| 15 assert(itemHeight != null); | 14 assert(itemHeight != null); |
| 16 } | 15 } |
| 17 | 16 |
| 18 ScrollBehavior createScrollBehavior() => new OverscrollBehavior(); | 17 ScrollBehavior createScrollBehavior() => new OverscrollBehavior(); |
| 19 OverscrollBehavior get scrollBehavior => super.scrollBehavior as OverscrollBeh
avior; | 18 OverscrollBehavior get scrollBehavior => super.scrollBehavior as OverscrollBeh
avior; |
| 20 | 19 |
| 21 double _height; | 20 double _height; |
| 22 final double itemHeight; | 21 final double itemHeight; |
| 23 | 22 |
| 24 int _itemCount = 0; | 23 int _itemCount = 0; |
| 25 int get itemCount => _itemCount; | 24 int get itemCount => _itemCount; |
| 26 void set itemCount (int value) { | 25 void set itemCount (int value) { |
| 27 if (_itemCount != value) { | 26 if (_itemCount != value) { |
| 28 _itemCount = value; | 27 _itemCount = value; |
| 29 scrollBehavior.contentsHeight = itemHeight * _itemCount; | 28 scrollBehavior.contentsHeight = itemHeight * _itemCount; |
| 30 } | 29 } |
| 31 } | 30 } |
| 32 | 31 |
| 33 void _handleSizeChanged(sky.Size newSize) { | 32 void _handleSizeChanged(Size newSize) { |
| 34 setState(() { | 33 setState(() { |
| 35 _height = newSize.height; | 34 _height = newSize.height; |
| 36 scrollBehavior.containerHeight = _height; | 35 scrollBehavior.containerHeight = _height; |
| 37 }); | 36 }); |
| 38 } | 37 } |
| 39 | 38 |
| 40 UINode buildContent() { | 39 UINode buildContent() { |
| 41 var itemNumber = 0; | 40 var itemNumber = 0; |
| 42 var itemCount = 0; | 41 var itemCount = 0; |
| 43 | 42 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 68 transform: transform, | 67 transform: transform, |
| 69 child: new BlockContainer( | 68 child: new BlockContainer( |
| 70 children: buildItems(itemNumber, itemCount)) | 69 children: buildItems(itemNumber, itemCount)) |
| 71 ) | 70 ) |
| 72 ) | 71 ) |
| 73 ); | 72 ); |
| 74 } | 73 } |
| 75 | 74 |
| 76 List<UINode> buildItems(int start, int count); | 75 List<UINode> buildItems(int start, int count); |
| 77 } | 76 } |
| OLD | NEW |