浏览代码

material tab widgets check + code style

/main
xingwei.zhu 6 年前
当前提交
47597a02
共有 5 个文件被更改,包括 32 次插入25 次删除
  1. 5
      Runtime/material/tab_bar_theme.cs
  2. 19
      Runtime/material/tab_controller.cs
  3. 31
      Runtime/material/tabs.cs
  4. 2
      Samples/UIWidgetSample/MaterialSample.cs
  5. 0
      /Runtime/widgets/preferred_size.cs

5
Runtime/material/tab_bar_theme.cs


Decoration indicator = null,
TabBarIndicatorSize? indicatorSize = null,
Color labelColor = null,
Color unselectedLabelColor = null) {
Color unselectedLabelColor = null
) {
return new TabBarTheme(
indicator: indicator ?? this.indicator,
indicatorSize: indicatorSize ?? this.indicatorSize,

public override int GetHashCode() {
unchecked {
var hashCode = (this.indicator != null ? this.indicator.GetHashCode() : 0);
var hashCode = this.indicator != null ? this.indicator.GetHashCode() : 0;
hashCode = (hashCode * 397) ^ (this.indicatorSize != null ? this.indicatorSize.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.labelColor != null ? this.labelColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^

19
Runtime/material/tab_controller.cs


public class TabController : ChangeNotifier {
public TabController(
int initialIndex = 0,
int length = 0,
int? length = null,
D.assert(length >= 0);
D.assert(length != null && length >= 0);
D.assert(vsync != null);
this.length = length.Value;
this.length = length;
upperBound: (length - 1),
upperBound: length.Value - 1,
vsync: vsync);
}

AnimationController _animationController;
readonly AnimationController _animationController;
public readonly int length;

D.assert(this._indexIsChangingCount >= 0);
if (value == this._index || this.length < 2) {
return;
}

}
public readonly TabController controller;
return this.enabled != _old.enabled || this.controller != _old.controller;
return this.enabled != _old.enabled
|| this.controller != _old.controller;
}
}

base.initState();
this._controller = new TabController(
vsync: this,
length: this.widget.length.Value,
length: this.widget.length,
initialIndex: this.widget.initialIndex
);
}

31
Runtime/material/tabs.cs


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(

2
Samples/UIWidgetSample/MaterialSample.cs


appBar: new AppBar(
title: new Center(
child: new Text("AppBar Bottom Widget")
),
),
leading: new IconButton(
tooltip: "Previous choice",
icon: new Icon(Unity.UIWidgets.material.Icons.arrow_back),

/Runtime/widgets/perferred_size.cs → /Runtime/widgets/preferred_size.cs

正在加载...
取消
保存