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
5 changes: 2 additions & 3 deletions Dietto/Dietto/Presentation/Common/ContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import SwiftUI

struct ContainerView<Content: View>: View {
var paddingSize: CGFloat
var height: CGFloat
var height: CGFloat? = nil
let content: () -> Content

init(paddingSize: CGFloat, height: CGFloat, @ViewBuilder content: @escaping () -> Content) {
init(paddingSize: CGFloat, height: CGFloat? = nil, @ViewBuilder content: @escaping () -> Content) {
self.paddingSize = paddingSize
self.height = height
self.content = content
Expand All @@ -22,7 +22,6 @@ struct ContainerView<Content: View>: View {
GeometryReader { geometry in
if geometry.size.width > paddingSize * 2 {
let width = geometry.size.width - (paddingSize * 2)

ZStack {
RoundedRectangle(cornerRadius: 21)
.fill(Color.white)
Expand Down
9 changes: 9 additions & 0 deletions Dietto/Dietto/Presentation/Common/SubViews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@ extension View {
func toastView(toast: Binding<ToastEntity?>) -> some View {
self.modifier(ToastModifier(toast: toast))
}
//MARK: - 높이를 동적, 정적으로 모두 사용하기 위한 .iflet
func iflet<T>(_ value: T?, apply: (Self, T) -> some View) -> some View{
if let value = value{
return AnyView(apply(self, value))
}else{
return AnyView(self)
}
}
}

95 changes: 44 additions & 51 deletions Dietto/Dietto/Presentation/Dietary/View/RecommendView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,78 +14,71 @@ struct RecommendView: View {
// @StateObject private var viewModel = DietaryViewModel() //디버깅용

@State private var isFoldRecommand : Bool = false // true : 펼친상태로 시작 , false: 가려진 채로 시작.
@State private var contentHeight : CGFloat = 0
// @State private var contentHeight : CGFloat = 0

var body: some View {
ZStack {
Color(.backGround).ignoresSafeArea(edges: .all)

ScrollView {
VStack {//컨테이너 뷰의 높이
ContainerView(paddingSize: 16,
height: 1000)
{
HStack{
VStack{
Text("추천 레시피에 등록된 재료를 이용해 식사를 추천합니다.")
.font(.pretendardSemiBold10)
.foregroundStyle(.textFieldGray)
.border(.black)

//MARK: - 안에 컨텐츠.
ScrollView {
LazyVStack(alignment: .leading, spacing: 16) {
ForEach(viewModel.recommendList, id : \.title) { item in
VStack(alignment: .leading, spacing: 8) {
Text(item.title)
.font(.pretendardBold24)
Text(item.description)
.font(.pretendardSemiBold16)
}
.border(.black)
VStack {
ContainerView(paddingSize: 16) {
HStack {
VStack {
Text("추천 레시피에 등록된 재료를 이용해 식사를 추천합니다.")
.font(.pretendardSemiBold10)
.foregroundStyle(.textFieldGray)

ScrollView {
LazyVStack(alignment: .leading, spacing: 16) {
ForEach(viewModel.recommendList, id: \.title) { item in
VStack(alignment: .leading, spacing: 8) {
Text(item.title)
.font(.pretendardBold24)
Text(item.description)
.font(.pretendardSemiBold16)
}
.padding()
.backgroundStyle(Color.textFieldGray)
.border(Color.appMain)
Divider()
}
.background(

)
}
.frame(height: 800)
.clipped()
.padding(.top, 8)
.border(.black)

Spacer()

Button{
withAnimation(.bouncy) {
isFoldRecommand.toggle()
}
}label: {
Image(systemName: isFoldRecommand ? "chevron.up" : "chevron.down")
.frame(width: 10, height: 10)
.font(.pretendardBold20)
}
.padding(.bottom, 8)
.border(.black)

.padding(.horizontal)
}
.clipped()

// Spacer()
//
// Button {
// withAnimation(.bouncy) {
// isFoldRecommand.toggle()
// }
// } label: {
// Image(systemName: isFoldRecommand ? "chevron.up" : "chevron.down")
// .frame(width: 10, height: 10)
// .font(.pretendardBold20)
// }
// .padding(.bottom, 8)
// .border(.black)
}
.padding()
}
.padding(.bottom, 10)
.padding()
}
.padding(.bottom, 10)
}
.padding(.top, 16)


}
.navigationTitle("추천 식사")
.navigationBarTitleDisplayMode(.inline)
.font(.pretendardBold16)
.progressOverlay(isPresented: $viewModel.isPresneted,message: "Alan이 식단을 생성하고 있어요 !") //로딩
.progressOverlay(isPresented: $viewModel.isPresneted, message: "Alan이 식단을 생성하고 있어요 !")
.toastView(toast: $viewModel.toast)

}
}

//디버깅용
////디버깅용
//#Preview {
// NavigationStack{
// RecommendView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ class DietaryViewModel: ObservableObject {
]

//추천 리스트
@Published var recommendList : [RecommendEntity] = []

@Published var recommendList : [RecommendEntity] = []
// RecommendEntity(title: "asd", description: "21124387923784235879235897"),
// RecommendEntity(title: "321123132132", description: "4539259340830459378345890"),
// RecommendEntity(title: "32112321131233132132", description: "453925934083041233123213213211231313259378345890"),
// RecommendEntity(title: "엔티티", description: "카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 ")
private let usecase : AlanUsecase

//MARK: - init
Expand Down