浏览代码

Update tabs, page view, scrollable and single child scroll view.

/main
Yuncong Zhang 5 年前
当前提交
bcfcf7e6
共有 4 个文件被更改,包括 63 次插入23 次删除
  1. 44
      Runtime/material/tabs.cs
  2. 8
      Runtime/widgets/page_view.cs
  3. 28
      Runtime/widgets/scrollable.cs
  4. 6
      Runtime/widgets/single_child_scroll_view.cs

44
Runtime/material/tabs.cs


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

8
Runtime/widgets/page_view.cs


using RSG;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.physics;
using Unity.UIWidgets.rendering;

public float page {
get {
return (Mathf.Max(0.0f, this.pixels.clamp(this.minScrollExtent, this.maxScrollExtent)) /
Mathf.Max(1.0f, this.viewportDimension * this.viewportFraction));
Mathf.Max(1.0f, this.viewportDimension * this.viewportFraction));
}
}

bool pageSnapping = true,
ValueChanged<int> onPageChanged = null,
List<Widget> children = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.down,
IndexedWidgetBuilder itemBuilder = null,
SliverChildDelegate childDelegate = null,
int itemCount = 0

this.physics = physics;
this.pageSnapping = pageSnapping;
this.onPageChanged = onPageChanged;
this.dragStartBehavior = dragStartBehavior;
this.controller = controller ?? PageViewUtils._defaultPageController;
if (itemBuilder != null) {
this.childrenDelegate = new SliverChildBuilderDelegate(itemBuilder, childCount: itemCount);

public readonly ValueChanged<int> onPageChanged;
public readonly SliverChildDelegate childrenDelegate;
public readonly DragStartBehavior dragStartBehavior;
public override State createState() {
return new _PageViewState();

return false;
},
child: new Scrollable(
dragStartBehavior: this.widget.dragStartBehavior,
axisDirection: axisDirection,
controller: this.widget.controller,
physics: physics,

28
Runtime/widgets/scrollable.cs


AxisDirection axisDirection = AxisDirection.down,
ScrollController controller = null,
ScrollPhysics physics = null,
ViewportBuilder viewportBuilder = null
ViewportBuilder viewportBuilder = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.down
) : base(key: key) {
D.assert(viewportBuilder != null);

this.viewportBuilder = viewportBuilder;
this.dragStartBehavior = dragStartBehavior;
}
public readonly AxisDirection axisDirection;

public readonly ScrollPhysics physics;
public readonly ViewportBuilder viewportBuilder;
public readonly DragStartBehavior dragStartBehavior;
public Axis axis {
get { return AxisUtils.axisDirectionToAxis(this.axisDirection); }

this._physics == null ? (float?) null : this._physics.minFlingVelocity;
instance.maxFlingVelocity =
this._physics == null ? (float?) null : this._physics.maxFlingVelocity;
instance.dragStartBehavior = this.widget.dragStartBehavior;
}
));
break;

this._physics == null ? (float?) null : this._physics.minFlingVelocity;
instance.maxFlingVelocity =
this._physics == null ? (float?) null : this._physics.maxFlingVelocity;
instance.dragStartBehavior = this.widget.dragStartBehavior;
}
));
break;

public override Widget build(BuildContext context) {
D.assert(this.position != null);
Widget result = new RawGestureDetector(
key: this._gestureDetectorKey,
gestures: this._gestureRecognizers,
behavior: HitTestBehavior.opaque,
child: new IgnorePointer(
key: this._ignorePointerKey,
ignoring: this._shouldIgnorePointer,
child: new _ScrollableScope(
scrollable: this,
position: this.position,
Widget result = new _ScrollableScope(
scrollable: this,
position: this.position,
child: new RawGestureDetector(
key: this._gestureDetectorKey,
gestures: this._gestureRecognizers,
behavior: HitTestBehavior.opaque,
child: new IgnorePointer(
key: this._ignorePointerKey,
ignoring: this._shouldIgnorePointer,
child: this.widget.viewportBuilder(context, this.position)
)
)

6
Runtime/widgets/single_child_scroll_view.cs


bool? primary = null,
ScrollPhysics physics = null,
ScrollController controller = null,
Widget child = null
Widget child = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.down
) : base(key: key) {
D.assert(!(controller != null && primary == true),
"Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. " +

this.physics = physics;
this.controller = controller;
this.child = child;
this.dragStartBehavior = dragStartBehavior;
}
public readonly Axis scrollDirection;

public readonly Widget child;
public readonly DragStartBehavior dragStartBehavior;
AxisDirection _getDirection(BuildContext context) {
return AxisDirectionUtils.getAxisDirectionFromAxisReverseAndDirectionality(context, this.scrollDirection,

: this.controller;
Scrollable scrollable = new Scrollable(
dragStartBehavior: this.dragStartBehavior,
axisDirection: axisDirection,
controller: scrollController,
physics: this.physics,

正在加载...
取消
保存