Skip to content

Commit 4a03925

Browse files
authored
Merge pull request #24 from BoostSwiftUI/ericKwon-Pillyze-QA
권승용 필라이즈 2차 QA 작업
2 parents a8a2198 + df73c19 commit 4a03925

File tree

16 files changed

+90
-45
lines changed

16 files changed

+90
-45
lines changed

멤버-개발-폴더/권승용/앱구현/2차(필라이즈)/Pillyze/Pillyze.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
60C610E02C4D3C4700C94465 /* CustomTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60C610DF2C4D3C4700C94465 /* CustomTabBar.swift */; };
4040
60DF1A4B2C4235E80090057B /* ComponentBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60DF1A4A2C4235E80090057B /* ComponentBackground.swift */; };
4141
60DF1A4F2C4238060090057B /* MyDiets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60DF1A4E2C4238060090057B /* MyDiets.swift */; };
42-
60DF1A542C423CD40090057B /* ButtonEnabledStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60DF1A532C423CD40090057B /* ButtonEnabledStyle.swift */; };
42+
60DF1A542C423CD40090057B /* MyButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60DF1A532C423CD40090057B /* MyButtonStyle.swift */; };
4343
60DF1A572C4260960090057B /* Diet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60DF1A562C4260960090057B /* Diet.swift */; };
4444
60DF1A592C429DFE0090057B /* TransparentBlurView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60DF1A582C429DFE0090057B /* TransparentBlurView.swift */; };
4545
60DF1A5C2C42C0D50090057B /* AddDiet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60DF1A5B2C42C0D50090057B /* AddDiet.swift */; };
@@ -97,7 +97,7 @@
9797
60C610DF2C4D3C4700C94465 /* CustomTabBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomTabBar.swift; sourceTree = "<group>"; };
9898
60DF1A4A2C4235E80090057B /* ComponentBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComponentBackground.swift; sourceTree = "<group>"; };
9999
60DF1A4E2C4238060090057B /* MyDiets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyDiets.swift; sourceTree = "<group>"; };
100-
60DF1A532C423CD40090057B /* ButtonEnabledStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonEnabledStyle.swift; sourceTree = "<group>"; };
100+
60DF1A532C423CD40090057B /* MyButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyButtonStyle.swift; sourceTree = "<group>"; };
101101
60DF1A562C4260960090057B /* Diet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Diet.swift; sourceTree = "<group>"; };
102102
60DF1A582C429DFE0090057B /* TransparentBlurView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransparentBlurView.swift; sourceTree = "<group>"; };
103103
60DF1A5B2C42C0D50090057B /* AddDiet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddDiet.swift; sourceTree = "<group>"; };
@@ -345,7 +345,7 @@
345345
isa = PBXGroup;
346346
children = (
347347
60DF1A4A2C4235E80090057B /* ComponentBackground.swift */,
348-
60DF1A532C423CD40090057B /* ButtonEnabledStyle.swift */,
348+
60DF1A532C423CD40090057B /* MyButtonStyle.swift */,
349349
);
350350
path = Modifiers;
351351
sourceTree = "<group>";
@@ -548,7 +548,7 @@
548548
60C610E02C4D3C4700C94465 /* CustomTabBar.swift in Sources */,
549549
6082A0EB2C410E8D00C72C97 /* PillyzeApp.swift in Sources */,
550550
6082A11F2C41299900C72C97 /* TabBarButton.swift in Sources */,
551-
60DF1A542C423CD40090057B /* ButtonEnabledStyle.swift in Sources */,
551+
60DF1A542C423CD40090057B /* MyButtonStyle.swift in Sources */,
552552
6076A3E42C45073100F95DC9 /* BottomPicker.swift in Sources */,
553553
6082A11D2C41288300C72C97 /* TabBar.swift in Sources */,
554554
60DF1A592C429DFE0090057B /* TransparentBlurView.swift in Sources */,

