Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,45 @@
import { StructurePreviewProps, topBar } from "@mendix/piw-utils-internal";
import { StructurePreviewProps } from "@mendix/piw-utils-internal";

import { RepeaterPreviewProps } from "../typings/RepeaterProps";

export function getPreview(values: RepeaterPreviewProps, isDarkMode: boolean): StructurePreviewProps {
return topBar(
"Repeater",
{
type: "DropZone",
placeholder: "Content",
property: values.content
},
isDarkMode
);
return {
type: "Container",
borders: true,
children: [
{
type: "Container",
backgroundColor: isDarkMode ? "#454545" : "#F5F5F5",
children: [
{
type: "Container",
padding: 4,
children: [
{
type: "Text",
fontColor: isDarkMode ? "#DEDEDE" : "#6B707B",
content: "Repeater"
}
]
}
]
},
{
type: "DropZone",
placeholder: "Content",
property: values.content
},
{
type: "Container",
borders: true,
children: [
{
type: "DropZone",
placeholder: "No items placeholder: Place widgets here",
property: values.emptyPlaceholder
}
]
}
]
};
}
11 changes: 4 additions & 7 deletions packages/pluggableWidgets/repeater-native/src/Repeater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,16 @@ import { mergeNativeStyles } from "@mendix/pluggable-widgets-tools";

export function Repeater(props: RepeaterProps<RepeaterStyle>): ReactElement {
const styles = mergeNativeStyles(defaultRepeaterStyle, props.style);
if (
props.datasource.status === ValueStatus.Loading ||
!props.datasource.items ||
props.datasource.items.length === 0
) {
if (props.datasource.status === ValueStatus.Loading || !props.datasource.items) {
return <View />;
}

const emptyPlaceholder = props.datasource.items.length === 0 ? props.emptyPlaceholder : null;
return (
<View style={styles.container}>
{props.datasource.items?.map((item, index) => (
{props.datasource.items.map((item, index) => (
<Fragment key={`item_${index}`}>{props.content.get(item)}</Fragment>
))}
{emptyPlaceholder}
</View>
);
}
4 changes: 4 additions & 0 deletions packages/pluggableWidgets/repeater-native/src/Repeater.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<property key="content" type="widgets" dataSource="datasource">
<caption>Content</caption>
<description/>
</property>
<property key="emptyPlaceholder" type="widgets" required="false">
<caption>Empty placeholder</caption>
<description/>
</property>
</propertyGroup>
<propertyGroup caption="Common">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface RepeaterProps<Style> {
style: Style[];
datasource: ListValue;
content: ListWidgetValue;
emptyPlaceholder?: ReactNode;
}

export interface RepeaterPreviewProps {
Expand All @@ -25,4 +26,5 @@ export interface RepeaterPreviewProps {
renderMode?: "design" | "xray" | "structure";
datasource: {} | { caption: string } | { type: string } | null;
content: { widgetCount: number; renderer: ComponentType<{ children: ReactNode; caption?: string }> };
emptyPlaceholder: { widgetCount: number; renderer: ComponentType<{ caption?: string }> };
}
Loading