mirror of
https://github.com/dscyrescotti/Memola.git
synced 2026-04-25 01:58:52 +02:00
chore: remove shortcut
This commit is contained in:
@@ -26,9 +26,6 @@
|
|||||||
EC2002D72C4160EF002EBD5F /* EditCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2002D62C4160EF002EBD5F /* EditCommands.swift */; };
|
EC2002D72C4160EF002EBD5F /* EditCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2002D62C4160EF002EBD5F /* EditCommands.swift */; };
|
||||||
EC2002D92C4161ED002EBD5F /* ViewCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2002D82C4161ED002EBD5F /* ViewCommands.swift */; };
|
EC2002D92C4161ED002EBD5F /* ViewCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2002D82C4161ED002EBD5F /* ViewCommands.swift */; };
|
||||||
EC2002DD2C4163E8002EBD5F /* AppCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2002DC2C4163E8002EBD5F /* AppCommands.swift */; };
|
EC2002DD2C4163E8002EBD5F /* AppCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2002DC2C4163E8002EBD5F /* AppCommands.swift */; };
|
||||||
EC2002E12C416470002EBD5F /* Shortcut.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2002E02C416470002EBD5F /* Shortcut.swift */; };
|
|
||||||
EC2002E52C416551002EBD5F /* Shortcuts.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2002E42C416551002EBD5F /* Shortcuts.swift */; };
|
|
||||||
EC2002E92C4167C5002EBD5F /* ShortcutKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2002E82C4167C5002EBD5F /* ShortcutKey.swift */; };
|
|
||||||
EC2002ED2C417B68002EBD5F /* AppScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2002EC2C417B68002EBD5F /* AppScene.swift */; };
|
EC2002ED2C417B68002EBD5F /* AppScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2002EC2C417B68002EBD5F /* AppScene.swift */; };
|
||||||
EC2002F02C417BF1002EBD5F /* ActiveSceneKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2002EF2C417BF1002EBD5F /* ActiveSceneKey.swift */; };
|
EC2002F02C417BF1002EBD5F /* ActiveSceneKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2002EF2C417BF1002EBD5F /* ActiveSceneKey.swift */; };
|
||||||
EC2106AD2C10C2A700FBE27C /* AnyStroke.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2106AC2C10C2A700FBE27C /* AnyStroke.swift */; };
|
EC2106AD2C10C2A700FBE27C /* AnyStroke.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC2106AC2C10C2A700FBE27C /* AnyStroke.swift */; };
|
||||||
@@ -167,9 +164,6 @@
|
|||||||
EC2002D62C4160EF002EBD5F /* EditCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditCommands.swift; sourceTree = "<group>"; };
|
EC2002D62C4160EF002EBD5F /* EditCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditCommands.swift; sourceTree = "<group>"; };
|
||||||
EC2002D82C4161ED002EBD5F /* ViewCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewCommands.swift; sourceTree = "<group>"; };
|
EC2002D82C4161ED002EBD5F /* ViewCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewCommands.swift; sourceTree = "<group>"; };
|
||||||
EC2002DC2C4163E8002EBD5F /* AppCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppCommands.swift; sourceTree = "<group>"; };
|
EC2002DC2C4163E8002EBD5F /* AppCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppCommands.swift; sourceTree = "<group>"; };
|
||||||
EC2002E02C416470002EBD5F /* Shortcut.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shortcut.swift; sourceTree = "<group>"; };
|
|
||||||
EC2002E42C416551002EBD5F /* Shortcuts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shortcuts.swift; sourceTree = "<group>"; };
|
|
||||||
EC2002E82C4167C5002EBD5F /* ShortcutKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortcutKey.swift; sourceTree = "<group>"; };
|
|
||||||
EC2002EC2C417B68002EBD5F /* AppScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppScene.swift; sourceTree = "<group>"; };
|
EC2002EC2C417B68002EBD5F /* AppScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppScene.swift; sourceTree = "<group>"; };
|
||||||
EC2002EF2C417BF1002EBD5F /* ActiveSceneKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActiveSceneKey.swift; sourceTree = "<group>"; };
|
EC2002EF2C417BF1002EBD5F /* ActiveSceneKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActiveSceneKey.swift; sourceTree = "<group>"; };
|
||||||
EC2106AC2C10C2A700FBE27C /* AnyStroke.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyStroke.swift; sourceTree = "<group>"; };
|
EC2106AC2C10C2A700FBE27C /* AnyStroke.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyStroke.swift; sourceTree = "<group>"; };
|
||||||
@@ -411,33 +405,6 @@
|
|||||||
path = Commands;
|
path = Commands;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
EC2002DE2C41645A002EBD5F /* Shortcut */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
EC2002D32C416002002EBD5F /* Commands */,
|
|
||||||
EC2002DF2C416466002EBD5F /* Core */,
|
|
||||||
EC2002E72C4167B1002EBD5F /* EnvironmentValues */,
|
|
||||||
);
|
|
||||||
path = Shortcut;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
EC2002DF2C416466002EBD5F /* Core */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
EC2002E02C416470002EBD5F /* Shortcut.swift */,
|
|
||||||
EC2002E42C416551002EBD5F /* Shortcuts.swift */,
|
|
||||||
);
|
|
||||||
path = Core;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
EC2002E72C4167B1002EBD5F /* EnvironmentValues */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
EC2002E82C4167C5002EBD5F /* ShortcutKey.swift */,
|
|
||||||
);
|
|
||||||
path = EnvironmentValues;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
EC2002EE2C417BBF002EBD5F /* AppScene */ = {
|
EC2002EE2C417BBF002EBD5F /* AppScene */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@@ -587,7 +554,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
ECA738762BE5EE4E00A4542E /* App */,
|
ECA738762BE5EE4E00A4542E /* App */,
|
||||||
EC2002DE2C41645A002EBD5F /* Shortcut */,
|
EC2002D32C416002002EBD5F /* Commands */,
|
||||||
ECA7387E2BE5FE4200A4542E /* Canvas */,
|
ECA7387E2BE5FE4200A4542E /* Canvas */,
|
||||||
EC50500A2BF6672000B4D86E /* Components */,
|
EC50500A2BF6672000B4D86E /* Components */,
|
||||||
EC5050102BF670EE00B4D86E /* Config */,
|
EC5050102BF670EE00B4D86E /* Config */,
|
||||||
@@ -1164,7 +1131,6 @@
|
|||||||
EC01511E2C305CA9008A115E /* DashboardView.swift in Sources */,
|
EC01511E2C305CA9008A115E /* DashboardView.swift in Sources */,
|
||||||
EC8F54AE2C2AF5A4001C7C74 /* LineGridVertex.swift in Sources */,
|
EC8F54AE2C2AF5A4001C7C74 /* LineGridVertex.swift in Sources */,
|
||||||
EC2002F02C417BF1002EBD5F /* ActiveSceneKey.swift in Sources */,
|
EC2002F02C417BF1002EBD5F /* ActiveSceneKey.swift in Sources */,
|
||||||
EC2002E12C416470002EBD5F /* Shortcut.swift in Sources */,
|
|
||||||
EC5E83902BFDB69C00261D9C /* MovingAverage.swift in Sources */,
|
EC5E83902BFDB69C00261D9C /* MovingAverage.swift in Sources */,
|
||||||
ECFA15262BEF224900455818 /* StrokeObject.swift in Sources */,
|
ECFA15262BEF224900455818 /* StrokeObject.swift in Sources */,
|
||||||
ECA738FC2BE61C5200A4542E /* Persistence.swift in Sources */,
|
ECA738FC2BE61C5200A4542E /* Persistence.swift in Sources */,
|
||||||
@@ -1174,7 +1140,6 @@
|
|||||||
ECFA15222BEF21F500455818 /* CanvasObject.swift in Sources */,
|
ECFA15222BEF21F500455818 /* CanvasObject.swift in Sources */,
|
||||||
ECA738AA2BE6026D00A4542E /* Uniforms.swift in Sources */,
|
ECA738AA2BE6026D00A4542E /* Uniforms.swift in Sources */,
|
||||||
ECF7B2D12C39169C004D2C57 /* CGAffineTransform++.swift in Sources */,
|
ECF7B2D12C39169C004D2C57 /* CGAffineTransform++.swift in Sources */,
|
||||||
EC2002E52C416551002EBD5F /* Shortcuts.swift in Sources */,
|
|
||||||
EC2002DD2C4163E8002EBD5F /* AppCommands.swift in Sources */,
|
EC2002DD2C4163E8002EBD5F /* AppCommands.swift in Sources */,
|
||||||
EC1815082C2D980B00541369 /* Sort.swift in Sources */,
|
EC1815082C2D980B00541369 /* Sort.swift in Sources */,
|
||||||
EC6E3BD92C43C6C000DD20F3 /* OnDismissSearchViewModifier.swift in Sources */,
|
EC6E3BD92C43C6C000DD20F3 /* OnDismissSearchViewModifier.swift in Sources */,
|
||||||
@@ -1238,7 +1203,6 @@
|
|||||||
ECA7388F2BE600DA00A4542E /* Grid.metal in Sources */,
|
ECA7388F2BE600DA00A4542E /* Grid.metal in Sources */,
|
||||||
EC2BEBF42C0F5FF7005DB0AF /* RTree.swift in Sources */,
|
EC2BEBF42C0F5FF7005DB0AF /* RTree.swift in Sources */,
|
||||||
ECA738C92BE60EF700A4542E /* GraphicContext.swift in Sources */,
|
ECA738C92BE60EF700A4542E /* GraphicContext.swift in Sources */,
|
||||||
EC2002E92C4167C5002EBD5F /* ShortcutKey.swift in Sources */,
|
|
||||||
EC0D14212BF79C73009BFE5F /* ToolObject.swift in Sources */,
|
EC0D14212BF79C73009BFE5F /* ToolObject.swift in Sources */,
|
||||||
ECDAC07B2C318DBC0000ED77 /* ElementToolbar.swift in Sources */,
|
ECDAC07B2C318DBC0000ED77 /* ElementToolbar.swift in Sources */,
|
||||||
EC50500D2BF6674400B4D86E /* OnDragViewModifier.swift in Sources */,
|
EC50500D2BF6674400B4D86E /* OnDragViewModifier.swift in Sources */,
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import SwiftUI
|
|||||||
final class Application: NSObject, ObservableObject {
|
final class Application: NSObject, ObservableObject {
|
||||||
@Published var memoObject: MemoObject?
|
@Published var memoObject: MemoObject?
|
||||||
@Published private(set) var sidebarVisibility: SidebarVisibility = .shown
|
@Published private(set) var sidebarVisibility: SidebarVisibility = .shown
|
||||||
|
|
||||||
|
lazy var newMemoPublisher = PassthroughSubject<Void, Never>()
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Application {
|
extension Application {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct FileCommands: Commands {
|
struct FileCommands: Commands {
|
||||||
@Environment(\.shortcut) private var shortcut
|
|
||||||
@FocusedValue(\.activeSceneKey) private var appScene
|
@FocusedValue(\.activeSceneKey) private var appScene
|
||||||
|
|
||||||
@ObservedObject private var application: Application
|
@ObservedObject private var application: Application
|
||||||
@@ -31,7 +30,7 @@ struct FileCommands: Commands {
|
|||||||
#endif
|
#endif
|
||||||
if appScene == .memos {
|
if appScene == .memos {
|
||||||
Button {
|
Button {
|
||||||
shortcut.trigger(.newMemo)
|
application.newMemoPublisher.send()
|
||||||
} label: {
|
} label: {
|
||||||
Text("New Memo")
|
Text("New Memo")
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct MemosView: View {
|
struct MemosView: View {
|
||||||
@Environment(\.shortcut) private var shortcut
|
|
||||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||||
|
|
||||||
@EnvironmentObject private var application: Application
|
@EnvironmentObject private var application: Application
|
||||||
@@ -159,8 +158,10 @@ struct MemosView: View {
|
|||||||
.onReceive(timer) { date in
|
.onReceive(timer) { date in
|
||||||
currentDate = date
|
currentDate = date
|
||||||
}
|
}
|
||||||
.onReceive(shortcut.publisher) { shortcut in
|
.onReceive(application.newMemoPublisher) { shortcut in
|
||||||
handleShortcut(for: shortcut)
|
if application.memoObject == nil {
|
||||||
|
createMemo(title: "Untitled")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,15 +290,4 @@ struct MemosView: View {
|
|||||||
try context.saveIfNeeded()
|
try context.saveIfNeeded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func handleShortcut(for shortcut: Shortcuts) {
|
|
||||||
switch shortcut {
|
|
||||||
case .newMemo:
|
|
||||||
if application.memoObject == nil {
|
|
||||||
createMemo(title: "Untitled")
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct TrashView: View {
|
struct TrashView: View {
|
||||||
@Environment(\.shortcut) private var shortcut
|
|
||||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||||
|
|
||||||
@EnvironmentObject private var application: Application
|
@EnvironmentObject private var application: Application
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
//
|
|
||||||
// Shortcut.swift
|
|
||||||
// Memola
|
|
||||||
//
|
|
||||||
// Created by Dscyre Scotti on 7/12/24.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Combine
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
final class Shortcut {
|
|
||||||
static let shared: Shortcut = .init()
|
|
||||||
|
|
||||||
private let _publisher = PassthroughSubject<Shortcuts, Never>()
|
|
||||||
|
|
||||||
lazy var publisher: AnyPublisher<Shortcuts, Never> = {
|
|
||||||
_publisher.eraseToAnyPublisher()
|
|
||||||
}()
|
|
||||||
|
|
||||||
private init() { }
|
|
||||||
|
|
||||||
func trigger(_ shortcut: Shortcuts) {
|
|
||||||
_publisher.send(shortcut)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
//
|
|
||||||
// Shortcuts.swift
|
|
||||||
// Memola
|
|
||||||
//
|
|
||||||
// Created by Dscyre Scotti on 7/12/24.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
enum Shortcuts {
|
|
||||||
// MARK: - Memos
|
|
||||||
case newMemo
|
|
||||||
case findMemo
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
//
|
|
||||||
// ShortcutKey.swift
|
|
||||||
// Memola
|
|
||||||
//
|
|
||||||
// Created by Dscyre Scotti on 7/12/24.
|
|
||||||
//
|
|
||||||
|
|
||||||
import SwiftUI
|
|
||||||
|
|
||||||
private struct ShortcutKey: EnvironmentKey {
|
|
||||||
static var defaultValue: Shortcut = .shared
|
|
||||||
}
|
|
||||||
|
|
||||||
extension EnvironmentValues {
|
|
||||||
var shortcut: Shortcut {
|
|
||||||
get { self[ShortcutKey.self] }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -29,7 +29,6 @@ extension Color {
|
|||||||
extension Color {
|
extension Color {
|
||||||
var hsba: (hue: Double, saturation: Double, brightness: Double, alpha: Double) {
|
var hsba: (hue: Double, saturation: Double, brightness: Double, alpha: Double) {
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
#warning("TODO: need double check")
|
|
||||||
let nsColor = NSColor(self)
|
let nsColor = NSColor(self)
|
||||||
var hue: CGFloat = 0
|
var hue: CGFloat = 0
|
||||||
var saturation: CGFloat = 0
|
var saturation: CGFloat = 0
|
||||||
@@ -52,7 +51,6 @@ extension Color {
|
|||||||
extension Platform.Color {
|
extension Platform.Color {
|
||||||
var components: [CGFloat] {
|
var components: [CGFloat] {
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
#warning("TODO: need double check")
|
|
||||||
let nsColor: NSColor = self
|
let nsColor: NSColor = self
|
||||||
let ciColor: CIColor = .init(color: nsColor) ?? CIColor(red: 0, green: 0, blue: 0)
|
let ciColor: CIColor = .init(color: nsColor) ?? CIColor(red: 0, green: 0, blue: 0)
|
||||||
return [ciColor.red, ciColor.green, ciColor.blue, ciColor.alpha]
|
return [ciColor.red, ciColor.green, ciColor.blue, ciColor.alpha]
|
||||||
|
|||||||
Reference in New Issue
Block a user