mirror of
https://github.com/dscyrescotti/Memola.git
synced 2026-07-08 05:45:17 +02: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
|
// MARK: - Photo
|
||||||
@Published var selectedPhotoItem: PhotoItem?
|
@Published var selectedPhotoItem: PhotoItem?
|
||||||
|
|
||||||
@Published var selection: ToolSelection = .none
|
@Published var selection: ToolSelection = .hand
|
||||||
|
|
||||||
let scrollPublisher = PassthroughSubject<String, Never>()
|
let scrollPublisher = PassthroughSubject<String, Never>()
|
||||||
var markers: [Pen] {
|
var markers: [Pen] {
|
||||||
@@ -32,6 +32,10 @@ public class Tool: NSObject, ObservableObject {
|
|||||||
self.object = object
|
self.object = object
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func selectTool(_ selection: ToolSelection) {
|
||||||
|
self.selection = selection
|
||||||
|
}
|
||||||
|
|
||||||
func load() {
|
func load() {
|
||||||
DispatchQueue.main.async { [weak self] in
|
DispatchQueue.main.async { [weak self] in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
enum ToolSelection: Equatable {
|
enum ToolSelection: Equatable {
|
||||||
case none
|
case hand
|
||||||
case pen
|
case pen
|
||||||
case photo
|
case photo
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -335,7 +335,7 @@ extension CanvasViewController {
|
|||||||
let enablesDrawing: Bool
|
let enablesDrawing: Bool
|
||||||
let enablesPhotoInsertion: Bool
|
let enablesPhotoInsertion: Bool
|
||||||
switch selection {
|
switch selection {
|
||||||
case .none:
|
case .hand:
|
||||||
enablesScrolling = true
|
enablesScrolling = true
|
||||||
enablesDrawing = false
|
enablesDrawing = false
|
||||||
enablesPhotoInsertion = false
|
enablesPhotoInsertion = false
|
||||||
|
|||||||
@@ -133,7 +133,20 @@ struct Toolbar: View {
|
|||||||
HStack(spacing: 0) {
|
HStack(spacing: 0) {
|
||||||
Button {
|
Button {
|
||||||
withAnimation {
|
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: {
|
} label: {
|
||||||
Image(systemName: "pencil")
|
Image(systemName: "pencil")
|
||||||
@@ -148,7 +161,7 @@ struct Toolbar: View {
|
|||||||
HStack(spacing: 0) {
|
HStack(spacing: 0) {
|
||||||
Button {
|
Button {
|
||||||
withAnimation {
|
withAnimation {
|
||||||
tool.selection = tool.selection == .photo ? .none : .photo
|
tool.selectTool(.photo)
|
||||||
}
|
}
|
||||||
} label: {
|
} label: {
|
||||||
Image(systemName: "photo")
|
Image(systemName: "photo")
|
||||||
|
|||||||
Reference in New Issue
Block a user