Skip to content

Commit

Permalink
pro.
Browse files Browse the repository at this point in the history
  • Loading branch information
sssynk committed Jan 14, 2022
1 parent 3d8374f commit 9d0d6ef
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 23 deletions.
34 changes: 18 additions & 16 deletions swiftapp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
101D76B0278CBFD5005423E0 /* swiftapp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = swiftapp.app; sourceTree = BUILT_PRODUCTS_DIR; };
101D76B0278CBFD5005423E0 /* Notes Pro.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Notes Pro.app"; sourceTree = BUILT_PRODUCTS_DIR; };
101D76B3278CBFD5005423E0 /* swiftappApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = swiftappApp.swift; sourceTree = "<group>"; };
101D76B5278CBFD5005423E0 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
101D76B7278CBFD7005423E0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -88,7 +88,7 @@
101D76B1278CBFD5005423E0 /* Products */ = {
isa = PBXGroup;
children = (
101D76B0278CBFD5005423E0 /* swiftapp.app */,
101D76B0278CBFD5005423E0 /* Notes Pro.app */,
101D76C1278CBFD7005423E0 /* swiftappTests.xctest */,
101D76CB278CBFD7005423E0 /* swiftappUITests.xctest */,
);
Expand Down Expand Up @@ -137,9 +137,9 @@
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
101D76AF278CBFD5005423E0 /* swiftapp */ = {
101D76AF278CBFD5005423E0 /* Notes Pro */ = {
isa = PBXNativeTarget;
buildConfigurationList = 101D76D5278CBFD7005423E0 /* Build configuration list for PBXNativeTarget "swiftapp" */;
buildConfigurationList = 101D76D5278CBFD7005423E0 /* Build configuration list for PBXNativeTarget "Notes Pro" */;
buildPhases = (
101D76AC278CBFD5005423E0 /* Sources */,
101D76AD278CBFD5005423E0 /* Frameworks */,
Expand All @@ -149,9 +149,9 @@
);
dependencies = (
);
name = swiftapp;
name = "Notes Pro";
productName = swiftapp;
productReference = 101D76B0278CBFD5005423E0 /* swiftapp.app */;
productReference = 101D76B0278CBFD5005423E0 /* Notes Pro.app */;
productType = "com.apple.product-type.application";
};
101D76C0278CBFD7005423E0 /* swiftappTests */ = {
Expand Down Expand Up @@ -226,7 +226,7 @@
projectDirPath = "";
projectRoot = "";
targets = (
101D76AF278CBFD5005423E0 /* swiftapp */,
101D76AF278CBFD5005423E0 /* Notes Pro */,
101D76C0278CBFD7005423E0 /* swiftappTests */,
101D76CA278CBFD7005423E0 /* swiftappUITests */,
);
Expand Down Expand Up @@ -292,12 +292,12 @@
/* Begin PBXTargetDependency section */
101D76C3278CBFD7005423E0 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 101D76AF278CBFD5005423E0 /* swiftapp */;
target = 101D76AF278CBFD5005423E0 /* Notes Pro */;
targetProxy = 101D76C2278CBFD7005423E0 /* PBXContainerItemProxy */;
};
101D76CD278CBFD7005423E0 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 101D76AF278CBFD5005423E0 /* swiftapp */;
target = 101D76AF278CBFD5005423E0 /* Notes Pro */;
targetProxy = 101D76CC278CBFD7005423E0 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
Expand Down Expand Up @@ -434,15 +434,16 @@
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = swiftapp/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Notes Pro";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.productivity";
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.jamesssystems.swiftapp;
PRODUCT_NAME = swiftapp;
MARKETING_VERSION = 1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.jamesssystems.notespro;
PRODUCT_NAME = "Notes Pro";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
};
Expand All @@ -464,15 +465,16 @@
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = swiftapp/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Notes Pro";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.productivity";
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.jamesssystems.swiftapp;
PRODUCT_NAME = swiftapp;
MARKETING_VERSION = 1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.jamesssystems.notespro;
PRODUCT_NAME = "Notes Pro";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
};
Expand Down Expand Up @@ -562,7 +564,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
101D76D5278CBFD7005423E0 /* Build configuration list for PBXNativeTarget "swiftapp" */ = {
101D76D5278CBFD7005423E0 /* Build configuration list for PBXNativeTarget "Notes Pro" */ = {
isa = XCConfigurationList;
buildConfigurations = (
101D76D6278CBFD7005423E0 /* Debug */,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 38 additions & 6 deletions swiftapp/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@
import SwiftUI
import WebKit
import Combine
import Foundation
import Foundation
import AppKit

class AppDelegate: NSObject, NSApplicationDelegate {
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}
func applicationDidFinishLaunching(_ notification: Notification) {
print("Info from `applicationDidFinishLaunching(_:): Finished launching…")
let _ = NSApplication.shared.windows.map { $0.tabbingMode = .disallowed }
}
}

struct Note: Identifiable, Equatable {
let id = UUID()
Expand All @@ -26,10 +38,15 @@ class CurrentApp: ObservableObject {
@Published var note = Note(noteid: "", title: "none", contents: "none")
}


struct ContentView: View {
@State private var window_n: NSWindow?
@State private var window_o: NSWindow?

@StateObject var current_data = CurrentApp()
@State var username: String = ""
@State var password: String = ""
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@State var errortext: String = ""
@Environment(\.openURL) var openURL
let myWindow:NSWindow?
Expand Down Expand Up @@ -69,6 +86,10 @@ struct ContentView: View {
Text(errortext)
.foregroundColor(Color.orange)
.padding(.top, 600)

Text("James Wilson 2021")
.foregroundColor(Color.white)
.padding(.top, 800)
}

}
Expand All @@ -79,6 +100,8 @@ struct ContentView: View {
func logUser() {
let request = requestLogin(username: username, password: password)
if (request == true) {

window_o = NSApplication.shared.keyWindow
NSApplication.shared.keyWindow?.close()

//openURL(url)
Expand All @@ -94,15 +117,20 @@ struct ContentView: View {
}
}

let window = NSWindow(contentRect: NSRect(x: 20, y: 20, width: 480, height: 300), styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], backing: .buffered, defer: false)
window.center()
window.setFrameAutosaveName("Main Window")
window.contentView = NSHostingView(rootView: Login().environmentObject(current_data))
window.makeKeyAndOrderFront(nil)
window.title = "Notes Pro"
window_n = NSWindow(contentRect: NSRect(x: 20, y: 20, width: 480, height: 300), styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], backing: .buffered, defer: false)
window_n!.center()
window_n!.setFrameAutosaveName("Main Window")
window_n!.contentView = NSHostingView(rootView: Login().environmentObject(current_data))
window_n!.makeKeyAndOrderFront(nil)
window_n!.title = "Notes Pro"
} else {
errortext = "Incorrect Username or Password!"
password = ""
let alert = NSAlert()
alert.messageText = "Incorrect Username/Password!"
alert.addButton(withTitle: "OK")
alert.alertStyle = .informational
alert.runModal()
}
}
func requestLogin(username: String, password: String) -> Bool {
Expand Down Expand Up @@ -189,10 +217,12 @@ struct Login: View {
@State var cont: String = ""
@State var savestr: String = ""
@State var autoSaveEnabled = true
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@State var currentNote: Note = Note(noteid: "n/a", title: "n/a", contents: "n/a")
@EnvironmentObject private var current_data: CurrentApp
var body: some View {
HStack {
ScrollViewReader { this_list in
List {
ForEach(current_data.all_notes.reversed()) { note in
Button("\(note.title)\n\(note.contents)"){
Expand All @@ -205,6 +235,7 @@ struct Login: View {
.zIndex(1)
}
}.animation(.interactiveSpring())
}
.frame(width: 300, height: 500, alignment: .leading)
ZStack {
HStack {
Expand Down Expand Up @@ -442,3 +473,4 @@ private final class ObservableDebounceSubject<Output: Equatable, Failure>: Subje
.receive(subscriber: subscriber)
}
}

5 changes: 4 additions & 1 deletion swiftapp/swiftappApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ struct swiftappApp: App {
WindowGroup {
ContentView(myWindow: nil)
.navigationTitle("Notes Pro - Login")
}.commands {
CommandGroup(replacing: .newItem, addition: { })
}
.handlesExternalEvents(matching: Set(arrayLiteral: "viewer")) // create new window if one doesn't exist
WindowGroup("Login") { // other scene
Login().handlesExternalEvents(preferring: Set(arrayLiteral: "login"), allowing: Set(arrayLiteral: "*")) // activate existing window if exists
}.commands {
CommandGroup(replacing: .newItem, addition: { })
}
.handlesExternalEvents(matching: Set(arrayLiteral: "login")) // create new window if one doesn't exist
}
Expand Down

0 comments on commit 9d0d6ef

Please sign in to comment.