From 967a587b5ce718d948221e20f50d5400a57e2def Mon Sep 17 00:00:00 2001 From: Oleksandr Glushchenko Date: Tue, 8 Aug 2017 09:09:57 +0300 Subject: [PATCH] modification date --- FSNotes/Base.lproj/Main.storyboard | 4 ++-- FSNotes/NoteCellView.swift | 7 ++++++- FSNotes/NoteRowView.swift | 2 +- FSNotes/ViewController.swift | 3 ++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/FSNotes/Base.lproj/Main.storyboard b/FSNotes/Base.lproj/Main.storyboard index c8f74783f..283414a62 100644 --- a/FSNotes/Base.lproj/Main.storyboard +++ b/FSNotes/Base.lproj/Main.storyboard @@ -958,7 +958,7 @@ - + @@ -973,7 +973,7 @@ - + diff --git a/FSNotes/NoteCellView.swift b/FSNotes/NoteCellView.swift index 154f49e9d..1dcf17720 100644 --- a/FSNotes/NoteCellView.swift +++ b/FSNotes/NoteCellView.swift @@ -59,8 +59,13 @@ class NoteCellView: NSTableCellView { } preview.translatesAutoresizingMaskIntoConstraints = false + date.translatesAutoresizingMaskIntoConstraints = false + let previewTop = preview.topAnchor.constraint(equalTo: self.topAnchor, constant: 2) let previewLeft = preview.leftAnchor.constraint(equalTo: name.rightAnchor, constant: 0) - NSLayoutConstraint.activate([previewTop, previewLeft]) + let dateRight = date.rightAnchor.constraint(equalTo: self.rightAnchor, constant: -5) + let dateTop = date.topAnchor.constraint(equalTo: self.topAnchor, constant: 3) + let previewRight = preview.rightAnchor.constraint(equalTo: self.rightAnchor, constant: -65) + NSLayoutConstraint.activate([previewTop, previewLeft, dateRight, dateTop, previewRight]) } } diff --git a/FSNotes/NoteRowView.swift b/FSNotes/NoteRowView.swift index dddfaf078..e7c28f416 100644 --- a/FSNotes/NoteRowView.swift +++ b/FSNotes/NoteRowView.swift @@ -18,7 +18,7 @@ class NoteRowView: NSTableRowView { if self.selectionHighlightStyle != .none { let selectionRect = NSInsetRect(self.bounds, 0, 0) NSColor(calibratedWhite: 0.55, alpha: 1).setStroke() - NSColor(calibratedRed: 0.3, green: 0.6, blue: 0.9, alpha: 0.9).setFill() + NSColor(calibratedRed: 0.3, green: 0.6, blue: 0.9, alpha: 0.8).setFill() let selectionPath = NSBezierPath.init(roundedRect: selectionRect, xRadius: 2, yRadius: 2) selectionPath.fill() selectionPath.stroke() diff --git a/FSNotes/ViewController.swift b/FSNotes/ViewController.swift index 27166b4d4..035f8eb02 100644 --- a/FSNotes/ViewController.swift +++ b/FSNotes/ViewController.swift @@ -89,6 +89,7 @@ class ViewController: NSViewController, if (notesTableView.notesList.indices.contains(selected)) { let note = notesTableView.notesList.remove(at: selected) note.content = content + note.date = Date.init() notesTableView.notesList.insert(note, at: 0) notesTableView.moveRow(at: selected, to: 0) @@ -150,7 +151,7 @@ class ViewController: NSViewController, do { let fileAttribute: [FileAttributeKey : Any] = try FileManager.default.attributesOfItem(atPath: url.path) - modificationDate = fileAttribute[FileAttributeKey.modificationDate] as! Date + modificationDate = fileAttribute[FileAttributeKey.modificationDate] as? Date } catch { print(error.localizedDescription) }