Skip to content

Commit

Permalink
wip + screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
rafiki270 committed Jul 1, 2018
1 parent 7ca6aa2 commit cdf5381
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 6 deletions.
Binary file added Other/screenshot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Other/screenshot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Other/screenshot3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# SwiftGit

<table>
<tr>
<td><img src="https://github.com/LiveUI/SwiftGit/blob/master/Other/screenshot1.png?raw=true" alt="" /></td>
<td><img src="https://github.com/LiveUI/SwiftGit/blob/master/Other/screenshot2.png?raw=true" alt="" /></td>
<td><img src="https://github.com/LiveUI/SwiftGit/blob/master/Other/screenshot3.png?raw=true" alt="" /></td>
</tr>
</table>

## Use
* Run `carthage update --platform osx --cache-builds` to install dependencies, run the app

Expand Down
8 changes: 4 additions & 4 deletions SwiftGit/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,20 @@ class AppDelegate: NSObject, NSApplicationDelegate {
@objc func commit(_ sender: NSMenuItem) {
let storyboard = NSStoryboard(name: "Main", bundle: nil)
let windowController = storyboard.instantiateController(withIdentifier: "Commit Window Controller") as! NSWindowController
guard let path = sender.project.path else { return }
var context = CustomContext()
context.currentdirectory = path
if let commitWindow = windowController.window {
let controller = commitWindow.contentViewController as! CommitViewController
controller.project = sender.project
controller.cancel = {
windowController.close()
}
controller.stageAll = {
guard let path = sender.project.path else { return }
var context = CustomContext()
context.currentdirectory = path
try? context.runAndPrint("git", "add", ".", "-A")
}
controller.commit = { commitMessage in
sender.project.repo?.commit(message: commitMessage, signature: Signature(name: "", email: <#T##String#>))
try? context.runAndPrint("git", "commit", "-m", commitMessage)
}

NSApplication.shared.runModal(for: commitWindow)
Expand Down
15 changes: 14 additions & 1 deletion SwiftGit/Commit/CommitViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Reloaded
import SwiftGit2


class CommitViewController: NSViewController, NSTextViewDelegate {
class CommitViewController: NSViewController, NSTextViewDelegate, NSTextFieldDelegate {

var project: Project!

Expand All @@ -26,6 +26,8 @@ class CommitViewController: NSViewController, NSTextViewDelegate {
var cancel: (() -> Void)?
var stageAll: (() -> Void)?

// MARK: View lifecycle

override func viewWillAppear() {
super.viewWillAppear()

Expand All @@ -49,11 +51,15 @@ class CommitViewController: NSViewController, NSTextViewDelegate {
NSApplication.shared.stopModal()
}

// MARK: Delegate methods

func textDidChange(_ notification: Notification) {
project.lastCommitMessage = (notification.object as? NSTextView)?.string
try! project.save()
}

// MARK: Actions

@IBAction func stageMissing(_ sender: NSButton) {
stageAll?()

Expand All @@ -70,6 +76,12 @@ class CommitViewController: NSViewController, NSTextViewDelegate {
}

@IBAction func makeCommit(_ sender: NSButton) {
guard !textView.string.isEmpty else {

return
}
sender.isEnabled = false

project.lastCommitMessage = ""
try! project.save()

Expand All @@ -96,6 +108,7 @@ extension CommitViewController: NSTableViewDelegate, NSTableViewDataSource {
let status = statuses[row]
if let cell = cell as? NSButtonCell {
cell.state = status.status.isStaged ? .on : .off
cell.isEnabled = false
} else if let cell = cell as? NSTextFieldCell {
cell.stringValue = status.title
}
Expand Down
2 changes: 1 addition & 1 deletion SwiftGit/Supporting files/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
<constraints>
<constraint firstItem="1jw-vR-zhQ" firstAttribute="leading" secondItem="wmF-MI-4cx" secondAttribute="trailing" constant="8" id="6mh-F6-Ckk"/>
<constraint firstItem="5S1-3e-rr4" firstAttribute="top" secondItem="Fho-b9-dLP" secondAttribute="top" constant="13" id="8Bv-9i-r2M"/>
<constraint firstItem="wsE-wg-062" firstAttribute="top" secondItem="1jw-vR-zhQ" secondAttribute="bottom" constant="8" id="J5k-wo-uwm"/>
<constraint firstItem="mjK-Ba-m8L" firstAttribute="leading" secondItem="Fho-b9-dLP" secondAttribute="leading" constant="8" id="QLH-9y-Ltx"/>
<constraint firstAttribute="bottom" secondItem="wsE-wg-062" secondAttribute="bottom" constant="10" id="Scn-4P-lNP"/>
<constraint firstAttribute="trailing" secondItem="wsE-wg-062" secondAttribute="trailing" constant="8" id="TCX-FG-iYE"/>
Expand All @@ -161,7 +162,6 @@
<constraint firstItem="1jw-vR-zhQ" firstAttribute="top" secondItem="5S1-3e-rr4" secondAttribute="bottom" constant="8" id="jgb-JG-rr4"/>
<constraint firstItem="wmF-MI-4cx" firstAttribute="leading" secondItem="Fho-b9-dLP" secondAttribute="leading" constant="8" id="kLR-mp-qPk"/>
<constraint firstAttribute="trailing" secondItem="1jw-vR-zhQ" secondAttribute="trailing" constant="8" id="ymd-G5-i6F"/>
<constraint firstItem="wsE-wg-062" firstAttribute="top" secondItem="1jw-vR-zhQ" secondAttribute="bottom" constant="8" id="z7k-wP-v5V"/>
</constraints>
</view>
<connections>
Expand Down

0 comments on commit cdf5381

Please sign in to comment.