diff --git a/CHDataManagement.xcodeproj/project.pbxproj b/CHDataManagement.xcodeproj/project.pbxproj index e6b230e..7535ec4 100644 --- a/CHDataManagement.xcodeproj/project.pbxproj +++ b/CHDataManagement.xcodeproj/project.pbxproj @@ -93,6 +93,7 @@ E25DA5952D023BD100AEF16D /* PageSettingsDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E25DA5942D023BCC00AEF16D /* PageSettingsDetailView.swift */; }; E25DA5992D02401E00AEF16D /* PageGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = E25DA5982D02401A00AEF16D /* PageGenerator.swift */; }; E25DA59B2D024A2B00AEF16D /* DateItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = E25DA59A2D024A2900AEF16D /* DateItem.swift */; }; + E2720B882DF38BB700FDB543 /* Insert+Video.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2720B872DF38BB200FDB543 /* Insert+Video.swift */; }; E29D31202D0320E70051B7F4 /* ContentLabels.swift in Sources */ = {isa = PBXBuildFile; fileRef = E29D311F2D0320E20051B7F4 /* ContentLabels.swift */; }; E29D31222D0363FD0051B7F4 /* ContentButtons.swift in Sources */ = {isa = PBXBuildFile; fileRef = E29D31212D0363FA0051B7F4 /* ContentButtons.swift */; }; E29D31242D0366860051B7F4 /* TagList.swift in Sources */ = {isa = PBXBuildFile; fileRef = E29D31232D0366820051B7F4 /* TagList.swift */; }; @@ -376,6 +377,7 @@ E25DA5942D023BCC00AEF16D /* PageSettingsDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageSettingsDetailView.swift; sourceTree = ""; }; E25DA5982D02401A00AEF16D /* PageGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageGenerator.swift; sourceTree = ""; }; E25DA59A2D024A2900AEF16D /* DateItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateItem.swift; sourceTree = ""; }; + E2720B872DF38BB200FDB543 /* Insert+Video.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Insert+Video.swift"; sourceTree = ""; }; E29D311F2D0320E20051B7F4 /* ContentLabels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentLabels.swift; sourceTree = ""; }; E29D31212D0363FA0051B7F4 /* ContentButtons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentButtons.swift; sourceTree = ""; }; E29D31232D0366820051B7F4 /* TagList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagList.swift; sourceTree = ""; }; @@ -1129,6 +1131,7 @@ E2EC1FB32DC0FA6D00C41784 /* Insert+Route.swift */, E2FD1D552D46CED500B48627 /* Insert+Labels.swift */, E2F3B3842DC49B4400CFA712 /* Insert+Gallery.swift */, + E2720B872DF38BB200FDB543 /* Insert+Video.swift */, ); path = Commands; sourceTree = ""; @@ -1472,6 +1475,7 @@ E2FE0EEE2D1C22F3002963B7 /* MarkdownLinkProcessor.swift in Sources */, E2FE0F602D2C0422002963B7 /* VideoBlock.swift in Sources */, E2B482032D5D1331005C309D /* WebServer.swift in Sources */, + E2720B882DF38BB700FDB543 /* Insert+Video.swift in Sources */, E2FE0F022D266FCB002963B7 /* LocalizedNavigationSettings.swift in Sources */, E29D313F2D04822C0051B7F4 /* AddPostView.swift in Sources */, E25DA5752D018B6100AEF16D /* FileDetailView.swift in Sources */, @@ -1763,7 +1767,7 @@ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 15.0; - MARKETING_VERSION = 1.1.1; + MARKETING_VERSION = 1.2; PRODUCT_BUNDLE_IDENTIFIER = de.christophhagen.CHDataManagement; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = auto; @@ -1802,7 +1806,7 @@ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 15.0; - MARKETING_VERSION = 1.1.1; + MARKETING_VERSION = 1.2; PRODUCT_BUNDLE_IDENTIFIER = de.christophhagen.CHDataManagement; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = auto; diff --git a/CHDataManagement/Views/Pages/Commands/Insert+Video.swift b/CHDataManagement/Views/Pages/Commands/Insert+Video.swift new file mode 100644 index 0000000..65f60cd --- /dev/null +++ b/CHDataManagement/Views/Pages/Commands/Insert+Video.swift @@ -0,0 +1,116 @@ +import SwiftUI +import SFSafeSymbols + +struct InsertableVideo: View, InsertableCommandView { + + final class Model: ObservableObject, InsertableCommandModel { + + @Published + var posterImage: FileResource? + + @Published + var videoH265: FileResource? + + @Published + var videoH264: FileResource? + + @Published + var videoWebm: FileResource? + + @Published + var controls: Bool = false + + @Published + var autoplay: Bool = false + + @Published + var loop: Bool = false + + @Published + var muted: Bool = false + + @Published + var playsinline = false + + @Published + var preload = false + + var isReady: Bool { + videoH265 != nil || videoH264 != nil + } + + init() { + + } + + var command: String? { + var lines: [String] = [] + lines.append("```video") + if let posterImage { + lines.append("\(VideoBlock.Key.poster): \(posterImage.id)") + } + if let videoH265 { + lines.append("\(VideoBlock.Key.h265): \(videoH265.id)") + } + if let videoH264 { + lines.append("\(VideoBlock.Key.h264): \(videoH264.id)") + } + if let videoWebm { + lines.append("\(VideoBlock.Key.webm): \(videoWebm.id)") + } + if controls { lines.append(VideoBlock.Key.controls.rawValue) } + if autoplay { lines.append(VideoBlock.Key.autoplay.rawValue) } + if loop { lines.append(VideoBlock.Key.loop.rawValue) } + if muted { lines.append(VideoBlock.Key.muted.rawValue) } + if playsinline { lines.append(VideoBlock.Key.playsinline.rawValue) } + if preload { lines.append(VideoBlock.Key.preload.rawValue) } + + lines.append("```") + return lines.joined(separator: "\n") + } + } + + static let title = "Video" + + static let sheetTitle = "Insert video" + + static let icon: SFSymbol = .movieclapper + + @ObservedObject + private var model: Model + + init(model: Model) { + self.model = model + } + + var body: some View { + VStack { + FilePropertyView( + title: "Video (h265)", + footer: "Select the video encoded using h265", + selectedFile: $model.videoH265, + allowedType: .video) + FilePropertyView( + title: "Video (h264)", + footer: "Select the video encoded using h264", + selectedFile: $model.videoH264, + allowedType: .video) + FilePropertyView( + title: "Poster image", + footer: "Select the image to show as the poster", + selectedFile: $model.posterImage, + allowedType: .image) + HStack { + Toggle("controls", isOn: $model.controls) + Toggle("autoplay", isOn: $model.autoplay) + Toggle("loop", isOn: $model.loop) + } + HStack { + Toggle("muted", isOn: $model.muted) + Toggle("playsinline", isOn: $model.playsinline) + Toggle("preload", isOn: $model.preload) + } + } + .toggleStyle(.checkbox) + } +} diff --git a/CHDataManagement/Views/Pages/Commands/InsertableItemsView.swift b/CHDataManagement/Views/Pages/Commands/InsertableItemsView.swift index d92cfd2..7575b63 100644 --- a/CHDataManagement/Views/Pages/Commands/InsertableItemsView.swift +++ b/CHDataManagement/Views/Pages/Commands/InsertableItemsView.swift @@ -4,9 +4,8 @@ struct InsertableItemsView: View { var body: some View { HStack { - Text("Commands") - .font(.headline) InsertableView() + InsertableView() InsertableView() InsertableView() InsertableView()