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
15 changes: 13 additions & 2 deletions Dietto/Dietto/Data/Network/NetworkError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,25 @@ public enum NetworkError: LocalizedError {
return "서버 오류가 발생했습니다. (\(code))"
case .invalidResponse:
return "서버 응답이 유효하지 않습니다."
case .decodingFailed(let error):
case .decodingFailed( _):
return "잠시 후 다시 시도해주세요."
case .requestCancelled:
return "요청이 취소되었습니다."
case .unknown(let error):
case .unknown(let _):
return "알 수 없는 에러가 발생했습니다. 관리자에게 문의하세요."
case .unacceptableStatusCode:
return "에러가 발생했습니다. 잠시후 다시 시도하세요."
}
}
}

extension NetworkError {
var asToast: ToastEntity {
return ToastEntity(
type: .error,
title: "오류 발생",
message: self.errorDescription ?? "알 수 없는 오류입니다.",
duration: 3
)
}
}
4 changes: 2 additions & 2 deletions Dietto/Dietto/Data/Repository/NetworkRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import Foundation

//MARK: - Alan Protocol
//MARK: - Alan Interface
protocol NetworkRepository {
func fetch<T: Decodable>(promptType: PromptType, rawValues: [Any], outputType: T.Type) async throws -> T}

//MARK: - Alan Protocol Implement
//MARK: - Alan Implement
final class NetworkRepositoryImpl: NetworkRepository {

private let promptManager: PromptManager
Expand Down
15 changes: 15 additions & 0 deletions Dietto/Dietto/Domain/Entities/ToastEntity.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// ToastEntity.swift
// Dietto
//
// Created by 안세훈 on 6/4/25.
//

import Foundation

struct ToastEntity: Equatable {
var type: ToastStyle
var title: String
var message: String
var duration: Double = 3
}
4 changes: 1 addition & 3 deletions Dietto/Dietto/Domain/Usecases/AlanUsecase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

//MARK: - Usecase
//MARK: - Interface

protocol AlanUsecase {
func fetchRecommend(ingredients: [IngredientEntity]) async throws -> [RecommendEntity]
Expand All @@ -26,14 +26,12 @@ final class AlanUsecaseImpl : AlanUsecase {
//추천식단
func fetchRecommend(ingredients: [IngredientEntity]) async throws -> [RecommendEntity] {
let wrapper = try await repository.fetch(promptType: .recommend, rawValues: ingredients, outputType: RecommendDTO.self)

return wrapper.recommendation
}

//아티클
func fetchArticle(topics: [InterestEntity]) async throws -> [ArticleEntity] {
let wrapper = try await repository.fetch(promptType: .article, rawValues: topics, outputType: ArticleDTO.self)

return wrapper.articles
}

Expand Down
1 change: 1 addition & 0 deletions Dietto/Dietto/Extensions/Font+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SwiftUI
extension Font {
static let AppLogo: Font = .custom("NerkoOne-regular", size: 32)
static let NerkoOne40: Font = .custom("NerkoOne-regular", size: 40)
static let NerkoOne80: Font = .custom("NerkoOne-regular", size: 80)

static let pretendardBlack32: Font = .custom("Pretendard-Black", size: 32)
static let pretendardBlack28: Font = .custom("Pretendard-Black", size: 28)
Expand Down
1 change: 1 addition & 0 deletions Dietto/Dietto/Presentation/Article/View/ArticleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct ArticleView: View {
.background(Color.appMain)
.clipShape(Capsule())
}

}
.padding([.leading, .trailing], 16)
Text("내 관심사")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SwiftUI
final class ArticleViewModel: ObservableObject {
@Published var selectedInterests: [InterestEntity] = []
@Published var articles: [ArticleEntity] = []
@Published var isLoading : Bool = false

private let alanUsecase: AlanUsecase
private let storageUsecase: InterestsUsecase
Expand Down Expand Up @@ -64,6 +65,5 @@ final class ArticleViewModel: ObservableObject {
addInterest(title)
storageUsecase.insertInterests(InterestEntity(title: title))
}
print(selectedInterests)
}
}
2 changes: 1 addition & 1 deletion Dietto/Dietto/Presentation/Common/ContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
struct ContainerView<Content: View>: View {
var paddingSize: CGFloat
var height: CGFloat
let content: () -> Content // ✅ 변수명은 소문자!
let content: () -> Content

init(paddingSize: CGFloat, height: CGFloat, @ViewBuilder content: @escaping () -> Content) {
self.paddingSize = paddingSize
Expand Down
120 changes: 120 additions & 0 deletions Dietto/Dietto/Presentation/Common/LogoProgress.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
//
// ProgressViews.swift
// Dietto
//
// Created by 안세훈 on 6/2/25.
//

import SwiftUI

struct LogoProgress: View {
@Binding var isAnimated: Bool
var width: CGFloat = 190
var message : String

var body: some View {
VStack {
Spacer()
ZStack {
//가려진 뷰
VStack(spacing: 3) {
Text("Dietto")
.font(.NerkoOne80)
.frame(width: width)
.scaledToFit()
.foregroundStyle(.black.opacity(0.3))
Text(message)
.font(.pretendardBlack12)
.frame(width: width)
.scaledToFit()
.foregroundStyle(.black.opacity(0.3))
}
//진행중인 뷰
VStack(spacing: 3) {
Text("Dietto")
.font(.NerkoOne80)
.frame(width: width)
.scaledToFit()
.foregroundStyle(.appMain)
.mask {
Rectangle()
.frame(width: isAnimated ? width : 0)
.offset(x: isAnimated ? 0 : -width)
}
Text(message)
.font(.pretendardBlack12)
.frame(width: width)
.scaledToFit()
.foregroundStyle(.appMain)
.mask {
Rectangle()
.frame(width: isAnimated ? width : 0)
.offset(x: isAnimated ? 0 : -width)
}
}
}
Spacer()
}
.frame(maxWidth: .infinity)
.background(Color.black.opacity(0.25))
}
}
//MARK: - ViewModifer

struct LogoProgressModifier: ViewModifier {
@Binding var isPresented: Bool
@State private var isAnimated = false
@State var message: String = "TEST"

var speed: Double = 0.3
var delayTime: Double = 0.3

func body(content: Content) -> some View {
ZStack {
content
if isPresented {
Rectangle()
.fill(Color.black.opacity(0.3))
.ignoresSafeArea()

LogoProgress(isAnimated: $isAnimated, message: message)
.onAppear {
isAnimated = true
}
.animation(
.easeInOut
.speed(speed)
.delay(delayTime)
.repeatForever(autoreverses: false),
value: isAnimated
)
}
}
}
}


////MARK: - 프리뷰 하려고 임시로 만들어놓은 것.
//
//#Preview {
// AnimatedLoadingPreview()
//}
//
//struct AnimatedLoadingPreview: View {
// @State private var isAnimated = false
// @State var message = "카리나카리나카리나카리나카리나"
//
// var body: some View {
// LogoProgress(isAnimated: $isAnimated, message: message)
// .onAppear {
// withAnimation(
// .easeInOut
// .speed(0.3)
// .delay(0.3)
// .repeatForever(autoreverses: false)
// ) {
// isAnimated = true
// }
// }
// }
//}
6 changes: 3 additions & 3 deletions Dietto/Dietto/Presentation/Common/PillText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct PillText: View {
var onDelete: (() -> Void)? = nil // X 버튼 클릭 액션

var body: some View {
HStack() {
HStack(spacing : 2) {
Button(action: {
onAdd?()
}) {
Expand All @@ -29,11 +29,11 @@ struct PillText: View {
Image(systemName: "xmark")
.font(.pretendardBold12)
.foregroundStyle(.white)
.padding(4)
.padding(2)
}
.buttonStyle(PlainButtonStyle())
}
.padding(.horizontal, 10)
.padding(.horizontal, 8)
.padding(.vertical, 4)
.background(Capsule().fill(Color.appMain))
.fixedSize()
Expand Down
20 changes: 20 additions & 0 deletions Dietto/Dietto/Presentation/Common/SubViews.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// SubView.swift
// Dietto
//
// Created by 안세훈 on 6/4/25.
//

import SwiftUI

extension View {
//MARK: - ProgressView Modifer
func progressOverlay(isPresented: Binding<Bool>, message: String = "") -> some View {
self.modifier(LogoProgressModifier(isPresented: isPresented, message: message))
}

//MARK: - ToastView Modifer
func toastView(toast: Binding<ToastEntity?>) -> some View {
self.modifier(ToastModifier(toast: toast))
}
}
Loading