|
|
|
|
|
|
using RSG; |
|
|
|
using Unity.UIWidgets.animation; |
|
|
|
using Unity.UIWidgets.foundation; |
|
|
|
using Unity.UIWidgets.gestures; |
|
|
|
using Unity.UIWidgets.painting; |
|
|
|
using Unity.UIWidgets.rendering; |
|
|
|
using Unity.UIWidgets.ui; |
|
|
|
|
|
|
height = TabsUtils._kTabHeight; |
|
|
|
label = this._buildLabelText(); |
|
|
|
} |
|
|
|
else if (this.text == null) { |
|
|
|
else if (this.text == null && this.child == null) { |
|
|
|
height = TabsUtils._kTabHeight; |
|
|
|
label = this.icon; |
|
|
|
} |
|
|
|
|
|
|
ThemeData themeData = Theme.of(context); |
|
|
|
TabBarTheme tabBarTheme = TabBarTheme.of(context); |
|
|
|
|
|
|
|
TextStyle defaultStyle = this.labelStyle ?? themeData.primaryTextTheme.body2; |
|
|
|
TextStyle defaultUnselectedStyle = |
|
|
|
this.unselectedLabelStyle ?? this.labelStyle ?? themeData.primaryTextTheme.body2; |
|
|
|
TextStyle defaultStyle = this.labelStyle ?? tabBarTheme.labelStyle ?? themeData.primaryTextTheme.body2; |
|
|
|
TextStyle defaultUnselectedStyle = this.unselectedLabelStyle |
|
|
|
?? tabBarTheme.unselectedLabelStyle |
|
|
|
?? this.labelStyle ?? themeData.primaryTextTheme.body2; |
|
|
|
Animation<float> animation = (Animation<float>) this.listenable; |
|
|
|
TextStyle textStyle = this.selected |
|
|
|
? TextStyle.lerp(defaultStyle, defaultUnselectedStyle, animation.value) |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public readonly _TabBarState tabBar; |
|
|
|
|
|
|
|
|
|
|
|
bool _initialViewportDimensionWasZero; |
|
|
|
|
|
|
|
if (!this.havePixels) { |
|
|
|
this.correctPixels(this.tabBar._initialScrollOffset(this.viewportDimension, minScrollExtent, maxScrollExtent)); |
|
|
|
if (this._initialViewportDimensionWasZero != true) { |
|
|
|
this._initialViewportDimensionWasZero = this.viewportDimension != 0.0; |
|
|
|
this.correctPixels(this.tabBar._initialScrollOffset(this.viewportDimension, minScrollExtent, |
|
|
|
maxScrollExtent)); |
|
|
|
|
|
|
|
return base.applyContentDimensions(minScrollExtent, maxScrollExtent) && result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
TextStyle labelStyle = null, |
|
|
|
EdgeInsets labelPadding = null, |
|
|
|
Color unselectedLabelColor = null, |
|
|
|
TextStyle unselectedLabelStyle = null |
|
|
|
TextStyle unselectedLabelStyle = null, |
|
|
|
DragStartBehavior dragStartBehavior = DragStartBehavior.down, |
|
|
|
ValueChanged<int> onTap = null |
|
|
|
) : base(key: key) { |
|
|
|
indicatorPadding = indicatorPadding ?? EdgeInsets.zero; |
|
|
|
D.assert(tabs != null); |
|
|
|
|
|
|
this.labelPadding = labelPadding; |
|
|
|
this.unselectedLabelColor = unselectedLabelColor; |
|
|
|
this.unselectedLabelStyle = unselectedLabelStyle; |
|
|
|
this.dragStartBehavior = dragStartBehavior; |
|
|
|
this.onTap = onTap; |
|
|
|
} |
|
|
|
|
|
|
|
public readonly List<Widget> tabs; |
|
|
|
|
|
|
|
|
|
|
public readonly TextStyle unselectedLabelStyle; |
|
|
|
|
|
|
|
public readonly DragStartBehavior dragStartBehavior; |
|
|
|
|
|
|
|
public readonly ValueChanged<int> onTap; |
|
|
|
|
|
|
|
public override Size preferredSize { |
|
|
|
get { |
|
|
|
foreach (Widget item in this.tabs) { |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Color color = this.widget.indicatorColor ?? Theme.of(this.context).indicatorColor; |
|
|
|
if (color.value == Material.of(this.context).color.value) { |
|
|
|
if (color.value == Material.of(this.context).color?.value) { |
|
|
|
color = Colors.white; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
void _handleTap(int index) { |
|
|
|
D.assert(index >= 0 && index < this.widget.tabs.Count); |
|
|
|
this._controller.animateTo(index); |
|
|
|
if (this.widget.onTap != null) { |
|
|
|
this.widget.onTap(index); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Widget _buildStyledTab(Widget child, bool selected, Animation<float> animation) { |
|
|
|
|
|
|
if (this.widget.isScrollable) { |
|
|
|
this._scrollController = this._scrollController ?? new _TabBarScrollController(this); |
|
|
|
tabBar = new SingleChildScrollView( |
|
|
|
dragStartBehavior: this.widget.dragStartBehavior, |
|
|
|
scrollDirection: Axis.horizontal, |
|
|
|
controller: this._scrollController, |
|
|
|
child: tabBar); |
|
|
|
|
|
|
Key key = null, |
|
|
|
List<Widget> children = null, |
|
|
|
TabController controller = null, |
|
|
|
ScrollPhysics physics = null |
|
|
|
ScrollPhysics physics = null, |
|
|
|
DragStartBehavior dragStartBehavior = DragStartBehavior.down |
|
|
|
this.dragStartBehavior = dragStartBehavior; |
|
|
|
} |
|
|
|
|
|
|
|
public readonly TabController controller; |
|
|
|
|
|
|
public readonly ScrollPhysics physics; |
|
|
|
|
|
|
|
public readonly DragStartBehavior dragStartBehavior; |
|
|
|
|
|
|
|
public override State createState() { |
|
|
|
return new _TabBarViewState(); |
|
|
|
|
|
|
return new NotificationListener<ScrollNotification>( |
|
|
|
onNotification: this._handleScrollNotification, |
|
|
|
child: new PageView( |
|
|
|
dragStartBehavior: this.widget.dragStartBehavior, |
|
|
|
controller: this._pageController, |
|
|
|
physics: this.widget.physics == null |
|
|
|
? TabsUtils._kTabBarViewPhysics |
|
|
|