Correct the TabBarView swipe selection change animation

The TabBarSelection change animation needs to start where the fling's drag gesture ended rather than from zero.  The intial vlaue of progress for the TabBarSelection's performance is now converted from the range used during an interactive drag, to the range used when animating from the previously selected tab to the new one.

TabBarSelection now requires a maxIndex parameter.
This commit is contained in:
Hans Muller
2015-12-16 14:33:30 -08:00
parent 1e8886930a
commit 65dca5b578
4 changed files with 60 additions and 30 deletions

View File

@@ -6,8 +6,8 @@ import 'package:flutter/material.dart';
import 'widget_demo.dart';
final TabBarSelection _selection = new TabBarSelection();
final List<String> _iconNames = <String>["event", "home", "android", "alarm", "face", "language"];
final TabBarSelection _selection = new TabBarSelection(maxIndex: _iconNames.length - 1);
Widget buildTabBar(_) {
return new TabBar(

View File

@@ -30,7 +30,7 @@ class StockHomeState extends State<StockHome> {
super.initState();
_tabBarSelection = PageStorage.of(context)?.readState(context);
if (_tabBarSelection == null) {
_tabBarSelection = new TabBarSelection();
_tabBarSelection = new TabBarSelection(maxIndex: 1);
PageStorage.of(context)?.writeState(context, _tabBarSelection);
}
}