Added Event Colors

This commit is contained in:
neon443
2024-12-27 14:00:39 +00:00
parent 35bb7c43ad
commit 8d33a47477
6 changed files with 219 additions and 210 deletions

View File

@@ -3,7 +3,7 @@
archiveVersion = 1; archiveVersion = 1;
classes = { classes = {
}; };
objectVersion = 77; objectVersion = 70;
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
@@ -34,21 +34,9 @@
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFileSystemSynchronizedRootGroup section */ /* Begin PBXFileSystemSynchronizedRootGroup section */
A9B4BFCA2D1AE66000212CE2 /* NearFuture */ = { A9B4BFCA2D1AE66000212CE2 /* NearFuture */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = NearFuture; sourceTree = "<group>"; };
isa = PBXFileSystemSynchronizedRootGroup; A9B4BFDE2D1AE66700212CE2 /* NearFutureTests */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = NearFutureTests; sourceTree = "<group>"; };
path = NearFuture; A9B4BFE82D1AE66700212CE2 /* NearFutureUITests */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = NearFutureUITests; sourceTree = "<group>"; };
sourceTree = "<group>";
};
A9B4BFDE2D1AE66700212CE2 /* NearFutureTests */ = {
isa = PBXFileSystemSynchronizedRootGroup;
path = NearFutureTests;
sourceTree = "<group>";
};
A9B4BFE82D1AE66700212CE2 /* NearFutureUITests */ = {
isa = PBXFileSystemSynchronizedRootGroup;
path = NearFutureUITests;
sourceTree = "<group>";
};
/* End PBXFileSystemSynchronizedRootGroup section */ /* End PBXFileSystemSynchronizedRootGroup section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@@ -193,6 +181,7 @@
}; };
}; };
buildConfigurationList = A9B4BFC32D1AE66000212CE2 /* Build configuration list for PBXProject "NearFuture" */; buildConfigurationList = A9B4BFC32D1AE66000212CE2 /* Build configuration list for PBXProject "NearFuture" */;
compatibilityVersion = "Xcode 15.3";
developmentRegion = en; developmentRegion = en;
hasScannedForEncodings = 0; hasScannedForEncodings = 0;
knownRegions = ( knownRegions = (
@@ -204,7 +193,6 @@
packageReferences = ( packageReferences = (
A91288572D1C7E3000912B3C /* XCRemoteSwiftPackageReference "SFSymbolsPicker" */, A91288572D1C7E3000912B3C /* XCRemoteSwiftPackageReference "SFSymbolsPicker" */,
); );
preferredProjectObjectVersion = 77;
productRefGroup = A9B4BFC92D1AE66000212CE2 /* Products */; productRefGroup = A9B4BFC92D1AE66000212CE2 /* Products */;
projectDirPath = ""; projectDirPath = "";
projectRoot = ""; projectRoot = "";
@@ -313,6 +301,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES; ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES; ENABLE_USER_SCRIPT_SANDBOXING = YES;
@@ -374,6 +363,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES; ENABLE_USER_SCRIPT_SANDBOXING = YES;
@@ -403,7 +393,7 @@
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"NearFuture/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"NearFuture/Preview Content\"";
DEVELOPMENT_TEAM = 85Q9QG6DN7; DEVELOPMENT_TEAM = P6PV2R9443;
ENABLE_HARDENED_RUNTIME = NO; ENABLE_HARDENED_RUNTIME = NO;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
@@ -422,7 +412,7 @@
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 14.0; MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.NearFuture; PRODUCT_BUNDLE_IDENTIFIER = com.hack.NearFuture;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = auto; SDKROOT = auto;
@@ -444,7 +434,7 @@
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"NearFuture/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"NearFuture/Preview Content\"";
DEVELOPMENT_TEAM = 85Q9QG6DN7; DEVELOPMENT_TEAM = P6PV2R9443;
ENABLE_HARDENED_RUNTIME = NO; ENABLE_HARDENED_RUNTIME = NO;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
@@ -463,7 +453,7 @@
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 14.0; MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.NearFuture; PRODUCT_BUNDLE_IDENTIFIER = com.hack.NearFuture;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto; SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
@@ -480,12 +470,12 @@
BUNDLE_LOADER = "$(TEST_HOST)"; BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 8626DL2GW3; DEVELOPMENT_TEAM = 85Q9QG6DN7;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 18.2; IPHONEOS_DEPLOYMENT_TARGET = 17;
MACOSX_DEPLOYMENT_TARGET = 15.1; MACOSX_DEPLOYMENT_TARGET = 14;
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.NearFutureTests; PRODUCT_BUNDLE_IDENTIFIER = com.neon443.NearFuture;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto; SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
@@ -493,7 +483,7 @@
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,7"; TARGETED_DEVICE_FAMILY = "1,2,7";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NearFuture.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/NearFuture"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NearFuture.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/NearFuture";
XROS_DEPLOYMENT_TARGET = 2.2; XROS_DEPLOYMENT_TARGET = 1;
}; };
name = Debug; name = Debug;
}; };
@@ -503,12 +493,12 @@
BUNDLE_LOADER = "$(TEST_HOST)"; BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 8626DL2GW3; DEVELOPMENT_TEAM = 85Q9QG6DN7;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 18.2; IPHONEOS_DEPLOYMENT_TARGET = 17;
MACOSX_DEPLOYMENT_TARGET = 15.1; MACOSX_DEPLOYMENT_TARGET = 14;
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.NearFutureTests; PRODUCT_BUNDLE_IDENTIFIER = com.neon443.NearFuture;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto; SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
@@ -516,7 +506,7 @@
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,7"; TARGETED_DEVICE_FAMILY = "1,2,7";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NearFuture.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/NearFuture"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NearFuture.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/NearFuture";
XROS_DEPLOYMENT_TARGET = 2.2; XROS_DEPLOYMENT_TARGET = 1;
}; };
name = Release; name = Release;
}; };
@@ -525,12 +515,12 @@
buildSettings = { buildSettings = {
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 8626DL2GW3; DEVELOPMENT_TEAM = 85Q9QG6DN7;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 18.2; IPHONEOS_DEPLOYMENT_TARGET = 17;
MACOSX_DEPLOYMENT_TARGET = 15.1; MACOSX_DEPLOYMENT_TARGET = 14;
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.NearFutureUITests; PRODUCT_BUNDLE_IDENTIFIER = com.neon443.NearFuture;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto; SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
@@ -538,7 +528,7 @@
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,7"; TARGETED_DEVICE_FAMILY = "1,2,7";
TEST_TARGET_NAME = NearFuture; TEST_TARGET_NAME = NearFuture;
XROS_DEPLOYMENT_TARGET = 2.2; XROS_DEPLOYMENT_TARGET = 1;
}; };
name = Debug; name = Debug;
}; };
@@ -547,12 +537,12 @@
buildSettings = { buildSettings = {
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 8626DL2GW3; DEVELOPMENT_TEAM = 85Q9QG6DN7;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 18.2; IPHONEOS_DEPLOYMENT_TARGET = 17;
MACOSX_DEPLOYMENT_TARGET = 15.1; MACOSX_DEPLOYMENT_TARGET = 14;
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.NearFutureUITests; PRODUCT_BUNDLE_IDENTIFIER = com.neon443.NearFuture;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto; SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx xros xrsimulator";
@@ -560,7 +550,7 @@
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,7"; TARGETED_DEVICE_FAMILY = "1,2,7";
TEST_TARGET_NAME = NearFuture; TEST_TARGET_NAME = NearFuture;
XROS_DEPLOYMENT_TARGET = 2.2; XROS_DEPLOYMENT_TARGET = 1;
}; };
name = Release; name = Release;
}; };

