Skip to content

Commit 2a2bf38

Browse files
authored
ExampleScreenPresenter - improve renderBooleanOption (#2037)
1 parent ae3692a commit 2a2bf38

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

demo/src/screens/ExampleScreenPresenter.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ interface RadioGroupOptions {
2222
useValueAsLabel?: boolean;
2323
}
2424

25+
interface BooleanGroupOptions {
26+
spread?: boolean;
27+
afterValueChanged?: () => void;
28+
}
29+
2530
export function renderHeader(title: string, others?: TextProps) {
2631
return (
2732
<Text text30 $textDefault {...others}>
@@ -30,19 +35,19 @@ export function renderHeader(title: string, others?: TextProps) {
3035
);
3136
}
3237

33-
export function renderBooleanOption(title: string, key: string) {
38+
export function renderBooleanOption(title: string, key: string, {spread, afterValueChanged}: BooleanGroupOptions = {spread: true}) {
3439
// @ts-ignore
3540
const value = this.state[key];
3641
return (
37-
<View row centerV spread marginB-s4 key={key}>
38-
<Text $textDefault flex>{title}</Text>
42+
<View row centerV spread={spread} marginB-s4 key={key}>
43+
<Text $textDefault flex={spread} marginR-s4={!spread}>{title}</Text>
3944
<Switch
4045
useCustomTheme
4146
key={key}
4247
testID={key}
4348
value={value}
4449
// @ts-ignore
45-
onValueChange={value => this.setState({[key]: value})}
50+
onValueChange={value => this.setState({[key]: value}, afterValueChanged)}
4651
/>
4752
</View>
4853
);

0 commit comments

Comments
 (0)