Skip to content

Commit

Permalink
[정주] 음식 리스트 추가 Lottie 애니메이션 표시
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongju9216 committed Jul 26, 2024
1 parent 1e4fc87 commit 453472c
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
9B5AE8462C452BA300BC1ED7 /* JSONLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B5AE8452C452BA300BC1ED7 /* JSONLoader.swift */; };
9B5AE8492C452D8000BC1ED7 /* food_list_with_rank.json in Resources */ = {isa = PBXBuildFile; fileRef = 9B5AE8482C452D8000BC1ED7 /* food_list_with_rank.json */; };
9B5AE84D2C46860800BC1ED7 /* AddDietTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B5AE84C2C46860800BC1ED7 /* AddDietTab.swift */; };
9B5AE8A12C53B6AD00BC1ED7 /* add-list.lottie in Resources */ = {isa = PBXBuildFile; fileRef = 9B5AE8A02C53B6AD00BC1ED7 /* add-list.lottie */; };
9B5AE8A72C53BAF400BC1ED7 /* Lottie in Frameworks */ = {isa = PBXBuildFile; productRef = 9B5AE8A62C53BAF400BC1ED7 /* Lottie */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -66,13 +68,15 @@
9B5AE8452C452BA300BC1ED7 /* JSONLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONLoader.swift; sourceTree = "<group>"; };
9B5AE8482C452D8000BC1ED7 /* food_list_with_rank.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = food_list_with_rank.json; sourceTree = "<group>"; };
9B5AE84C2C46860800BC1ED7 /* AddDietTab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddDietTab.swift; sourceTree = "<group>"; };
9B5AE8A02C53B6AD00BC1ED7 /* add-list.lottie */ = {isa = PBXFileReference; lastKnownFileType = file; path = "add-list.lottie"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
9B046FF02C41735B00ADAFF3 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9B5AE8A72C53BAF400BC1ED7 /* Lottie in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -149,6 +153,7 @@
9B0470212C41752800ADAFF3 /* Resource */ = {
isa = PBXGroup;
children = (
9B5AE89F2C53B69400BC1ED7 /* Lottie */,
9B5AE8472C452D6F00BC1ED7 /* JSON */,
9B046FFA2C41735C00ADAFF3 /* Assets.xcassets */,
);
Expand Down Expand Up @@ -244,6 +249,14 @@
path = ViewModel;
sourceTree = "<group>";
};
9B5AE89F2C53B69400BC1ED7 /* Lottie */ = {
isa = PBXGroup;
children = (
9B5AE8A02C53B6AD00BC1ED7 /* add-list.lottie */,
);
path = Lottie;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand All @@ -260,6 +273,9 @@
dependencies = (
);
name = BoostPillyze;
packageProductDependencies = (
9B5AE8A62C53BAF400BC1ED7 /* Lottie */,
);
productName = BoostPillyze;
productReference = 9B046FF32C41735B00ADAFF3 /* BoostPillyze.app */;
productType = "com.apple.product-type.application";
Expand Down Expand Up @@ -310,6 +326,9 @@
Base,
);
mainGroup = 9B046FEA2C41735B00ADAFF3;
packageReferences = (
9B5AE8A52C53BAF400BC1ED7 /* XCRemoteSwiftPackageReference "lottie-ios" */,
);
productRefGroup = 9B046FF42C41735B00ADAFF3 /* Products */;
projectDirPath = "";
projectRoot = "";
Expand All @@ -328,6 +347,7 @@
9B046FFE2C41735C00ADAFF3 /* Preview Assets.xcassets in Resources */,
9B046FFB2C41735C00ADAFF3 /* Assets.xcassets in Resources */,
9B5AE8492C452D8000BC1ED7 /* food_list_with_rank.json in Resources */,
9B5AE8A12C53B6AD00BC1ED7 /* add-list.lottie in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -641,6 +661,25 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
9B5AE8A52C53BAF400BC1ED7 /* XCRemoteSwiftPackageReference "lottie-ios" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/airbnb/lottie-ios";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 4.5.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
9B5AE8A62C53BAF400BC1ED7 /* Lottie */ = {
isa = XCSwiftPackageProductDependency;
package = 9B5AE8A52C53BAF400BC1ED7 /* XCRemoteSwiftPackageReference "lottie-ios" */;
productName = Lottie;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 9B046FEB2C41735B00ADAFF3 /* Project object */;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import SwiftUI
import Combine
import Lottie

struct AddDietView: View {

Expand All @@ -23,42 +24,60 @@ struct AddDietView: View {
@State private var currentTab: AddDietTab = .most
@State private var categories: [String] = ["전체", "음식", "세트", "인기"]
@State private var currentCategory: String = "인기"
@State private var playbackMode: LottiePlaybackMode = LottiePlaybackMode.paused
@State private var animationCount = 0

var body: some View {
SearchHeaderView(
didTapCancelButton: didTapCancelButton,
searchKeyword: $searchKeyword
)
.padding(.horizontal)

ZStack(alignment: .bottom) {
TopTabBar(currentTab: $currentTab)
Rectangle()
.frame(height: 1)
.foregroundStyle(.disabled)
VStack {
SearchHeaderView(
didTapCancelButton: didTapCancelButton,
searchKeyword: $searchKeyword
)
.padding(.horizontal)

ZStack(alignment: .bottom) {
TopTabBar(currentTab: $currentTab)
Rectangle()
.frame(height: 1)
.foregroundStyle(.disabled)
}

ScrollView(.horizontal) {
HStack {
ForEach(categories, id: \.self) { category in
CategoryChipButton(currentCategory: $currentCategory, title: category)
}
}
.padding(.vertical, 11)
.padding(.horizontal, 20)
}

switch currentTab {
case .most:
ZStack {
FoodList(
didTapFoodListItem: didTapFoodListItem,
foods: $output.foods,
selectedFoods: $output.selectedFoods
)
}
case .favorites:
PlaceholderView()
case .custom:
Spacer()
}
}

ScrollView(.horizontal) {
HStack {
ForEach(categories, id: \.self) { category in
CategoryChipButton(currentCategory: $currentCategory, title: category)
.overlay {
if animationCount > 0 {
LottieView {
try await DotLottieFile.named("add-list")
}
.playing(.fromProgress(0, toProgress: 1, loopMode: .playOnce))
.id(animationCount)
}
.padding(.vertical, 11)
.padding(.horizontal, 20)
}

switch currentTab {
case .most:
FoodList(
didTapFoodListItem: didTapFoodListItem,
foods: $output.foods,
selectedFoods: $output.selectedFoods
)
case .favorites:
PlaceholderView()
case .custom:
Spacer()
.onReceive(output.playAddListLottie) {
animationCount += 1
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ private extension AddDietViewModel {
output.selectedFoods.remove(food)
} else {
output.selectedFoods.insert(food)
output.playAddListLottie.send()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ extension AddDietViewModel {

@Published var foods: [Food] = []
@Published var selectedFoods: Set<Food> = []
let playAddListLottie: PassthroughSubject<Void, Never> = .init()
}
}
Binary file not shown.

0 comments on commit 453472c

Please sign in to comment.