View File

@@ -1,102 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1620"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A9B4BFC72D1AE66000212CE2"
BuildableName = "NearFuture.app"
BlueprintName = "NearFuture"
ReferencedContainer = "container:NearFuture.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A9B4BFDA2D1AE66700212CE2"
BuildableName = "NearFutureTests.xctest"
BlueprintName = "NearFutureTests"
ReferencedContainer = "container:NearFuture.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A9B4BFE42D1AE66700212CE2"
BuildableName = "NearFutureUITests.xctest"
BlueprintName = "NearFutureUITests"
ReferencedContainer = "container:NearFuture.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A9B4BFC72D1AE66000212CE2"
BuildableName = "NearFuture.app"
BlueprintName = "NearFuture"
ReferencedContainer = "container:NearFuture.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A9B4BFC72D1AE66000212CE2"
BuildableName = "NearFuture.app"
BlueprintName = "NearFuture"
ReferencedContainer = "container:NearFuture.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -12,6 +12,7 @@ struct AddEventView: View {
@ObservedObject var viewModel: EventViewModel @ObservedObject var viewModel: EventViewModel
@Binding var eventName: String @Binding var eventName: String
@Binding var eventSymbol: String @Binding var eventSymbol: String
@Binding var eventColor: Color
@Binding var eventDescription: String @Binding var eventDescription: String
@Binding var eventDate: Date @Binding var eventDate: Date
@Binding var eventRecurrence: Event.RecurrenceType @Binding var eventRecurrence: Event.RecurrenceType
@@ -29,8 +30,9 @@ struct AddEventView: View {
Image(systemName: eventSymbol) Image(systemName: eventSymbol)
.resizable() .resizable()
.scaledToFit() .scaledToFit()
.frame(width: 30, height: 30) .frame(width: 25, height: 25)
} }
// .frame(width: 30)
.buttonStyle(.bordered) .buttonStyle(.bordered)
.sheet(isPresented: $isSymbolPickerPresented) { .sheet(isPresented: $isSymbolPickerPresented) {
SymbolsPicker( SymbolsPicker(
@@ -39,6 +41,8 @@ struct AddEventView: View {
searchLabel: "Search...", searchLabel: "Search...",
autoDismiss: true) autoDismiss: true)
} }
ColorPicker("", selection: $eventColor, supportsOpacity: true)
.fixedSize()
Divider() Divider()
ZStack { ZStack {
TextField("Event Name", text: $eventName) TextField("Event Name", text: $eventName)
@@ -48,6 +52,7 @@ struct AddEventView: View {
MagicClearButton(text: $eventName) MagicClearButton(text: $eventName)
} }
} }
Text(eventColor.description)
// dscription // dscription
ZStack { ZStack {
@@ -83,12 +88,23 @@ struct AddEventView: View {
viewModel.addEvent( viewModel.addEvent(
name: eventName, name: eventName,
symbol: eventSymbol, symbol: eventSymbol,
color: ColorCodable(eventColor),
description: eventDescription, description: eventDescription,
date: eventDate, date: eventDate,
recurrence: eventRecurrence recurrence: eventRecurrence
) )
//reset addeventView
eventName = "" eventName = ""
eventSymbol = "star" eventSymbol = "star"
eventColor = [
Color.red,
Color.orange,
Color.yellow,
Color.green,
Color.blue,
Color.indigo,
Color.purple
].randomElement() ?? Color.red
eventDescription = "" eventDescription = ""
eventDate = Date() eventDate = Date()
eventRecurrence = .none eventRecurrence = .none
@@ -135,12 +151,14 @@ struct MagicClearButton: View {
struct AddEvent_Preview: PreviewProvider { struct AddEvent_Preview: PreviewProvider {
@State static var symbol = "star" @State static var symbol = "star"
@State static var date = Date() @State static var date = Date()
@State static var color = Color(.red)
static var previews: some View { static var previews: some View {
AddEventView( AddEventView(
viewModel: EventViewModel(), viewModel: EventViewModel(),
eventName: .constant("Birthday"), eventName: .constant("Birthday"),
eventSymbol: $symbol, eventSymbol: $symbol,
eventColor: $color,
eventDescription: .constant("A very special day"), eventDescription: .constant("A very special day"),
eventDate: $date, eventDate: $date,
eventRecurrence: .constant(.monthly), eventRecurrence: .constant(.monthly),

View File

@@ -70,6 +70,15 @@ struct ContentView: View {
@StateObject private var viewModel = EventViewModel() @StateObject private var viewModel = EventViewModel()
@State private var eventName = "" @State private var eventName = ""
@State private var eventSymbol = "star" @State private var eventSymbol = "star"
@State private var eventColor: Color = [
Color.red,
Color.orange,
Color.yellow,
Color.green,
Color.blue,
Color.indigo,
Color.purple
].randomElement() ?? Color.red
@State private var eventDescription = "" @State private var eventDescription = ""
@State private var eventDate = Date() @State private var eventDate = Date()
@State private var eventRecurrence: Event.RecurrenceType = .none @State private var eventRecurrence: Event.RecurrenceType = .none
@@ -85,52 +94,87 @@ struct ContentView: View {
} }
} }
} }
@Environment(\.colorScheme) var appearance
private var backgroundGradient: LinearGradient {
switch appearance {
case .light:
return LinearGradient(
gradient: Gradient(colors: [.gray.opacity(0.2), .white]),
startPoint: .top,
endPoint: .bottom
)
case .dark:
return LinearGradient(
gradient: Gradient(colors: [.gray.opacity(0.2), .black]),
startPoint: .top,
endPoint: .bottom)
@unknown default:
//red bg gradient for uknown appearance
return LinearGradient(
gradient: Gradient(colors: [.red, .black]),
startPoint: .bottom,
endPoint: .top
)
}
}
var body: some View { var body: some View {
NavigationView { NavigationView {
VStack { ZStack {
ZStack { backgroundGradient
TextField( .ignoresSafeArea(.all)
"\(Image(systemName: "magnifyingglass")) Search", VStack {
text: $searchInput ZStack {
) TextField(
.padding(.trailing, searchInput.isEmpty ? 0 : 30) "\(Image(systemName: "magnifyingglass")) Search",
.animation(.spring, value: searchInput) text: $searchInput
.textFieldStyle(RoundedBorderTextFieldStyle()) )
MagicClearButton(text: $searchInput) .padding(.trailing, searchInput.isEmpty ? 0 : 30)
} .animation(.spring, value: searchInput)
.padding(.horizontal) .textFieldStyle(RoundedBorderTextFieldStyle())
List { MagicClearButton(text: $searchInput)
ForEach(filteredEvents) { event in }
EventListView(event: event) .padding(.horizontal)
List {
ForEach(filteredEvents) { event in
var eventBackgroundGradient: LinearGradient {
return LinearGradient(
colors: [
event.color.color,
Color.black
],
startPoint: .leading,
endPoint: .trailing
)
}
EventListView(event: event)
}
.onDelete(perform: viewModel.removeEvent)
} }
.onDelete(perform: viewModel.removeEvent)
} }
} .navigationTitle("Near Future")
.navigationTitle("Near Future") .navigationBarTitleDisplayMode(.inline)
// .navigationTitle() { .sheet(isPresented: $showingAddEventView) {
// Text("hi") AddEventView(
// } viewModel: viewModel,
.navigationBarTitleDisplayMode(.inline) eventName: $eventName,
.sheet(isPresented: $showingAddEventView) { eventSymbol: $eventSymbol,
AddEventView( eventColor: $eventColor,
viewModel: viewModel, eventDescription: $eventDescription,
eventName: $eventName, eventDate: $eventDate,
eventSymbol: $eventSymbol, eventRecurrence: $eventRecurrence,
eventDescription: $eventDescription, isPresented: $showingAddEventView
eventDate: $eventDate, )
eventRecurrence: $eventRecurrence, }
isPresented: $showingAddEventView .toolbar {
) ToolbarItem(placement: .topBarTrailing) {
} Button(action: {
.toolbar { showingAddEventView.toggle()
ToolbarItem(placement: .topBarTrailing) { }) {
Button(action: { Image(systemName: "plus.circle")
showingAddEventView.toggle() .resizable()
}) { .scaledToFit()
Image(systemName: "plus.circle") }
.resizable()
.scaledToFit()
} }
} }
} }
@@ -143,35 +187,45 @@ struct EventListView: View {
@State var event: Event @State var event: Event
var body: some View { var body: some View {
HStack { // var testColor = Color.red
VStack(alignment: .leading) { // var codableColor = ColorCodable(testColor)
HStack { // Text("\(codableColor.red), \(codableColor.green), \(codableColor.blue), \(codableColor.alpha)")
Image(systemName: event.symbol) ZStack {
Text(event.name) HStack {
.font(.headline) RoundedRectangle(cornerRadius: 5)
.padding(.bottom, 2) .frame(width: 5)
} .foregroundStyle(event.color.color)
Text(event.description) .padding(.leading, -5)
.font(.subheadline) VStack(alignment: .leading) {
.foregroundColor(.gray) HStack {
Text("Recurring: \(event.recurrence.rawValue.capitalized)") Image(systemName: event.symbol)
Text(event.name)
.font(.headline)
.padding(.bottom, 2)
}
Text(event.description)
.font(.subheadline)
.foregroundColor(.gray)
if event.recurrence != .none {
Text("Recurring: \(event.recurrence.rawValue.capitalized)")
.font(.subheadline)
.foregroundColor(.blue)
}
Text(event.date.formatted(date: .long, time: .omitted))
.font(.subheadline) .font(.subheadline)
.foregroundColor(.blue) .foregroundColor(.blue)
Text("In \(daysUntilEvent(event.date))") }
Spacer()
Text("\(daysUntilEvent(event.date))")
.font(.subheadline) .font(.subheadline)
.foregroundColor(.gray) .foregroundColor(.gray)
} }
.padding(.vertical, 8)
Spacer()
Text(event.date.formatted(date: .long, time: .omitted))
.font(.subheadline)
.foregroundColor(.blue)
} }
.padding(.vertical, 8)
} }
} }
#Preview { #Preview {
ContentView() ContentView()
} }

View File

@@ -7,6 +7,7 @@
import Foundation import Foundation
import SwiftData import SwiftData
import SwiftUI
@Model @Model
final class Item { final class Item {
@@ -21,6 +22,7 @@ struct Event: Identifiable, Codable {
var id = UUID() var id = UUID()
var name: String var name: String
var symbol: String var symbol: String
var color: ColorCodable
var description: String var description: String
var date: Date var date: Date
var recurrence: RecurrenceType var recurrence: RecurrenceType
@@ -30,11 +32,49 @@ struct Event: Identifiable, Codable {
} }
} }
struct ColorCodable: Codable {
var red: Double
var green: Double
var blue: Double
var alpha: Double
//for the brainrotted: alpha is the opacity/transparency of the color,
//alpha == 0 completely transparent
//alpha == 1 completely opaque
var color: Color {
Color(red: red, green: green, blue: blue, opacity: alpha)
}
init(_ color: Color) {
let uiColor = UIColor(color)
var r: CGFloat = 0, g: CGFloat = 0, b: CGFloat = 0, a: CGFloat = 0
uiColor.getRed(&r, green: &g, blue: &b, alpha: &a)
self.red = Double(r)
self.green = Double(g)
self.blue = Double(b)
self.alpha = Double(a)
}
init(red: Double, green: Double, blue: Double, alpha: Double = 1.0) {
self.red = red
self.green = green
self.blue = blue
self.alpha = alpha
}
}
func daysUntilEvent(_ eventDate: Date) -> String { func daysUntilEvent(_ eventDate: Date) -> String {
let calendar = Calendar.current let calendar = Calendar.current
let currentDate = Date() let currentDate = Date()
let components = calendar.dateComponents([.day], from: currentDate, to: eventDate) let components = calendar.dateComponents([.day], from: currentDate, to: eventDate)
guard let days = components.day else { return "N/A" } guard let days = components.day else { return "N/A" }
guard days >= 0 else {
return "\(days) days ago"
}
guard days != 0 else {
return "Today"
}
return "\(days) days" return "\(days) days"
} }
@@ -61,10 +101,18 @@ class EventViewModel: ObservableObject {
} }
} }
func addEvent(name: String, symbol: String, description: String, date: Date, recurrence: Event.RecurrenceType) { func addEvent(
name: String,
symbol: String,
color: ColorCodable,
description: String,
date: Date,
recurrence: Event.RecurrenceType
) {
let newEvent = Event( let newEvent = Event(
name: name, name: name,
symbol: symbol, symbol: symbol,
color: color,
description: description, description: description,
date: date, date: date,
recurrence: recurrence recurrence: recurrence

View File

@@ -6,9 +6,10 @@ Near Future is a SwiftUI App to help people to track upcoming events - Holidays,
- [x] Add and delete events - [x] Add and delete events
- [x] Descriptions - [x] Descriptions
- [x] Icons - [x] Icons
- [ ] Event colors - [x] Event colors
- [ ] Recurrence - [ ] Recurrence
- [x] Search - [x] Search
- [ ] Apple Watch App
- [ ] Home Screen Widgets - [ ] Home Screen Widgets
- [ ] Lock Screen Widgets - [ ] Lock Screen Widgets
@@ -41,5 +42,5 @@ Contributions are welcome! just follow these:
3. Open a pull request 3. Open a pull request
## Used Tools/Frameworks ## Used Tools/Frameworks
- Swift & SwiftUI - Apple - Swift & SwiftUI by Apple
- **SFSymbolsPicker** - [alessiorubicini/SFSymbolsPickerForSwiftUI]. - **SFSymbolsPicker** by [alessiorubicini/SFSymbolsPickerForSwiftUI].