make name the core block info
This commit is contained in:
@@ -4,8 +4,8 @@ import Foundation
|
||||
final class PHBlock: ObservableObject, Decodable, Identifiable {
|
||||
let id = UUID()
|
||||
|
||||
let command: String
|
||||
let name: String?
|
||||
let name: String
|
||||
let _command: String?
|
||||
let textName: String?
|
||||
@Published var text: PHThemeText = .default
|
||||
let styleName: String?
|
||||
@@ -14,6 +14,10 @@ final class PHBlock: ObservableObject, Decodable, Identifiable {
|
||||
let centered: Bool?
|
||||
var debug: Bool = false
|
||||
|
||||
var command: String {
|
||||
_command ?? PHPaths.configDirectory.appending(path: "scripts/\(name)").relativePath
|
||||
}
|
||||
|
||||
var visible: Bool {
|
||||
label != nil && !label!.isEmpty
|
||||
}
|
||||
@@ -39,7 +43,8 @@ final class PHBlock: ObservableObject, Decodable, Identifiable {
|
||||
var updateScheduled = false
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case command, name
|
||||
case name
|
||||
case _command = "command"
|
||||
case textName = "text"
|
||||
case styleName = "style"
|
||||
case refresh, events, centered
|
||||
|
||||
@@ -4,7 +4,7 @@ enum PHBlockKind: String {
|
||||
|
||||
extension PHBlock {
|
||||
var kind: PHBlockKind {
|
||||
if command.starts(with: "_space") { return .space }
|
||||
if name.starts(with: "_space") { return .space }
|
||||
return .text
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ struct SpaceBlockView: View {
|
||||
@ObservedObject var block: PHBlock
|
||||
|
||||
var width: CGFloat? {
|
||||
guard let arg = block.command.split(separator: " ").last else { return nil }
|
||||
guard let arg = block.name.split(separator: " ").last else { return nil }
|
||||
guard let width = Double(arg) else { return nil }
|
||||
return CGFloat(width)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user