API for real-time detection of widget dimensions (width and height), with automatic updates upon every resize

未关闭
#374 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
22/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
ios, react-native, swift, typescript
领域
mobile-dev

调研方向

Start by tracing how widget cell dimensions are computed on the Swift side and how any values currently cross into JS — look for the existing native module/bridge and the VoltraAndroid component definitions the example references. Read the widget layout code and the example app that renders VoltraAndroid.LazyVerticalGrid to see where a size hook would attach. Done means a documented hook or callback returning live { width, height } in cells that fires on resize, plus an example and tests showing the value updating.

由索引模型根据 Issue 内容生成。

描述

enhancement
Feature Description

I would like an API that provides the actual number of cells occupied by the widget in terms of width and height, in real time.

These values ​​should update automatically and immediately whenever the user resizes the widget, allowing the layout to be dynamically adjusted based on the actual dimensions.

Problem Statement

Currently, it is not possible to determine the actual number of cells occupied by a widget when it is resized.
This limits the ability to create dynamic and responsive layouts.

Being able to access the width and height in real time would allow for the automatic adjustment of content and the number of columns based on the widget's actual dimensions, eliminating the need for manual calculations and approximate solutions.

Proposed Solution

Add an API or callback that returns the actual number of cells occupied by the widget, in terms of both width and height.

These values ​​must update in real time whenever the user resizes the widget.

For example, if the widget occupies 2 columns, the API should return width = 2
if it is resized to 5 columns, it should automatically return width = 5.

This will make it possible to dynamically adapt components, such as VoltraAndroid.LazyVerticalGrid to the widget's actual dimensions.

const [widgetSize, setWidgetSize] = useState({
    width: 2,
    height: 2
});

VoltraAndroid.onWidgetResize((size) => {
    setWidgetSize({
        width: size.width,
        height: size.height
    });
});

<VoltraAndroid.LazyVerticalGrid
    columns={widgetSize.width}
>
</VoltraAndroid.LazyVerticalGrid>
Alternatives Considered

No response

Current Library Version

2.6.0

Implementation
  • I would be willing to submit a pull request for this feature
Additional Context

No response

主要语言
TypeScript
星标
865
派生
50
平均合并
2 天 22 小时
30 天内合并 PR
18

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

callstackincubator/voltra 的其他 Issue

查看 callstackincubator/voltra 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。