浏览代码

fix alignment bug

add reorderable list sample
/siyaoH-1.17-PlatformMessage
xingweizhu 4 年前
当前提交
e8bf3f02
共有 4 个文件被更改,包括 99 次插入9 次删除
  1. 10
      com.unity.uiwidgets/Runtime/painting/alignment.cs
  2. 8
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample.meta
  3. 79
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/ReorderableListSample.cs
  4. 11
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/ReorderableListSample.cs.meta

10
com.unity.uiwidgets/Runtime/painting/alignment.cs


}
public override Alignment resolve(TextDirection? direction) {
direction = direction ?? TextDirection.ltr;
switch (direction) {
case TextDirection.rtl:
return new Alignment(_x - _start, _y);
case TextDirection.ltr:
return new Alignment(_x + _start, _y);
}
return null;
return this;
}

8
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample.meta


fileFormatVersion: 2
guid: c0f377c78881e9243879a01b93524d63
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

79
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/ReorderableListSample.cs


using System.Collections.Generic;
using System.Linq;
using uiwidgets;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Material = Unity.UIWidgets.material.Material;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {
public class ReorderableListSample : UIWidgetsPanel {
protected override void main() {
ui_.runApp(new MaterialApp(
showPerformanceOverlay: false,
home: new MaterialReorderableListViewWidget()));
}
protected new void OnEnable() {
base.OnEnable();
}
}
class MaterialReorderableListViewWidget : StatefulWidget {
public MaterialReorderableListViewWidget(Key key = null) : base(key) {
}
public override State createState() {
return new MaterialReorderableListViewWidgetState();
}
}
class MaterialReorderableListViewWidgetState : State<MaterialReorderableListViewWidget> {
List<string> _list = new List<string> {"Apple", "Ball", "Cat", "Dog", "Elephant"};
public override Widget build(BuildContext context) {
return new Scaffold(
body: new ReorderableListView(
children: this._list.Select<string, Widget>((item) =>
{
return new ListTile(
Key.key(item),
title: new Text(item),
trailing: new Icon(Icons.menu));
}).ToList(),
onReorder: (int start, int current) =>
{
if (start < current) {
int end = current - 1;
string startItem = _list[start];
int i = 0;
int local = start;
do {
_list[local] = _list[++local];
i++;
} while (i < end - start);
_list[end] = startItem;
}
// dragging from bottom to top
else if (start > current) {
string startItem = _list[start];
for (int i = start; i > current; i--) {
_list[i] = _list[i - 1];
}
_list[current] = startItem;
}
setState(() => {});
}
)
);
}
}
}

11
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/ReorderableListSample.cs.meta


fileFormatVersion: 2
guid: f510d7fbd19431046bfb4b92c39b4da4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存