Skip to content

Commit

Permalink
Merge dev
Browse files Browse the repository at this point in the history
  • Loading branch information
EmeraldLoc committed May 20, 2023
2 parents e4009f3 + 603791f commit 9826cb1
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 56 deletions.
10 changes: 6 additions & 4 deletions sm_osx.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 10;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\"";
DEVELOPMENT_TEAM = 25RK3JMVLT;
Expand All @@ -431,10 +431,11 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.3.0.5;
MARKETING_VERSION = 1.3.0.92;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
};
Expand All @@ -449,7 +450,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 10;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\"";
DEVELOPMENT_TEAM = 25RK3JMVLT;
Expand All @@ -465,10 +466,11 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.3.0.5;
MARKETING_VERSION = 1.3.0.92;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
};
Expand Down
12 changes: 6 additions & 6 deletions sm_osx/FirstLaunchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ struct FirstLaunchView: View {
Text("Checking Homebrew Installation...")
.onAppear {
if isArm() {
if !((Shell().shell("which brew"))).contains("/opt/homebrew/bin/brew") {
if !FileManager.default.fileExists(atPath: "/opt/homebrew/bin/brew") {

let task = Process()
task.launchPath = "/usr/bin/osascript"
Expand All @@ -161,7 +161,7 @@ struct FirstLaunchView: View {
}
}
} else {
if Shell().shell("which brew").contains("/usr/local/bin/brew") {
if !FileManager.default.fileExists(atPath: "/usr/local/bin/brew") {

let task = Process()
task.launchPath = "/usr/bin/osascript"
Expand All @@ -176,13 +176,13 @@ struct FirstLaunchView: View {
}
}.onReceive(timer) { _ in
if isArm() {
if Shell().shell("which brew").contains("/opt/homebrew/bin/brew") {
if FileManager.default.fileExists(atPath: "/opt/homebrew/bin/brew") {
withAnimation {
status = .checkingIntelHomebrewInstallation
}
}
} else {
if Shell().shell("which brew").contains("/usr/local/bin/brew") {
if FileManager.default.fileExists(atPath: "/usr/local/bin/brew") {
withAnimation {
status = .installingDeps
}
Expand All @@ -192,7 +192,7 @@ struct FirstLaunchView: View {
} else if status == .checkingIntelHomebrewInstallation {
Text("Checking Intel Homebrew Installation...")
.onAppear {
if Shell().shell("which /usr/local/bin/brew").contains("/usr/local/bin/brew\n") {
if !FileManager.default.fileExists(atPath: "/usr/local/bin/brew") {

let task = Process()
task.launchPath = "/usr/bin/osascript"
Expand All @@ -205,7 +205,7 @@ struct FirstLaunchView: View {
}
}
}.onReceive(timer) { _ in
if Shell().shell("which /usr/local/bin/brew").contains("/usr/local/bin/brew\n") {
if FileManager.default.fileExists(atPath: "/usr/local/bin/brew") {
withAnimation(.linear(duration: 0.4)) {
status = .installingDeps
}
Expand Down
41 changes: 21 additions & 20 deletions sm_osx/GeneralView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,30 @@ struct GeneralView: View {
let outHandle = pipe.fileHandleForReading

outHandle.readabilityHandler = { pipe in
if let line = String(data: pipe.availableData, encoding: String.Encoding.utf8) {
if line.contains("Finished installing deps") {

withAnimation() {
isInstallingDeps = false
if pipe.availableData.count > 0 {
if let line = String(data: pipe.availableData, encoding: String.Encoding.utf8) {
if line.contains("Finished installing deps") {

withAnimation() {
isInstallingDeps = false
}

let content = UNMutableNotificationContent()
content.title = "Finished installing dependencies"
content.subtitle = "Dependencies are now installed."
content.sound = UNNotificationSound.default

let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.0001, repeats: false)

let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)

UNUserNotificationCenter.current().add(request)
}

let content = UNMutableNotificationContent()
content.title = "Finished installing dependencies"
content.subtitle = "Dependencies are now installed."
content.sound = UNNotificationSound.default

// show this notification instantly
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.0001, repeats: false)

// choose a random identifier
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)

// add our notification request
UNUserNotificationCenter.current().add(request)
} else {
print("Error decoding data. why do I program...: \(pipe.availableData)")
}
} else {
print("Error decoding data. why do I program...: \(pipe.availableData)")
outHandle.readabilityHandler = nil
}
}

Expand Down
Binary file modified sm_osx/HomebrewInstaller.scpt
Binary file not shown.
96 changes: 74 additions & 22 deletions sm_osx/LauncherGridView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ struct LauncherGridView: View {
@FetchRequest(sortDescriptors:[SortDescriptor(\.title)]) var launcherRepos: FetchedResults<LauncherRepos>
@Binding var reloadMenuBarLauncher: Bool
@Binding var existingRepo: URL?
@State var removeEntireRepo = false
@State var removeRepo = false
@State var item: Int? = nil
let layout = [GridItem(.adaptive(minimum: 260))]

func launcherShell(_ command: String) {
Expand All @@ -34,8 +37,13 @@ struct LauncherGridView: View {
}

var observer : NSObjectProtocol?
observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { notification -> Void in
observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { [observer] _ in
if process.terminationStatus != 0 {

if NSApp.activationPolicy() == .prohibited {
showApp()
}

openWindow(id: "crash-log", value: output)
}

Expand All @@ -49,6 +57,7 @@ struct LauncherGridView: View {
LazyVGrid(columns: layout) {
ForEach(launcherRepos) { LauncherRepo in
let i = launcherRepos.firstIndex(of: LauncherRepo) ?? 0

VStack {
Button {

Expand Down Expand Up @@ -102,26 +111,8 @@ struct LauncherGridView: View {
}

Button(action: {

if launcherRepos.isEmpty { return }

for i in 0...launcherRepos.count - 1 {
launcherRepos[i].isEditing = false
}

let launcherRepo = launcherRepos[i]

moc.delete(launcherRepo)

do {
try withAnimation {
try moc.save()
}
reloadMenuBarLauncher = true
}
catch {
print("Error: its broken: \(error)")
}
item = i
removeRepo = true
}) {
Text("Remove Repo")
}
Expand All @@ -146,6 +137,67 @@ struct LauncherGridView: View {
LauncherEditView(i: i, existingRepo: $existingRepo, reloadMenuBarLauncher: $reloadMenuBarLauncher)
}
}
}.padding(15)
}.alert("Are You Sure You Want to Remove the Repo?", isPresented: $removeEntireRepo) {
Button("Yes", role: .destructive) {

if launcherRepos.isEmpty { return }

let launcherRepo = launcherRepos[item!]

do {
let path = URL(filePath: (launcherRepo.path!)).deletingLastPathComponent().path()

Shell().shell("rm -rf \(path)")
} catch {
print("Error, could not delete file due to: \(error)")
}

moc.delete(launcherRepo)

do {
try withAnimation {
try moc.save()
}
reloadMenuBarLauncher = true
} catch {
print("Error: its broken: \(error)")
}

item = nil
}

Button("No", role: .cancel) {}
} message: {
Text("Make sure there are no important files in that folder!")
}
.padding(15)
.alert("Remove Repo \(launcherRepos[item ?? 0].title ?? "")?", isPresented: $removeRepo) {
Button("Remove Repo", role: .destructive) {
removeEntireRepo = true
}

Button("Remove Entry", role: .destructive) {
if item != nil {
if launcherRepos.isEmpty { return }

let launcherRepo = launcherRepos[item!]

moc.delete(launcherRepo)

do {
try withAnimation {
try moc.save()
}
reloadMenuBarLauncher = true
} catch {
print("Error: its broken: \(error)")
}

item = nil
}
}

Button("Cancel", role: .cancel) {}
}
}
}
7 changes: 6 additions & 1 deletion sm_osx/LauncherListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ struct LauncherListView: View {
}

var observer : NSObjectProtocol?
observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { notification -> Void in
observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { [observer] _ in
if process.terminationStatus != 0 {

if NSApp.activationPolicy() == .prohibited {
showApp()
}

openWindow(id: "crash-log", value: output)
}

Expand Down
7 changes: 6 additions & 1 deletion sm_osx/LauncherView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ struct LauncherView: View {
}

var observer : NSObjectProtocol?
observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { notification -> Void in
observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { [observer] _ in
if process.terminationStatus != 0 {

if NSApp.activationPolicy() == .prohibited {
showApp()
}

openWindow(id: "crash-log", value: output)
}

Expand Down
14 changes: 12 additions & 2 deletions sm_osx/MenuCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ struct MenuCommands: Commands {
}

var observer : NSObjectProtocol?
observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { notification -> Void in
observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { [observer] _ in
if process.terminationStatus != 0 {

if NSApp.activationPolicy() == .prohibited {
showApp()
}

openWindow(id: "crash-log", value: output)
}

Expand Down Expand Up @@ -186,8 +191,13 @@ struct menuExtras: Scene {
}

var observer : NSObjectProtocol?
observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { notification -> Void in
observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { [observer] _ in
if process.terminationStatus != 0 {

if NSApp.activationPolicy() == .prohibited {
showApp()
}

openWindow(id: "crash-log", value: output)
}

Expand Down

0 comments on commit 9826cb1

Please sign in to comment.