Skip to content
Merged
Show file tree
Hide file tree
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
65 changes: 45 additions & 20 deletions front/app/flashcards/study.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import { fetchFlashcards, Flashcard } from "@/api/flashcards";
import { PlatformPressable } from "@react-navigation/elements";
import { useThemeColor } from "@/hooks/useThemeColor";

const { width: SCREEN_WIDTH } = Dimensions.get("window");
const CARD_WIDTH = SCREEN_WIDTH - 40;
Expand All @@ -33,6 +34,14 @@
const [isFlipped, setIsFlipped] = useState(false);
const flip = useSharedValue(0);

const cardBackground = useThemeColor({}, "cardBackground");
const studyCardBack = useThemeColor({}, "studyCardBack");
const textColor = useThemeColor({}, "text");
const iconColor = useThemeColor({}, "icon");
const disabledColor = useThemeColor({}, "disabled");
const navButtonBg = useThemeColor({}, "navButton");
const navButtonIcon = useThemeColor({}, "navButtonIcon");

useEffect(() => {
const loadCards = async () => {
if (!deckId) {
Expand All @@ -44,7 +53,7 @@
setCards(flashcards.results || []);
};
loadCards();
}, [deckId]);

Check warning on line 56 in front/app/flashcards/study.tsx

View workflow job for this annotation

GitHub Actions / frontend

React Hook useEffect has a missing dependency: 'router'. Either include it or remove the dependency array

const flipCard = () => {
if (process.env.EXPO_OS === "ios") {
Expand Down Expand Up @@ -118,30 +127,55 @@
onPress={flipCard}
activeOpacity={0.9}
>
<Animated.View style={[styles.card, styles.cardFront, frontAnimatedStyle]}>
<ThemedText style={styles.cardText}>{currentCard?.front}</ThemedText>
<ThemedText style={styles.tapHint}>Tap to reveal</ThemedText>
<Animated.View
style={[
styles.card,
styles.cardFront,
frontAnimatedStyle,
{ backgroundColor: cardBackground },
]}
>
<ThemedText style={[styles.cardText, { color: textColor }]}>
{currentCard?.front}
</ThemedText>
<ThemedText style={[styles.tapHint, { color: iconColor }]}>
Tap to reveal
</ThemedText>
</Animated.View>
<Animated.View style={[styles.card, styles.cardBack, backAnimatedStyle]}>
<ThemedText style={styles.cardText}>{currentCard?.back}</ThemedText>
<Animated.View
style={[
styles.card,
styles.cardBack,
backAnimatedStyle,
{ backgroundColor: studyCardBack },
]}
>
<ThemedText style={[styles.cardText, { color: textColor }]}>
{currentCard?.back}
</ThemedText>
</Animated.View>
</TouchableOpacity>

<View style={styles.navigation}>
<PlatformPressable
style={[styles.navButton, currentIndex === 0 && styles.navButtonDisabled]}
style={[
styles.navButton,
{ backgroundColor: navButtonBg },
currentIndex === 0 && styles.navButtonDisabled,
]}
onPress={goToPrev}
disabled={currentIndex === 0}
>
<IconSymbol
name="chevron.left"
size={30}
color={currentIndex === 0 ? "#ccc" : "#03465b"}
color={currentIndex === 0 ? disabledColor : navButtonIcon}
/>
</PlatformPressable>
<PlatformPressable
style={[
styles.navButton,
{ backgroundColor: navButtonBg },
currentIndex === cards.length - 1 && styles.navButtonDisabled,
]}
onPress={goToNext}
Expand All @@ -150,7 +184,7 @@
<IconSymbol
name="chevron.right"
size={30}
color={currentIndex === cards.length - 1 ? "#ccc" : "#03465b"}
color={currentIndex === cards.length - 1 ? disabledColor : navButtonIcon}
/>
</PlatformPressable>
</View>
Expand Down Expand Up @@ -180,7 +214,6 @@
position: "absolute",
width: "100%",
height: "100%",
backgroundColor: "#fff",
borderRadius: 16,
padding: 20,
justifyContent: "center",
Expand All @@ -191,22 +224,16 @@
shadowRadius: 4,
elevation: 5,
},
cardFront: {
backgroundColor: "#fff",
},
cardBack: {
backgroundColor: "#f0f8ff",
},
cardFront: {},
cardBack: {},
cardText: {
fontSize: 20,
textAlign: "center",
color: "#333",
},
tapHint: {
position: "absolute",
bottom: 20,
fontSize: 14,
color: "#888",
},
navigation: {
flexDirection: "row",
Expand All @@ -217,15 +244,13 @@
navButton: {
padding: 20,
borderRadius: 30,
backgroundColor: "#f0f0f0",
},
navButtonDisabled: {
opacity: 0.5,
},
emptyText: {
fontSize: 18,
color: "#888",
textAlign: "center",
marginTop: 100,
},
});
});
8 changes: 8 additions & 0 deletions front/constants/Colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export const Colors = {
cardBackground: '#fff',
cardBackgroundSelected: tintColorLight,
border: '#ccc',
studyCardBack: '#f0f8ff',
disabled: '#ccc',
navButton: '#f0f0f0',
navButtonIcon: '#03465b',
},
dark: {
text: '#ECEDEE',
Expand All @@ -24,5 +28,9 @@ export const Colors = {
cardBackground: '#1C1C1E',
cardBackgroundSelected: tintColorDark,
border: '#444',
studyCardBack: '#1a2a3a',
disabled: '#555',
navButton: '#333',
navButtonIcon: '#00a4c9',
},
};
Loading