From 3eef30566154114f44a8f445819b21a1b163c638 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 12 Apr 2024 14:45:35 +0700 Subject: [PATCH] use disable prop --- .../ReportActionItem/MoneyRequestView.tsx | 2 +- src/components/Switch.tsx | 19 ++++--------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 526fe5766c43..a9818c122a43 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -488,7 +488,7 @@ function MoneyRequestView({ accessibilityLabel={translate('common.billable')} isOn={!!transactionBillable} onToggle={saveBillable} - interactive={canEdit} + disabled={!canEdit} /> )} diff --git a/src/components/Switch.tsx b/src/components/Switch.tsx index 9c49681e621b..1693bafe323d 100644 --- a/src/components/Switch.tsx +++ b/src/components/Switch.tsx @@ -18,9 +18,6 @@ type SwitchProps = { /** Accessibility label for the switch */ accessibilityLabel: string; - /** Whether the menu item should be interactive at all */ - interactive?: boolean; - /** Whether the switch is disabled */ disabled?: boolean; }; @@ -30,7 +27,7 @@ const OFFSET_X = { ON: 20, }; -function Switch({isOn, onToggle, accessibilityLabel, interactive = true, disabled}: SwitchProps) { +function Switch({isOn, onToggle, accessibilityLabel, disabled}: SwitchProps) { const styles = useThemeStyles(); const offsetX = useRef(new Animated.Value(isOn ? OFFSET_X.ON : OFFSET_X.OFF)); const theme = useTheme(); @@ -43,20 +40,12 @@ function Switch({isOn, onToggle, accessibilityLabel, interactive = true, disable }).start(); }, [isOn]); - const onPressOrLongPressAction = () => { - if (!interactive) { - return; - } - - onToggle(!isOn); - }; - return ( onToggle(!isOn)} + onLongPress={() => onToggle(!isOn)} role={CONST.ROLE.SWITCH} aria-checked={isOn} accessibilityLabel={accessibilityLabel}