Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: sky/sdk/lib/widgets/fixed_height_scrollable.dart

Issue 1226113007: Add @override annotation to known overriden methods (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/sdk/lib/widgets/drawer_header.dart ('k') | sky/sdk/lib/widgets/flat_button.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:vector_math/vector_math.dart'; 7 import 'package:vector_math/vector_math.dart';
8 8
9 import '../animation/scroll_behavior.dart'; 9 import '../animation/scroll_behavior.dart';
10 import 'basic.dart'; 10 import 'basic.dart';
11 import 'scrollable.dart'; 11 import 'scrollable.dart';
12 12
13 abstract class FixedHeightScrollable extends Scrollable { 13 abstract class FixedHeightScrollable extends Scrollable {
14 14
15 FixedHeightScrollable({ String key, this.itemHeight, Color backgroundColor, th is.padding }) 15 FixedHeightScrollable({ String key, this.itemHeight, Color backgroundColor, th is.padding })
16 : super(key: key, backgroundColor: backgroundColor) { 16 : super(key: key, backgroundColor: backgroundColor) {
17 assert(itemHeight != null); 17 assert(itemHeight != null);
18 } 18 }
19 19
20 EdgeDims padding; 20 EdgeDims padding;
21 double itemHeight; 21 double itemHeight;
22 22
23 /// Subclasses must implement `get itemCount` to tell FixedHeightScrollable 23 /// Subclasses must implement `get itemCount` to tell FixedHeightScrollable
24 /// how many items there are in the list. 24 /// how many items there are in the list.
25 int get itemCount; 25 int get itemCount;
26 26
27 @override
27 void syncFields(FixedHeightScrollable source) { 28 void syncFields(FixedHeightScrollable source) {
28 padding = source.padding; 29 padding = source.padding;
29 itemHeight = source.itemHeight; 30 itemHeight = source.itemHeight;
30 super.syncFields(source); 31 super.syncFields(source);
31 } 32 }
32 33
34 @override
33 ScrollBehavior createScrollBehavior() => new OverscrollBehavior(); 35 ScrollBehavior createScrollBehavior() => new OverscrollBehavior();
36
37 @override
34 OverscrollBehavior get scrollBehavior => super.scrollBehavior; 38 OverscrollBehavior get scrollBehavior => super.scrollBehavior;
35 39
36 double _height; 40 double _height;
37 void _handleSizeChanged(Size newSize) { 41 void _handleSizeChanged(Size newSize) {
38 setState(() { 42 setState(() {
39 _height = newSize.height; 43 _height = newSize.height;
40 scrollBehavior.containerHeight = _height; 44 scrollBehavior.containerHeight = _height;
41 }); 45 });
42 } 46 }
43 47
48 @override
44 bool scrollTo(double newScrollOffset) { 49 bool scrollTo(double newScrollOffset) {
45 if (_height != null && _height > 0.0) { 50 if (_height != null && _height > 0.0) {
46 double maxScrollOffset = math.max(0.0, itemCount * itemHeight - _height); 51 double maxScrollOffset = math.max(0.0, itemCount * itemHeight - _height);
47 newScrollOffset = math.min(newScrollOffset, maxScrollOffset); 52 newScrollOffset = math.min(newScrollOffset, maxScrollOffset);
48 } 53 }
49 return super.scrollTo(newScrollOffset); 54 return super.scrollTo(newScrollOffset);
50 } 55 }
51 56
52 void _updateContentsHeight() { 57 void _updateContentsHeight() {
53 double contentsHeight = itemHeight * itemCount; 58 double contentsHeight = itemHeight * itemCount;
54 if (padding != null) 59 if (padding != null)
55 contentsHeight += padding.top + padding.bottom; 60 contentsHeight += padding.top + padding.bottom;
56 scrollBehavior.contentsHeight = contentsHeight; 61 scrollBehavior.contentsHeight = contentsHeight;
57 } 62 }
58 63
64 @override
59 Widget buildContent() { 65 Widget buildContent() {
60 _updateContentsHeight(); 66 _updateContentsHeight();
61 67
62 var itemShowIndex = 0; 68 var itemShowIndex = 0;
63 var itemShowCount = 0; 69 var itemShowCount = 0;
64 Matrix4 transform = new Matrix4.identity(); 70 Matrix4 transform = new Matrix4.identity();
65 71
66 if (_height != null && _height > 0.0) { 72 if (_height != null && _height > 0.0) {
67 if (scrollOffset < 0.0) { 73 if (scrollOffset < 0.0) {
68 double visibleHeight = _height + scrollOffset; 74 double visibleHeight = _height + scrollOffset;
(...skipping 25 matching lines...) Expand all
94 child: new Block(items) 100 child: new Block(items)
95 ) 101 )
96 ) 102 )
97 ) 103 )
98 ); 104 );
99 } 105 }
100 106
101 List<Widget> buildItems(int start, int count); 107 List<Widget> buildItems(int start, int count);
102 108
103 } 109 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/drawer_header.dart ('k') | sky/sdk/lib/widgets/flat_button.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698