Skip to content

Commit

Permalink
Simplify ButtonSpinner logic as old getThemeColor only works on web
Browse files Browse the repository at this point in the history
  • Loading branch information
fjsj committed Jan 28, 2025
1 parent a81fb71 commit 8176e70
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
5 changes: 3 additions & 2 deletions components/ChatMessageBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useMedplumProfile } from "@medplum/react-hooks";
import { useVideoPlayer } from "expo-video";
import { VideoView } from "expo-video";
import { CirclePlay, FileDown, UserRound } from "lucide-react-native";
import { useColorScheme } from "nativewind";
import { memo, useCallback, useRef, useState } from "react";
import { Pressable, StyleSheet, View } from "react-native";
import { Alert } from "react-native";
Expand All @@ -15,7 +16,6 @@ import type { ChatMessage } from "@/models/chat";
import type { AttachmentWithUrl } from "@/types/attachment";
import { formatTime } from "@/utils/datetime";
import { isMediaExpired, mediaKey, shareFile } from "@/utils/media";
import { getThemeColor } from "@/utils/theme";

interface ChatMessageBubbleProps {
message: ChatMessage;
Expand Down Expand Up @@ -82,6 +82,7 @@ VideoAttachment.displayName = "VideoAttachment";

function FileAttachment({ attachment }: { attachment: AttachmentWithUrl }) {
const [isDownloading, setIsDownloading] = useState(false);
const { colorScheme } = useColorScheme();

const handleShare = useCallback(async () => {
setIsDownloading(true);
Expand All @@ -102,7 +103,7 @@ function FileAttachment({ attachment }: { attachment: AttachmentWithUrl }) {
disabled={isDownloading}
>
{isDownloading ? (
<ButtonSpinner color={getThemeColor("--color-typography-900")} />
<ButtonSpinner color={colorScheme === "dark" ? "black" : "white"} />
) : (
<ButtonIcon as={FileDown} className="text-typography-0 text-typography-600" />
)}
Expand Down
6 changes: 4 additions & 2 deletions components/CreateThreadModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useRouter } from "expo-router";
import { X } from "lucide-react-native";
import { useColorScheme } from "nativewind";
import { useCallback, useState } from "react";
import { Modal as RNModal, Pressable } from "react-native";
import Animated, { FadeIn, FadeOut } from "react-native-reanimated";
Expand All @@ -9,7 +10,6 @@ import { Icon } from "@/components/ui/icon";
import { Input, InputField } from "@/components/ui/input";
import { Text } from "@/components/ui/text";
import { View } from "@/components/ui/view";
import { getThemeColor } from "@/utils/theme";

interface CreateThreadModalProps {
isOpen: boolean;
Expand Down Expand Up @@ -69,14 +69,16 @@ interface ModalFooterProps {
}

function ModalFooter({ onClose, onCreate, isCreating, isValid }: ModalFooterProps) {
const { colorScheme } = useColorScheme();

return (
<View className="flex-row justify-end gap-2 p-4">
<Button variant="outline" onPress={onClose} className="mr-2">
<ButtonText>Cancel</ButtonText>
</Button>
<Button className="min-w-[100px]" disabled={!isValid || isCreating} onPress={onCreate}>
{isCreating ? (
<ButtonSpinner color={getThemeColor("--color-typography-900")} />
<ButtonSpinner color={colorScheme === "dark" ? "black" : "white"} />
) : (
<ButtonText>Create</ButtonText>
)}
Expand Down
8 changes: 0 additions & 8 deletions utils/theme.ts

This file was deleted.

0 comments on commit 8176e70

Please sign in to comment.