멤버-개발-폴더/권승용/앱구현/2차(필라이즈)/Pillyze/Pillyze/Models/Food.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
struct Food: Identifiable, Codable {
10+
struct Food: Hashable, Identifiable, Codable {
1111
let id = UUID().uuidString
1212
let name: String
1313
let unit: String

멤버-개발-폴더/권승용/앱구현/2차(필라이즈)/Pillyze/Pillyze/Models/ModelData.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ import Foundation
99

1010
@Observable
1111
class ModelData {
12-
var foods: [Food] = JSONLoader.load("food_list_with_rank.json")
12+
var foods: [Food] = JSONLoader.load("food_list_with_rank.json") {
13+
didSet {
14+
foodsWithRice = foods.filter { $0.name.contains("") }
15+
}
16+
}
17+
var foodsWithRice: [Food] = []
1318
var isAdded: Bool = false
19+
var selectedFoods: [Food: Int] = [:]
1420
}

멤버-개발-폴더/권승용/앱구현/2차(필라이즈)/Pillyze/Pillyze/Resources/Assets.xcassets/Colors/AppPrimaryDisabled.colorset/Contents.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"components" : {
77
"alpha" : "1.000",
88
"blue" : "0xFF",
9-
"green" : "0xAA",
10-
"red" : "0xBC"
9+
"green" : "0xE8",
10+
"red" : "0xEC"
1111
}
1212
},
1313
"idiom" : "universal"
Lines changed: 1 addition & 1 deletion
Loading

멤버-개발-폴더/권승용/앱구현/2차(필라이즈)/Pillyze/Pillyze/Views/AddDiet/AddDiet.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ struct AddDiet: View {
2121
Color.componentBackground
2222
.ignoresSafeArea(edges: .top)
2323

24-
VStack {
24+
VStack(spacing: 0) {
2525
searchBar()
2626
CustomTabBar()
2727
}
2828

29-
VStack {
29+
VStack(spacing: 0) {
3030
Spacer()
3131
BottomPicker(isAddingList: $isAddingList)
3232
.padding(.bottom, proxy.safeAreaInsets.bottom)

멤버-개발-폴더/권승용/앱구현/2차(필라이즈)/Pillyze/Pillyze/Views/AddDiet/Common/BottomBar/BottomPicker.swift

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

1010
struct BottomPicker: View {
1111
@Binding var isAddingList: Bool
12+
@Environment(ModelData.self) private var modelData
1213

1314
var body: some View {
1415
VStack(spacing: 0) {
@@ -29,12 +30,13 @@ struct BottomPicker: View {
2930
.font(.system(size: 18))
3031
.fontWeight(.heavy)
3132
.foregroundStyle(.textNormal)
33+
.padding(.trailing, 29)
3234

3335
Button {
3436

3537
} label: {
3638
Text("기록하기")
37-
.buttonEnabledStyle()
39+
.myButtonStyle(isEnabled: !modelData.selectedFoods.isEmpty)
3840
}
3941
.buttonStyle(PlainButtonStyle())
4042
}
@@ -45,7 +47,8 @@ struct BottomPicker: View {
4547
}
4648

4749
#Preview {
48-
BottomPicker(isAddingList: .constant(true))
50+
BottomPicker(isAddingList: .constant(false))
51+
.environment(ModelData())
4952
}
5053

5154
struct MealPicker: View {

멤버-개발-폴더/권승용/앱구현/2차(필라이즈)/Pillyze/Pillyze/Views/AddDiet/Common/FoodList/FoodInfo.swift

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ struct FoodInfo: View {
1919

2020
HStack(spacing: 12) {
2121
Text("\(food.caloriesPerUnit)kcal")
22-
AddButton()
22+
.font(.system(size: 16))
23+
.fontWeight(.medium)
24+
.foregroundStyle(.textSecondary)
25+
AddButton(food: food)
2326
}
2427
}
2528
.padding(.vertical, 16)
@@ -61,8 +64,8 @@ struct FoodInfo: View {
6164
.foregroundStyle(.textNormal)
6265
Text(food.unit)
6366
.font(.system(size: 16))
64-
.fontWeight(.light)
65-
.foregroundStyle(.textSecondary)
67+
.fontWeight(.regular)
68+
.foregroundStyle(.textPlaceholder)
6669
}
6770
}
6871
}
@@ -71,6 +74,7 @@ struct FoodInfo: View {
7174
struct AddButton: View {
7275
@Environment(ModelData.self) private var modelData
7376
@State private var isAdded: Bool = false
77+
let food: Food
7478

7579
var body: some View {
7680
Image(isAdded ? .dietSelected : .dietUnselected)
@@ -81,10 +85,25 @@ struct AddButton: View {
8185
isAdded.toggle()
8286
if isAdded {
8387
modelData.isAdded = true
88+
modelData.selectedFoods[food] = food.hashValue
89+
} else {
90+
modelData.selectedFoods[food] = nil
8491
}
8592
}
8693
.animation(.easeInOut, value: isAdded)
8794
.disabled(modelData.isAdded)
95+
.onAppear {
96+
if modelData.selectedFoods[food] != nil {
97+
isAdded = true
98+
}
99+
}
100+
.onChange(of: modelData.selectedFoods) { oldValue, newValue in
101+
if newValue[food] != nil {
102+
isAdded = true
103+
} else {
104+
isAdded = false
105+
}
106+
}
88107
}
89108
}
90109

멤버-개발-폴더/권승용/앱구현/2차(필라이즈)/Pillyze/Pillyze/Views/AddDiet/Common/FoodList/FoodListRow.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ struct FoodListRow: View {
3636

3737
#Preview {
3838
FoodListRow(food: ModelData().foods.first!, isRankedList: true)
39+
.environment(ModelData())
3940
}

멤버-개발-폴더/권승용/앱구현/2차(필라이즈)/Pillyze/Pillyze/Views/AddDiet/CustomTabBar/CustomTabBar.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct CustomTabBar: View {
2929
VStack(spacing: 0) {
3030
TabBarHeader(selection: $selection, indicatorOffset: $indicatorOffset, proxy: proxy)
3131
.onChange(of: selection) { oldValue, newValue in
32+
modelData.selectedFoods = [:]
3233
switch newValue {
3334
case .frequentlyEaten:
3435
indicatorOffset = 0

0 commit comments

Comments
 (0)