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
41 changes: 26 additions & 15 deletions src/screens/diet/DietScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -991,18 +991,27 @@ const DietScreen = ({navigation, route}: any) => {
}}
activeOpacity={0.7}
>
<View style={[
styles.monthDateBadge,
isToday && !isSelected && styles.monthDateBadgeToday,
isSelected && styles.monthDateBadgeSelected
]}>
<Text style={[
styles.monthDateText,
isToday && !isSelected && styles.monthDateTextToday,
isSelected && styles.monthDateTextSelected,
!isToday && !isSelected && styles.monthDateTextNotSelected,
!isCurrentMonth && styles.monthDateTextMuted
]}>
<View
style={[
styles.monthDateBadge,
isSelected
? styles.monthDateBadgeSelected
: isToday
? styles.monthDateBadgeToday
: null,
]}
>
<Text
style={[
styles.monthDateText,
isSelected
? styles.monthDateTextSelected
: isToday
? styles.monthDateTextToday
: styles.monthDateTextNotSelected,
!isCurrentMonth && styles.monthDateTextMuted,
]}
>
{d.getDate()}
</Text>
</View>
Expand Down Expand Up @@ -1093,14 +1102,14 @@ const DietScreen = ({navigation, route}: any) => {
<View
style={[
styles.calendarNumberInner,
isToday && !isSelected && styles.calendarNumberToday,
isToday && styles.calendarNumberToday,
isSelected && styles.calendarNumberSelected,
]}
>
<Text
style={[
styles.calendarNumberText,
isToday && !isSelected && styles.calendarNumberTextToday,
isToday && styles.calendarNumberTextToday,
isSelected && styles.calendarNumberSelectedText,
!isToday && !isSelected && styles.calendarNumberTextNotSelected,
]}
Expand Down Expand Up @@ -1633,7 +1642,7 @@ const styles = StyleSheet.create({
alignItems: 'center',
},
monthDateBadge: {
minWidth: 28,
width: 28,
height: 28,
borderRadius: 14,
justifyContent: 'center',
Expand Down Expand Up @@ -1662,6 +1671,7 @@ const styles = StyleSheet.create({
},
monthDateBadgeSelected: {
backgroundColor: '#e3ff7c',
borderRadius: 14,
},
monthDateTextSelected: {
color: '#000',
Expand Down Expand Up @@ -1692,6 +1702,7 @@ const styles = StyleSheet.create({
},
calendarNumberSelected: {
backgroundColor: '#e3ff7c',
borderRadius: 14,
},
calendarNumberText: {
fontSize: 16,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코드 패치는 스타일 적용 시 변경된 로직에 주의가 필요합니다.

  1. 조건부 스타일링: 기존 코드에서는 isTodayisSelected의 조합에 따라 여러 상태를 구별했습니다. 패치 후 코드는 이 로직을 간소화해 가독성을 높였지만, 상태에 대한 정보를 잃어버린 위험이 있습니다. 예를 들어, isToday가 true이면서 isSelected가 false일 때의 스타일이 실제로 올바르게 적용되는지 확인할 필요가 있습니다.

  2. 네이밍 일관성: CSS 스타일 이름이 비슷하여 혼동할 수 있습니다. monthDateTextSelectedcalendarNumberTextToday와 같은 이름은 직관적인 의미를 부여하기에 충분하지 않을 수 있으므로 재조정하는 것이 좋습니다.

  3. null 처리: 새로운 스타일 조건에서 null을 반환하는 대신 기본 값을 설정하는 것이 안전합니다. 이는 사고를 방지하고 기본 스타일을 항상 유지할 수 있도록 합니다.

  4. 디자인 일관성: borderRadius를 직접적으로 설정한 이유에 대한 문서화가 필요합니다. 이 변경이 다른 상태의 디자인에 영향을 미칠 수 있습니다. 디자인 가이드라인에 따라 설정되었는지 확인하세요.

  5. 주석 및 문서화: 이후 개발자들이 이해하기 쉽도록 각 복잡한 스타일 정의에 대한 주석을 추가하는 것이 좋습니다.

결론적으로, 효율성을 높이기 위한 좋은 시도였지만, 유지보수성과 안정성을 향상시키기 위해 몇 가지 조정이 필요합니다.

Expand Down
27 changes: 21 additions & 6 deletions src/screens/exercise/ExerciseScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3989,13 +3989,21 @@ const ExerciseScreen = ({ navigation }: any) => {
<View
style={[
styles.monthDateBadge,
isSelected && styles.monthDateBadgeToday,
isSelected
? styles.monthDateBadgeSelected
: isToday
? styles.monthDateBadgeToday
: null,
]}
>
<Text
style={[
styles.monthDateText,
isSelected && styles.monthDateTextToday,
isSelected
? styles.monthDateTextSelected
: isToday
? styles.monthDateTextToday
: null,
!isCurrentMonth && styles.monthDateTextMuted,
]}
>
Expand Down Expand Up @@ -4106,15 +4114,15 @@ const ExerciseScreen = ({ navigation }: any) => {
<View
style={[
styles.calendarNumberInner,
isSelected && styles.calendarNumberSelected,
isToday && styles.calendarNumberToday,
isSelected && styles.calendarNumberSelected,
]}
>
<Text
style={[
styles.calendarNumberText,
isSelected && styles.calendarNumberSelectedText,
isToday && styles.calendarNumberTodayText,
isSelected && styles.calendarNumberSelectedText,
]}
>
{label}
Expand Down Expand Up @@ -5119,6 +5127,9 @@ const styles = StyleSheet.create({
justifyContent: "center",
alignItems: "center",
},
monthDateBadgeSelected: {
backgroundColor: "#e3ff7c",
},
monthDateBadgeToday: {
backgroundColor: "#ffffff",
},
Expand All @@ -5132,6 +5143,9 @@ const styles = StyleSheet.create({
monthDateTextToday: {
color: "#000",
},
monthDateTextSelected: {
color: "#000",
},
monthDateTextMuted: {
color: "#777777",
},
Expand Down Expand Up @@ -5161,10 +5175,11 @@ const styles = StyleSheet.create({
backgroundColor: "transparent",
},
calendarNumberSelected: {
backgroundColor: "#ffffff",
backgroundColor: "#e3ff7c",
borderRadius: 14,
},
calendarNumberToday: {
backgroundColor: "#e3ff7c",
backgroundColor: "#ffffff",
},
calendarNumberText: {
fontSize: 16,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 코드 패치에서 몇 가지 주의할 점과 개선 사항이 있습니다.

  1. 조건문 개선: isSelectedisToday의 상태를 처리하는 부분이 중복 코드로 되어 있습니다. 중복을 피하고 가독성을 높이기 위해 별도의 함수로 분리할 수 있습니다.

  2. 스타일 적용: 스타일 정의가 styles.calendarNumberTodaystyles.calendarNumberSelected에서 충돌하는 부분이 있어 보입니다. 예를 들어, calendarNumberToday의 배경색이 흰색으로 되어 있기 때문에 isToday일 때 선택된 칸이 잘 구분되지 않을 수 있습니다. 이 부분의 디자인을 명확히 하는 것이 좋습니다.

  3. 성능 고려: 조건부 스타일링이 늘어남에 따라 성능에 미치는 영향을 고려해야 합니다. 특히 목록이나 큰 데이터셋을 다룰 때는 성능 저하가 발생할 수 있습니다.

  4. 상수 사용: 색상 값으로 하드코딩된 부분을 상수로 관리하는 것이 좋습니다. 이로 인해 유지보수가 용이해지고 일관성을 유지할 수 있습니다.

  5. 주석 추가: 코드의 가독성을 높이기 위해 주요 변경 사항에 대한 주석을 추가하는 것이 좋습니다. 코드의 의도를 명확하게 전달할 수 있습니다.

이와 같은 사항들을 개선하면 코드의 가독성과 유지보수성이 향상될 것입니다.

Expand Down
30 changes: 10 additions & 20 deletions src/screens/pay/PaymentSuccessScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// src/screens/pay/PaymentSuccessScreen.tsx
import React, { useEffect, useState } from "react";
import { View, Text, StyleSheet, TouchableOpacity, Alert } from "react-native";
import { View, Text, StyleSheet, Alert } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import { Ionicons as Icon } from "@expo/vector-icons";
import { LinearGradient } from "expo-linear-gradient";
import { useNavigation } from "@react-navigation/native";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { useRoute } from "@react-navigation/native";
import { paymentAPI, authAPI } from "../../services";
import { paymentAPI } from "../../services";
import { CommonActions } from "@react-navigation/native";

const PaymentSuccessScreen = () => {
Expand Down Expand Up @@ -44,24 +44,19 @@ const PaymentSuccessScreen = () => {
await AsyncStorage.removeItem("testMembershipType");
console.log("✅ 로컬 PREMIUM 저장 완료");

// 4. ✅ 로그아웃 처리
await AsyncStorage.removeItem("accessToken");
await AsyncStorage.removeItem("refreshToken");
console.log("✅ 로그아웃 완료");

// 5. 안내 메시지 + 로그인 화면으로 이동
// 4. 안내 메시지 + 홈으로 이동
Alert.alert(
"업그레이드 완료! 🎉",
"프리미엄 회원이 되셨습니다!\n더 나은 서비스를 위해 다시 로그인해주세요.",
"프리미엄 회원이 되셨습니다!\n모든 기능을 자유롭게 이용하세요!",
[
{
text: "로그인하러 가기",
text: "홈으로 가기",
onPress: () => {
// ✅ 스택 초기화하고 Login으로 이동
// ✅ 스택 초기화하고 Main(홈)으로 이동
navigation.dispatch(
CommonActions.reset({
index: 0,
routes: [{ name: "Login" }],
routes: [{ name: "Main" }],
})
);
},
Expand Down Expand Up @@ -91,22 +86,17 @@ const PaymentSuccessScreen = () => {
await AsyncStorage.removeItem("testMembershipType");
console.log("✅ 로컬 PREMIUM 저장 완료");

// ✅ 로그아웃
await AsyncStorage.removeItem("accessToken");
await AsyncStorage.removeItem("refreshToken");
console.log("✅ 로그아웃 완료");

Alert.alert(
"업그레이드 완료! 🎉",
"프리미엄 회원이 되셨습니다!\n더 나은 서비스를 위해 다시 로그인해주세요.",
"프리미엄 회원이 되셨습니다!\n모든 기능을 자유롭게 이용하세요!",
[
{
text: "로그인하러 가기",
text: "홈으로 가기",
onPress: () => {
navigation.dispatch(
CommonActions.reset({
index: 0,
routes: [{ name: "Login" }],
routes: [{ name: "Main" }],
})
);
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 코드 패치는 몇 가지 수정 사항을 포함하고 있으며, 그에 따른 리스크가 존재합니다. 몇 가지 주요 리뷰 포인트는 다음과 같습니다:

  1. 로그아웃 처리: 이전에는 'accessToken'과 'refreshToken'을 AsyncStorage에서 제거하고 로그아웃을 처리했습니다. 이 부분이 제거되었는데, 프리미엄 업그레이드 후 사용자가 로그인을 다시 하지 않고도 권한을 가질 수 있다는 점에서 보안적인 위험이 있습니다. 사용자가 로그아웃을 하지 않는다면, 이전 단계에서의 인증 정보가 남아있어 보안적인 문제가 발생할 수 있습니다.

  2. UI 흐름 변경: 사용자가 프리미엄 회원이 된 후 안내 메시지에서 이전에는 로그인하러 가는 옵션이 있었지만, 현재는 홈으로 가는 옵션으로 변경되었습니다. 이는 사용자 경험에 긍정적인 변화일 수 있으나, 사용자가 로그아웃된 상태에서 홈으로 이동한다면, 이후의 행동이 어색할 수 있습니다. 따라서 이 변경 사항에 대한 충분한 문서화가 필요합니다.

  3. 코드 중복: 컴포넌트 내에서 Alert.alert 호출이 중복적으로 사용되고 있습니다. 이를 함수로 분리할 수 있으며, 코드의 유지보수성을 높일 수 있습니다.

  4. 주석 및 의도: 주석이 일관되지 않습니다. '로그인'과 '홈'으로 가는 의도가 바뀌었으므로 관련된 주석들도 수정해야 합니다.

결론적으로, 이 패치는 일관성 및 보안상의 리스크를 가진 코드 변경을 포함하고 있으므로, 추가적인 검토와 수정이 필요합니다.

Expand Down