Skip to content

Commit 6ed4cfd

Browse files
authored
Merge pull request #47 from EST-iOS-TEAM2/fix/#44
[FIX] RecommendView를 수정합니다.
2 parents 5ba245a + f1daec3 commit 6ed4cfd

File tree

4 files changed

+60
-56
lines changed

4 files changed

+60
-56
lines changed

Dietto/Dietto/Presentation/Common/ContainerView.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import SwiftUI
99

1010
struct ContainerView<Content: View>: View {
1111
var paddingSize: CGFloat
12-
var height: CGFloat
12+
var height: CGFloat? = nil
1313
let content: () -> Content
1414

15-
init(paddingSize: CGFloat, height: CGFloat, @ViewBuilder content: @escaping () -> Content) {
15+
init(paddingSize: CGFloat, height: CGFloat? = nil, @ViewBuilder content: @escaping () -> Content) {
1616
self.paddingSize = paddingSize
1717
self.height = height
1818
self.content = content
@@ -22,7 +22,6 @@ struct ContainerView<Content: View>: View {
2222
GeometryReader { geometry in
2323
if geometry.size.width > paddingSize * 2 {
2424
let width = geometry.size.width - (paddingSize * 2)
25-
2625
ZStack {
2726
RoundedRectangle(cornerRadius: 21)
2827
.fill(Color.white)

Dietto/Dietto/Presentation/Common/SubViews.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,13 @@ extension View {
1717
func toastView(toast: Binding<ToastEntity?>) -> some View {
1818
self.modifier(ToastModifier(toast: toast))
1919
}
20+
//MARK: - 높이를 동적, 정적으로 모두 사용하기 위한 .iflet
21+
func iflet<T>(_ value: T?, apply: (Self, T) -> some View) -> some View{
22+
if let value = value{
23+
return AnyView(apply(self, value))
24+
}else{
25+
return AnyView(self)
26+
}
27+
}
2028
}
29+

Dietto/Dietto/Presentation/Dietary/View/RecommendView.swift

Lines changed: 44 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -14,78 +14,71 @@ struct RecommendView: View {
1414
// @StateObject private var viewModel = DietaryViewModel() //디버깅용
1515

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

1919
var body: some View {
2020
ZStack {
2121
Color(.backGround).ignoresSafeArea(edges: .all)
2222

23-
ScrollView {
24-
VStack {//컨테이너 뷰의 높이
25-
ContainerView(paddingSize: 16,
26-
height: 1000)
27-
{
28-
HStack{
29-
VStack{
30-
Text("추천 레시피에 등록된 재료를 이용해 식사를 추천합니다.")
31-
.font(.pretendardSemiBold10)
32-
.foregroundStyle(.textFieldGray)
33-
.border(.black)
34-
35-
//MARK: - 안에 컨텐츠.
36-
ScrollView {
37-
LazyVStack(alignment: .leading, spacing: 16) {
38-
ForEach(viewModel.recommendList, id : \.title) { item in
39-
VStack(alignment: .leading, spacing: 8) {
40-
Text(item.title)
41-
.font(.pretendardBold24)
42-
Text(item.description)
43-
.font(.pretendardSemiBold16)
44-
}
45-
.border(.black)
23+
VStack {
24+
ContainerView(paddingSize: 16) {
25+
HStack {
26+
VStack {
27+
Text("추천 레시피에 등록된 재료를 이용해 식사를 추천합니다.")
28+
.font(.pretendardSemiBold10)
29+
.foregroundStyle(.textFieldGray)
30+
31+
ScrollView {
32+
LazyVStack(alignment: .leading, spacing: 16) {
33+
ForEach(viewModel.recommendList, id: \.title) { item in
34+
VStack(alignment: .leading, spacing: 8) {
35+
Text(item.title)
36+
.font(.pretendardBold24)
37+
Text(item.description)
38+
.font(.pretendardSemiBold16)
4639
}
40+
.padding()
41+
.backgroundStyle(Color.textFieldGray)
42+
.border(Color.appMain)
43+
Divider()
4744
}
48-
.background(
49-
50-
)
51-
}
52-
.frame(height: 800)
53-
.clipped()
54-
.padding(.top, 8)
55-
.border(.black)
56-
57-
Spacer()
58-
59-
Button{
60-
withAnimation(.bouncy) {
61-
isFoldRecommand.toggle()
62-
}
63-
}label: {
64-
Image(systemName: isFoldRecommand ? "chevron.up" : "chevron.down")
65-
.frame(width: 10, height: 10)
66-
.font(.pretendardBold20)
6745
}
68-
.padding(.bottom, 8)
69-
.border(.black)
70-
46+
.padding(.horizontal)
7147
}
48+
.clipped()
49+
50+
// Spacer()
51+
//
52+
// Button {
53+
// withAnimation(.bouncy) {
54+
// isFoldRecommand.toggle()
55+
// }
56+
// } label: {
57+
// Image(systemName: isFoldRecommand ? "chevron.up" : "chevron.down")
58+
// .frame(width: 10, height: 10)
59+
// .font(.pretendardBold20)
60+
// }
61+
// .padding(.bottom, 8)
62+
// .border(.black)
7263
}
73-
.padding()
7464
}
75-
.padding(.bottom, 10)
65+
.padding()
7666
}
67+
.padding(.bottom, 10)
7768
}
7869
.padding(.top, 16)
70+
71+
7972
}
8073
.navigationTitle("추천 식사")
8174
.navigationBarTitleDisplayMode(.inline)
8275
.font(.pretendardBold16)
83-
.progressOverlay(isPresented: $viewModel.isPresneted,message: "Alan이 식단을 생성하고 있어요 !") //로딩
76+
.progressOverlay(isPresented: $viewModel.isPresneted, message: "Alan이 식단을 생성하고 있어요 !")
8477
.toastView(toast: $viewModel.toast)
78+
8579
}
8680
}
87-
88-
//디버깅용
81+
////디버깅용
8982
//#Preview {
9083
// NavigationStack{
9184
// RecommendView()

Dietto/Dietto/Presentation/Dietary/ViewModel/DietaryViewModel.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ class DietaryViewModel: ObservableObject {
3333
]
3434

3535
//추천 리스트
36-
@Published var recommendList : [RecommendEntity] = []
37-
36+
@Published var recommendList : [RecommendEntity] = []
37+
// RecommendEntity(title: "asd", description: "21124387923784235879235897"),
38+
// RecommendEntity(title: "321123132132", description: "4539259340830459378345890"),
39+
// RecommendEntity(title: "32112321131233132132", description: "453925934083041233123213213211231313259378345890"),
40+
// RecommendEntity(title: "엔티티", description: "카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 카리나 ")
3841
private let usecase : AlanUsecase
3942

4043
//MARK: - init

0 commit comments

Comments
 (0)