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

Đang mở
#374 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
22/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
ios, react-native, swift, typescript
Lĩnh vực
mobile-dev

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
TypeScript
Star
865
Fork
50
Merge trung bình
2 ngày 22 giờ
Pull request đã merge (30 ngày)
18

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của callstackincubator/voltra

Tất cả issue của callstackincubator/voltra

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.