From 13704f8e6d8be0bdf05dbd0c523ea254f04f4810 Mon Sep 17 00:00:00 2001 From: Zhigang Fang Date: Wed, 25 Oct 2017 11:14:17 +0800 Subject: [PATCH] Add keychain --- .gitignore | 1 + FloatingToggl.xcodeproj/project.pbxproj | 6 + .../xcschemes/xcschememanagement.plist | 2 +- FloatingToggl/AppDelegate.swift | 17 + FloatingToggl/Base.lproj/Main.storyboard | 352 +----------------- FloatingToggl/ViewController.swift | 28 +- Podfile | 1 + Podfile.lock | 5 +- 8 files changed, 46 insertions(+), 366 deletions(-) diff --git a/.gitignore b/.gitignore index 8f30a7e..1b10b74 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ Pods +xcuserdata diff --git a/FloatingToggl.xcodeproj/project.pbxproj b/FloatingToggl.xcodeproj/project.pbxproj index 051f8b6..8f95202 100644 --- a/FloatingToggl.xcodeproj/project.pbxproj +++ b/FloatingToggl.xcodeproj/project.pbxproj @@ -167,11 +167,13 @@ ); inputPaths = ( "${SRCROOT}/Pods/Target Support Files/Pods-FloatingToggl/Pods-FloatingToggl-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/KeychainSwift/KeychainSwift.framework", "${BUILT_PRODUCTS_DIR}/RxCocoa/RxCocoa.framework", "${BUILT_PRODUCTS_DIR}/RxSwift/RxSwift.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KeychainSwift.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxCocoa.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxSwift.framework", ); @@ -352,6 +354,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = FloatingToggl/FloatingToggl.entitlements; + CODE_SIGN_IDENTITY = "Mac Developer"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = 7CRYNR44B3; @@ -359,6 +362,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.matrix.FloatingToggl; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 4.0; }; name = Debug; @@ -369,6 +373,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = FloatingToggl/FloatingToggl.entitlements; + CODE_SIGN_IDENTITY = "Mac Developer"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = 7CRYNR44B3; @@ -376,6 +381,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.matrix.FloatingToggl; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 4.0; }; name = Release; diff --git a/FloatingToggl.xcodeproj/xcuserdata/kylefang.xcuserdatad/xcschemes/xcschememanagement.plist b/FloatingToggl.xcodeproj/xcuserdata/kylefang.xcuserdatad/xcschemes/xcschememanagement.plist index 5407082..ce0c271 100644 --- a/FloatingToggl.xcodeproj/xcuserdata/kylefang.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/FloatingToggl.xcodeproj/xcuserdata/kylefang.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,7 +7,7 @@ FloatingToggl.xcscheme orderHint - 3 + 4 diff --git a/FloatingToggl/AppDelegate.swift b/FloatingToggl/AppDelegate.swift index 9894ffd..3b0761c 100644 --- a/FloatingToggl/AppDelegate.swift +++ b/FloatingToggl/AppDelegate.swift @@ -11,7 +11,24 @@ import Cocoa @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { + @IBAction func setToken(_ sender: NSMenuItem) { + let alert = NSAlert() + alert.alertStyle = .informational + alert.messageText = "Toggl API Token:\nhttps://toggl.com/app/profile" + let tokenField = NSTextField() + tokenField.frame = NSRect(x: 0, y: 0, width: 300, height: 20) + tokenField.usesSingleLineMode = true + + alert.accessoryView = tokenField + alert.addButton(withTitle: "Set") + alert.addButton(withTitle: "Cancel") + alert.beginSheetModal(for: NSApplication.shared.keyWindow!) { (response) in + guard response == .alertFirstButtonReturn else { return } + print(tokenField.stringValue) + } + tokenField.becomeFirstResponder() + } func applicationDidFinishLaunching(_ aNotification: Notification) { // Insert code here to initialize your application diff --git a/FloatingToggl/Base.lproj/Main.storyboard b/FloatingToggl/Base.lproj/Main.storyboard index 4304e18..42aaadc 100644 --- a/FloatingToggl/Base.lproj/Main.storyboard +++ b/FloatingToggl/Base.lproj/Main.storyboard @@ -62,60 +62,9 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -340,300 +289,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Default - - - - - - - Left to Right - - - - - - - Right to Left - - - - - - - - - - - Default - - - - - - - Left to Right - - - - - - - Right to Left - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -726,9 +381,6 @@ - - - diff --git a/FloatingToggl/ViewController.swift b/FloatingToggl/ViewController.swift index f8c91bb..3ed06f2 100644 --- a/FloatingToggl/ViewController.swift +++ b/FloatingToggl/ViewController.swift @@ -17,6 +17,20 @@ class ViewController: NSViewController { @IBOutlet weak var actionButton: NSButton! + var tableView: NSTableView { + let column = NSTableColumn(identifier: NSUserInterfaceItemIdentifier("text")) + column.isEditable = false + column.width = 500 + let tableView = NSTableView() + tableView.selectionHighlightStyle = .regular + tableView.rowSizeStyle = .small + tableView.intercellSpacing = NSSize(width: 20, height: 3) + tableView.headerView = nil + tableView.refusesFirstResponder = true + tableView.target = self + return tableView + } + override func viewDidLoad() { super.viewDidLoad() self.timerLabel.isHidden = true @@ -33,20 +47,6 @@ class ViewController: NSViewController { } -extension ViewController: NSTextFieldDelegate { - - func control(_ control: NSControl, textView: NSTextView, completions words: [String], forPartialWordRange charRange: NSRange, indexOfSelectedItem index: UnsafeMutablePointer) -> [String] { - return words - } - -// override func controlTextDidChange(_ obj: Notification) { -// guard let fieldEditor = obj.userInfo?["NSFieldEditor"] as? NSTextView else { return } -//// fieldEditor.complete(nil) -// } - -} - - private extension ViewController { func setupUI() { diff --git a/Podfile b/Podfile index b3ce403..4793136 100644 --- a/Podfile +++ b/Podfile @@ -8,6 +8,7 @@ target 'FloatingToggl' do # Pods for FloatingToggl pod 'RxSwift' pod 'RxCocoa' + pod 'KeychainSwift' end diff --git a/Podfile.lock b/Podfile.lock index 7215218..289151f 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,16 +1,19 @@ PODS: + - KeychainSwift (8.0.2) - RxCocoa (3.6.1): - RxSwift (~> 3.6) - RxSwift (3.6.1) DEPENDENCIES: + - KeychainSwift - RxCocoa - RxSwift SPEC CHECKSUMS: + KeychainSwift: 213db04dfe7244988e61f77c72a2afb2f775954a RxCocoa: 84a08739ab186248c7f31ce4ee92d6f8a947d690 RxSwift: f9de85ea20cd2f7716ee5409fc13523dc638e4e4 -PODFILE CHECKSUM: f6447ba2728eb9ca94647f84fcf6c043ca15a015 +PODFILE CHECKSUM: 2ff1ecfdbeb49f2b0872a44c758fc852e39c2197 COCOAPODS: 1.3.1