Skip to content

Commit

Permalink
Add splash screen
Browse files Browse the repository at this point in the history
  • Loading branch information
lukakerr committed Aug 29, 2019
1 parent e1ceb02 commit 9891f32
Show file tree
Hide file tree
Showing 11 changed files with 573 additions and 26 deletions.
40 changes: 36 additions & 4 deletions Pine.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
objects = {

/* Begin PBXBuildFile section */
008CD6E8A653CDDA656D692B /* Pods_Pine.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B66B7DAE689A6827E658233B /* Pods_Pine.framework */; };
03782B4223158A60008AABFC /* SplashScreenWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 03782B3E23158A60008AABFC /* SplashScreenWindowController.xib */; };
03782B4323158A60008AABFC /* SplashScreenWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03782B3F23158A60008AABFC /* SplashScreenWindowController.swift */; };
03782B4423158A60008AABFC /* SplashScreenRecentDocumentView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 03782B4023158A60008AABFC /* SplashScreenRecentDocumentView.xib */; };
8F34580B873BD2CCD033F53B /* Pods_Pine.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 300B3A71DC5543C53B684729 /* Pods_Pine.framework */; };
A104782520E7338800E0930A /* FileSystemItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = A104782420E7338800E0930A /* FileSystemItem.swift */; };
A10B86DD2227BB3E000656DD /* PreferencesSplitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A10B86DC2227BB3E000656DD /* PreferencesSplitViewController.swift */; };
Expand Down Expand Up @@ -80,6 +82,7 @@
A1D7174622475B21003BE7BC /* MARKDOWN_REFERENCE.md in Resources */ = {isa = PBXBuildFile; fileRef = A1D7174322475B21003BE7BC /* MARKDOWN_REFERENCE.md */; };
A1E647DC20D1E9C000F32E55 /* PineSplitView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1E647DB20D1E9C000F32E55 /* PineSplitView.swift */; };
A1F122DF20DE0D27007DFD1A /* FileSaver.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1F122DE20DE0D27007DFD1A /* FileSaver.swift */; };
A1F40E70231742C400BD98D2 /* SplashScreenRecentDocumentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1F40E6F231742C400BD98D2 /* SplashScreenRecentDocumentViewController.swift */; };
A1F818B222499058006A4C10 /* GeneralStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1F818B122499058006A4C10 /* GeneralStackView.swift */; };
A1FB7A9A2227DC5900DC2E0E /* UIStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1FB7A992227DC5900DC2E0E /* UIStackView.swift */; };
A1FB7A9E2227DFCB00DC2E0E /* PreferencesStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1FB7A9D2227DFCB00DC2E0E /* PreferencesStackView.swift */; };
Expand Down Expand Up @@ -107,6 +110,9 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
03782B3E23158A60008AABFC /* SplashScreenWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SplashScreenWindowController.xib; sourceTree = "<group>"; };
03782B3F23158A60008AABFC /* SplashScreenWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SplashScreenWindowController.swift; sourceTree = "<group>"; };
03782B4023158A60008AABFC /* SplashScreenRecentDocumentView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SplashScreenRecentDocumentView.xib; sourceTree = "<group>"; };
300B3A71DC5543C53B684729 /* Pods_Pine.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Pine.framework; sourceTree = BUILT_PRODUCTS_DIR; };
8DB191E8E2AB43CED7C8E01D /* Pods-Pine.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Pine.release.xcconfig"; path = "Pods/Target Support Files/Pods-Pine/Pods-Pine.release.xcconfig"; sourceTree = "<group>"; };
A104782420E7338800E0930A /* FileSystemItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileSystemItem.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -187,6 +193,7 @@
A1D7174722475B2A003BE7BC /* Plugins.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Plugins.md; sourceTree = "<group>"; };
A1E647DB20D1E9C000F32E55 /* PineSplitView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PineSplitView.swift; sourceTree = "<group>"; };
A1F122DE20DE0D27007DFD1A /* FileSaver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileSaver.swift; sourceTree = "<group>"; };
A1F40E6F231742C400BD98D2 /* SplashScreenRecentDocumentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashScreenRecentDocumentViewController.swift; sourceTree = "<group>"; };
A1F818B122499058006A4C10 /* GeneralStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneralStackView.swift; sourceTree = "<group>"; };
A1FB7A992227DC5900DC2E0E /* UIStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIStackView.swift; sourceTree = "<group>"; };
A1FB7A9D2227DFCB00DC2E0E /* PreferencesStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesStackView.swift; sourceTree = "<group>"; };
Expand All @@ -206,7 +213,6 @@
buildActionMask = 2147483647;
files = (
8F34580B873BD2CCD033F53B /* Pods_Pine.framework in Frameworks */,
008CD6E8A653CDDA656D692B /* Pods_Pine.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -227,6 +233,15 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
03782B4623158A65008AABFC /* SplashScreen */ = {
isa = PBXGroup;
children = (
03782B4023158A60008AABFC /* SplashScreenRecentDocumentView.xib */,
03782B3E23158A60008AABFC /* SplashScreenWindowController.xib */,
);
path = SplashScreen;
sourceTree = "<group>";
};
A10378522249CF2700E6F3C6 /* Core Text */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -272,11 +287,12 @@
children = (
A1C65D81221179230053C422 /* DocumentController.swift */,
A156AF822090606C0098BBDD /* MarkdownViewController.swift */,
A156AFAE209061D60098BBDD /* PineWindowController.swift */,
A13C23FB20919672008557D0 /* PreviewViewController.swift */,
A127E31D20DF0F8400E13795 /* SidebarViewController.swift */,
A156AFAE209061D60098BBDD /* PineWindowController.swift */,
A10B86DB2227BB2E000656DD /* Preferences */,
A1904EA92228A75A0004FB82 /* Reference */,
A1F40E6E231742A000BD98D2 /* SplashScreen */,
);
path = Controllers;
sourceTree = "<group>";
Expand Down Expand Up @@ -313,6 +329,7 @@
A142C98320D673B0002ED94F /* Views */ = {
isa = PBXGroup;
children = (
03782B4623158A65008AABFC /* SplashScreen */,
A13B2E8A22322CBD00F24A84 /* MarkdownTextView.swift */,
A198047220DB64BA0066FDA6 /* MarkdownView.swift */,
A1E647DB20D1E9C000F32E55 /* PineSplitView.swift */,
Expand Down Expand Up @@ -489,6 +506,15 @@
path = WIki;
sourceTree = "<group>";
};
A1F40E6E231742A000BD98D2 /* SplashScreen */ = {
isa = PBXGroup;
children = (
03782B3F23158A60008AABFC /* SplashScreenWindowController.swift */,
A1F40E6F231742C400BD98D2 /* SplashScreenRecentDocumentViewController.swift */,
);
path = SplashScreen;
sourceTree = "<group>";
};
A1FB7AA32227F4E200DC2E0E /* Preferences */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -589,7 +615,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0930;
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1100;
ORGANIZATIONNAME = "Luka Kerr";
TargetAttributes = {
A156AF7C2090606C0098BBDD = {
Expand Down Expand Up @@ -642,10 +668,12 @@
buildActionMask = 2147483647;
files = (
A1C4020C221F851B00E3DBCC /* Reference.html in Resources */,
03782B4423158A60008AABFC /* SplashScreenRecentDocumentView.xib in Resources */,
A165D1F6223DB66500A00821 /* autocomplete in Resources */,
A189EA742091E4F300DB0559 /* Markdown.css in Resources */,
A14BF5942241C4E600ED250D /* Credits.rtf in Resources */,
A124783C2233356400CA7A67 /* File.icns in Resources */,
03782B4223158A60008AABFC /* SplashScreenWindowController.xib in Resources */,
A1D7174622475B21003BE7BC /* MARKDOWN_REFERENCE.md in Resources */,
A156AF872090606C0098BBDD /* Assets.xcassets in Resources */,
A1D7174522475B21003BE7BC /* RELEASE.md in Resources */,
Expand Down Expand Up @@ -738,6 +766,7 @@
A1BC8B08224214AF00623917 /* Character.swift in Sources */,
A1BC8B09224214AF00623917 /* URL.swift in Sources */,
A127E32020DF13FA00E13795 /* OpenDocuments.swift in Sources */,
A1F40E70231742C400BD98D2 /* SplashScreenRecentDocumentViewController.swift in Sources */,
A1904E9E22288AB80004FB82 /* DocumentStackView.swift in Sources */,
A1FB7A9E2227DFCB00DC2E0E /* PreferencesStackView.swift in Sources */,
A156AFB120908ECE0098BBDD /* Theme.swift in Sources */,
Expand All @@ -751,6 +780,7 @@
A10B86DD2227BB3E000656DD /* PreferencesSplitViewController.swift in Sources */,
A1FB7AA02227EE9300DC2E0E /* PreferencesRoundedButton.swift in Sources */,
A18A040820958C8B006F6B99 /* Preferences.swift in Sources */,
03782B4323158A60008AABFC /* SplashScreenWindowController.swift in Sources */,
A1F122DF20DE0D27007DFD1A /* FileSaver.swift in Sources */,
A198047320DB64BA0066FDA6 /* MarkdownView.swift in Sources */,
A13C23F8209153E1008557D0 /* ReferenceWindowController.swift in Sources */,
Expand Down Expand Up @@ -952,6 +982,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = QY544RDL2W;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Pine",
Expand Down Expand Up @@ -979,6 +1010,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = QY544RDL2W;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Pine",
Expand Down
24 changes: 10 additions & 14 deletions Pine.xcodeproj/xcshareddata/xcschemes/Pine.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1100"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A156AF7C2090606C0098BBDD"
BuildableName = "Pine.app"
BlueprintName = "Pine"
ReferencedContainer = "container:Pine.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -49,17 +58,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A156AF7C2090606C0098BBDD"
BuildableName = "Pine.app"
BlueprintName = "Pine"
ReferencedContainer = "container:Pine.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -81,8 +79,6 @@
ReferencedContainer = "container:Pine.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
22 changes: 17 additions & 5 deletions Pine/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ let defaults = UserDefaults.standard
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

var splashScreenWindowController: SplashScreenWindowController! = nil

/// The key window's `WindowController` instance
private var keyWindowController: PineWindowController? {
return NSApp.keyWindow?.windowController as? PineWindowController
Expand All @@ -32,8 +34,19 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}

func applicationOpenUntitledFile(_ sender: NSApplication) -> Bool {
if preferences[.openNewDocumentOnStartup] {
return false
} else {
splashScreenWindowController = SplashScreenWindowController()
splashScreenWindowController.showWindow(self)

return true
}
}

func applicationShouldOpenUntitledFile(_ sender: NSApplication) -> Bool {
return preferences[.openNewDocumentOnStartup]
return true
}

func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
Expand Down Expand Up @@ -62,7 +75,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
guard
dialog.runModal() == .OK,
let result = dialog.url
else { return }
else { return }

openFiles(files: [result])
}
Expand All @@ -75,7 +88,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
guard FileManager.default.fileExists(
atPath: file.path,
isDirectory: &isDirectory
) else { continue }
) else { continue }

DispatchQueue.global(qos: .userInitiated).async {
let parent = FileSystemItem.createParents(url: file)
Expand All @@ -97,8 +110,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
display: true,
completionHandler: { _, _, _ in
Utils.getCurrentMainWindowController()?.window?.makeKeyAndOrderFront(nil)
}
)
})
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions Pine/Controllers/DocumentController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ class DocumentController: NSDocumentController {
displayDocument: true,
completionHandler: completionHandler
)

// Ensure after opening a document that the splash screen window is closed
for window in NSApp.windows {
if let splashScreenWindow = window.windowController as? SplashScreenWindowController {
splashScreenWindow.close()
}
}
}

/// Replace the currently opened document (if it exists) with the provided URL
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// SplashScreenRecentDocumentViewController.swift
// Pine
//
// Created by Luka Kerr on 29/8/19.
// Copyright © 2019 Luka Kerr. All rights reserved.
//

import Cocoa

/// View controller for the "recent document" rows in the tableview in the splash screen.
final class SplashScreenRecentDocumentViewController: NSViewController {

var url: URL?

@IBOutlet weak var icon: NSImageView!
@IBOutlet weak var filename: NSTextField!
@IBOutlet weak var path: NSTextField!

override var nibName: NSNib.Name? {
return NSNib.Name( "SplashScreenRecentDocumentView")
}

override func viewDidLoad() {
guard let url = url else { return }
icon.image = NSImage(named: "File")
filename.stringValue = (url.lastPathComponent as NSString).deletingPathExtension
path.stringValue = ((url.path as NSString).deletingLastPathComponent as NSString).abbreviatingWithTildeInPath
}

}
Loading

0 comments on commit 9891f32

Please sign in to comment.