Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
glushchenko committed Sep 25, 2024
1 parent 30d6916 commit 45f7f54
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
18 changes: 9 additions & 9 deletions FSNotes/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -2001,8 +2001,8 @@ CA
<rect key="frame" x="12" y="11" width="66" height="16"/>
<subviews>
<button translatesAutoresizingMaskIntoConstraints="NO" id="Ote-7U-BZm">
<rect key="frame" x="0.0" y="-2.5" width="16" height="22"/>
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="NSLockLockedTemplate" imagePosition="only" alignment="center" imageScaling="proportionallyUpOrDown" inset="2" id="aHW-dK-rqB">
<rect key="frame" x="0.0" y="-2.5" width="16.5" height="22"/>
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="NSLockUnlockedTemplate" imagePosition="only" alignment="center" imageScaling="proportionallyUpOrDown" inset="2" id="aHW-dK-rqB">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
Expand Down Expand Up @@ -4015,14 +4015,14 @@ Olena Hlushcneko</string>
</textFieldCell>
</textField>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="Uul-l1-jKT" userLabel="Title Bar Additional View">
<rect key="frame" x="391" y="0.0" width="89" height="38"/>
<rect key="frame" x="387" y="0.0" width="93" height="38"/>
<subviews>
<stackView distribution="fill" orientation="horizontal" alignment="top" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="OFt-xi-XVU">
<rect key="frame" x="12" y="15" width="65" height="9"/>
<rect key="frame" x="12" y="15" width="69" height="9"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="PiC-RU-ugX">
<rect key="frame" x="0.0" y="-2.5" width="13" height="15"/>
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="NSLockLockedTemplate" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="VTh-q6-3p6">
<rect key="frame" x="0.0" y="-2.5" width="17.5" height="15"/>
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="NSLockUnlockedTemplate" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="VTh-q6-3p6">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
Expand All @@ -4031,7 +4031,7 @@ Olena Hlushcneko</string>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="grq-z8-mu5">
<rect key="frame" x="21" y="-2" width="21.5" height="13"/>
<rect key="frame" x="25" y="-2" width="21.5" height="13"/>
<buttonCell key="cell" type="bevel" bezelStyle="regularSquare" image="NSQuickLookTemplate" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="Hg1-rI-n1u">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -4041,7 +4041,7 @@ Olena Hlushcneko</string>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jV1-b8-PLn">
<rect key="frame" x="50" y="-3" width="15.5" height="18"/>
<rect key="frame" x="54" y="-3" width="15.5" height="18"/>
<buttonCell key="cell" type="bevel" bezelStyle="regularSquare" image="NSShareTemplate" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="Uwd-ec-6d5">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand Down Expand Up @@ -4911,7 +4911,7 @@ Olena Hlushcneko</string>
</scene>
</scenes>
<resources>
<image name="NSLockLockedTemplate" width="17" height="19"/>
<image name="NSLockUnlockedTemplate" width="21" height="19"/>
<image name="NSQuickLookTemplate" width="26" height="17"/>
<image name="NSShareTemplate" width="19" height="23"/>
<image name="icon" width="1024" height="1024"/>
Expand Down
17 changes: 17 additions & 0 deletions FSNotes/EditorViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,10 @@ class EditorViewController: NSViewController, NSTextViewDelegate, NSMenuItemVali
viewController.editor.fill(note: note)

if note.isEncryptedAndLocked() {
viewController.lockUnlockButton.image = NSImage(named: NSImage.lockLockedTemplateName)
viewController.toggleNotesLock(self)
} else {
viewController.lockUnlockButton.image = NSImage(named: NSImage.lockUnlockedTemplateName)
}

AppDelegate.noteWindows.insert(windowController, at: 0)
Expand Down Expand Up @@ -1161,6 +1164,20 @@ class EditorViewController: NSViewController, NSTextViewDelegate, NSMenuItemVali
if editor.note == note {
editor.editorViewController?.refillEditArea(force: true)

let lockIcon = note.isEncryptedAndLocked()
? NSImage.lockLockedTemplateName
: NSImage.lockUnlockedTemplateName

let lockImage = NSImage(named: lockIcon)

if let noteVC = editor.editorViewController as? NoteViewController {
noteVC.lockUnlockButton.image = lockImage
}

if let mainVC = editor.editorViewController as? ViewController {
mainVC.lockUnlock.image = lockImage
}

editor.window?.makeFirstResponder(editor)
}
}
Expand Down
6 changes: 3 additions & 3 deletions FSNotes/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ class ViewController: EditorViewController,
guard self?.titleLabel.isEnabled == false || self?.titleLabel.isEditable == false else { return }

if let note = self?.editor.note {
if note.isUnlocked() {
self?.lockUnlock.image = NSImage(named: NSImage.lockUnlockedTemplateName)
} else {
if note.isEncryptedAndLocked() {
self?.lockUnlock.image = NSImage(named: NSImage.lockLockedTemplateName)
} else {
self?.lockUnlock.image = NSImage(named: NSImage.lockUnlockedTemplateName)
}
}

Expand Down

0 comments on commit 45f7f54

Please sign in to comment.