-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5b6568
commit bee8545
Showing
10 changed files
with
37,297 additions
and
11,058 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
const base = require("@mendix/pluggable-widgets-tools/configs/prettier.base.json"); | ||
|
||
module.exports = { | ||
...base | ||
...base, | ||
plugins: [require.resolve("@prettier/plugin-xml")], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,19 @@ | ||
import { Component, ReactNode, createElement } from "react"; | ||
import { ViewStyle } from "react-native"; | ||
import { createElement, ReactElement } from "react"; | ||
import { NativeResponsiveListviewProps } from "../typings/NativeResponsiveListviewProps"; | ||
import { Style } from "./utils/common"; | ||
import { ResponsiveListview } from "./components/ResponsiveListview"; | ||
import { CustomStyle } from "./ui/styles"; | ||
|
||
export interface CustomStyle extends Style { | ||
container: ViewStyle; | ||
} | ||
|
||
export class NativeResponsiveListview extends Component<NativeResponsiveListviewProps<CustomStyle>> { | ||
render(): ReactNode { | ||
const { ds, content, style } = this.props; | ||
if (!ds || !ds.items) { | ||
return null; | ||
} | ||
let showVertically = false; | ||
if (this.props.showVertically && this.props.showVertically.value) { | ||
showVertically = true; | ||
} | ||
return <ResponsiveListview ds={ds} content={content} style={style} showVertically={showVertically} />; | ||
export function NativeResponsiveListview(props: NativeResponsiveListviewProps<CustomStyle>): ReactElement | null { | ||
const { ds, showVertically } = props; | ||
if (!ds || !ds.items) { | ||
return null; | ||
} | ||
return ( | ||
<ResponsiveListview | ||
dsItems={ds.items} | ||
content={props.content} | ||
style={props.style} | ||
showVertically={!!showVertically?.value} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,30 @@ | ||
import { Component, ReactNode, createElement } from "react"; | ||
import { ReactElement, createElement } from "react"; | ||
import { View } from "react-native"; | ||
import { ListValue, ListWidgetValue } from "mendix"; | ||
import { ListWidgetValue, ObjectItem } from "mendix"; | ||
import { CustomStyle, defaultStyle, defaultVerticalStyle } from "../ui/styles"; | ||
|
||
import { CustomStyle } from "../NativeResponsiveListview"; | ||
import { flattenStyles } from "../utils/common"; | ||
import { mergeNativeStyles } from "@mendix/pluggable-widgets-tools"; | ||
|
||
export interface ResponsiveListviewProps { | ||
ds: ListValue; | ||
dsItems: ObjectItem[]; | ||
content: ListWidgetValue; | ||
style: CustomStyle[]; | ||
showVertically: boolean; | ||
} | ||
|
||
const defaultStyle: CustomStyle = { | ||
container: { | ||
flexDirection: "row", | ||
flexWrap: "wrap" | ||
} | ||
}; | ||
|
||
const defaultVerticalStyle: CustomStyle = { | ||
container: { | ||
flexDirection: "column" | ||
} | ||
}; | ||
|
||
export class ResponsiveListview extends Component<ResponsiveListviewProps> { | ||
render(): ReactNode { | ||
const { ds, content, showVertically } = this.props; | ||
let styles: CustomStyle; | ||
if (showVertically) { | ||
styles = flattenStyles(defaultVerticalStyle, this.props.style); | ||
} else { | ||
styles = flattenStyles(defaultStyle, this.props.style); | ||
} | ||
if (!ds || !ds.items) { | ||
return null; | ||
} | ||
return ( | ||
<View style={styles.container}> | ||
{ds.items.map(item => ( | ||
<View key={item.id}>{content.get(item)}</View> | ||
))} | ||
</View> | ||
); | ||
export function ResponsiveListview(props: ResponsiveListviewProps): ReactElement { | ||
const { dsItems, content, showVertically } = props; | ||
let styles: CustomStyle; | ||
if (showVertically) { | ||
styles = mergeNativeStyles(defaultVerticalStyle, props.style); | ||
} else { | ||
styles = mergeNativeStyles(defaultStyle, props.style); | ||
} | ||
return ( | ||
<View style={styles.container}> | ||
{dsItems.map(item => ( | ||
<View key={item.id}>{content.get(item)}</View> | ||
))} | ||
</View> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ViewStyle } from "react-native"; | ||
|
||
import { Style } from "@mendix/pluggable-widgets-tools"; | ||
|
||
export interface CustomStyle extends Style { | ||
container: ViewStyle; | ||
} | ||
|
||
export const defaultStyle: CustomStyle = { | ||
container: { | ||
flexDirection: "row", | ||
flexWrap: "wrap" | ||
} | ||
}; | ||
|
||
export const defaultVerticalStyle: CustomStyle = { | ||
container: { | ||
flexDirection: "column" | ||
} | ||
}; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
{ | ||
"extends": "./node_modules/@mendix/pluggable-widgets-tools/configs/tsconfig.base.json" | ||
"extends": "@mendix/pluggable-widgets-tools/configs/tsconfig.base", | ||
"compilerOptions": { | ||
"baseUrl": "./" | ||
}, | ||
"include": ["./src", "./typings"] | ||
} |