Skip to content

Commit

Permalink
Merge pull request #133 from Good-MoGong/Luther/#113
Browse files Browse the repository at this point in the history
Fix: 기록하기 뷰 에러 해결
  • Loading branch information
LutherCho authored Mar 5, 2024
2 parents 6ae948e + 6a589f0 commit ab74ea7
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 67 deletions.
14 changes: 8 additions & 6 deletions Projects/App/Sources/DesignSystem/Common/ProgressView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct ProgressView: View {
@State private var isAnimating = true // 점의 움직임을 제어할 상태 변수

var body: some View {

VStack {
HStack(alignment: .center) {
Text("시미가 답장 쓰는 중")
Expand All @@ -22,19 +23,20 @@ struct ProgressView: View {
}
}
}
.onAppear {
// 뷰가 나타날 때 애니메이션 시작
withAnimation(Animation.easeInOut(duration: 0.6).repeatForever()) {
isAnimating.toggle()
}
}
}

@ViewBuilder
private func circle(delay: Double) -> some View {
Circle()
.frame(width: 6, height: 6)
.animation(Animation.easeInOut.repeatForever().delay(delay))
.offset(y: isAnimating ? -5 : 0)
.onAppear {
withAnimation(Animation.easeInOut(duration: 0.6).repeatForever()) {
isAnimating.toggle()
}
}
.animation(.easeInOut.repeatForever().delay(delay), value: isAnimating)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// DismissKeyBoard.swift
// SYM
//
// Created by 민근의 mac on 3/4/24.
// Copyright © 2024 Mogong. All rights reserved.
//

import SwiftUI

struct DismissKeyboard: ViewModifier {
func body(content: Content) -> some View {
content
.onTapGesture {
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
}
}
}

extension View {
func dismissKeyboardOnTap() -> some View {
modifier(DismissKeyboard())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// DismissKeyboardDemo.swift
// SYM
//
// Created by 민근의 mac on 3/4/24.
// Copyright © 2024 Mogong. All rights reserved.
//

import SwiftUI

struct DismissKeyboardDemo: View {
@State private var text: String = ""

var body: some View {
VStack {
TextField("Type something", text: $text)
.padding()
.textFieldStyle(RoundedBorderTextFieldStyle())
.dismissKeyboardOnTap() // 이 부분을 통해 사용할 수 있습니다.

Text("You typed: \(text)")
}
.padding()
}
}

#Preview {
DismissKeyboardDemo()
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ final class RecordViewModel: RecordConditionFetch {
self.recordUseCase = recordUseCase
}

@MainActor
func movePage(to direction: PageDirection) {
guard let currentIndex = RecordOrder.allCases.firstIndex(of: recordOrder) else { return }

Expand All @@ -55,6 +54,7 @@ final class RecordViewModel: RecordConditionFetch {

func recordSpecificFetch() {
recordUseCase.fetchRecord(date: recordDiary.date) { diary, isSuccess in
print("😵‍💫\(isSuccess)")
DispatchQueue.main.async {
self.recordDiary = diary
self.isShowingOrganizeView = isSuccess
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,73 +15,73 @@ struct RecordCompletionView: View {
@Binding var isShowingOrganizeView: Bool

var body: some View {
ZStack {
Image("RecordBackground")
.resizable()
.ignoresSafeArea()

VStack(spacing: .symHeight * 0.05) {
ZStack {
HStack {
Button {
isShowingOrganizeView = false
} label: {
Image(systemName: "xmark")
NavigationStack {
ZStack {
Image("RecordBackground")
.resizable()
.ignoresSafeArea()

VStack(spacing: .symHeight * 0.05) {
ZStack {
HStack {
Button {
isShowingOrganizeView = false
} label: {
Image(systemName: "xmark")
}
.buttonStyle(.plain)

Spacer()

}
.buttonStyle(.plain)

Spacer()
.frame(height: 44)
.frame(maxWidth: .infinity)

HStack {
Spacer()

Text("감정일기")
.font(PretendardFont.h4Medium)

Spacer()
}
}
.frame(height: 44)
.frame(maxWidth: .infinity)
Text("기록이 완료되었어요!")
.font(PretendardFont.h3Bold)
Image("SimiSmile2")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: .symWidth * 0.6)

HStack {
Spacer()

Text("감정일기")
.font(PretendardFont.h4Medium)

Spacer()
}
}
Text("기록이 완료되었어요!")
.font(PretendardFont.h3Bold)
Image("SimiSmile2")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: .symWidth * 0.6)

VStack(alignment: .leading) {
if recordViewModel.isGPTLoading {
ProgressView()
} else {
ChatBubble(message: recordViewModel.recordDiary.gptAnswer, animatedMessage: $animatedMessage)
}
Spacer()
}

HStack {
Button("") {
isShowingOrganizeView = false
}
// .buttonStyle에 적용
.buttonStyle(smallGrayButtonStyle())
// 버튼 사이 간격 20
.padding(.trailing, 20)

Button("기록 보기") {
recordViewModel.recordSpecificFetch()
HStack {
Button("") {
isShowingOrganizeView = false
}
// .buttonStyle에 적용
.buttonStyle(smallGrayButtonStyle())
// 버튼 사이 간격 20
.padding(.trailing, 20)

Button("기록 보기") {
recordViewModel.recordSpecificFetch()
}
.buttonStyle(MainButtonStyle(isButtonEnabled: true))
}
.buttonStyle(MainButtonStyle(isButtonEnabled: true))
}
.padding()
}
.padding()
}
.navigationDestination(isPresented: $recordViewModel.isShowingOrganizeView) {
RecordOrganizeView(organizeViewModel: recordViewModel, isShowingOrganizeView: $isShowingOrganizeView)
.navigationDestination(isPresented: $recordViewModel.isShowingOrganizeView) {
RecordOrganizeView(organizeViewModel: recordViewModel, isShowingOrganizeView: $isShowingOrganizeView)
}
.navigationBarBackButtonHidden()
}
.navigationBarBackButtonHidden()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ struct RecordOrganizeView<viewModel: RecordConditionFetch>: View {
}
}
.navigationBarBackButtonHidden()
.dismissKeyboardOnTap()
}

let screenSize = UIScreen.main.bounds.size.width
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,16 @@ struct RecordStartView: View {
Spacer().frame(maxHeight: .symHeight * 0.03)
switch recordViewModel.recordOrder {
case .event, .idea, .action:
Image("SimiSmile")
.resizable()
.frame(width: 200, height: 220)
TextEditor(text: $recordViewModel.currentText)
.customStyle(placeholder: TextEditorContent.writtingDiary.rawValue, userInput: $recordViewModel.currentText)
.frame(height: 200)
Spacer().frame(maxHeight: .symHeight * 0.03)
.frame(maxHeight: .infinity)
ScrollView {
Image("SimiSmile")
.resizable()
.frame(width: 200, height: 220)
TextEditor(text: $recordViewModel.currentText)
.customStyle(placeholder: TextEditorContent.writtingDiary.rawValue, userInput: $recordViewModel.currentText)
.frame(height: 200)
Spacer().frame(maxHeight: .symHeight * 0.03)
.frame(maxHeight: .infinity)
}
Button(recordViewModel.recordOrder == .action ? "기록하기" : "다음으로") {
recordViewModel.movePage(to: .next)
}
Expand All @@ -116,6 +118,7 @@ struct RecordStartView: View {
.padding()
}
}
.dismissKeyboardOnTap()
.popup(isShowing: $recordViewModel.isShowingOutPopUp,
type: .doubleButton(leftTitle: "그만두기", rightTitle: "이어쓰기"),
title: PopupContent.stop.title,
Expand All @@ -140,6 +143,7 @@ struct RecordStartView: View {
recordViewModel.userID = authViewModel.userId ?? ""
withAnimation {
isAppearAnimation = true

}
}
}
Expand Down Expand Up @@ -225,4 +229,5 @@ struct EmotionButton: View {

#Preview {
RecordStartView(isShowingOrganizeView: .constant(false))
.environmentObject(AuthenticationViewModel(container: DIContainer(services: Services())))
}
1 change: 1 addition & 0 deletions Projects/App/Sources/SYMApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct SYMApp: App {
}
}
}

}
}

Expand Down

0 comments on commit ab74ea7

Please sign in to comment.