Skip to content

Commit

Permalink
feat: add targetCell values (#83)
Browse files Browse the repository at this point in the history
* chore: add targetCell values

* docs: update changelog

* docs: update targetCell attribute desc

* chore: fix typo

---------

Co-authored-by: Stefan Aleksovski <[email protected]>
  • Loading branch information
justinkx and sAleksovski authored May 13, 2024
1 parent 7b10c24 commit 923b998
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- `targetCellWidth` and `targetCellHeight` options in config plugin

## [0.13.2] - 2024-05-12

### Fixed
Expand Down
12 changes: 12 additions & 0 deletions app.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export interface Widget {
description?: string;
minWidth: `${number}dp`;
minHeight: `${number}dp`;
targetCellWidth?: number;
targetCellHeight?: number;
maxResizeWidth?: `${number}dp`;
maxResizeHeight?: `${number}dp`;
previewImage?: ResourcePath;
Expand Down Expand Up @@ -375,6 +377,16 @@ function withWidgetProviderXml(
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="${widget.minWidth}"
android:minHeight="${widget.minHeight}"
${
widget.targetCellWidth
? ` android:targetCellWidth="${widget.targetCellWidth}"`
: ''
}
${
widget.targetCellHeight
? ` android:targetCellHeight="${widget.targetCellHeight}"`
: ''
}
${
widget.maxResizeWidth
? ` android:maxResizeWidth="${widget.maxResizeWidth}"`
Expand Down
5 changes: 5 additions & 0 deletions docs/docs/tutorial/make-widget-configurable.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ In the widget provider we created, add `configure` and `widgetFeatures` properti
android:minWidth="320dp"
android:minHeight="120dp"

android:targetCellWidth="5"
android:targetCellHeight="2"

android:updatePeriodMillis="0"

android:initialLayout="@layout/rn_widget"
Expand Down Expand Up @@ -124,6 +127,8 @@ const widgetConfig: WithAndroidWidgetsParams = {
label: 'My Hello Widget',
minWidth: '320dp',
minHeight: '120dp',
targetCellWidth: 5,
targetCellHeight: 2,
description: 'This is my first widget',
previewImage: './assets/widget-preview/hello.png',
updatePeriodMillis: 1800000,
Expand Down
5 changes: 5 additions & 0 deletions docs/docs/tutorial/register-widget-expo.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ const widgetConfig: WithAndroidWidgetsParams = {
label: 'My Hello Widget', // Label shown in the widget picker
minWidth: '320dp',
minHeight: '120dp',
// This means the widget's default size is 5x2 cells, as specified by the targetCellWidth and targetCellHeight attributes.
// Or 320×120dp, as specified by minWidth and minHeight for devices running Android 11 or lower.
// If defined, targetCellWidth,targetCellHeight attributes are used instead of minWidth or minHeight.
targetCellWidth: 5,
targetCellHeight: 2,
description: 'This is my first widget', // Description shown in the widget picker
previewImage: './assets/widget-preview/hello.png', // Path to widget preview image

Expand Down
2 changes: 2 additions & 0 deletions src/config-plugin.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface Widget {
description?: string;
minWidth: `${number}dp`;
minHeight: `${number}dp`;
targetCellWidth?: number;
targetCellHeight?: number;
maxResizeWidth?: `${number}dp`;
maxResizeHeight?: `${number}dp`;
previewImage?: ResourcePath;
Expand Down

0 comments on commit 923b998

Please sign in to comment.