@@ -2,7 +2,7 @@ import * as React from 'react';
22import { AppRegistry } from 'react-native' ;
33import { AndroidWidget } from '../AndroidWidget' ;
44import { buildWidgetTree } from './build-widget-tree' ;
5- import type { WidgetInfo } from './types' ;
5+ import type { WidgetInfo , WidgetRepresentation } from './types' ;
66
77const WIDGET_CONFIGURATION_SCREEN_KEY = 'RNWidgetConfigurationScreen' ;
88
@@ -14,7 +14,7 @@ export interface WidgetConfigurationScreenProps {
1414 /**
1515 * Function that can be called with the Widget JSX to render
1616 */
17- renderWidget : ( widgetComponent : React . JSX . Element ) => void ;
17+ renderWidget : ( widgetComponent : WidgetRepresentation ) => void ;
1818
1919 /**
2020 * This must be called after finishing with configuration.
@@ -45,9 +45,23 @@ function widgetConfigurationScreenProvider(
4545 WidgetConfigurationScreen : WidgetConfigurationScreen
4646) {
4747 return ( { widgetInfo } : { widgetInfo : WidgetInfo } ) => {
48- function renderWidget ( widgetComponent : React . JSX . Element ) {
48+ function renderWidget ( widgetComponent : WidgetRepresentation ) {
49+ const lightWidget =
50+ 'light' in widgetComponent
51+ ? buildWidgetTree ( widgetComponent . light )
52+ : buildWidgetTree ( widgetComponent ) ;
53+ const darkWidget =
54+ 'dark' in widgetComponent
55+ ? buildWidgetTree ( widgetComponent . dark as React . JSX . Element )
56+ : null ;
57+
58+ const config = {
59+ light : lightWidget ,
60+ dark : darkWidget ,
61+ } ;
62+
4963 AndroidWidget . drawWidgetById (
50- buildWidgetTree ( widgetComponent ) ,
64+ config ,
5165 widgetInfo . widgetName ,
5266 widgetInfo . widgetId
5367 ) ;
0 commit comments