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

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

Issue 1216323002: Add a TabNavigator to the Stocks demo (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/editing/editable_text.dart ('k') | sky/tests/examples/stocks-expected.txt » ('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';
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 43
44 double _height; 44 double _height;
45 void _handleSizeChanged(Size newSize) { 45 void _handleSizeChanged(Size newSize) {
46 setState(() { 46 setState(() {
47 _height = newSize.height; 47 _height = newSize.height;
48 scrollBehavior.containerHeight = _height; 48 scrollBehavior.containerHeight = _height;
49 }); 49 });
50 } 50 }
51 51
52 bool scrollTo(double newScrollOffset) {
53 if (_height != null && _height > 0.0) {
54 double maxScrollOffset = math.max(0.0, itemCount * itemHeight - _height);
55 newScrollOffset = math.min(newScrollOffset, maxScrollOffset);
56 }
57 return super.scrollTo(newScrollOffset);
58 }
59
52 Widget buildContent() { 60 Widget buildContent() {
53 var itemShowIndex = 0; 61 var itemShowIndex = 0;
54 var itemShowCount = 0; 62 var itemShowCount = 0;
55 63
56 Matrix4 transform = new Matrix4.identity(); 64 Matrix4 transform = new Matrix4.identity();
57 65
58 if (_height != null && _height > 0.0) { 66 if (_height != null && _height > 0.0) {
59 if (scrollOffset < 0.0) { 67 if (scrollOffset < 0.0) {
60 double visibleHeight = _height + scrollOffset; 68 double visibleHeight = _height + scrollOffset;
61 itemShowCount = (visibleHeight / itemHeight).round() + 1; 69 itemShowCount = (visibleHeight / itemHeight).round() + 1;
(...skipping 24 matching lines...) Expand all
86 child: new Block(items) 94 child: new Block(items)
87 ) 95 )
88 ) 96 )
89 ) 97 )
90 ); 98 );
91 } 99 }
92 100
93 List<Widget> buildItems(int start, int count); 101 List<Widget> buildItems(int start, int count);
94 102
95 } 103 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/editing/editable_text.dart ('k') | sky/tests/examples/stocks-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698