浏览代码

add cupertino

/siyaoH-1.17-PlatformMessage
Shiyun Wen 4 年前
当前提交
93ba9083
共有 7 个文件被更改,包括 145 次插入29 次删除
  1. 109
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs
  2. 15
      com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs
  3. 10
      com.unity.uiwidgets/Runtime/cupertino/page_scaffold.cs
  4. 10
      com.unity.uiwidgets/Runtime/cupertino/route.cs
  5. 2
      com.unity.uiwidgets/Runtime/rendering/view.cs
  6. 9
      com.unity.uiwidgets/Runtime/widgets/framework.cs
  7. 19
      com.unity.uiwidgets/Runtime/widgets/preferred_size.cs

109
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs


using TextStyle = Unity.UIWidgets.painting.TextStyle;
using ui_ = Unity.UIWidgets.widgets.ui_;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.rendering;
namespace UIWidgetsSample
{

onPressed: () =>
{
Navigator.of(contex1).push(
new CupertinoPageRoute(builder: (conte2) =>
new CupertinoPageRoute(builder: (contex3) =>
return new DetailScreen(index==0? "views" : "articles" );
return new DetailScreen1(index==0? "views" : "articles" );
);
);
}
)
)

}
}
public class DetailScreen : StatelessWidget
public class DetailScreen1 : StatelessWidget
public DetailScreen(string topic)
public DetailScreen1(string topic)
{
this.topic = topic;

{
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
middle: new Text("Details")
//middle: new Text("Details")
child: new Text("hello world")
)
);
}
}
public class DetailScreen : StatefulWidget
{
public DetailScreen(string topic)
{
this.topic = topic;
}
public string topic;
public override State createState()
{
return new DetailScreenState();
}
}
public class DetailScreenState : State<DetailScreen>
{
public bool switchValue = false;
public override Widget build(BuildContext context)
{
var widgets = new List<Widget>();
widgets.Add( new Expanded(child : new Text("a switch")));
widgets.Add(new CupertinoSwitch(
value: switchValue,
onChanged: value =>
{
setState(() => switchValue = value);
}
));
var rowWidgtes = new List<Widget>();
var row = new Row(children:widgets);
//rowWidgtes.Add(row);
var cupBtn = new CupertinoButton(
child: new Text("launch action sheet"),
onPressed: () =>
{
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
builder: (context1) =>
{
return new CupertinoActionSheet(
title: new Text("some choices"),
actions: new List<Widget>(){
new CupertinoActionSheetAction(
child: new Text("one"),
onPressed: () =>
{
Navigator.pop(context1, 1);
},
isDefaultAction: true
),
new CupertinoActionSheetAction(
child: new Text("two"),
onPressed: () =>
{
Navigator.pop(context1, 2);
}
),
new CupertinoActionSheetAction(
child: new Text("three"),
onPressed: () =>
{
Navigator.pop(context1, 3);
}
)
}
);
}
);
}
);
rowWidgtes.Add(cupBtn);
return new CupertinoPageScaffold(
child: new Center(
child: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children:rowWidgtes
)
/*,
navigationBar: new CupertinoNavigationBar(
middle: new Text("hello world")
)*/
);
}
}

