orlikraf / flutter-hexagon

MIT License
31 stars 17 forks source link

add hexagonPadding attribute to HexagonOffsetGrid #2

Closed slovnicki closed 3 years ago

slovnicki commented 3 years ago

hexagonPadding is of type EdgeInsetsGeometry and is used for Padding around all HexagonWidget tiles in grid:

return Padding(
  padding: hexagonPadding,
  child: hexagonTemplate?.copyWith(
    type: hexType,
    inBounds: false,
    width: hexType.isPointy ? size.width : null,
    height: hexType.isFlat ? size.height : null,
    child: buildChild != null
        ? buildChild.call(col, row)
        : hexagonTemplate.child,
  ),
);

It's not required and the default value is, naturally, const EdgeInsets.all(0.0).

This also affects the available space for hexagons, so I updated _hexSize to take this into consideration by using hexagonPadding.horizontal or hexagonPadding.vertical, as needed. This means that hexagonPadding can really be any EdgeInsets, for example EdgeInsets.only(top: 2.0, left: 6.0).

I also added the example usage to example/, but you decide whether to include this in README screenshots or not, or remove it from example altogether.

Here is the screenshot of how this looks by applying it to V-Grid example: Screenshot_1609809844

orlikraf commented 3 years ago

I noticed that some calculations are throwing hexagons off from being centered. After all I've added padding attribute to HexagonWidget where it is easier apply it. And I will only use single double to describe padding as not equal horizontal and vertical padding would deform hexagon shape.

slovnicki commented 3 years ago

Ok. That seems reasonable.