From 1b6d1c656869c00112ef1f563b96e515b88a8214 Mon Sep 17 00:00:00 2001 From: iyungui Date: Fri, 3 May 2024 18:12:57 +0900 Subject: [PATCH 1/8] - --- Packing.xcodeproj/project.pbxproj | 12 +++++++++- Packing/JourneyListView.swift | 40 +++++++++++++++---------------- Packing/OnboardingView.swift | 10 +------- Packing/PackingApp.swift | 6 ++--- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Packing.xcodeproj/project.pbxproj b/Packing.xcodeproj/project.pbxproj index a853813..3ce3d1a 100644 --- a/Packing.xcodeproj/project.pbxproj +++ b/Packing.xcodeproj/project.pbxproj @@ -118,6 +118,7 @@ children = ( C68C4B782BE0CBE600B62122 /* Packing */, C68C4B772BE0CBE600B62122 /* Products */, + C6EFA8002BE4CFB400AA4686 /* Recovered References */, ); sourceTree = ""; }; @@ -149,7 +150,6 @@ 4BC8056D2BE35D67004880FE /* StorageManager.swift */, C60C5F1C2BE2A1E500558210 /* ProfileView.swift */, C68C4B8B2BE0CE3000B62122 /* LoginView.swift */, - C68C4B8B2BE0CE3000B62122 /* RegisterationView.swift */, C6EFA7E22BE4942400AA4686 /* GoogleService-Info.plist */, C60C5F1A2BE2A19300558210 /* AuthenticationViewmodel.swift */, C60C5F182BE2A00800558210 /* OnboardingView.swift */, @@ -169,6 +169,14 @@ path = "Preview Content"; sourceTree = ""; }; + C6EFA8002BE4CFB400AA4686 /* Recovered References */ = { + isa = PBXGroup; + children = ( + B8232FB22BE4BB04009CD6FA /* GoogleService-Info.plist */, + ); + name = "Recovered References"; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -427,6 +435,7 @@ INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UIUserInterfaceStyle = Dark; IPHONEOS_DEPLOYMENT_TARGET = 17.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -464,6 +473,7 @@ INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UIUserInterfaceStyle = Dark; IPHONEOS_DEPLOYMENT_TARGET = 17.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", diff --git a/Packing/JourneyListView.swift b/Packing/JourneyListView.swift index 05c9b91..2e53ad6 100644 --- a/Packing/JourneyListView.swift +++ b/Packing/JourneyListView.swift @@ -13,32 +13,30 @@ struct JourneyListView: View { @Environment(\.colorScheme) var colorScheme var body: some View { - NavigationStack { - ZStack { - BackgroundGradientView(colorScheme: colorScheme) - .ignoresSafeArea() + ZStack { + BackgroundGradientView(colorScheme: colorScheme) + .ignoresSafeArea() - if service.journeys.isEmpty { - EmptyStateView() - } else { - JourneyList() - } + if service.journeys.isEmpty { + EmptyStateView() + } else { + JourneyList() } - .navigationTitle("Your Journeys") - .toolbar { - ToolbarItem(placement: .navigationBarTrailing) { - NavigationLink(destination: AddJourneyView(packingItemService: PackingItemService(documentID: "test"), service: service)) { - Image(systemName: "plus.circle.fill") - .imageScale(.large) - .foregroundColor(.accentColor) - } + } + .navigationTitle("Your Journeys") + .toolbar { + ToolbarItem(placement: .navigationBarTrailing) { + NavigationLink(destination: AddJourneyView(packingItemService: PackingItemService(documentID: "test"), service: service)) { + Image(systemName: "plus.circle.fill") + .imageScale(.large) + .foregroundColor(.accentColor) } } - .task { - service.fetch() - } -// .environmentObject(service) } + .task { + service.fetch() + } + .navigationBarBackButtonHidden(true) } @ViewBuilder diff --git a/Packing/OnboardingView.swift b/Packing/OnboardingView.swift index 9d08e20..324a00f 100644 --- a/Packing/OnboardingView.swift +++ b/Packing/OnboardingView.swift @@ -7,14 +7,6 @@ // MARK: fdeprecated import SwiftUI -struct MainView: View { - var body: some View { - Text("Welcome to LAB5 Packing APP") - .font(.title) - .padding() - } -} - struct OnboardingView: View { @StateObject private var authenticationViewModel = AuthenticationViewModel() @@ -23,7 +15,7 @@ struct OnboardingView: View { var body: some View { if showMainView { - MainView() + JourneyListView() } else { ZStack { Color("mainColor").edgesIgnoringSafeArea(.all) diff --git a/Packing/PackingApp.swift b/Packing/PackingApp.swift index a24801d..8d0dbd7 100644 --- a/Packing/PackingApp.swift +++ b/Packing/PackingApp.swift @@ -30,10 +30,10 @@ struct PackingApp: App { var body: some Scene { WindowGroup { -// LoginView() -// .environmentObject(authenticationViewModel) + LoginView() + .environmentObject(authenticationViewModel) - JourneyListView() +// JourneyListView() } } } From d9bc525cabec7169b15a02ab1bbc27ea1f7891ec Mon Sep 17 00:00:00 2001 From: iyungui Date: Sat, 4 May 2024 19:45:19 +0900 Subject: [PATCH 2/8] remove NavigationStack in AddShareLuggageView, ViewBuilder -> ViewModifier/var --- Packing.xcodeproj/project.pbxproj | 2 -- Packing/AddShareLuggageView.swift | 6 ++--- Packing/JourneyListView.swift | 37 ++++++++++++++++++------------- Packing/PackingApp.swift | 2 -- Packing/PackingListView.swift | 2 -- 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/Packing.xcodeproj/project.pbxproj b/Packing.xcodeproj/project.pbxproj index 3ce3d1a..ac024c2 100644 --- a/Packing.xcodeproj/project.pbxproj +++ b/Packing.xcodeproj/project.pbxproj @@ -435,7 +435,6 @@ INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - INFOPLIST_KEY_UIUserInterfaceStyle = Dark; IPHONEOS_DEPLOYMENT_TARGET = 17.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -473,7 +472,6 @@ INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - INFOPLIST_KEY_UIUserInterfaceStyle = Dark; IPHONEOS_DEPLOYMENT_TARGET = 17.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", diff --git a/Packing/AddShareLuggageView.swift b/Packing/AddShareLuggageView.swift index 8bf2edc..0178dbf 100644 --- a/Packing/AddShareLuggageView.swift +++ b/Packing/AddShareLuggageView.swift @@ -19,10 +19,7 @@ struct AddShareLuggageView: View { @Environment(\.dismiss) var dismiss var body: some View { - NavigationStack { - JourneySummaryView(journey: journey) - .frame(minWidth: 200, maxWidth: .infinity, minHeight: 100) - .padding() + VStack { Form { Section(header: Text("공용 물품 이름") @@ -87,3 +84,4 @@ struct AddShareLuggageView: View { } } } + diff --git a/Packing/JourneyListView.swift b/Packing/JourneyListView.swift index 2e53ad6..8897d52 100644 --- a/Packing/JourneyListView.swift +++ b/Packing/JourneyListView.swift @@ -7,22 +7,35 @@ import SwiftUI +struct GradientBackground: ViewModifier { + @Environment(\.colorScheme) var colorScheme + + func body(content: Content) -> some View { + content + .background(LinearGradient(gradient: Gradient(colors: colorScheme == .light ? [Color(hex: "AEC6CF"), Color(hex: "ECECEC"), Color(hex: "FFFDD0")] : [Color(hex: "34495E"), Color(hex: "555555"), Color(hex: "333333")]), startPoint: .topLeading, endPoint: .bottomTrailing)) + } +} + +extension View { + func gradientBackground() -> some View { + modifier(GradientBackground()) + } +} + struct JourneyListView: View { @StateObject private var service: JourneyService = JourneyService() @State private var selectedJourney: Journey? @Environment(\.colorScheme) var colorScheme var body: some View { - ZStack { - BackgroundGradientView(colorScheme: colorScheme) - .ignoresSafeArea() - + VStack { if service.journeys.isEmpty { - EmptyStateView() + EmptyStateView } else { - JourneyList() + JourneyList } } + .gradientBackground() .navigationTitle("Your Journeys") .toolbar { ToolbarItem(placement: .navigationBarTrailing) { @@ -39,13 +52,7 @@ struct JourneyListView: View { .navigationBarBackButtonHidden(true) } - @ViewBuilder - private func BackgroundGradientView(colorScheme: ColorScheme) -> some View { - LinearGradient(gradient: Gradient(colors: colorScheme == .light ? [Color(hex: "AEC6CF"), Color(hex: "ECECEC"), Color(hex: "FFFDD0")] : [Color(hex: "34495E"), Color(hex: "555555"), Color(hex: "333333")]), startPoint: .topLeading, endPoint: .bottomTrailing) - } - - @ViewBuilder - private func EmptyStateView() -> some View { + private var EmptyStateView: some View { VStack { Image(systemName: "airplane") .font(.largeTitle) @@ -55,10 +62,10 @@ struct JourneyListView: View { .multilineTextAlignment(.center) .padding() } + .frame(maxWidth: .infinity, maxHeight: .infinity) } - @ViewBuilder - private func JourneyList() -> some View { + private var JourneyList: some View { List(service.journeys) { journey in Button(action: { self.selectedJourney = journey diff --git a/Packing/PackingApp.swift b/Packing/PackingApp.swift index 8d0dbd7..47b0b5a 100644 --- a/Packing/PackingApp.swift +++ b/Packing/PackingApp.swift @@ -32,8 +32,6 @@ struct PackingApp: App { WindowGroup { LoginView() .environmentObject(authenticationViewModel) - -// JourneyListView() } } } diff --git a/Packing/PackingListView.swift b/Packing/PackingListView.swift index c0565ca..c57b20d 100644 --- a/Packing/PackingListView.swift +++ b/Packing/PackingListView.swift @@ -16,7 +16,6 @@ struct PackingListView: View { var journey: Journey @Environment(\.colorScheme) var colorScheme -// @Environment(\.dismiss) var dismiss var body: some View { VStack { @@ -152,7 +151,6 @@ struct PackingListView: View { .scrollContentBackground(.hidden) } -// .navigationBarBackButtonHidden(true) .padding(.top, 90) .ignoresSafeArea() .sheet(isPresented: $isNewSharePresented) { From f2ffddd286114340b43006273a1a4d2a93ab29f3 Mon Sep 17 00:00:00 2001 From: iyungui Date: Sat, 4 May 2024 19:54:13 +0900 Subject: [PATCH 3/8] use gradientbackground viewModifier in AddJourneyView, PackingListView --- Packing/AddJourneyView.swift | 256 +++++++++++++++++----------------- Packing/PackingListView.swift | 2 +- 2 files changed, 127 insertions(+), 131 deletions(-) diff --git a/Packing/AddJourneyView.swift b/Packing/AddJourneyView.swift index 4210b73..82f0084 100644 --- a/Packing/AddJourneyView.swift +++ b/Packing/AddJourneyView.swift @@ -26,154 +26,150 @@ struct AddJourneyView: View { var body: some View { - ZStack{ - LinearGradient(gradient: Gradient(colors: colorScheme == .light ? [Color(hex: "AEC6CF"), Color(hex: "ECECEC"), Color(hex: "FFFDD0")] : [Color(hex: "34495E"), Color(hex: "555555"), Color(hex: "333333")]), startPoint: .topLeading, endPoint: .bottomTrailing) - .ignoresSafeArea() + VStack{ - VStack{ - - // MARK: - Image - - ZStack{ - if let image = image { - Image(uiImage: image) - .resizable() - .clipShape(RoundedRectangle(cornerRadius: 30)) - .frame(minWidth: 200, maxWidth: .infinity, maxHeight: .infinity) - .padding(.top, 60) - .shadow(radius: 3) - } else { - Spacer() - PhotosPicker(selection: $selectedItem, matching: .images, photoLibrary: .shared()) { - ZStack{ - Rectangle() - .clipShape(RoundedRectangle(cornerRadius: 30)) - .frame(minWidth: 200, maxWidth: .infinity, maxHeight: .infinity) - .padding(.top, 60) - .shadow(radius: 3) - .foregroundStyle(colorScheme == .dark ? Color("DarkColor") : .white) - VStack{ - Image(systemName: "photo.badge.plus") - .resizable() - .aspectRatio(contentMode: .fit) - .frame(width: 100) - .padding(.top, 50) - .foregroundStyle(Color(hex: 0x566375)) - } + // MARK: - Image + + ZStack{ + if let image = image { + Image(uiImage: image) + .resizable() + .clipShape(RoundedRectangle(cornerRadius: 30)) + .frame(minWidth: 200, maxWidth: .infinity, maxHeight: .infinity) + .padding(.top, 60) + .shadow(radius: 3) + } else { + Spacer() + PhotosPicker(selection: $selectedItem, matching: .images, photoLibrary: .shared()) { + ZStack{ + Rectangle() + .clipShape(RoundedRectangle(cornerRadius: 30)) + .frame(minWidth: 200, maxWidth: .infinity, maxHeight: .infinity) + .padding(.top, 60) + .shadow(radius: 3) + .foregroundStyle(colorScheme == .dark ? Color("DarkColor") : .white) + VStack{ + Image(systemName: "photo.badge.plus") + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: 100) + .padding(.top, 50) + .foregroundStyle(Color(hex: 0x566375)) } - }.onChange(of: selectedItem) { - loadImage() } + }.onChange(of: selectedItem) { + loadImage() } } - - - ZStack{ - RoundedRectangle(cornerRadius: 30) - .foregroundStyle(colorScheme == .dark ? Color("DarkColor") : .white) - .frame(minHeight: 550, maxHeight: .infinity) - VStack { - VStack(alignment:.center){ - - // MARK: 여행 목적지 - Text("여행목적지") - .font(.title2) - .fontWeight(.bold) - - TextField("여행목적지",text: $testString) - .padding() - .font(.subheadline) - .background(colorScheme == .dark ? Color(hex: 0x1A1A1A) : Color(hex: 0xF3F3F3)) - .clipShape(RoundedRectangle(cornerRadius: 15.0)) - .frame(width: 300) - .padding(.bottom,30) - - // MARK: - 여행 기간 - Text("여행 기간") - .font(.title2) - .fontWeight(.bold) - VStack{ - DatePicker("시작 날짜", selection: $startdate, displayedComponents: [.date]) - .padding() - DatePicker("종료 날짜", selection: $endDate, displayedComponents: [.date]) - .padding() - } - .bold() - .font(.body) - .frame(width: 300 , alignment: .leading) + } + + + ZStack{ + RoundedRectangle(cornerRadius: 30) + .foregroundStyle(colorScheme == .dark ? Color("DarkColor") : .white) + .frame(minHeight: 550, maxHeight: .infinity) + VStack { + VStack(alignment:.center){ + + // MARK: 여행 목적지 + Text("여행목적지") + .font(.title2) + .fontWeight(.bold) + + TextField("여행목적지",text: $testString) + .padding() + .font(.subheadline) .background(colorScheme == .dark ? Color(hex: 0x1A1A1A) : Color(hex: 0xF3F3F3)) .clipShape(RoundedRectangle(cornerRadius: 15.0)) - .padding() - - //MARK: - 여행 목적 - // Picker("여행 활동", selection: $travelActivitys){ - // ForEach(TravelActivity.allCases, id: \.self) { - // Text($0.rawValue) - // .font(.body) - // } - // } - // .foregroundStyle(colorScheme == .dark ? .white : .black) - // .font(.title3) - // .bold() - // .padding() - // .pickerStyle(.navigationLink) - // .frame(width: 300,height: 60) - // .background(colorScheme == .dark ? Color(hex: 0x1A1A1A) : Color(hex: 0xF3F3F3)) - // .clipShape(RoundedRectangle(cornerRadius: 15.0)) - NavigationLink(destination: MultiSelector(selections: $travelActivitys)) { - HStack{ - - Text("여행활동") - .font(.title3) - .padding() - .bold() - Spacer() - if travelActivitys.isEmpty { - Text("추가") - .foregroundStyle(.gray) - .font(.title3) - .padding() - } - Text("\(travelActivitysString(travelActivitys: travelActivitys))") + .frame(width: 300) + .padding(.bottom,30) + + // MARK: - 여행 기간 + Text("여행 기간") + .font(.title2) + .fontWeight(.bold) + VStack{ + DatePicker("시작 날짜", selection: $startdate, displayedComponents: [.date]) + .padding() + DatePicker("종료 날짜", selection: $endDate, displayedComponents: [.date]) + .padding() + } + .bold() + .font(.body) + .frame(width: 300 , alignment: .leading) + .background(colorScheme == .dark ? Color(hex: 0x1A1A1A) : Color(hex: 0xF3F3F3)) + .clipShape(RoundedRectangle(cornerRadius: 15.0)) + .padding() + + //MARK: - 여행 목적 + // Picker("여행 활동", selection: $travelActivitys){ + // ForEach(TravelActivity.allCases, id: \.self) { + // Text($0.rawValue) + // .font(.body) + // } + // } + // .foregroundStyle(colorScheme == .dark ? .white : .black) + // .font(.title3) + // .bold() + // .padding() + // .pickerStyle(.navigationLink) + // .frame(width: 300,height: 60) + // .background(colorScheme == .dark ? Color(hex: 0x1A1A1A) : Color(hex: 0xF3F3F3)) + // .clipShape(RoundedRectangle(cornerRadius: 15.0)) + NavigationLink(destination: MultiSelector(selections: $travelActivitys)) { + HStack{ + + Text("여행활동") + .font(.title3) + .padding() + .bold() + Spacer() + if travelActivitys.isEmpty { + Text("추가") .foregroundStyle(.gray) + .font(.title3) .padding() - } - .foregroundStyle(.black) - .background(Color(hex: 0xF3F3F3)) - .clipShape(RoundedRectangle(cornerRadius: 15.0)) - .frame(width: 300 , alignment: .leading) - + Text("\(travelActivitysString(travelActivitys: travelActivitys))") + .foregroundStyle(.gray) + .padding() } - - - } - - //MARK: - 확인 버튼 - if isUploading { - ProgressView() - } else { - Button{ - addJourney() - } label: { - Text("확인") - .fontWeight(.bold) - .foregroundStyle(.white) - .padding(.horizontal,50) - .padding(.vertical,20) - .background(testString.isEmpty ? Color(hex: 0x566375).opacity(0.5) : Color(hex: 0x566375)) - .clipShape(RoundedRectangle(cornerRadius: 15.0)) + .foregroundStyle(.black) + .background(Color(hex: 0xF3F3F3)) + .clipShape(RoundedRectangle(cornerRadius: 15.0)) + .frame(width: 300 , alignment: .leading) + + } - .padding(.top, 30) - .disabled(testString.isEmpty) + + + } + + //MARK: - 확인 버튼 + if isUploading { + ProgressView() + } else { + Button{ + addJourney() + } label: { + Text("확인") + .fontWeight(.bold) + .foregroundStyle(.white) + .padding(.horizontal,50) + .padding(.vertical,20) + .background(testString.isEmpty ? Color(hex: 0x566375).opacity(0.5) : Color(hex: 0x566375)) + .clipShape(RoundedRectangle(cornerRadius: 15.0)) } + .padding(.top, 30) + .disabled(testString.isEmpty) } } - .ignoresSafeArea(.all) - } + .ignoresSafeArea(.all) + } + .gradientBackground() // MARK: - ALERT .alert("알람", isPresented: $showAlert) { diff --git a/Packing/PackingListView.swift b/Packing/PackingListView.swift index c57b20d..a2dcec5 100644 --- a/Packing/PackingListView.swift +++ b/Packing/PackingListView.swift @@ -159,7 +159,7 @@ struct PackingListView: View { .sheet(isPresented: $isNewPersonalPresented) { AddPersonalLuggageView(journey: journey, service: service) } - .background(LinearGradient(gradient: Gradient(colors: colorScheme == .light ? [Color(hex: "AEC6CF"), Color(hex: "ECECEC"), Color(hex: "FFFDD0")] : [Color(hex: "34495E"), Color(hex: "555555"), Color(hex: "333333")]), startPoint: .topLeading, endPoint: .bottomTrailing)) + .gradientBackground() } } From 09690d9717ae773cd0be0db80e0fd88f888d55d1 Mon Sep 17 00:00:00 2001 From: iyungui Date: Sat, 4 May 2024 20:27:35 +0900 Subject: [PATCH 4/8] use gradientbackground viewModifier in AddLuggageView --- Packing/AddPersonalLuggageView.swift | 9 ++------- Packing/AddShareLuggageView.swift | 3 +-- Packing/JourneyListView.swift | 1 + 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Packing/AddPersonalLuggageView.swift b/Packing/AddPersonalLuggageView.swift index 8be7831..9801824 100644 --- a/Packing/AddPersonalLuggageView.swift +++ b/Packing/AddPersonalLuggageView.swift @@ -18,11 +18,7 @@ struct AddPersonalLuggageView: View { @Environment(\.dismiss) var dismiss var body: some View { - NavigationStack { - JourneySummaryView(journey: journey) - .frame(minWidth: 200, maxWidth: .infinity, minHeight: 100) - .padding() - + VStack { Form { Section(header: Text("개인 물품 이름") ){ @@ -74,8 +70,7 @@ struct AddPersonalLuggageView: View { .font(.title2) .fontWeight(.bold) .scrollContentBackground(.hidden) - .background(RoundedRectangle(cornerRadius: 30) - .fill(LinearGradient(colors: [Color(hex: "AEC6CF"),Color(hex: "ECECEC"),Color(hex: "FFFDD0")], startPoint: .topLeading, endPoint: .bottomTrailing))) + .gradientBackground() .ignoresSafeArea() } } diff --git a/Packing/AddShareLuggageView.swift b/Packing/AddShareLuggageView.swift index 0178dbf..faae1b5 100644 --- a/Packing/AddShareLuggageView.swift +++ b/Packing/AddShareLuggageView.swift @@ -78,8 +78,7 @@ struct AddShareLuggageView: View { .font(.title2) .fontWeight(.bold) .scrollContentBackground(.hidden) - .background(RoundedRectangle(cornerRadius: 30) - .fill(LinearGradient(colors: [Color(hex: "AEC6CF"),Color(hex: "ECECEC"),Color(hex: "FFFDD0")], startPoint: .topLeading, endPoint: .bottomTrailing))) + .gradientBackground() .ignoresSafeArea() } } diff --git a/Packing/JourneyListView.swift b/Packing/JourneyListView.swift index 8897d52..a20237b 100644 --- a/Packing/JourneyListView.swift +++ b/Packing/JourneyListView.swift @@ -7,6 +7,7 @@ import SwiftUI +// MARK: - VIEW MODIFIER struct GradientBackground: ViewModifier { @Environment(\.colorScheme) var colorScheme From 441ac2e226467c9f4c29e148a520a6b1d8829ce4 Mon Sep 17 00:00:00 2001 From: iyungui Date: Thu, 9 May 2024 21:34:03 +0900 Subject: [PATCH 5/8] refactoring journeyListView --- Packing/View/AddJourneyView.swift | 238 ++++++++++++++--------------- Packing/View/JourneyListView.swift | 10 +- 2 files changed, 122 insertions(+), 126 deletions(-) diff --git a/Packing/View/AddJourneyView.swift b/Packing/View/AddJourneyView.swift index 318ccec..6223bb6 100644 --- a/Packing/View/AddJourneyView.swift +++ b/Packing/View/AddJourneyView.swift @@ -28,143 +28,122 @@ struct AddJourneyView: View { var body: some View { VStack{ - VStack{ - - // MARK: - Image - - ZStack{ - PhotosPicker(selection: $selectedItem, matching: .images, photoLibrary: .shared()) { - if let image = image { - Image(uiImage: image) - .resizable() + // MARK: - Image + + ZStack{ + PhotosPicker(selection: $selectedItem, matching: .images, photoLibrary: .shared()) { + if let image = image { + Image(uiImage: image) + .resizable() + .clipShape(RoundedRectangle(cornerRadius: 30)) + .frame(minWidth: 200, maxWidth: .infinity, maxHeight: .infinity) + .padding(.top, 60) + .shadow(radius: 3) + } else { + Spacer() + ZStack{ + Rectangle() .clipShape(RoundedRectangle(cornerRadius: 30)) .frame(minWidth: 200, maxWidth: .infinity, maxHeight: .infinity) .padding(.top, 60) .shadow(radius: 3) - } else { - Spacer() - ZStack{ - Rectangle() - .clipShape(RoundedRectangle(cornerRadius: 30)) - .frame(minWidth: 200, maxWidth: .infinity, maxHeight: .infinity) - .padding(.top, 60) - .shadow(radius: 3) - .foregroundStyle(colorScheme == .dark ? Color("DarkColor") : .white) - VStack{ - Image(systemName: "photo.badge.plus") - .resizable() - .aspectRatio(contentMode: .fit) - .frame(width: 100) - .padding(.top, 50) - .foregroundStyle(Color(hex: 0x566375)) - } + .foregroundStyle(colorScheme == .dark ? Color("DarkColor") : .white) + VStack{ + Image(systemName: "photo.badge.plus") + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: 100) + .padding(.top, 50) + .foregroundStyle(Color(hex: 0x566375)) } } - }.onChange(of: selectedItem) { - loadImage() } + }.onChange(of: selectedItem) { + loadImage() } - - - ZStack{ - RoundedRectangle(cornerRadius: 30) - .foregroundStyle(colorScheme == .dark ? Color("DarkColor") : .white) - .frame(minHeight: 550, maxHeight: .infinity) - VStack { - VStack(alignment:.center){ - - // MARK: 여행 목적지 - Text("여행목적지") - .font(.title2) - .fontWeight(.bold) + } + + + ZStack{ + RoundedRectangle(cornerRadius: 30) + .foregroundStyle(colorScheme == .dark ? Color("DarkColor") : .white) + .frame(minHeight: 550, maxHeight: .infinity) + VStack { + VStack(alignment:.center){ + + // MARK: 여행 목적지 + Text("여행목적지") + .font(.title2) + .fontWeight(.bold) + + TextField("여행목적지",text: $testString) + .padding() + .font(.subheadline) + .background(colorScheme == .dark ? Color(hex: 0x1A1A1A) : Color(hex: 0xF3F3F3)) + .clipShape(RoundedRectangle(cornerRadius: 15.0)) + .frame(width: 300) + .padding(.bottom,30) + + // MARK: - 여행 기간 + Text("여행 기간") + .font(.title2) + .fontWeight(.bold) + VStack{ + DatePicker("시작 날짜", selection: $startdate,displayedComponents: [.date]) - TextField("여행목적지",text: $testString) .padding() - .font(.subheadline) - .background(colorScheme == .dark ? Color(hex: 0x1A1A1A) : Color(hex: 0xF3F3F3)) - .clipShape(RoundedRectangle(cornerRadius: 15.0)) - .frame(width: 300) - .padding(.bottom,30) - - // MARK: - 여행 기간 - Text("여행 기간") - .font(.title2) - .fontWeight(.bold) - VStack{ - DatePicker("시작 날짜", selection: $startdate,displayedComponents: [.date]) + DatePicker("종료 날짜", selection: $endDate, displayedComponents: [.date]) + .padding() + } + .bold() + .font(.body) + .frame(width: 300 , alignment: .leading) + .background(colorScheme == .dark ? Color(hex: 0x1A1A1A) : Color(hex: 0xF3F3F3)) + .clipShape(RoundedRectangle(cornerRadius: 15.0)) + .padding() + + //MARK: - 여행 목적 + // Picker("여행 활동", selection: $travelActivitys){ + // ForEach(TravelActivity.allCases, id: \.self) { + // Text($0.rawValue) + // .font(.body) + // } + // } + // .foregroundStyle(colorScheme == .dark ? .white : .black) + // .font(.title3) + // .bold() + // .padding() + // .pickerStyle(.navigationLink) + // .frame(width: 300,height: 60) + // .background(colorScheme == .dark ? Color(hex: 0x1A1A1A) : Color(hex: 0xF3F3F3)) + // .clipShape(RoundedRectangle(cornerRadius: 15.0)) + NavigationLink(destination: MultiSelector(selections: $travelActivitys)) { + HStack{ + Text("여행활동") + .font(.title3) .padding() - DatePicker("종료 날짜", selection: $endDate, displayedComponents: [.date]) - .padding() - } - .bold() - .font(.body) - .frame(width: 300 , alignment: .leading) - .background(colorScheme == .dark ? Color(hex: 0x1A1A1A) : Color(hex: 0xF3F3F3)) - .clipShape(RoundedRectangle(cornerRadius: 15.0)) - .padding() - - //MARK: - 여행 목적 - // Picker("여행 활동", selection: $travelActivitys){ - // ForEach(TravelActivity.allCases, id: \.self) { - // Text($0.rawValue) - // .font(.body) - // } - // } - // .foregroundStyle(colorScheme == .dark ? .white : .black) - // .font(.title3) - // .bold() - // .padding() - // .pickerStyle(.navigationLink) - // .frame(width: 300,height: 60) - // .background(colorScheme == .dark ? Color(hex: 0x1A1A1A) : Color(hex: 0xF3F3F3)) - // .clipShape(RoundedRectangle(cornerRadius: 15.0)) - NavigationLink(destination: MultiSelector(selections: $travelActivitys)) { - HStack{ - - Text("여행활동") - .font(.title3) - .padding() - .bold() - Spacer() - if travelActivitys.isEmpty { - Text("추가") - .foregroundStyle(.gray) - .font(.title3) - .padding() - } - Text("\(travelActivitysString(travelActivitys: travelActivitys))") + .bold() + Spacer() + if travelActivitys.isEmpty { + Text("추가") .foregroundStyle(.gray) + .font(.title3) .padding() - } - .foregroundStyle(.black) - .background(Color(hex: 0xF3F3F3)) - .clipShape(RoundedRectangle(cornerRadius: 15.0)) - .frame(width: 300 , alignment: .leading) - + Text("\(travelActivitysString(travelActivitys: travelActivitys))") + .foregroundStyle(.gray) + .padding() } + .foregroundStyle(.black) + .background(Color(hex: 0xF3F3F3)) + .clipShape(RoundedRectangle(cornerRadius: 15.0)) + .frame(width: 300 , alignment: .leading) } - //MARK: - 확인 버튼 - if isUploading { - ProgressView() - } else { - Button{ - addJourney() - } label: { - Text("확인") - .fontWeight(.bold) - .foregroundStyle(.white) - .padding(.horizontal,50) - .padding(.vertical,20) - .background(testString.isEmpty ? Color(hex: 0x566375).opacity(0.5) : Color(hex: 0x566375)) - .clipShape(RoundedRectangle(cornerRadius: 15.0)) - } - } @@ -183,14 +162,33 @@ struct AddJourneyView: View { .background(testString.isEmpty ? Color(hex: 0x566375).opacity(0.5) : Color(hex: 0x566375)) .clipShape(RoundedRectangle(cornerRadius: 15.0)) } - .padding(.top, 30) - .disabled(testString.isEmpty) + + + } + + //MARK: - 확인 버튼 + if isUploading { + ProgressView() + } else { + Button{ + addJourney() + } label: { + Text("확인") + .fontWeight(.bold) + .foregroundStyle(.white) + .padding(.horizontal,50) + .padding(.vertical,20) + .background(testString.isEmpty ? Color(hex: 0x566375).opacity(0.5) : Color(hex: 0x566375)) + .clipShape(RoundedRectangle(cornerRadius: 15.0)) } + .padding(.top, 30) + .disabled(testString.isEmpty) } } - .ignoresSafeArea(.all) - } + .ignoresSafeArea(.all) + + } .gradientBackground() // MARK: - ALERT diff --git a/Packing/View/JourneyListView.swift b/Packing/View/JourneyListView.swift index 777d1b2..95efad0 100644 --- a/Packing/View/JourneyListView.swift +++ b/Packing/View/JourneyListView.swift @@ -29,16 +29,14 @@ struct JourneyListView: View { @Environment(\.colorScheme) var colorScheme var body: some View { - ZStack { - BackgroundGradientView(colorScheme: colorScheme) - .ignoresSafeArea() - + VStack { if service.journeys.isEmpty { - EmptyStateView() + EmptyStateView } else { - JourneyList() + JourneyList } } + .gradientBackground() .navigationTitle("Your Journeys") .toolbar { ToolbarItem(placement: .navigationBarTrailing) { From faff268ff08986c0b5d50f8b98c8adc35710fd6e Mon Sep 17 00:00:00 2001 From: iyungui Date: Thu, 9 May 2024 21:44:50 +0900 Subject: [PATCH 6/8] delete navigationView in OnboardingView, Change backgroundColor --- Packing/View/JourneyListView.swift | 13 ++++++++++--- Packing/View/OnboardingView.swift | 9 +++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Packing/View/JourneyListView.swift b/Packing/View/JourneyListView.swift index 95efad0..255cae3 100644 --- a/Packing/View/JourneyListView.swift +++ b/Packing/View/JourneyListView.swift @@ -13,7 +13,12 @@ struct GradientBackground: ViewModifier { func body(content: Content) -> some View { content - .background(LinearGradient(gradient: Gradient(colors: colorScheme == .light ? [Color(hex: "AEC6CF"), Color(hex: "ECECEC"), Color(hex: "FFFDD0")] : [Color(hex: "34495E"), Color(hex: "555555"), Color(hex: "333333")]), startPoint: .topLeading, endPoint: .bottomTrailing)) + .background( + LinearGradient(gradient: Gradient(colors: colorScheme == .light ? + [Color(hex: "AEC6CF"), Color(hex: "D6D6D6"), Color(hex: "F0EAD6")] : + [Color(hex: "34495E"), Color(hex: "4E4E4E"), Color(hex: "2E2E2E")]), + startPoint: .topLeading, endPoint: .bottomTrailing) + ) } } @@ -147,8 +152,10 @@ struct JourneySummaryView: View { #Preview { - JourneyListView() - .environmentObject(JourneyService()) + NavigationStack { + JourneyListView() + .environmentObject(JourneyService()) + } } // MARK: - COLOR EXTENSION diff --git a/Packing/View/OnboardingView.swift b/Packing/View/OnboardingView.swift index 097e561..c777996 100644 --- a/Packing/View/OnboardingView.swift +++ b/Packing/View/OnboardingView.swift @@ -16,7 +16,7 @@ struct OnboardingView: View { @AppStorage("hasCompletedOnboarding") var showMainView: Bool = false var body: some View { - NavigationView { +// NavigationView { if showMainView { JourneyListView() } else { @@ -35,10 +35,11 @@ struct OnboardingView: View { NavigationButtons(currentPage: $currentPage, totalPages: 4) } + .navigationBarHidden(true) + .navigationBarBackButtonHidden(true) } - } - .navigationBarHidden(true) - .navigationBarBackButtonHidden(true) +// } + } } From b2dd412992c9d42e7601a2b4b11e5856da2cd6ed Mon Sep 17 00:00:00 2001 From: iyungui Date: Thu, 9 May 2024 22:08:31 +0900 Subject: [PATCH 7/8] change background, journeylist color --- Packing/View/JourneyListView.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Packing/View/JourneyListView.swift b/Packing/View/JourneyListView.swift index 255cae3..097807e 100644 --- a/Packing/View/JourneyListView.swift +++ b/Packing/View/JourneyListView.swift @@ -130,15 +130,15 @@ struct JourneySummaryView: View { AsyncImage(url: URL(string: journey.image)) { image in image.resizable() } placeholder: { - EmptyView() + colorScheme == .dark ? Color("DarkColor") : Color(hex: 0xE2E8F0) } .scaledToFill() - LinearGradient(gradient: Gradient(stops: [ - .init(color: colorScheme == .dark ? Color.black.opacity(0.6) : Color.white.opacity(0.8), location: 0.3), - .init(color: colorScheme == .dark ? Color.black.opacity(0.4) : Color.white.opacity(0.5), location: 0.7), - .init(color: .clear, location: 1) - ]), startPoint: .leading, endPoint: .trailing) +// LinearGradient(gradient: Gradient(stops: [ +// .init(color: colorScheme == .dark ? Color.black.opacity(0.6) : Color.white.opacity(0.8), location: 0.3), +// .init(color: colorScheme == .dark ? Color.black.opacity(0.4) : Color.white.opacity(0.5), location: 0.7), +// .init(color: .clear, location: 1) +// ]), startPoint: .leading, endPoint: .trailing) } // .frame(height: 100) // .clipped() From 61f0d7aa891400e8ff12d4ce18d4ce2e154e2adb Mon Sep 17 00:00:00 2001 From: iyungui Date: Thu, 9 May 2024 22:18:36 +0900 Subject: [PATCH 8/8] sync --- Packing/View/JourneyListView.swift | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Packing/View/JourneyListView.swift b/Packing/View/JourneyListView.swift index 097807e..34470d7 100644 --- a/Packing/View/JourneyListView.swift +++ b/Packing/View/JourneyListView.swift @@ -126,22 +126,19 @@ struct JourneySummaryView: View { } .padding() .background( - ZStack { - AsyncImage(url: URL(string: journey.image)) { image in + AsyncImage(url: URL(string: journey.image)) { image in + ZStack { image.resizable() - } placeholder: { - colorScheme == .dark ? Color("DarkColor") : Color(hex: 0xE2E8F0) + LinearGradient(gradient: Gradient(stops: [ + .init(color: colorScheme == .dark ? Color.black.opacity(0.6) : Color.white.opacity(0.8), location: 0.3), + .init(color: colorScheme == .dark ? Color.black.opacity(0.4) : Color.white.opacity(0.5), location: 0.7), + .init(color: .clear, location: 1) + ]), startPoint: .leading, endPoint: .trailing) } - .scaledToFill() - -// LinearGradient(gradient: Gradient(stops: [ -// .init(color: colorScheme == .dark ? Color.black.opacity(0.6) : Color.white.opacity(0.8), location: 0.3), -// .init(color: colorScheme == .dark ? Color.black.opacity(0.4) : Color.white.opacity(0.5), location: 0.7), -// .init(color: .clear, location: 1) -// ]), startPoint: .leading, endPoint: .trailing) + } placeholder: { + colorScheme == .dark ? Color("DarkColor") : Color(hex: 0xE2E8F0) } -// .frame(height: 100) -// .clipped() + .scaledToFill() ) .cornerRadius(8) .scaledToFill()