15
com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs


}
}
public class CupertinoNavigationBar : ObstructingPreferredSizeWidget {
public class CupertinoNavigationBar : StatefulWidget {
public CupertinoNavigationBar(
Key key = null,
Widget leading = null,

bool transitionBetweenRoutes = true,
object heroTag = null
) : base(key: key) {
//D.assert(automaticallyImplyLeading != null);
//D.assert(automaticallyImplyMiddle != null);
//D.assert(transitionBetweenRoutes != null);
this.leading = leading;
this.automaticallyImplyLeading = automaticallyImplyLeading;
this.automaticallyImplyMiddle = automaticallyImplyMiddle;

this.actionsForegroundColor = actionsForegroundColor;
this.transitionBetweenRoutes = transitionBetweenRoutes;
this.heroTag = heroTag ?? NavBarUtils._defaultHeroTag;
}
public readonly Widget leading;

public readonly object heroTag;
public override bool? fullObstruction {
//public override bool? fullObstruction {
public bool? fullObstruction {
public override Size preferredSize {
//public override Size preferredSize {
public Size preferredSize {
get { return Size.fromHeight(NavBarUtils._kNavBarPersistentHeight); }
}

10
com.unity.uiwidgets/Runtime/cupertino/page_scaffold.cs


public CupertinoPageScaffold(
Widget child,
Key key = null,
ObstructingPreferredSizeWidget navigationBar = null,
//ObstructingPreferredSizeWidget navigationBar = null,
CupertinoNavigationBar navigationBar = null,
Color backgroundColor = null,
bool resizeToAvoidBottomInset = true
) : base(key: key) {

this.resizeToAvoidBottomInset = resizeToAvoidBottomInset;
}
public readonly ObstructingPreferredSizeWidget navigationBar;
//public readonly ObstructingPreferredSizeWidget navigationBar;
public readonly CupertinoNavigationBar navigationBar;
public readonly Widget child;
public readonly Color backgroundColor;
public readonly bool resizeToAvoidBottomInset;

right: 0.0f,
height: existingMediaQuery.padding.top,
child: new GestureDetector(
//excludeFromSemantics: true,
onTap: _handleStatusBarTap
)
)

public abstract class ObstructingPreferredSizeWidget : PreferredSizeWidget {
protected ObstructingPreferredSizeWidget(Key key = null) : base(key: key) {}
//public virtual Size preferredSize { get; }
}

10
com.unity.uiwidgets/Runtime/cupertino/route.cs


}
}
protected internal override void didChangePrevious(Route previousRoute) {
protected internal override void didChangePrevious(Route previousRoute) {
string previousTitleString = previousRoute is CupertinoPageRoute
? ((CupertinoPageRoute) previousRoute).title
: null;

class CupertinoPageTransition : StatelessWidget {
public CupertinoPageTransition(
Animation<float> primaryRouteAnimation,
Animation<float> secondaryRouteAnimation,
Widget child,
bool linearTransition,
Animation<float> primaryRouteAnimation = null,
Animation<float> secondaryRouteAnimation = null,
Widget child = null,
bool linearTransition = default,
Key key = null
) : base(key: key) {
_primaryPositionAnimation =

2
com.unity.uiwidgets/Runtime/rendering/view.cs


public readonly float devicePixelRatio;
public Matrix4 toMatrix() {
return new Matrix4().diagonal3Values(this.devicePixelRatio, this.devicePixelRatio, 0);
return new Matrix4().diagonal3Values(devicePixelRatio, devicePixelRatio, 0);
//return new Matrix4().identity();
}

9
com.unity.uiwidgets/Runtime/widgets/framework.cs


}
protected virtual Element updateChild(Element child, Widget newWidget, object newSlot) {
int p = 1;
D.assert(() => {
if (newWidget != null && newWidget.key is GlobalKey) {
GlobalKey key = (GlobalKey) newWidget.key;

}
public override RenderObject createRenderObject(BuildContext context) {
return null;
// return new RenderErrorBox(message);
//return null;
return new RenderErrorBox(message);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {

void _debugUpdateRenderObjectOwner() {
D.assert(() => {
if (_renderObject == null) {
int i = 0;
}
_renderObject.debugCreator = new _DebugCreator(this);
return true;
});

19
com.unity.uiwidgets/Runtime/widgets/preferred_size.cs


Size preferredSize { get; }
}
public abstract class PreferredSizeWidget : StatefulWidget, SizePreferred {
public abstract class PreferredSizeWidget : Widget{ //StatefulWidget, SizePreferred {
protected PreferredSizeWidget(Key key = null) : base(key: key) {
}

public class PreferredSize : PreferredSizeWidget {
public class PreferredSize : StatelessWidget{//PreferredSizeWidget {
public PreferredSize(
Key key = null,
Widget child = null,

public readonly Widget child;
public override Size preferredSize { get; }
public override State createState() {
//public override Size preferredSize { get; }
public Size preferredSize { get; }
/*public override State createState() {
}*/
public override Widget build(BuildContext context) {
return child;
//throw new System.NotImplementedException();
class _PreferredSizeState : State<PreferredSize> {
/*class _PreferredSizeState : State<PreferredSize> {
}
}*/
}
正在加载...
取消
保存