Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LoadingSpinner to the ListItemSwitch #108

Merged
merged 1 commit into from
Oct 17, 2023
Merged
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
15 changes: 8 additions & 7 deletions src/components/listitems/ListItemSwitch.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import React, { useMemo } from "react";
import { GestureResponderEvent, Switch, View } from "react-native";
import {
ActivityIndicator,
GestureResponderEvent,
Switch,
View
} from "react-native";
import {
IOColors,
IOSelectionListItemStyles,
IOSelectionListItemVisualParams,
useIOExperimentalDesign,
useIOTheme
} from "../../core";
import { IOIcons, Icon } from "../icons";
Expand All @@ -16,6 +13,7 @@ import { H6, LabelSmall, LabelLink } from "../typography";
import { NativeSwitch } from "../switch/NativeSwitch";
import { Badge } from "../badge";
import { IOLogoPaymentType, LogoPayment } from "../logos";
import { LoadingSpinner } from "../loadingSpinner";

type PartialProps = {
label: string;
Expand Down Expand Up @@ -59,6 +57,7 @@ export const ListItemSwitch = React.memo(
badge,
onSwitchValueChange
}: ListItemSwitchProps) => {
const { isExperimental } = useIOExperimentalDesign();
const theme = useIOTheme();

// If we have a badge or we are loading, we can't render the switch
Expand All @@ -68,6 +67,8 @@ export const ListItemSwitch = React.memo(
[isLoading, badge]
);

const primaryColor: IOColors = isExperimental ? "blueIO-500" : "blue";

return (
<View
testID="ListItemSwitch"
Expand Down Expand Up @@ -153,7 +154,7 @@ export const ListItemSwitch = React.memo(
testID={badge.testID}
/>
)}
{isLoading && <ActivityIndicator color={"black"} />}
{isLoading && <LoadingSpinner size={24} color={primaryColor} />}
{canRenderSwitch && (
<NativeSwitch
value={value}
Expand Down