Skip to content

Commit

Permalink
Added ExampleManager.
Browse files Browse the repository at this point in the history
  • Loading branch information
theboringhumane committed Sep 9, 2024
1 parent 794bf87 commit 636a4ce
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 10 deletions.
24 changes: 18 additions & 6 deletions TheBoringWorker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
148544322C8F0CE900943381 /* TheBoringWorkerNotifier in Frameworks */ = {isa = PBXBuildFile; productRef = 148544312C8F0CE900943381 /* TheBoringWorkerNotifier */; };
148544352C8F5B3200943381 /* ExampleManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 148544342C8F5B3200943381 /* ExampleManager.swift */; };
14D4F9252C8D589F0093FA42 /* TheBoringWorkerApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14D4F9242C8D589F0093FA42 /* TheBoringWorkerApp.swift */; };
14D4F9272C8D589F0093FA42 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14D4F9262C8D589F0093FA42 /* ContentView.swift */; };
14D4F9292C8D589F0093FA42 /* Item.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14D4F9282C8D589F0093FA42 /* Item.swift */; };
Expand All @@ -21,6 +22,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
148544342C8F5B3200943381 /* ExampleManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleManager.swift; sourceTree = "<group>"; };
14D4F9212C8D589F0093FA42 /* TheBoringWorker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TheBoringWorker.app; sourceTree = BUILT_PRODUCTS_DIR; };
14D4F9242C8D589F0093FA42 /* TheBoringWorkerApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TheBoringWorkerApp.swift; sourceTree = "<group>"; };
14D4F9262C8D589F0093FA42 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
Expand All @@ -47,6 +49,14 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
148544332C8F5B2200943381 /* managers */ = {
isa = PBXGroup;
children = (
148544342C8F5B3200943381 /* ExampleManager.swift */,
);
path = managers;
sourceTree = "<group>";
};
14D4F9182C8D589F0093FA42 = {
isa = PBXGroup;
children = (
Expand All @@ -66,6 +76,7 @@
14D4F9232C8D589F0093FA42 /* TheBoringWorker */ = {
isa = PBXGroup;
children = (
148544332C8F5B2200943381 /* managers */,
14D4F9412C8D5B800093FA42 /* Extensions */,
14D4F9382C8D59D30093FA42 /* views */,
14D4F9352C8D599D0093FA42 /* models */,
Expand Down Expand Up @@ -193,6 +204,7 @@
files = (
14D4F93A2C8D59DE0093FA42 /* SettingsView.swift in Sources */,
14D4F9272C8D589F0093FA42 /* ContentView.swift in Sources */,
148544352C8F5B3200943381 /* ExampleManager.swift in Sources */,
14D4F9372C8D59B60093FA42 /* BoringViewModel.swift in Sources */,
14D4F9432C8D5BA30093FA42 /* BundleInfo.swift in Sources */,
14D4F9292C8D589F0093FA42 /* Item.swift in Sources */,
Expand Down Expand Up @@ -327,13 +339,13 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = TheBoringWorker/TheBoringWorker.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"TheBoringWorker/Preview Content\"";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = JPWMG84CH8;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -360,13 +372,13 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = TheBoringWorker/TheBoringWorker.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"TheBoringWorker/Preview Content\"";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = JPWMG84CH8;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down
8 changes: 4 additions & 4 deletions TheBoringWorker/TheBoringWorkerApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Created by Harsh Vardhan Goswami on 08/09/24.
//

import SwiftUI
import SwiftData
import SwiftUI

@main
struct TheBoringWorkerApp: App {
Expand All @@ -15,7 +15,7 @@ struct TheBoringWorkerApp: App {
Item.self,
])
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)

do {
return try ModelContainer(for: schema, configurations: [modelConfiguration])
} catch {
Expand All @@ -26,7 +26,6 @@ struct TheBoringWorkerApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@AppStorage("showMenuBarIcon") var showMenuBarIcon: Bool = true


var body: some Scene {
Settings {
SettingsView()
Expand All @@ -53,12 +52,14 @@ class AppDelegate: NSObject, NSApplicationDelegate {
var statusItem: NSStatusItem?
let vm: BoringViewModel = .init()
var window: NSWindow!
let exampleManager: ExampleManager

func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return false
}

override init() {
exampleManager = ExampleManager(vm: vm)
super.init()
}

Expand All @@ -67,7 +68,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

func applicationDidFinishLaunching(_ notification: Notification) {

vm.setupWorkerNotifiers()

NSApp.setActivationPolicy(.accessory)
Expand Down
24 changes: 24 additions & 0 deletions TheBoringWorker/managers/ExampleManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// ExampleManager.swift
// TheBoringWorker
//
// Created by Harsh Vardhan Goswami on 09/09/24.
//

import Foundation

class ExampleManager: ObservableObject {
var vm: BoringViewModel?

init(vm: BoringViewModel) {
self.vm = vm
}

func YOUR_FUNCTION_NAME() {
// Do something

// Throw a event to boring.notch

vm?.notifier.postNotification(name: "YOUR_EVENT_NAME_HERE", userInfo: ["KEY": {}])
}
}

0 comments on commit 636a4ce

Please sign in to comment.