mirror of
https://github.com/neon443/NearFuture.git
synced 2026-03-11 14:56:15 +00:00
app intents make me wanna kms
This commit is contained in:
@@ -580,7 +580,7 @@
|
|||||||
);
|
);
|
||||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_VERSION = 6.0;
|
SWIFT_VERSION = 5.0;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
@@ -639,7 +639,7 @@
|
|||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
SWIFT_COMPILATION_MODE = wholemodule;
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
SWIFT_VERSION = 6.0;
|
SWIFT_VERSION = 5.0;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict/>
|
<dict>
|
||||||
|
<key>AppIntents</key>
|
||||||
|
<array>
|
||||||
|
<string>com.neon443.NearFuture.CompleteEvent</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import SwiftData
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
import WidgetKit
|
import WidgetKit
|
||||||
import UserNotifications
|
import UserNotifications
|
||||||
|
import AppIntents
|
||||||
|
|
||||||
//@Model
|
//@Model
|
||||||
//final class Item {
|
//final class Item {
|
||||||
@@ -590,3 +591,58 @@ func getDevice() -> (sf: String, label: String) {
|
|||||||
}
|
}
|
||||||
return (sf: "iphone", label: "iPhone")
|
return (sf: "iphone", label: "iPhone")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension Event: AppEntity {
|
||||||
|
static let defaultQuery = EventQuery()
|
||||||
|
|
||||||
|
static var typeDisplayRepresentation: TypeDisplayRepresentation {
|
||||||
|
TypeDisplayRepresentation("skdfj")
|
||||||
|
}
|
||||||
|
|
||||||
|
var displayRepresentation: DisplayRepresentation {
|
||||||
|
DisplayRepresentation("eventsss")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct EventQuery: EntityQuery, DynamicOptionsProvider {
|
||||||
|
typealias Entity = Event
|
||||||
|
@Dependency var vm: EventViewModel
|
||||||
|
func results() async throws -> some ResultsCollection {
|
||||||
|
return vm.events
|
||||||
|
}
|
||||||
|
// func defaultResult() async -> DefaultValue? {
|
||||||
|
// return vm.events[0]
|
||||||
|
// }
|
||||||
|
func entities(for identifiers: [Entity.ID]) async throws -> [Entity] {
|
||||||
|
return vm.events
|
||||||
|
}
|
||||||
|
func suggestedEntities() async throws -> some ResultsCollection {
|
||||||
|
return vm.events //lol cba
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct CompleteEvent: AppIntent {
|
||||||
|
static var title: LocalizedStringResource = "Complete An Event"
|
||||||
|
static var description = IntentDescription("Mark an Event as complete.")
|
||||||
|
|
||||||
|
@Parameter(title: "Event ID")
|
||||||
|
var eventID: String
|
||||||
|
|
||||||
|
func perform() async throws -> some IntentResult {
|
||||||
|
print("s")
|
||||||
|
var viewModel = EventViewModel()
|
||||||
|
var eventss = viewModel.events
|
||||||
|
print("hip")
|
||||||
|
guard let eventUUID = UUID(uuidString: eventID) else {
|
||||||
|
print(":sdklfajk")
|
||||||
|
return .result()
|
||||||
|
}
|
||||||
|
print("hii")
|
||||||
|
if let eventToModify = viewModel.events.firstIndex(where: { $0.id == eventUUID }) {
|
||||||
|
print("hiii")
|
||||||
|
viewModel.events[eventToModify].complete = true
|
||||||
|
viewModel.saveEvents()
|
||||||
|
}
|
||||||
|
return .result()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
// Created by neon443 on 12/05/2025.
|
// Created by neon443 on 12/05/2025.
|
||||||
//
|
//
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI;import AppIntents
|
||||||
|
|
||||||
struct HomeView: View {
|
struct HomeView: View {
|
||||||
@ObservedObject var viewModel: EventViewModel
|
@ObservedObject var viewModel: EventViewModel
|
||||||
@@ -72,9 +72,13 @@ struct HomeView: View {
|
|||||||
} else {
|
} else {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
ForEach(filteredEvents) { event in
|
ForEach(filteredEvents) { event in
|
||||||
|
if #available(iOS 17, *) {
|
||||||
|
Completebutton(event: event)
|
||||||
|
}
|
||||||
EventListView(viewModel: viewModel, event: event)
|
EventListView(viewModel: viewModel, event: event)
|
||||||
.transition(.moveAndFade)
|
.transition(.moveAndFade)
|
||||||
.id(event.complete)
|
.id(event.complete)
|
||||||
|
Divider()
|
||||||
}
|
}
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
if filteredEvents.isEmpty {
|
if filteredEvents.isEmpty {
|
||||||
@@ -127,3 +131,17 @@ struct HomeView: View {
|
|||||||
settingsModel: dummySettingsViewModel()
|
settingsModel: dummySettingsViewModel()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@available(iOS 17.0, *)
|
||||||
|
struct Completebutton: View {
|
||||||
|
@State var event: Event
|
||||||
|
var body: some View {
|
||||||
|
Button(intent: CompleteEvent(eventID: IntentParameter(
|
||||||
|
title: LocalizedStringResource(
|
||||||
|
stringLiteral: event.id.uuidString
|
||||||
|
)
|
||||||
|
))) {
|
||||||
|
Text(event.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
import WidgetKit
|
import WidgetKit
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import AppIntents
|
||||||
|
|
||||||
// Timeline Entry for Widget
|
// Timeline Entry for Widget
|
||||||
struct EventWidgetEntry: TimelineEntry {
|
struct EventWidgetEntry: TimelineEntry {
|
||||||
@@ -46,6 +47,24 @@ struct EventWidgetProvider: TimelineProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Event Widget View
|
// Event Widget View
|
||||||
struct EventWidgetView: View {
|
struct EventWidgetView: View {
|
||||||
var entry: EventWidgetEntry
|
var entry: EventWidgetEntry
|
||||||
@@ -135,6 +154,25 @@ struct EventWidgetView: View {
|
|||||||
.foregroundColor(event.date < Date() ? .red : .primary)
|
.foregroundColor(event.date < Date() ? .red : .primary)
|
||||||
.padding(.trailing, -12)
|
.padding(.trailing, -12)
|
||||||
} else {
|
} else {
|
||||||
|
Button(
|
||||||
|
intent: CompleteEvent(
|
||||||
|
eventID: IntentParameter(
|
||||||
|
title: LocalizedStringResource(
|
||||||
|
stringLiteral: event.id.uuidString
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
if event.complete {
|
||||||
|
Circle()
|
||||||
|
.frame(width: 10)
|
||||||
|
.foregroundStyle(.green)
|
||||||
|
} else {
|
||||||
|
Circle()
|
||||||
|
.frame(width: 10)
|
||||||
|
.foregroundStyle(.gray)
|
||||||
|
}
|
||||||
|
}
|
||||||
Text(daysUntilEvent(event.date).long)
|
Text(daysUntilEvent(event.date).long)
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
.multilineTextAlignment(.trailing)
|
.multilineTextAlignment(.trailing)
|
||||||
|
|||||||
Reference in New Issue
Block a user