-
Notifications
You must be signed in to change notification settings - Fork 0
운동 저장 UI 변경 #130
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
운동 저장 UI 변경 #130
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1896,6 +1896,7 @@ const AnalysisScreen = ({ navigation }: any) => { | |
| // 랜덤 코멘트 로드 | ||
| const loadRandomScoreComment = useCallback(async () => { | ||
| try { | ||
| console.log("[ANALYSIS][COMMENT] 코멘트 로드 시작"); | ||
| setScoreCommentLoading(true); | ||
| setScoreComment(null); | ||
|
|
||
|
|
@@ -1907,21 +1908,35 @@ const AnalysisScreen = ({ navigation }: any) => { | |
| ]; | ||
| const randomIndex = Math.floor(Math.random() * commentTypes.length); | ||
| const selectedCommentAPI = commentTypes[randomIndex]; | ||
| const apiType = randomIndex === 0 ? "daily" : randomIndex === 1 ? "weekly" : "monthly"; | ||
|
|
||
| console.log("[ANALYSIS] 코멘트 API 선택:", randomIndex === 0 ? "daily" : randomIndex === 1 ? "weekly" : "monthly"); | ||
| console.log("[ANALYSIS][COMMENT] 코멘트 API 선택:", apiType, "index:", randomIndex); | ||
|
|
||
| const comment = await selectedCommentAPI(); | ||
| console.log("[ANALYSIS][COMMENT] API 호출 완료, 반환된 comment:", comment); | ||
| console.log("[ANALYSIS][COMMENT] comment 타입:", typeof comment); | ||
| console.log("[ANALYSIS][COMMENT] comment가 truthy인가?", !!comment); | ||
| console.log("[ANALYSIS][COMMENT] comment가 문자열인가?", typeof comment === 'string'); | ||
| console.log("[ANALYSIS][COMMENT] comment 길이:", comment ? (typeof comment === 'string' ? comment.length : 'N/A') : 0); | ||
|
|
||
| if (comment) { | ||
| setScoreComment(comment); | ||
| console.log("[ANALYSIS] 코멘트 로드 성공:", comment); | ||
| console.log("[ANALYSIS][COMMENT] 코멘트 로드 성공, state에 설정:", comment); | ||
| } else { | ||
| console.log("[ANALYSIS] 코멘트 없음"); | ||
| console.log("[ANALYSIS][COMMENT] 코멘트 없음 (null 또는 빈 값)"); | ||
| } | ||
| } catch (error) { | ||
| console.error("[ANALYSIS] 코멘트 로드 실패:", error); | ||
| } catch (error: any) { | ||
| console.error("[ANALYSIS][COMMENT] 코멘트 로드 실패:", { | ||
| message: error?.message, | ||
| status: error?.status, | ||
| data: error?.data, | ||
| stack: error?.stack, | ||
| error: error, | ||
| }); | ||
| setScoreComment(null); | ||
| } finally { | ||
| setScoreCommentLoading(false); | ||
| console.log("[ANALYSIS][COMMENT] 코멘트 로드 완료, loading: false"); | ||
| } | ||
| }, []); | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 코드 리뷰 코멘트
결론적으로, 코드가 개념적으로 잘 작성되어 있지만, 에러 핸들링과 코드 유지관리를 위한 리팩토링이 필요하며, 함수의 안정성을 높이는 데 중점을 두는 것이 좋습니다. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -561,7 +561,7 @@ const ChatbotScreen = ({ navigation }: any) => { | |
| <View | ||
| style={[ | ||
| styles.chatinputContainer, | ||
| { paddingBottom: insets.bottom > 0 ? insets.bottom : 10 }, | ||
| { paddingBottom: insets.bottom > 0 ? Math.max(insets.bottom, 4) : 4 }, | ||
| ]} | ||
| > | ||
| <TextInput | ||
|
|
@@ -631,7 +631,7 @@ const styles = StyleSheet.create({ | |
| }, | ||
| scrollViewContent: { | ||
| flexGrow: 1, | ||
| paddingBottom: 20, | ||
| paddingBottom: 10, | ||
| }, | ||
| mainContent: { | ||
| flex: 1, | ||
|
|
@@ -800,7 +800,7 @@ const styles = StyleSheet.create({ | |
| borderRadius: 12, | ||
| }, | ||
| messagesContainer: { | ||
| paddingBottom: 20, | ||
| paddingBottom: 10, | ||
| }, | ||
| message: { | ||
| maxWidth: "80%", | ||
|
|
@@ -831,7 +831,7 @@ const styles = StyleSheet.create({ | |
| chatinputContainer: { | ||
| flexDirection: "row", | ||
| paddingHorizontal: 10, | ||
| paddingTop: 10, | ||
| paddingTop: 8, | ||
| backgroundColor: NEW_COLORS.card_bg, | ||
| borderTopWidth: 1, | ||
| borderTopColor: NEW_COLORS.separator, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 코드 패치에서 몇 가지 우려사항이 있습니다:
코드에서의 변경사항을 좀 더 이해하고, UI 테스트를 통해 불편함이 없는지 확실히 확인해보는 것이 필요합니다. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6386,10 +6386,91 @@ const StretchDetailContent = ({ | |
|
|
||
| // 문자열 형태의 설명 | ||
| if (typeof instructions === "string" && instructions.length > 0) { | ||
| const lines = instructions | ||
| // 운동 설명과 동일한 방식으로 Step 처리 | ||
| const stepMatches: Array<{ number: string; content: string }> = | ||
| []; | ||
|
|
||
| // 먼저 줄바꿈으로 분리 | ||
| const instructionLines = instructions | ||
| .split("\n") | ||
| .filter((line) => line.trim()); | ||
|
|
||
| instructionLines.forEach((line) => { | ||
| // 한 줄에 여러 Step이 쉼표로 구분되어 있을 수 있음 | ||
| // "Step: 1 ..., Step:2 ..., Step:3 ..." 형식 처리 | ||
|
|
||
| // Step: 또는 ,Step: 패턴으로 분리 | ||
| const stepParts = line | ||
| .split(/(?:^|,\s*)Step:/i) | ||
| .filter((part) => part.trim()); | ||
| const foundSteps: Array<{ | ||
| stepNum: number; | ||
| description: string; | ||
| }> = []; | ||
|
|
||
| stepParts.forEach((part) => { | ||
| // Step: 다음에 오는 숫자와 설명 추출 | ||
| const stepMatch = part.match(/^\s*(\d+)\s*(.+)$/); | ||
| if (stepMatch) { | ||
| const stepNum = parseInt(stepMatch[1], 10); | ||
| let description = stepMatch[2].trim(); | ||
| // 끝의 쉼표, 점, 공백 제거 | ||
| description = description.replace(/[,\.\s]+$/, "").trim(); | ||
|
|
||
| if (description) { | ||
| foundSteps.push({ stepNum, description }); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| // Step: 패턴으로 분리되지 않은 경우, 정규식으로 다시 시도 | ||
| if (foundSteps.length === 0) { | ||
| const stepRegex = /Step:\s*(\d+)\s*([^,]+?)(?=,\s*Step:|$)/gi; | ||
| let match; | ||
|
|
||
| while ((match = stepRegex.exec(line)) !== null) { | ||
| const stepNum = parseInt(match[1], 10); | ||
| let description = match[2].trim(); | ||
| description = description.replace(/[,\.\s]+$/, "").trim(); | ||
|
|
||
| if (description) { | ||
| foundSteps.push({ stepNum, description }); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // 찾은 Step들을 stepMatches에 추가 | ||
| foundSteps.forEach(({ stepNum, description }) => { | ||
| stepMatches.push({ | ||
| number: stepNum.toString(), | ||
| content: description, | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| // Step 패턴이 있으면 Step 기준으로 렌더링 | ||
| if (stepMatches.length > 0) { | ||
| return stepMatches.map((step, idx) => { | ||
| return ( | ||
| <View key={idx}> | ||
| <View style={styles.stretchDetailStep}> | ||
| <Text style={styles.stretchDetailStepNumber}> | ||
| {step.number} | ||
| </Text> | ||
| <Text style={styles.stretchDetailStepTitle}> | ||
| {step.content} | ||
| </Text> | ||
| </View> | ||
| </View> | ||
| ); | ||
| }); | ||
| } | ||
|
|
||
| // Step 패턴이 없으면 기존대로 줄바꿈으로 분리 | ||
| const fallbackLines = instructions | ||
| .split("\n") | ||
| .filter((line) => line.trim()); | ||
| return lines.map((line: string, idx: number) => ( | ||
| return fallbackLines.map((line: string, idx: number) => ( | ||
| <Text key={idx} style={styles.stretchDetailStepText}> | ||
| {line.trim()} | ||
| </Text> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 코드 검토 피드백
이 코드는 전반적으로 좋은 접근법이지만 위에서 언급한 대로 몇 가지 수정 사항과 개선 사항이 필요합니다. 그렇지 않으면 문제를 일으킬 가능성이 있습니다. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코드 수정을 검토한 결과, 몇 가지 잠재적인 버그 및 개선점이 발견되었습니다.
안전 영역 인셋:
useSafeAreaInsets를 추가함으로써paddingBottom에 동적으로 값을 적용하는 것은 좋은 접근입니다. 그러나 이 값이paddingBottom: Math.max(insets.bottom, 34)로 설정되어 있어, 경우에 따라 34가 항상 적용될 수 있습니다. 즉, 괜찮은 안전 영역 설정이 있는 상황에서도 불필요하게 많은 여백이 생길 수 있습니다. 이를 위해 조건부 로직을 추가하여 모바일 기기에서 더 나은 사용자 경험을 제공하면 좋겠습니다.스타일 변경의 영향:
footer및feedbackSection의 패딩 크기를 변경했는데, 이는 전반적인 디자인에 영향을 줄 수 있습니다. 변경된 디자인이 예상되는 사용자 인터페이스에 적절한지 확인할 필요가 있습니다. 디자이너와의 협업이 필요합니다.불필요한 코드 주석: 수정된 코드 블록에서 큰 코드 블록(주석 처리된 이전 코드)의 주석을 제거하는 것이 좋습니다. 버전 히스토리에서 추적할 수 있는 위해 불필요한 주석은 코드 가독성을 해칠 수 있습니다.
메모리 누수 위험:
React.useCallback으로 감싸진getExerciseDisplayName이 제대로 종속성을 관리하는지 확인이 필요합니다. 이 함수의 종속성이 변경되었을 때 내부 구현이 호출되지 않는다면, 메모리 누수나 잘못된 동작을 초래할 수 있습니다.이러한 사항을 고려해주시기 바랍니다.