mirror of
https://github.com/dscyrescotti/Memola.git
synced 2026-03-20 08:34:05 +01:00
refactor: rename view variables and methods
This commit is contained in:
@@ -75,7 +75,7 @@
|
||||
ECA738F42BE612A000A4542E /* Array++.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECA738F32BE612A000A4542E /* Array++.swift */; };
|
||||
ECA738F62BE612B700A4542E /* MTLDevice++.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECA738F52BE612B700A4542E /* MTLDevice++.swift */; };
|
||||
ECA738FC2BE61C5200A4542E /* Persistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECA738FB2BE61C5200A4542E /* Persistence.swift */; };
|
||||
ECA739082BE623F300A4542E /* PenDockView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECA739072BE623F300A4542E /* PenDockView.swift */; };
|
||||
ECA739082BE623F300A4542E /* PenDock.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECA739072BE623F300A4542E /* PenDock.swift */; };
|
||||
ECEC01A82BEE11BA006DA24C /* QuadShape.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECEC01A72BEE11BA006DA24C /* QuadShape.swift */; };
|
||||
ECFA15202BEF21EF00455818 /* MemoObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECFA151F2BEF21EF00455818 /* MemoObject.swift */; };
|
||||
ECFA15222BEF21F500455818 /* CanvasObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECFA15212BEF21F500455818 /* CanvasObject.swift */; };
|
||||
@@ -156,7 +156,7 @@
|
||||
ECA738F32BE612A000A4542E /* Array++.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Array++.swift"; sourceTree = "<group>"; };
|
||||
ECA738F52BE612B700A4542E /* MTLDevice++.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MTLDevice++.swift"; sourceTree = "<group>"; };
|
||||
ECA738FB2BE61C5200A4542E /* Persistence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Persistence.swift; sourceTree = "<group>"; };
|
||||
ECA739072BE623F300A4542E /* PenDockView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PenDockView.swift; sourceTree = "<group>"; };
|
||||
ECA739072BE623F300A4542E /* PenDock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PenDock.swift; sourceTree = "<group>"; };
|
||||
ECEC01A72BEE11BA006DA24C /* QuadShape.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuadShape.swift; sourceTree = "<group>"; };
|
||||
ECFA151F2BEF21EF00455818 /* MemoObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MemoObject.swift; sourceTree = "<group>"; };
|
||||
ECFA15212BEF21F500455818 /* CanvasObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CanvasObject.swift; sourceTree = "<group>"; };
|
||||
@@ -220,7 +220,7 @@
|
||||
EC5050052BF65CCD00B4D86E /* PenDock */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
ECA739072BE623F300A4542E /* PenDockView.swift */,
|
||||
ECA739072BE623F300A4542E /* PenDock.swift */,
|
||||
EC5050062BF65CED00B4D86E /* PenDropDelegate.swift */,
|
||||
);
|
||||
path = PenDock;
|
||||
@@ -731,7 +731,7 @@
|
||||
ECA738862BE5FF2500A4542E /* Canvas.swift in Sources */,
|
||||
ECA738882BE5FF4400A4542E /* Renderer.swift in Sources */,
|
||||
ECA738D42BE60F9100A4542E /* StrokeGenerator.swift in Sources */,
|
||||
ECA739082BE623F300A4542E /* PenDockView.swift in Sources */,
|
||||
ECA739082BE623F300A4542E /* PenDock.swift in Sources */,
|
||||
ECA738CB2BE60F1900A4542E /* ViewPortContext.swift in Sources */,
|
||||
ECA738EE2BE6125D00A4542E /* simd_float4x4++.swift in Sources */,
|
||||
ECA7388C2BE6009600A4542E /* Textures.swift in Sources */,
|
||||
|
||||
@@ -28,7 +28,7 @@ struct MemoView: View {
|
||||
CanvasView()
|
||||
.ignoresSafeArea()
|
||||
.overlay(alignment: .trailing) {
|
||||
PenDockView()
|
||||
PenDock()
|
||||
.frame(maxHeight: .infinity)
|
||||
.padding()
|
||||
}
|
||||
@@ -40,9 +40,9 @@ struct MemoView: View {
|
||||
.overlay {
|
||||
switch canvas.state {
|
||||
case .loading:
|
||||
progressView("Loading memo...")
|
||||
loadingIndicator("Loading memo...")
|
||||
case .closing:
|
||||
progressView("Saving memo...")
|
||||
loadingIndicator("Saving memo...")
|
||||
default:
|
||||
EmptyView()
|
||||
}
|
||||
@@ -52,7 +52,7 @@ struct MemoView: View {
|
||||
.environmentObject(history)
|
||||
}
|
||||
|
||||
func progressView(_ title: String) -> some View {
|
||||
func loadingIndicator(_ title: String) -> some View {
|
||||
ProgressView {
|
||||
Text(title)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// PenDockView.swift
|
||||
// PenDock.swift
|
||||
// Memola
|
||||
//
|
||||
// Created by Dscyre Scotti on 5/4/24.
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct PenDockView: View {
|
||||
struct PenDock: View {
|
||||
@EnvironmentObject var tool: Tool
|
||||
|
||||
let width: CGFloat = 90
|
||||
@@ -19,33 +19,18 @@ struct PenDockView: View {
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .trailing) {
|
||||
if let pen = tool.selectedPen {
|
||||
VStack(spacing: 5) {
|
||||
penColorView(pen)
|
||||
penThicknessView(pen)
|
||||
}
|
||||
.padding(10)
|
||||
.frame(width: width * factor - 18)
|
||||
.background {
|
||||
RoundedRectangle(cornerRadius: 20)
|
||||
.fill(.regularMaterial)
|
||||
}
|
||||
.transition(.move(edge: .trailing).combined(with: .opacity))
|
||||
} else {
|
||||
Color.clear
|
||||
.frame(width: width * factor - 18, height: 50)
|
||||
}
|
||||
penScrollView
|
||||
penPropertyTool
|
||||
penItemList
|
||||
}
|
||||
.fixedSize()
|
||||
}
|
||||
|
||||
var penScrollView: some View {
|
||||
var penItemList: some View {
|
||||
ScrollViewReader { proxy in
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
LazyVStack(spacing: 0) {
|
||||
ForEach(tool.pens) { pen in
|
||||
penView(pen)
|
||||
penItemRow(pen)
|
||||
.id(pen.id)
|
||||
.scrollTransition { content, phase in
|
||||
content
|
||||
@@ -79,9 +64,9 @@ struct PenDockView: View {
|
||||
}
|
||||
}
|
||||
|
||||
func penView(_ pen: Pen) -> some View {
|
||||
func penItemRow(_ pen: Pen) -> some View {
|
||||
ZStack {
|
||||
penShadowView(pen)
|
||||
penShadow(pen)
|
||||
if let tip = pen.style.icon.tip {
|
||||
Image(tip)
|
||||
.resizable()
|
||||
@@ -139,7 +124,7 @@ struct PenDockView: View {
|
||||
}
|
||||
.controlGroupStyle(.menu)
|
||||
} preview: {
|
||||
penPreviewView(pen)
|
||||
penPreview(pen)
|
||||
.drawingGroup()
|
||||
.contentShape(.contextMenuPreview, .rect(cornerRadius: 10))
|
||||
}
|
||||
@@ -147,14 +132,34 @@ struct PenDockView: View {
|
||||
tool.draggedPen = pen
|
||||
return NSItemProvider(contentsOf: URL(string: pen.id)) ?? NSItemProvider()
|
||||
} preview: {
|
||||
penPreviewView(pen)
|
||||
penPreview(pen)
|
||||
.contentShape(.dragPreview, .rect(cornerRadius: 10))
|
||||
}
|
||||
.onDrop(of: [.item], delegate: PenDropDelegate(id: pen.id, tool: tool, action: { refreshScrollId = UUID() }))
|
||||
.offset(x: tool.selectedPen === pen ? 0 : 25)
|
||||
}
|
||||
|
||||
func penColorView(_ pen: Pen) -> some View {
|
||||
@ViewBuilder
|
||||
var penPropertyTool: some View {
|
||||
if let pen = tool.selectedPen {
|
||||
VStack(spacing: 5) {
|
||||
penColorPicker(pen)
|
||||
penThicknessPicker(pen)
|
||||
}
|
||||
.padding(10)
|
||||
.frame(width: width * factor - 18)
|
||||
.background {
|
||||
RoundedRectangle(cornerRadius: 20)
|
||||
.fill(.regularMaterial)
|
||||
}
|
||||
.transition(.move(edge: .trailing).combined(with: .opacity))
|
||||
} else {
|
||||
Color.clear
|
||||
.frame(width: width * factor - 18, height: 50)
|
||||
}
|
||||
}
|
||||
|
||||
func penColorPicker(_ pen: Pen) -> some View {
|
||||
Button {
|
||||
opensColorPicker = true
|
||||
} label: {
|
||||
@@ -199,7 +204,7 @@ struct PenDockView: View {
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
func penThicknessView(_ pen: Pen) -> some View {
|
||||
func penThicknessPicker(_ pen: Pen) -> some View {
|
||||
let minimum: CGFloat = pen.style.thickness.min
|
||||
let maximum: CGFloat = pen.style.thickness.max
|
||||
let start: CGFloat = 5
|
||||
@@ -254,7 +259,7 @@ struct PenDockView: View {
|
||||
.hoverEffect(.lift)
|
||||
}
|
||||
|
||||
func penPreviewView(_ pen: Pen) -> some View {
|
||||
func penPreview(_ pen: Pen) -> some View {
|
||||
ZStack {
|
||||
if let tip = pen.style.icon.tip {
|
||||
Image(tip)
|
||||
@@ -270,7 +275,7 @@ struct PenDockView: View {
|
||||
.padding(.leading, 10)
|
||||
}
|
||||
|
||||
func penShadowView(_ pen: Pen) -> some View {
|
||||
func penShadow(_ pen: Pen) -> some View {
|
||||
ZStack {
|
||||
Group {
|
||||
if let tip = pen.style.icon.tip {
|
||||
Reference in New Issue
Block a user