diff --git a/NearFuture.xcodeproj/project.pbxproj b/NearFuture.xcodeproj/project.pbxproj index 514e7b7..b6c92d7 100644 --- a/NearFuture.xcodeproj/project.pbxproj +++ b/NearFuture.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 70; + objectVersion = 56; objects = { /* Begin PBXBuildFile section */ @@ -25,6 +25,8 @@ A949F8542DCAABE00064DCA0 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949F8462DCAABE00064DCA0 /* SettingsView.swift */; }; A949F8552DCAABE00064DCA0 /* StatsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949F8482DCAABE00064DCA0 /* StatsView.swift */; }; A949F8562DCAABE00064DCA0 /* ExportView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949F8432DCAABE00064DCA0 /* ExportView.swift */; }; + A949F8592DCAAD670064DCA0 /* NearFutureTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949F8572DCAAD670064DCA0 /* NearFutureTests.swift */; }; + A949F85F2DCABB420064DCA0 /* Buttons.swift in Sources */ = {isa = PBXBuildFile; fileRef = A949F85D2DCABB420064DCA0 /* Buttons.swift */; }; A979F6052D270AF00094C0B3 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A979F6042D270AF00094C0B3 /* WidgetKit.framework */; }; A979F6072D270AF00094C0B3 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A979F6062D270AF00094C0B3 /* SwiftUI.framework */; }; A979F60A2D270AF00094C0B3 /* NearFutureWidgetsBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = A979F6092D270AF00094C0B3 /* NearFutureWidgetsBundle.swift */; }; @@ -89,6 +91,8 @@ A949F8452DCAABE00064DCA0 /* ImportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImportView.swift; sourceTree = ""; }; A949F8462DCAABE00064DCA0 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = ""; }; A949F8482DCAABE00064DCA0 /* StatsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatsView.swift; sourceTree = ""; }; + A949F8572DCAAD670064DCA0 /* NearFutureTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NearFutureTests.swift; sourceTree = ""; }; + A949F85D2DCABB420064DCA0 /* Buttons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Buttons.swift; sourceTree = ""; }; A979F58B2D2700680094C0B3 /* NearFutureWidgetsBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NearFutureWidgetsBundle.swift; sourceTree = ""; }; A979F58D2D2700680094C0B3 /* NearFutureWidgetsLiveActivity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NearFutureWidgetsLiveActivity.swift; sourceTree = ""; }; A979F58F2D2700680094C0B3 /* NearFutureWidgets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NearFutureWidgets.swift; sourceTree = ""; }; @@ -108,10 +112,6 @@ A9FC7EE92D28238A0020D75B /* NearFutureWidgets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NearFutureWidgets.swift; sourceTree = ""; }; /* End PBXFileReference section */ -/* Begin PBXFileSystemSynchronizedRootGroup section */ - A980FC382D93FB2B006A778F /* NearFutureTests */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = NearFutureTests; sourceTree = ""; }; -/* End PBXFileSystemSynchronizedRootGroup section */ - /* Begin PBXFrameworksBuildPhase section */ A920C2812D24011300E4F9B1 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; @@ -147,7 +147,7 @@ A949F8002DCAA0340064DCA0 /* Resources */, A920C2862D24011400E4F9B1 /* NearFuture */, A979F6082D270AF00094C0B3 /* NearFutureWidgets */, - A980FC382D93FB2B006A778F /* NearFutureTests */, + A949F8582DCAAD670064DCA0 /* NearFutureTests */, A979F6032D270AF00094C0B3 /* Frameworks */, A920C2852D24011400E4F9B1 /* Products */, ); @@ -251,10 +251,27 @@ A949F8422DCAABE00064DCA0 /* Home */, A949F8472DCAABE00064DCA0 /* Settings */, A949F8492DCAABE00064DCA0 /* Stats */, + A949F85E2DCABB420064DCA0 /* Misc */, ); path = Views; sourceTree = ""; }; + A949F8582DCAAD670064DCA0 /* NearFutureTests */ = { + isa = PBXGroup; + children = ( + A949F8572DCAAD670064DCA0 /* NearFutureTests.swift */, + ); + path = NearFutureTests; + sourceTree = ""; + }; + A949F85E2DCABB420064DCA0 /* Misc */ = { + isa = PBXGroup; + children = ( + A949F85D2DCABB420064DCA0 /* Buttons.swift */, + ); + path = Misc; + sourceTree = ""; + }; A979F58A2D2700680094C0B3 /* NearFutureWidgets */ = { isa = PBXGroup; children = ( @@ -345,9 +362,6 @@ dependencies = ( A980FC3C2D93FB2B006A778F /* PBXTargetDependency */, ); - fileSystemSynchronizedGroups = ( - A980FC382D93FB2B006A778F /* NearFutureTests */, - ); name = NearFutureTests; packageProductDependencies = ( ); @@ -440,6 +454,7 @@ A949F84E2DCAABE00064DCA0 /* ContentView.swift in Sources */, A949F84F2DCAABE00064DCA0 /* EventListView.swift in Sources */, A949F8502DCAABE00064DCA0 /* HelpView.swift in Sources */, + A949F85F2DCABB420064DCA0 /* Buttons.swift in Sources */, A949F8512DCAABE00064DCA0 /* ExportView.swift in Sources */, A949F8522DCAABE00064DCA0 /* iCloudSettingsView.swift in Sources */, A949F8532DCAABE00064DCA0 /* ImportView.swift in Sources */, @@ -464,6 +479,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + A949F8592DCAAD670064DCA0 /* NearFutureTests.swift in Sources */, A949F8562DCAABE00064DCA0 /* ExportView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/NearFuture/Views/Events/AddEventView.swift b/NearFuture/Views/Events/AddEventView.swift index d6c5ff9..d047c2b 100644 --- a/NearFuture/Views/Events/AddEventView.swift +++ b/NearFuture/Views/Events/AddEventView.swift @@ -215,26 +215,6 @@ struct AddEventView: View { } } -struct MagicClearButton: View { - @Binding var text: String - var body: some View { - HStack { - Spacer() - Button { - text = "" - } label: { - Image(systemName: "xmark.circle.fill") - .resizable() - .scaledToFit() - .frame(width: text.isEmpty ? 0 : 25) - .symbolRenderingMode(.hierarchical) - .padding(.trailing, -5) - .animation(.spring, value: text.isEmpty) - } - .buttonStyle(.borderless) - } - } -} #Preview { let vm = dummyEventViewModel() diff --git a/NearFuture/Views/Home/ContentView.swift b/NearFuture/Views/Home/ContentView.swift index dd5385c..4a4ef31 100644 --- a/NearFuture/Views/Home/ContentView.swift +++ b/NearFuture/Views/Home/ContentView.swift @@ -63,11 +63,18 @@ struct ContentView: View { backgroundGradient VStack { ZStack { - SearchBar(searchInput: $searchInput) - .focused($focusedField, equals: Field.Search) - .onSubmit { - focusedField = nil - } + TextField( + "\(Image(systemName: "magnifyingglass")) Search", + text: $searchInput + ) + .padding(.trailing, searchInput.isEmpty ? 0 : 30) + .animation(.spring, value: searchInput) + .textFieldStyle(RoundedBorderTextFieldStyle()) + .submitLabel(.done) + .focused($focusedField, equals: Field.Search) + .onSubmit { + focusedField = nil + } MagicClearButton(text: $searchInput) .onTapGesture { focusedField = nil @@ -168,42 +175,6 @@ struct ContentView: View { ) } -struct SearchBar: View { - @Binding var searchInput: String - - var body: some View { - TextField( - "\(Image(systemName: "magnifyingglass")) Search", - text: $searchInput - ) - .padding(.trailing, searchInput.isEmpty ? 0 : 30) - .animation(.spring, value: searchInput) - .textFieldStyle(RoundedBorderTextFieldStyle()) - .submitLabel(.done) - } -} - -struct AddEventButton: View { - @Binding var showingAddEventView: Bool - var body: some View { - Button() { - showingAddEventView.toggle() - } label: { - ZStack { - Circle() - .frame(width: 33) - .foregroundStyle(.one) - Image(systemName: "plus") - .resizable() - .scaledToFit() - .frame(width: 15) - .bold() - .foregroundStyle(.two) - } - } - } -} - extension View { var appearance: ColorScheme { return UITraitCollection.current.userInterfaceStyle == .dark ? .dark : .light diff --git a/NearFuture/Views/Misc/Buttons.swift b/NearFuture/Views/Misc/Buttons.swift new file mode 100644 index 0000000..48a447b --- /dev/null +++ b/NearFuture/Views/Misc/Buttons.swift @@ -0,0 +1,58 @@ +// +// MagicClearButton.swift +// NearFuture +// +// Created by neon443 on 06/05/2025. +// + +import SwiftUI + +struct MagicClearButton: View { + @Binding var text: String + var body: some View { + HStack { + Spacer() + Button { + text = "" + } label: { + Image(systemName: "xmark.circle.fill") + .resizable() + .scaledToFit() + .frame(width: text.isEmpty ? 0 : 25) + .symbolRenderingMode(.hierarchical) + .padding(.trailing, -5) + .animation(.spring, value: text.isEmpty) + } + .buttonStyle(.borderless) + } + } +} + +struct AddEventButton: View { + @Binding var showingAddEventView: Bool + var body: some View { + Button() { + showingAddEventView.toggle() + } label: { + ZStack { + Circle() + .frame(width: 33) + .foregroundStyle(.one) + Image(systemName: "plus") + .resizable() + .scaledToFit() + .frame(width: 15) + .bold() + .foregroundStyle(.two) + } + } + } +} + +#Preview { + MagicClearButton(text: .constant("s")) +} + +#Preview { + AddEventButton(showingAddEventView: .constant(false)) +}