Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit e235a17

Browse files
author
Yuncong Zhang
committed
[Cupertino] Implement nav_bar.
1 parent e1081c6 commit e235a17

File tree

9 files changed

+656
-482
lines changed

9 files changed

+656
-482
lines changed

Runtime/cupertino/nav_bar.cs

Lines changed: 530 additions & 475 deletions
Large diffs are not rendered by default.

Runtime/cupertino/page_scaffold.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ public override Widget build(BuildContext context) {
6767
? existingMediaQuery.viewInsets.copyWith(bottom: 0.0f)
6868
: existingMediaQuery.viewInsets;
6969

70-
bool fullObstruction =
70+
bool? fullObstruction =
7171
this.widget.navigationBar.fullObstruction == false
7272
? CupertinoTheme.of(context).barBackgroundColor.alpha == 0xFF
7373
: this.widget.navigationBar.fullObstruction;
7474

75-
if (fullObstruction) {
75+
if (fullObstruction == true) {
7676
paddedContent = new MediaQuery(
7777
data: existingMediaQuery
7878
.removePadding(removeTop: true)
@@ -138,6 +138,8 @@ public override Widget build(BuildContext context) {
138138
}
139139

140140
public abstract class ObstructingPreferredSizeWidget : PreferredSizeWidget {
141-
public bool fullObstruction { get; }
141+
142+
protected ObstructingPreferredSizeWidget(Key key = null) : base(key: key) {}
143+
public virtual bool? fullObstruction { get; }
142144
}
143145
}

Runtime/cupertino/text_theme.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public TextStyle tabLabelTextStyle {
134134

135135
readonly TextStyle _navTitleTextStyle;
136136

137-
TextStyle navTitleTextStyle {
137+
public TextStyle navTitleTextStyle {
138138
get {
139139
return this._navTitleTextStyle ??
140140
(this._isLight

Runtime/widgets/transitions.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Unity.UIWidgets.ui;
66
using UnityEngine;
77
using Rect = Unity.UIWidgets.ui.Rect;
8+
using TextStyle = Unity.UIWidgets.painting.TextStyle;
89

910
namespace Unity.UIWidgets.widgets {
1011
public abstract class AnimatedWidget : StatefulWidget {
@@ -361,6 +362,48 @@ protected internal override Widget build(BuildContext context) {
361362
}
362363
}
363364

365+
public class DefaultTextStyleTransition : AnimatedWidget {
366+
public DefaultTextStyleTransition(
367+
Key key = null,
368+
Animation<TextStyle> style = null,
369+
Widget child = null,
370+
TextAlign? textAlign = null,
371+
bool softWrap = true,
372+
TextOverflow overflow = TextOverflow.clip,
373+
int? maxLines = null
374+
) : base(key: key, listenable: style) {
375+
D.assert(style != null);
376+
D.assert(child != null);
377+
this.textAlign = textAlign;
378+
this.softWrap = softWrap;
379+
this.overflow = overflow;
380+
this.maxLines = maxLines;
381+
this.child = child;
382+
}
383+
384+
Animation<TextStyle> style {
385+
get { return (Animation<TextStyle>) this.listenable; }
386+
}
387+
388+
public readonly TextAlign? textAlign;
389+
390+
public readonly bool softWrap;
391+
public readonly TextOverflow overflow;
392+
public readonly int? maxLines;
393+
public readonly Widget child;
394+
395+
protected internal override Widget build(BuildContext context) {
396+
return new DefaultTextStyle(
397+
style: this.style.value,
398+
textAlign: this.textAlign,
399+
softWrap: this.softWrap,
400+
overflow: this.overflow,
401+
maxLines: this.maxLines,
402+
child: this.child
403+
);
404+
}
405+
}
406+
364407

365408
public class AnimatedBuilder : AnimatedWidget {
366409
public readonly TransitionBuilder builder;
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using Unity.UIWidgets.foundation;
2+
3+
namespace Unity.UIWidgets.widgets {
4+
public delegate Widget ValueWidgetBuilder<T>(BuildContext context, T value, Widget child);
5+
6+
public class ValueListenableBuilder<T> : StatefulWidget {
7+
public ValueListenableBuilder(
8+
ValueListenable<T> valueListenable,
9+
ValueWidgetBuilder<T> builder,
10+
Widget child = null
11+
) {
12+
D.assert(valueListenable != null);
13+
D.assert(builder != null);
14+
this.valueListenable = valueListenable;
15+
this.builder = builder;
16+
this.child = child;
17+
}
18+
19+
public readonly ValueListenable<T> valueListenable;
20+
21+
public readonly ValueWidgetBuilder<T> builder;
22+
23+
public readonly Widget child;
24+
25+
public override State createState() {
26+
return new _ValueListenableBuilderState<T>();
27+
}
28+
}
29+
30+
class _ValueListenableBuilderState<T> : State<ValueListenableBuilder<T>> {
31+
T value;
32+
33+
public override void initState() {
34+
base.initState();
35+
this.value = this.widget.valueListenable.value;
36+
this.widget.valueListenable.addListener(this._valueChanged);
37+
}
38+
39+
public override void didUpdateWidget(StatefulWidget _oldWidget) {
40+
ValueListenableBuilder<T> oldWidget = _oldWidget as ValueListenableBuilder<T>;
41+
if (oldWidget.valueListenable != this.widget.valueListenable) {
42+
oldWidget.valueListenable.removeListener(this._valueChanged);
43+
this.value = this.widget.valueListenable.value;
44+
this.widget.valueListenable.addListener(this._valueChanged);
45+
}
46+
47+
base.didUpdateWidget(oldWidget);
48+
}
49+
50+
public override void dispose() {
51+
this.widget.valueListenable.removeListener(this._valueChanged);
52+
base.dispose();
53+
}
54+
55+
void _valueChanged() {
56+
this.setState(() => { this.value = this.widget.valueListenable.value; });
57+
}
58+
59+
public override Widget build(BuildContext context) {
60+
return this.widget.builder(context, this.value, this.widget.child);
61+
}
62+
}
63+
}

Runtime/widgets/value_listenable_builder.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Samples/UIWidgetsGallery/demo/animation/home.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ float _indicatorOpacity(int index) {
340340
);
341341
}
342342

343-
protected override Widget build(BuildContext context) {
343+
protected internal override Widget build(BuildContext context) {
344344
return new LayoutBuilder(builder: this._build);
345345
}
346346
}

Samples/UIWidgetsGallery/demo/material/backdrop_demo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public BackdropTitle(
222222
) : base(key: key, listenable: listenable) {
223223
}
224224

225-
protected override Widget build(BuildContext context) {
225+
protected internal override Widget build(BuildContext context) {
226226
Animation<float> animation = (Animation<float>) this.listenable;
227227
return new DefaultTextStyle(
228228
style: Theme.of(context).primaryTextTheme.title,

Samples/UIWidgetsGallery/gallery/backdrop.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public _CrossFadeTransition(
9595
public readonly Widget child0;
9696
public readonly Widget child1;
9797

98-
protected override Widget build(BuildContext context) {
98+
protected internal override Widget build(BuildContext context) {
9999
Animation<float> progress = this.listenable as Animation<float>;
100100

101101
float opacity1 = new CurvedAnimation(

0 commit comments

Comments
 (0)