From b9a9ed2ef59317e07931ab3ba53b95dbb42fe83d Mon Sep 17 00:00:00 2001 From: Xerath Date: Mon, 12 Aug 2024 03:29:25 +0900 Subject: [PATCH] =?UTF-8?q?[=EB=8F=99=EC=A3=BC]=20TabView=20=EB=82=B4=20?= =?UTF-8?q?=EB=A1=9C=EB=94=A9=20Lottie=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pillyze.xcodeproj/project.pbxproj" | 22 +++++++- .../Source/View/Record/RecordView.swift" | 51 ++++++++++++++----- 2 files changed, 58 insertions(+), 15 deletions(-) diff --git "a/\353\251\244\353\262\204-\352\260\234\353\260\234-\355\217\264\353\215\224/\354\234\244\353\217\231\354\243\274/Pillyze/Pillyze.xcodeproj/project.pbxproj" "b/\353\251\244\353\262\204-\352\260\234\353\260\234-\355\217\264\353\215\224/\354\234\244\353\217\231\354\243\274/Pillyze/Pillyze.xcodeproj/project.pbxproj" index 26f1f1d..db2f134 100644 --- "a/\353\251\244\353\262\204-\352\260\234\353\260\234-\355\217\264\353\215\224/\354\234\244\353\217\231\354\243\274/Pillyze/Pillyze.xcodeproj/project.pbxproj" +++ "b/\353\251\244\353\262\204-\352\260\234\353\260\234-\355\217\264\353\215\224/\354\234\244\353\217\231\354\243\274/Pillyze/Pillyze.xcodeproj/project.pbxproj" @@ -37,6 +37,7 @@ 087B50A42C492100005BF53C /* RoundedCorner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 087B50A32C492100005BF53C /* RoundedCorner.swift */; }; 088DFC4E2C52489400469FD1 /* loading.lottie in Resources */ = {isa = PBXBuildFile; fileRef = 088DFC4D2C52489400469FD1 /* loading.lottie */; }; 088DFC512C524A9600469FD1 /* DotLottie in Frameworks */ = {isa = PBXBuildFile; productRef = 088DFC502C524A9600469FD1 /* DotLottie */; }; + 08A793AB2C623933004A1FEB /* addList.lottie in Resources */ = {isa = PBXBuildFile; fileRef = 08A793AA2C62392F004A1FEB /* addList.lottie */; }; 08C737A92C4C06A000FA93A4 /* DoubleSidedBackgroundScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08C737A82C4C06A000FA93A4 /* DoubleSidedBackgroundScrollView.swift */; }; 08C737AB2C4C0E7200FA93A4 /* SlidingTabView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08C737AA2C4C0E7200FA93A4 /* SlidingTabView.swift */; }; 08C737AD2C4CA2B400FA93A4 /* FrequentlyAteView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08C737AC2C4CA2B400FA93A4 /* FrequentlyAteView.swift */; }; @@ -45,6 +46,8 @@ 08C737F72C52277E00FA93A4 /* ModelData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08C737F62C52277E00FA93A4 /* ModelData.swift */; }; 08C737F92C52297600FA93A4 /* FoodRankCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08C737F82C52297600FA93A4 /* FoodRankCell.swift */; }; 08CC18702C492BA8007EF06E /* SearchNavigatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08CC186F2C492BA8007EF06E /* SearchNavigatorView.swift */; }; + 08EAA4F52C58DF7C00115508 /* FavoriteView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08EAA4F42C58DF7C00115508 /* FavoriteView.swift */; }; + 08EAA4F72C58DF8500115508 /* DirectRegisterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08EAA4F62C58DF8500115508 /* DirectRegisterView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -79,6 +82,7 @@ 087B509F2C4906B4005BF53C /* TabBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBar.swift; sourceTree = ""; }; 087B50A32C492100005BF53C /* RoundedCorner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundedCorner.swift; sourceTree = ""; }; 088DFC4D2C52489400469FD1 /* loading.lottie */ = {isa = PBXFileReference; lastKnownFileType = file; path = loading.lottie; sourceTree = ""; }; + 08A793AA2C62392F004A1FEB /* addList.lottie */ = {isa = PBXFileReference; lastKnownFileType = file; path = addList.lottie; sourceTree = ""; }; 08C737A82C4C06A000FA93A4 /* DoubleSidedBackgroundScrollView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DoubleSidedBackgroundScrollView.swift; sourceTree = ""; }; 08C737AA2C4C0E7200FA93A4 /* SlidingTabView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SlidingTabView.swift; sourceTree = ""; }; 08C737AC2C4CA2B400FA93A4 /* FrequentlyAteView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FrequentlyAteView.swift; sourceTree = ""; }; @@ -87,6 +91,8 @@ 08C737F62C52277E00FA93A4 /* ModelData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelData.swift; sourceTree = ""; }; 08C737F82C52297600FA93A4 /* FoodRankCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FoodRankCell.swift; sourceTree = ""; }; 08CC186F2C492BA8007EF06E /* SearchNavigatorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchNavigatorView.swift; sourceTree = ""; }; + 08EAA4F42C58DF7C00115508 /* FavoriteView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteView.swift; sourceTree = ""; }; + 08EAA4F62C58DF8500115508 /* DirectRegisterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DirectRegisterView.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -182,6 +188,7 @@ 082D45222C4582F9007AD8FB /* Fonts */, 082D450D2C458093007AD8FB /* Assets.xcassets */, 088DFC4D2C52489400469FD1 /* loading.lottie */, + 08A793AA2C62392F004A1FEB /* addList.lottie */, ); path = Resource; sourceTree = ""; @@ -287,10 +294,10 @@ 082D45552C468E14007AD8FB /* Record */ = { isa = PBXGroup; children = ( + 08EAA4F32C58DF4900115508 /* RecordTabmenuView */, 082D45562C468E20007AD8FB /* RecordView.swift */, 08CC186F2C492BA8007EF06E /* SearchNavigatorView.swift */, 08C737AA2C4C0E7200FA93A4 /* SlidingTabView.swift */, - 08C737AC2C4CA2B400FA93A4 /* FrequentlyAteView.swift */, 08C737F82C52297600FA93A4 /* FoodRankCell.swift */, 08621D232C57EC2F00E26998 /* UserSexFilterView.swift */, 08621D262C57FDF400E26998 /* RecordButtonView.swift */, @@ -306,6 +313,16 @@ path = Component; sourceTree = ""; }; + 08EAA4F32C58DF4900115508 /* RecordTabmenuView */ = { + isa = PBXGroup; + children = ( + 08C737AC2C4CA2B400FA93A4 /* FrequentlyAteView.swift */, + 08EAA4F42C58DF7C00115508 /* FavoriteView.swift */, + 08EAA4F62C58DF8500115508 /* DirectRegisterView.swift */, + ); + path = RecordTabmenuView; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -379,6 +396,7 @@ 082D452E2C458325007AD8FB /* Pretendard-Bold.otf in Resources */, 082D452D2C458325007AD8FB /* Pretendard-Light.otf in Resources */, 082D45112C458093007AD8FB /* Preview Assets.xcassets in Resources */, + 08A793AB2C623933004A1FEB /* addList.lottie in Resources */, 082D45312C458325007AD8FB /* Pretendard-Regular.otf in Resources */, 082D452F2C458325007AD8FB /* Pretendard-Black.otf in Resources */, 082D453D2C458DE2007AD8FB /* food_list_with_rank.json in Resources */, @@ -408,8 +426,10 @@ 082D450C2C458092007AD8FB /* MyHealthView.swift in Sources */, 082D454E2C468B21007AD8FB /* ContentView.swift in Sources */, 08C737AF2C4CA2D900FA93A4 /* ChipButton.swift in Sources */, + 08EAA4F72C58DF8500115508 /* DirectRegisterView.swift in Sources */, 082D450A2C458092007AD8FB /* PillyzeApp.swift in Sources */, 08C737AB2C4C0E7200FA93A4 /* SlidingTabView.swift in Sources */, + 08EAA4F52C58DF7C00115508 /* FavoriteView.swift in Sources */, 082D45542C468B96007AD8FB /* NutrientsView.swift in Sources */, 082D454A2C467F0D007AD8FB /* MyHealthSectionStack.swift in Sources */, 08C737A92C4C06A000FA93A4 /* DoubleSidedBackgroundScrollView.swift in Sources */, diff --git "a/\353\251\244\353\262\204-\352\260\234\353\260\234-\355\217\264\353\215\224/\354\234\244\353\217\231\354\243\274/Pillyze/Pillyze/Source/View/Record/RecordView.swift" "b/\353\251\244\353\262\204-\352\260\234\353\260\234-\355\217\264\353\215\224/\354\234\244\353\217\231\354\243\274/Pillyze/Pillyze/Source/View/Record/RecordView.swift" index 1eeb325..9632c28 100644 --- "a/\353\251\244\353\262\204-\352\260\234\353\260\234-\355\217\264\353\215\224/\354\234\244\353\217\231\354\243\274/Pillyze/Pillyze/Source/View/Record/RecordView.swift" +++ "b/\353\251\244\353\262\204-\352\260\234\353\260\234-\355\217\264\353\215\224/\354\234\244\353\217\231\354\243\274/Pillyze/Pillyze/Source/View/Record/RecordView.swift" @@ -48,11 +48,16 @@ struct RecordView: View { @State private var selectionTab: Int = RecordTabMenu.frequentlyAte.selectedTab @State private var filterElement: FilteringMenu = .all @State private var userSex: UserSex = .male + @State private var isLottieAnimationShown = false + @State private var selectedFoods: [RankingFood] = [] + @State private var isLoadingLottieShown: Bool = true @Binding var isRecordSheetShown: Bool + var lottieAnimation = DotLottieAnimation(fileName: "loading", config: AnimationConfig(autoplay: true, loop: false)) + var body: some View { - VStack { + VStack(spacing: 0) { SearchNavigatorView(isRecordSheetShown: $isRecordSheetShown) .padding(20) @@ -101,29 +106,47 @@ struct RecordView: View { } Spacer() } + .padding(.vertical, 11) + Spacer() .frame(height: 23) - UserSexFilterView(userSex: $userSex) - - ScrollView { - ForEach(Array(modelData.rankingFoods.enumerated()), - id: \.element.id) { index, food in - FoodRankCell(food: food, index: index + 1) - Divider() + ZStack { + switch menu { + case .frequentlyAte: + FrequentlyAteView(selectedFoods: $selectedFoods, + isLottieAnimationShown: $isLottieAnimationShown, + userSex: $userSex) + case .favorite: + FavoriteView() + case .directRegister: + DirectRegisterView() + } + if isLoadingLottieShown { + ZStack { + Color.white + .frame(maxWidth: .infinity, maxHeight: .infinity) + lottieAnimation.view() + .frame(width: 100, height: 100) + .onAppear { + DispatchQueue.main.asyncAfter(deadline: .now() + 2) { + isLoadingLottieShown = false + } + } + } } } - .scrollIndicators(.hidden) - Spacer() + } .padding(.horizontal, 20) - .tag(menu.selectedTab) + .tag(index) } } - .tabViewStyle(PageTabViewStyle(indexDisplayMode: .automatic)) - .onChange(of: selectionTab) { oldValue, newValue in + .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never)) + .onChange(of: selectionTab) { _, newValue in self.selectionTab = newValue } - RecordButtonView() + RecordButtonView(isLottieAnimationShown: $isLottieAnimationShown, + selectedFoods: $selectedFoods) } }