浏览代码

update for realtime update

/imageFlow
siyao 3 年前
当前提交
fab25136
共有 2 个文件被更改,包括 23 次插入8 次删除
  1. 13
      AwesomeUIWidgets/Assets/Packages/SGrid/render/sliver_staggered_grid.cs
  2. 18
      AwesomeUIWidgets/Assets/Scripts/ImageFlowDemo.cs

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


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

) : base(childManager: childManager)
{
_gridDelegate = gridDelegate;
_pageSizeToViewportOffsets = new Dictionary<float, SplayTree<int, _ViewportOffsets>>();
_pageSizeToViewportOffsets = new Dictionary<int, SplayTree<int, _ViewportOffsets>>();
}
public override void setupParentData(RenderObject child)

SliverStaggeredGridDelegate _gridDelegate;
readonly Dictionary<float, SplayTree<int, _ViewportOffsets>> _pageSizeToViewportOffsets;
// modified by siyao for uiwidgets
readonly Dictionary<int, SplayTree<int, _ViewportOffsets>> _pageSizeToViewportOffsets;
protected override void performLayout()
{

var pageSize = configuration.mainAxisOffsetsCacheSize *
constraints.viewportMainAxisExtent;
if (pageSize == 0.0)
if (pageSize == 0.0f)
{
geometry = SliverGeometry.zero;
childManager.didFinishLayout();

var pageIndex = (int) (scrollOffset / pageSize);
D.assert(pageIndex >= 0);
// If the viewport is resized, we keep the in memory the old offsets caches. (Useful if only the orientation changes multiple times).
// modified by siyao for uiwidgets
pageSize, () => new SplayTree<int, _ViewportOffsets>());
configuration.crossAxisCount, () => new SplayTree<int, _ViewportOffsets>());
Debug.Log($"page size {pageSize} update: {_pageSizeToViewportOffsets.Count}");
_ViewportOffsets viewportOffset;
if (viewportOffsets.isEmpty())

18
AwesomeUIWidgets/Assets/Scripts/ImageFlowDemo.cs


internal static readonly List<StaggeredTile> _staggeredTiles = new List<StaggeredTile>
{
StaggeredTile.count(2, 2),
// StaggeredTile.count(2, 1),
StaggeredTile.count(2, 1),
// StaggeredTile.count(1, 2),
// StaggeredTile.count(1, 1),
// StaggeredTile.count(2, 2),

// StaggeredTile.count(1, 1),
// StaggeredTile.count(4, 1),
};
public static List<Color> colors = new List<Color>()
{
Colors.red,
Colors.amber,
Colors.cyan,
Colors.brown,
Colors.purpleAccent,
Colors.blue
};
public static List<string> lotties = new List<string>()
{

internal static 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 _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"),

readonly List<StaggeredTile> _staggeredTiles = new List<StaggeredTile>
{
StaggeredTile.count(2, 2),
StaggeredTile.count(2, 1),
new _Example01Tile(Colors.lightBlue, Icons.wifi, "1370-confetti.json"),
};
private int count = 4;

Debug.Log($"x tile count {_tiles.Count}");
_tiles.Add(
new _Example01Tile(
Colors.cyan,
Utils.colors[Utils.random.Next(Utils.colors.Count)],
Icons.widgets,
Utils.lotties[Utils.random.Next(Utils.lotties.Count)]
)

正在加载...
取消
保存