diff --git a/Memola/Canvas/Tool/Core/Tool.swift b/Memola/Canvas/Tool/Core/Tool.swift index 4c837c2..0f604c2 100644 --- a/Memola/Canvas/Tool/Core/Tool.swift +++ b/Memola/Canvas/Tool/Core/Tool.swift @@ -21,7 +21,7 @@ public class Tool: NSObject, ObservableObject { // MARK: - Photo @Published var selectedPhotoItem: PhotoItem? - @Published var selection: ToolSelection = .none + @Published var selection: ToolSelection = .hand let scrollPublisher = PassthroughSubject() var markers: [Pen] { @@ -32,6 +32,10 @@ public class Tool: NSObject, ObservableObject { self.object = object } + func selectTool(_ selection: ToolSelection) { + self.selection = selection + } + func load() { DispatchQueue.main.async { [weak self] in guard let self else { return } diff --git a/Memola/Canvas/Tool/Core/ToolSelection.swift b/Memola/Canvas/Tool/Core/ToolSelection.swift index 76c3589..ed3fc26 100644 --- a/Memola/Canvas/Tool/Core/ToolSelection.swift +++ b/Memola/Canvas/Tool/Core/ToolSelection.swift @@ -8,7 +8,7 @@ import Foundation enum ToolSelection: Equatable { - case none + case hand case pen case photo } diff --git a/Memola/Canvas/View/Bridge/ViewController/CanvasViewController.swift b/Memola/Canvas/View/Bridge/ViewController/CanvasViewController.swift index a21f7fb..00347cb 100644 --- a/Memola/Canvas/View/Bridge/ViewController/CanvasViewController.swift +++ b/Memola/Canvas/View/Bridge/ViewController/CanvasViewController.swift @@ -335,7 +335,7 @@ extension CanvasViewController { let enablesDrawing: Bool let enablesPhotoInsertion: Bool switch selection { - case .none: + case .hand: enablesScrolling = true enablesDrawing = false enablesPhotoInsertion = false diff --git a/Memola/Features/Memo/Toolbar/Toolbar.swift b/Memola/Features/Memo/Toolbar/Toolbar.swift index 980f2a9..c341bad 100644 --- a/Memola/Features/Memo/Toolbar/Toolbar.swift +++ b/Memola/Features/Memo/Toolbar/Toolbar.swift @@ -133,7 +133,20 @@ struct Toolbar: View { HStack(spacing: 0) { Button { withAnimation { - tool.selection = tool.selection == .pen ? .none : .pen + tool.selectTool(.hand) + } + } label: { + Image(systemName: "hand.draw.fill") + .fontWeight(.heavy) + .contentShape(.circle) + .frame(width: size, height: size) + .background(tool.selection == .hand ? Color.accentColor : Color.clear) + .foregroundStyle(tool.selection == .hand ? Color.white : Color.accentColor) + .clipShape(.rect(cornerRadius: 8)) + } + Button { + withAnimation { + tool.selectTool(.pen) } } label: { Image(systemName: "pencil") @@ -148,7 +161,7 @@ struct Toolbar: View { HStack(spacing: 0) { Button { withAnimation { - tool.selection = tool.selection == .photo ? .none : .photo + tool.selectTool(.photo) } } label: { Image(systemName: "photo")