mirror of
https://github.com/dscyrescotti/Memola.git
synced 2026-03-19 16:21:18 +01:00
feat: add hand button in element tool bar
This commit is contained in:
@@ -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<String, Never>()
|
||||
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 }
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import Foundation
|
||||
|
||||
enum ToolSelection: Equatable {
|
||||
case none
|
||||
case hand
|
||||
case pen
|
||||
case photo
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ extension CanvasViewController {
|
||||
let enablesDrawing: Bool
|
||||
let enablesPhotoInsertion: Bool
|
||||
switch selection {
|
||||
case .none:
|
||||
case .hand:
|
||||
enablesScrolling = true
|
||||
enablesDrawing = false
|
||||
enablesPhotoInsertion = false
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user