Skip to content
This repository has been archived by the owner on Aug 6, 2021. It is now read-only.

Commit

Permalink
implemented some things for the popover drop list; see #28
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Schulze committed May 31, 2015
1 parent 1723284 commit 6ad9168
Show file tree
Hide file tree
Showing 8 changed files with 263 additions and 25 deletions.
14 changes: 13 additions & 1 deletion idrop.link.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
650D6C151AE981AE00F5EF87 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 650D6C141AE981AE00F5EF87 /* Images.xcassets */; };
6513E43E1AF76635001B8A82 /* Notification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6513E43D1AF76635001B8A82 /* Notification.swift */; };
652BE27A1B1AF96700128B8B /* PopoverTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652BE2791B1AF96700128B8B /* PopoverTableView.swift */; };
652BE27C1B1B092400128B8B /* PopoverTableCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652BE27B1B1B092400128B8B /* PopoverTableCellView.swift */; };
652BE27E1B1B130C00128B8B /* PopoverTableViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652BE27D1B1B130C00128B8B /* PopoverTableViewDelegate.swift */; };
652BE2801B1B19E600128B8B /* Drop.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652BE27F1B1B19E600128B8B /* Drop.swift */; };
6536B5401B00D1E100751C4D /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 6536B53F1B00D1E100751C4D /* [email protected] */; };
6536B5491B01057500751C4D /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 6536B5451B01057500751C4D /* [email protected] */; };
6536B54A1B01057500751C4D /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 6536B5461B01057500751C4D /* [email protected] */; };
Expand Down Expand Up @@ -73,6 +76,9 @@
650D6C141AE981AE00F5EF87 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
6513E43D1AF76635001B8A82 /* Notification.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Notification.swift; sourceTree = "<group>"; };
652BE2791B1AF96700128B8B /* PopoverTableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PopoverTableView.swift; sourceTree = "<group>"; };
652BE27B1B1B092400128B8B /* PopoverTableCellView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PopoverTableCellView.swift; sourceTree = "<group>"; };
652BE27D1B1B130C00128B8B /* PopoverTableViewDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PopoverTableViewDelegate.swift; sourceTree = "<group>"; };
652BE27F1B1B19E600128B8B /* Drop.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Drop.swift; sourceTree = "<group>"; };
6536B53F1B00D1E100751C4D /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
6536B5451B01057500751C4D /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
6536B5461B01057500751C4D /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -157,6 +163,7 @@
650D6BF91AE9818100F5EF87 /* Base.lproj */,
650D6BDE1AE9813900F5EF87 /* AppDelegate.swift */,
650D6BFC1AE9818100F5EF87 /* Config.swift */,
652BE27D1B1B130C00128B8B /* PopoverTableViewDelegate.swift */,
650D6BE21AE9813900F5EF87 /* MainMenu.xib */,
6569DDFC1AEF9FFA0085C52F /* Custom Views */,
6569DDFB1AEF9FEC0085C52F /* Library */,
Expand Down Expand Up @@ -249,9 +256,10 @@
6569DDFB1AEF9FEC0085C52F /* Library */ = {
isa = PBXGroup;
children = (
652BE27F1B1B19E600128B8B /* Drop.swift */,
650D6C011AE9818100F5EF87 /* Networking.swift */,
650D6C071AE9818100F5EF87 /* User.swift */,
6513E43D1AF76635001B8A82 /* Notification.swift */,
650D6C071AE9818100F5EF87 /* User.swift */,
);
name = Library;
sourceTree = "<group>";
Expand All @@ -261,6 +269,7 @@
children = (
650D6BFD1AE9818100F5EF87 /* IconView.swift */,
652BE2791B1AF96700128B8B /* PopoverTableView.swift */,
652BE27B1B1B092400128B8B /* PopoverTableCellView.swift */,
);
name = "Custom Views";
sourceTree = "<group>";
Expand Down Expand Up @@ -479,12 +488,15 @@
files = (
650D6C101AE9818100F5EF87 /* PreferencesWindowController.swift in Sources */,
652BE27A1B1AF96700128B8B /* PopoverTableView.swift in Sources */,
652BE2801B1B19E600128B8B /* Drop.swift in Sources */,
650D6BDF1AE9813900F5EF87 /* AppDelegate.swift in Sources */,
652BE27C1B1B092400128B8B /* PopoverTableCellView.swift in Sources */,
650D6C0E1AE9818100F5EF87 /* Networking.swift in Sources */,
650D6C0A1AE9818100F5EF87 /* IconView.swift in Sources */,
6513E43E1AF76635001B8A82 /* Notification.swift in Sources */,
650D6C091AE9818100F5EF87 /* Config.swift in Sources */,
650D6C131AE9818100F5EF87 /* User.swift in Sources */,
652BE27E1B1B130C00128B8B /* PopoverTableViewDelegate.swift in Sources */,
6569DDF61AEF6DCB0085C52F /* LoginWindowController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
36 changes: 27 additions & 9 deletions idrop.link/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@
import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDelegate {
class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDelegate,
NSTableViewDataSource, NSTableViewDelegate {

@IBOutlet var window: NSWindow?
@IBOutlet var popover : NSPopover?
@IBOutlet weak var menu: NSMenu!
@IBOutlet weak var loggedInMenu: NSMenu!
@IBOutlet weak var popoverTableView: NSScrollView!
@IBOutlet weak var popoverTableView: PopoverTableView!

var user: User

var preferencesWindowController: PreferencesWindowController
var loginWindowController: LoginWindowController

var popoverTableViewDelegate: PopoverTableViewDelegate

let icon: IconView
let item: NSStatusItem

Expand All @@ -35,19 +39,15 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele

self.user = User()

// try to get data out of keychain if any
if self.user.tryKeychainDataFetch() {
self.user.tryLogin({ (success) -> Void in
// Does nothing atm
})
}

// initialize window controller
self.preferencesWindowController = PreferencesWindowController()
self.preferencesWindowController.user = self.user
self.loginWindowController = LoginWindowController()
self.loginWindowController.user = self.user

self.popoverTableViewDelegate = PopoverTableViewDelegate()
self.popoverTableViewDelegate.user = self.user

super.init();
}

Expand All @@ -59,6 +59,24 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
self.user.onProgress = { (prog: Float) -> Void in
self.icon.progress = prog
}

self.popoverTableView.setDelegate(self.popoverTableViewDelegate)
self.popoverTableView.setDataSource(self.popoverTableViewDelegate)

// try to get data out of keychain if any
if self.user.tryKeychainDataFetch() {
self.user.tryLogin({ (success) -> Void in
self.user.onDropSync = { () -> Void in
if let ptv = self.popoverTableView {
ptv.reloadData()
}
}

if (success) {
self.user.syncDrops()
}
})
}
}

func applicationWillTerminate(aNotification: NSNotification) {
Expand Down
49 changes: 40 additions & 9 deletions idrop.link/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
<outlet property="loggedInMenu" destination="Ppi-Dm-b3o" id="V9C-QJ-Eqy"/>
<outlet property="menu" destination="QKl-2u-n0Q" id="TPs-Nl-xfS"/>
<outlet property="popover" destination="79J-8G-uar" id="csQ-r6-VX8"/>
<outlet property="popoverTableView" destination="OiZ-uy-hdW" id="7Iz-Zy-eaz"/>
<outlet property="popoverTableView" destination="Gih-3w-qLQ" id="gDu-2Z-ADi"/>
</connections>
</customObject>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<customObject id="nPd-Wu-3Vr" customClass="PopoverTableViewDelegate" customModule="idrop_link" customModuleProvider="target"/>
<menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
<items>
<menuItem title="idrop.link" id="1Xt-HY-uBw">
Expand Down Expand Up @@ -683,20 +684,21 @@
<rect key="frame" x="0.0" y="0.0" width="306" height="176"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<scrollView fixedFrame="YES" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OiZ-uy-hdW">
<scrollView fixedFrame="YES" autohidesScrollers="YES" horizontalLineScroll="52" horizontalPageScroll="10" verticalLineScroll="52" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OiZ-uy-hdW">
<rect key="frame" x="12" y="13" width="283" height="151"/>
<clipView key="contentView" misplaced="YES" drawsBackground="NO" copiesOnScroll="NO" id="54v-dp-2CI">
<rect key="frame" x="1" y="17" width="238" height="117"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" headerView="vGx-yO-zTD" viewBased="YES" id="Gih-3w-qLQ" customClass="PopoverTableView" customModule="idrop_link" customModuleProvider="target">
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowHeight="50" rowSizeStyle="automatic" viewBased="YES" id="Gih-3w-qLQ" customClass="PopoverTableView" customModule="idrop_link" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="278" height="0.0"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<tableViewGridLines key="gridStyleMask" horizontal="YES"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn editable="NO" width="278" minWidth="40" maxWidth="1000" id="lXh-fd-56A">
<tableColumn identifier="MainCell" editable="NO" width="278" minWidth="40" maxWidth="1000" id="lXh-fd-56A">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
Expand All @@ -708,24 +710,53 @@
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView identifier="MainCell" id="yGM-tM-5mu" customClass="PopoverTableCellView" customModule="idrop_link" customModuleProvider="target">
<rect key="frame" x="1" y="1" width="278" height="50"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="aeT-m6-2fL">
<rect key="frame" x="57" y="30" width="152" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="fJw-aK-hBr">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="O6e-91-5mv">
<rect key="frame" x="57" y="5" width="152" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Label" id="5qY-0C-Xea">
<font key="font" metaFont="system"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="0DB-dC-btv">
<rect key="frame" x="3" y="1" width="48" height="48"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="oAM-Hp-WEk"/>
</imageView>
</subviews>
<connections>
<outlet property="dateTextField" destination="O6e-91-5mv" id="FF2-XL-76K"/>
<outlet property="imgView" destination="0DB-dC-btv" id="gl7-il-z9N"/>
<outlet property="titleTextField" destination="aeT-m6-2fL" id="ISl-JX-II0"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
</tableColumns>
</tableView>
</subviews>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="0L9-fY-BQE">
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="0L9-fY-BQE">
<rect key="frame" x="1" y="116.47991275787354" width="235" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="rS6-01-bBN">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="vGx-yO-zTD">
<rect key="frame" x="0.0" y="0.0" width="238" height="17"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
</subviews>
<point key="canvasLocation" x="276" y="319"/>
Expand Down
40 changes: 40 additions & 0 deletions idrop.link/Drop.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// Drop.swift
// idrop.link
//
// Created by Christian Schulze on 31/05/15.
// Copyright (c) 2015 andinfinity. All rights reserved.
//

import Cocoa

class Drop: NSObject {
var dropDate: String?
var name: String?
var _id: String?
var url: String?
var shortId: String?
var type: String?
var path: String?

override init() {
self.dropDate = nil
self.name = nil
self._id = nil
self.url = nil
self.shortId = nil
self.type = nil
self.path = nil
}

init(dropDate: String?, name: String?, _id: String?, url: String?,
shortId: String?, type: String?, path: String?) {
self.dropDate = dropDate
self.name = name
self._id = _id
self.url = url
self.shortId = shortId
self.type = type
self.path = path
}
}
15 changes: 15 additions & 0 deletions idrop.link/PopoverTableCellView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// PopoverTableCellView.swift
// idrop.link
//
// Created by Christian Schulze on 31/05/15.
// Copyright (c) 2015 andinfinity. All rights reserved.
//

import Cocoa

class PopoverTableCellView: NSTableCellView {
@IBOutlet var imgView:NSImageView?
@IBOutlet var titleTextField:NSTextField?
@IBOutlet var dateTextField:NSTextField?
}
1 change: 0 additions & 1 deletion idrop.link/PopoverTableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import Cocoa

class PopoverTableView: NSTableView {

override func awakeFromNib() {
self.enclosingScrollView?.drawsBackground = false
self.enclosingScrollView?.borderType = NSBorderType.NoBorder
Expand Down
Loading

0 comments on commit 6ad9168

Please sign in to comment.