Yuncong Zhang
5 年前
当前提交
0b6b7511
共有 9 个文件被更改,包括 571 次插入 和 327 次删除
-
765Runtime/cupertino/nav_bar.cs
-
8Runtime/cupertino/page_scaffold.cs
-
2Runtime/cupertino/text_theme.cs
-
43Runtime/widgets/transitions.cs
-
2Samples/UIWidgetsGallery/demo/animation/home.cs
-
2Samples/UIWidgetsGallery/demo/material/backdrop_demo.cs
-
2Samples/UIWidgetsGallery/gallery/backdrop.cs
-
63Runtime/widgets/value_listenable_builder.cs
-
11Runtime/widgets/value_listenable_builder.cs.meta
765
Runtime/cupertino/nav_bar.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
using Unity.UIWidgets.foundation; |
|||
|
|||
namespace Unity.UIWidgets.widgets { |
|||
public delegate Widget ValueWidgetBuilder<T>(BuildContext context, T value, Widget child); |
|||
|
|||
public class ValueListenableBuilder<T> : StatefulWidget { |
|||
public ValueListenableBuilder( |
|||
ValueListenable<T> valueListenable, |
|||
ValueWidgetBuilder<T> builder, |
|||
Widget child = null |
|||
) { |
|||
D.assert(valueListenable != null); |
|||
D.assert(builder != null); |
|||
this.valueListenable = valueListenable; |
|||
this.builder = builder; |
|||
this.child = child; |
|||
} |
|||
|
|||
public readonly ValueListenable<T> valueListenable; |
|||
|
|||
public readonly ValueWidgetBuilder<T> builder; |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public override State createState() { |
|||
return new _ValueListenableBuilderState<T>(); |
|||
} |
|||
} |
|||
|
|||
class _ValueListenableBuilderState<T> : State<ValueListenableBuilder<T>> { |
|||
T value; |
|||
|
|||
public override void initState() { |
|||
base.initState(); |
|||
this.value = this.widget.valueListenable.value; |
|||
this.widget.valueListenable.addListener(this._valueChanged); |
|||
} |
|||
|
|||
public override void didUpdateWidget(StatefulWidget _oldWidget) { |
|||
ValueListenableBuilder<T> oldWidget = _oldWidget as ValueListenableBuilder<T>; |
|||
if (oldWidget.valueListenable != this.widget.valueListenable) { |
|||
oldWidget.valueListenable.removeListener(this._valueChanged); |
|||
this.value = this.widget.valueListenable.value; |
|||
this.widget.valueListenable.addListener(this._valueChanged); |
|||
} |
|||
|
|||
base.didUpdateWidget(oldWidget); |
|||
} |
|||
|
|||
public override void dispose() { |
|||
this.widget.valueListenable.removeListener(this._valueChanged); |
|||
base.dispose(); |
|||
} |
|||
|
|||
void _valueChanged() { |
|||
this.setState(() => { this.value = this.widget.valueListenable.value; }); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return this.widget.builder(context, this.value, this.widget.child); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c4b7ae22b588cdf4093501087a4ecadb |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue