浏览代码

clean

/imageFlow
siyao 3 年前
当前提交
e96dfe2f
共有 3 个文件被更改,包括 73 次插入93 次删除
  1. 3
      AwesomeUIWidgets/Assets/Packages/SGrid/render/sliver_staggered_grid.cs
  2. 1
      AwesomeUIWidgets/Assets/Packages/SGrid/widget/staggered_grid_view.cs
  3. 162
      AwesomeUIWidgets/Assets/Scripts/ImageFlowDemo.cs

3
AwesomeUIWidgets/Assets/Packages/SGrid/render/sliver_staggered_grid.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
public static class GridUtil
{

// modified by siyao for uiwidgets
var viewportOffsets = _pageSizeToViewportOffsets.putIfAbsent(
configuration.crossAxisCount, () => new SplayTree<int, _ViewportOffsets>());
Debug.Log($"page size {pageSize} update: {_pageSizeToViewportOffsets.Count}");
_ViewportOffsets viewportOffset;
if (viewportOffsets.isEmpty())

1
AwesomeUIWidgets/Assets/Packages/SGrid/widget/staggered_grid_view.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;

162
AwesomeUIWidgets/Assets/Scripts/ImageFlowDemo.cs


using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;

using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using FontStyle = Unity.UIWidgets.ui.FontStyle;
using Random = System.Random;

bodyText2: new TextStyle(fontSize: 14.0f)
)
),
home: new Example01()
home: new ImageFlow()
);
}
}

{
internal static readonly List<StaggeredTile> _staggeredTiles = new List<StaggeredTile>
{
StaggeredTile.count(2, 2),
StaggeredTile.count(2, 1),
// StaggeredTile.count(1, 2),
// StaggeredTile.count(1, 1),
// StaggeredTile.count(2, 2),
// StaggeredTile.count(1, 2),
// StaggeredTile.count(1, 1),
// StaggeredTile.count(3, 1),
// StaggeredTile.count(1, 1),
// StaggeredTile.count(4, 1),
};
public static List<Color> colors = new List<Color>()
{
Colors.red,

"lottieflow-social-networks-16-7-000000-easey.json",
};
internal static readonly List<Widget> _tiles = new List<Widget>
internal static Random random = new Random();
public static T RandomSelect<T>(this List<T> a)
new _Example01Tile(Colors.green, Icons.widgets, "1055-world-locations.json"),
new _Example01Tile(Colors.lightBlue, Icons.wifi, "1370-confetti.json"),
// new _Example01Tile(Colors.amber, Icons.panorama_wide_angle, "1798-check-animation.json"),
// new _Example01Tile(Colors.brown, Icons.map, "226-splashy-loader.json"),
// new _Example01Tile(Colors.deepOrange, Icons.send, "66992-the-flying-rocket.json"),
// new _Example01Tile(Colors.indigo, Icons.airline_seat_flat, "77-im-thirsty.json"),
// new _Example01Tile(Colors.red, Icons.bluetooth, "782-check-mark-success.json"),
// new _Example01Tile(Colors.pink, Icons.battery_alert, "91-mailsent.json"),
// new _Example01Tile(Colors.purple, Icons.desktop_windows, "lottieflow-checkbox-06-000000-easey.json"),
// new _Example01Tile(Colors.blue, Icons.radio, "lottieflow-cta-04-000000-easey.json"),
};
if (a.isEmpty())
{
return default;
}
internal static Random random = new Random();
return a[random.Next(a.Count)];
}
class Example01 : StatefulWidget
class ImageFlow : StatefulWidget
return new Example01State();
return new ImageFlowState();
class Example01State : State<Example01>
class ImageFlowState : State<ImageFlow>
{
readonly List<StaggeredTile> _staggeredTiles = new List<StaggeredTile>
{

readonly List<Widget> _tiles = new List<Widget>
readonly List<Widget> _tiles = new List<Widget>
new _Example01Tile(Colors.green, Icons.widgets, "1055-world-locations.json"),
new _Example01Tile(Colors.lightBlue, Icons.wifi, "1370-confetti.json"),
new LottieTile(Colors.green, "1055-world-locations.json"),
new LottieTile(Colors.lightBlue, "1370-confetti.json"),
};
private int count = 4;

Debug.Log($"o tile count {_tiles.Count}");
title: new Text("example 01")
title: new Text("Flow")
),
body:
new Column(

StaggeredGridView.count(
crossAxisCount: count,
staggeredTiles: _staggeredTiles,
mainAxisSpacing: 5,
crossAxisSpacing: 10,
mainAxisSpacing: 3,
crossAxisSpacing: 3,
padding: EdgeInsets.all(4),
children: _tiles
)

children: new List<Widget>()
{
new MaterialButton(height: 100, minWidth: 100, color: Colors.amber,
onPressed: () => { setState(() => { count++; }); }),
new MaterialButton(height: 100, minWidth: 100, color: Colors.amber,
onPressed: () => { setState(() => { count--; }); }),
new MaterialButton(height: 100, minWidth: 100, color: Colors.amber,
onPressed: () =>
{
setState(() =>
new Expanded(
child:
new MaterialButton(
color: Colors.amber,
child: new Text("Expand Column", style: new TextStyle(fontSize: 10)),
onPressed: () => { setState(() => { count++; }); })
),
new Expanded(child:
new MaterialButton(
color: Colors.blue,
child: new Text("Shrink Column", style: new TextStyle(fontSize: 10)),
onPressed: () => { setState(() => { count--; }); })
),
new Expanded(child:
new MaterialButton(
color: Colors.green,
child: new Text("Remove Tile", style: new TextStyle(fontSize: 10)),
onPressed: () =>
Debug.Log($"tile count {_tiles.Count}");
_tiles.RemoveAt(0);
Debug.Log($"tile count {_tiles.Count}");
_staggeredTiles.RemoveAt(0);
});
}),
new MaterialButton(height: 100, minWidth: 100, color: Colors.amber,
onPressed: () =>
{
setState(() =>
if (!_tiles.isEmpty())
{
setState(() =>
{
_tiles.RemoveAt(0);
_staggeredTiles.RemoveAt(0);
});
}
})
),
new Expanded(child:
new MaterialButton(
color: Colors.pink,
child: new Text("Add Tile", style: new TextStyle(fontSize: 10)),
onPressed: () =>
Debug.Log($"x tile count {_tiles.Count}");
_tiles.Add(
new _Example01Tile(
Utils.colors[Utils.random.Next(Utils.colors.Count)],
Icons.widgets,
Utils.lotties[Utils.random.Next(Utils.lotties.Count)]
)
);
Debug.Log($"y tile count {_tiles.Count}");
_staggeredTiles.Add(
StaggeredTile.count(
Utils.random.Next(2) + 1,
Utils.random.Next(2) + 1)
);
});
})
setState(() =>
{
_tiles.Add(
new LottieTile(
Utils.colors.RandomSelect(),
Utils.lotties.RandomSelect()
)
);
_staggeredTiles.Add(
StaggeredTile.count(
Utils.random.Next(2) + 1,
Utils.random.Next(2) + 1)
);
});
})
),
}
)
}

}
internal class _Example01Tile : StatefulWidget
internal class LottieTile : StatefulWidget
internal _Example01Tile(Color backgroundColor, IconData iconData, string path)
internal LottieTile(Color backgroundColor, string path)
this.iconData = iconData;
public readonly IconData iconData;
return new _Example01TileState();
return new LottieTileState();
internal class _Example01TileState : State<_Example01Tile>
internal class LottieTileState : State<LottieTile>
{
public override Widget build(BuildContext context)
{

onTap: () =>
{
},
onTap: () => { },
child: new Center(
child: new Padding(
padding: EdgeInsets.all(4),

正在加载...
取消
保存