|
|
|
|
|
|
return (controllerValue - currentIndex).abs() / (currentIndex - previousIndex).abs(); |
|
|
|
} |
|
|
|
|
|
|
|
public static PageScrollPhysics _kTabBarViewPhysics = |
|
|
|
public static readonly PageScrollPhysics _kTabBarViewPhysics = |
|
|
|
(PageScrollPhysics) new PageScrollPhysics().applyTo(new ClampingScrollPhysics()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
TabBarTheme tabBarTheme = TabBarTheme.of(context); |
|
|
|
|
|
|
|
TextStyle defaultStyle = this.labelStyle ?? themeData.primaryTextTheme.body2; |
|
|
|
TextStyle defaultUnselectedStyle = this.unselectedLabelStyle ?? themeData.primaryTextTheme.body2; |
|
|
|
TextStyle defaultUnselectedStyle = |
|
|
|
this.unselectedLabelStyle ?? this.labelStyle ?? themeData.primaryTextTheme.body2; |
|
|
|
Animation<float> animation = (Animation<float>) this.listenable; |
|
|
|
TextStyle textStyle = this.selected |
|
|
|
? TextStyle.lerp(defaultStyle, defaultUnselectedStyle, animation.value) |
|
|
|
|
|
|
D.assert(mainAxisAlignment != null); |
|
|
|
D.assert(crossAxisAlignment != null); |
|
|
|
D.assert(verticalDirection != null); |
|
|
|
|
|
|
|
D.assert(onPerformLayout != null); |
|
|
|
this.onPerformLayout = onPerformLayout; |
|
|
|
} |
|
|
|
|
|
|
public readonly List<GlobalKey> tabKeys; |
|
|
|
|
|
|
|
List<float> _currentTabOffsets; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool _needsPaint = false; |
|
|
|
|
|
|
|
void markNeedsPaint() { |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public readonly TabController controller; |
|
|
|
|
|
|
|
public readonly int index; |
|
|
|
|
|
|
|
public override Animation<float> parent { |
|
|
|
|
|
|
) : base(key: key) { |
|
|
|
indicatorPadding = indicatorPadding ?? EdgeInsets.zero; |
|
|
|
D.assert(tabs != null); |
|
|
|
D.assert(indicator != null || (indicatorWeight > 0.0f)); |
|
|
|
D.assert(indicator != null || indicatorWeight > 0.0f); |
|
|
|
D.assert(indicator != null || indicatorPadding != null); |
|
|
|
this.tabs = tabs; |
|
|
|
this.controller = controller; |
|
|
|
|
|
|
TabController _controller; |
|
|
|
_IndicatorPainter _indicatorPainter; |
|
|
|
int _currentIndex; |
|
|
|
float _tabStripWidth; |
|
|
|
List<GlobalKey> _tabKeys; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
position.maxScrollExtent); |
|
|
|
} |
|
|
|
|
|
|
|
public float _initialScrollOffset(float viewportWidth, float minExtent, float maxExtent) { |
|
|
|
float _initialScrollOffset(float viewportWidth, float minExtent, float maxExtent) { |
|
|
|
return this._tabScrollOffset(this._currentIndex, viewportWidth, minExtent, maxExtent); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void _saveTabOffsets(List<float> tabOffsets, float width) { |
|
|
|
this._tabStripWidth = width; |
|
|
|
this._indicatorPainter?.saveTabOffsets(tabOffsets); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override Widget build(BuildContext context) { |
|
|
|
D.assert(MaterialD.debugCheckHasMaterialLocalizations(context)); |
|
|
|
MaterialLocalizations localizations = MaterialLocalizations.of(context); |
|
|
|
|
|
|
|
if (this._controller.length == 0) { |
|
|
|
return new Container( |
|
|
|
|
|
|
padding: this.widget.labelPadding ?? Constants.kTabLabelPadding, |
|
|
|
child: new KeyedSubtree( |
|
|
|
key: this._tabKeys[i], |
|
|
|
child: this.widget.tabs[i])) |
|
|
|
child: this.widget.tabs[i] |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
unselectedLabelStyle: this.widget.unselectedLabelStyle, |
|
|
|
child: new _TabLabelBar( |
|
|
|
onPerformLayout: this._saveTabOffsets, |
|
|
|
children: wrappedTabs) |
|
|
|
children: wrappedTabs |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
"No TabController for " + this.widget.GetType() + "\n" + |
|
|
|
"When creating a " + this.widget.GetType() + ", you must either provide an explicit " + |
|
|
|
"TabController using the \"controller\" property, or you must ensure that there " + |
|
|
|
"is a DefaultTabController above the " + this.widget.GetType() + ".\n" + |
|
|
|
"is a DefaultTabController above the " + this.widget.GetType() + ".\n" + |
|
|
|
"In this case, there was neither an explicit controller nor a default controller." |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public override void didUpdateWidget(StatefulWidget oldWidget) { |
|
|
|
TabBarView _oldWidget = (TabBarView) oldWidget; |
|
|
|
TabBarView _oldWidget = (TabBarView) oldWidget; |
|
|
|
if (this.widget.controller != _oldWidget.controller) { |
|
|
|
this._updateTabController(); |
|
|
|
} |
|
|
|
|
|
|
tabIndex, |
|
|
|
tabController, |
|
|
|
selectedColorTween, |
|
|
|
previousColorTween)); |
|
|
|
previousColorTween) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
return new Row( |
|
|
|