Skip to content

Commit

Permalink
Improve code of CheckboxLabel
Browse files Browse the repository at this point in the history
  • Loading branch information
dmnplb committed Nov 21, 2024
1 parent ac50c1d commit 312a614
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions src/components/checkbox/CheckboxLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import * as React from "react";
import { ComponentProps, useState } from "react";
import { Pressable, View } from "react-native";
import { IOSelectionTickVisualParams, useIOTheme } from "../../core";
import { IOStyles } from "../../core/IOStyles";
import {
IOSelectionTickVisualParams,
IOSpacingScale,
useIOTheme
} from "../../core";
import { triggerHaptic } from "../../functions/haptic-feedback/hapticFeedback";
import { useIOFontDynamicScale } from "../../utils/accessibility";
import { HStack } from "../stack";
import { H6 } from "../typography/H6";
import { AnimatedCheckbox } from "./AnimatedCheckbox";

Expand All @@ -15,6 +19,7 @@ type Props = {
};

const DISABLED_OPACITY = 0.5;
const CHECKBOX_MARGIN: IOSpacingScale = 8;

// disabled: the component is no longer touchable
// onPress:
Expand Down Expand Up @@ -66,15 +71,10 @@ export const CheckboxLabel = ({
// inheritance on Android
needsOffscreenAlphaCompositing={true}
>
<View
style={[
IOStyles.row,
{
alignItems: "center",
width: "100%",
columnGap: 8 * dynamicFontScale * spacingScaleMultiplier
}
]}
<HStack
allowScaleSpacing
style={{ alignItems: "center", width: "100%" }}
space={CHECKBOX_MARGIN}
>
<View
pointerEvents="none"
Expand All @@ -92,7 +92,7 @@ export const CheckboxLabel = ({
<H6 style={{ flexShrink: 1 }} color={theme["textBody-default"]}>
{label}
</H6>
</View>
</HStack>
</Pressable>
);
};
2 changes: 1 addition & 1 deletion src/components/stack/Stack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useIOFontDynamicScale } from "../../utils/accessibility";

type AllowedStyleProps = Pick<
ViewStyle,
"alignItems" | "flexShrink" | "flexGrow" | "flex" | "flexWrap"
"alignItems" | "flexShrink" | "flexGrow" | "flex" | "flexWrap" | "width"
>;

type Stack = {
Expand Down

0 comments on commit 312a614

Please sign in to comment.