mirror of
https://github.com/somegeekintn/SimDirs.git
synced 2026-04-24 14:27:44 +00:00
Added/refined some path actions
This commit is contained in:
parent
4cd720cce8
commit
56b1768cae
5 changed files with 86 additions and 42 deletions
|
|
@ -7,6 +7,8 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
C927A0D92846414900533D66 /* Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = C927A0D82846414900533D66 /* Helpers.swift */; };
|
||||
C927A0DB2846502300533D66 /* PathActions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C927A0DA2846502300533D66 /* PathActions.swift */; };
|
||||
C94C52C52844E7D400E2129E /* SimItemList.swift in Sources */ = {isa = PBXBuildFile; fileRef = C94C52C42844E7D400E2129E /* SimItemList.swift */; };
|
||||
C94C52C72844E80A00E2129E /* SimItemRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = C94C52C62844E80A00E2129E /* SimItemRow.swift */; };
|
||||
C94C52C92844E99B00E2129E /* SimItemContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = C94C52C82844E99B00E2129E /* SimItemContent.swift */; };
|
||||
|
|
@ -28,6 +30,8 @@
|
|||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
C927A0D82846414900533D66 /* Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Helpers.swift; sourceTree = "<group>"; };
|
||||
C927A0DA2846502300533D66 /* PathActions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PathActions.swift; sourceTree = "<group>"; };
|
||||
C94C52C42844E7D400E2129E /* SimItemList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimItemList.swift; sourceTree = "<group>"; };
|
||||
C94C52C62844E80A00E2129E /* SimItemRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimItemRow.swift; sourceTree = "<group>"; };
|
||||
C94C52C82844E99B00E2129E /* SimItemContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimItemContent.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -82,6 +86,7 @@
|
|||
children = (
|
||||
C982F858283B9F9000D491F4 /* SimDirsApp.swift */,
|
||||
C982F85A283B9F9000D491F4 /* ContentView.swift */,
|
||||
C927A0D82846414900533D66 /* Helpers.swift */,
|
||||
C982F867283BA09B00D491F4 /* Model */,
|
||||
C982F881283E7F0400D491F4 /* Views */,
|
||||
C982F85C283B9F9200D491F4 /* Assets.xcassets */,
|
||||
|
|
@ -127,6 +132,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
C982F882283E813F00D491F4 /* DeviceTypeView.swift */,
|
||||
C927A0DA2846502300533D66 /* PathActions.swift */,
|
||||
C94C52CA2844EAAC00E2129E /* RuntimeView.swift */,
|
||||
C94C52C82844E99B00E2129E /* SimItemContent.swift */,
|
||||
C94C52C42844E7D400E2129E /* SimItemList.swift */,
|
||||
|
|
@ -207,6 +213,7 @@
|
|||
files = (
|
||||
C982F883283E813F00D491F4 /* DeviceTypeView.swift in Sources */,
|
||||
C94C52C92844E99B00E2129E /* SimItemContent.swift in Sources */,
|
||||
C927A0DB2846502300533D66 /* PathActions.swift in Sources */,
|
||||
C982F85B283B9F9000D491F4 /* ContentView.swift in Sources */,
|
||||
C982F875283CEEBB00D491F4 /* SimDevice.swift in Sources */,
|
||||
C982F873283CE9AD00D491F4 /* SimDeviceType.swift in Sources */,
|
||||
|
|
@ -215,6 +222,7 @@
|
|||
C982F871283CE7B800D491F4 /* SimRuntime.swift in Sources */,
|
||||
C94C52C72844E80A00E2129E /* SimItemRow.swift in Sources */,
|
||||
C982F86B283BA22100D491F4 /* SimPlatform.swift in Sources */,
|
||||
C927A0D92846414900533D66 /* Helpers.swift in Sources */,
|
||||
C982F87E283E57B200D491F4 /* PresentableModel.swift in Sources */,
|
||||
C94C52CB2844EAAC00E2129E /* RuntimeView.swift in Sources */,
|
||||
C982F880283E57E600D491F4 /* PresentationItem.swift in Sources */,
|
||||
|
|
|
|||
23
SimDirs/Helpers.swift
Normal file
23
SimDirs/Helpers.swift
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// Helpers.swift
|
||||
// SimDirs
|
||||
//
|
||||
// Created by Casey Fleser on 5/31/22.
|
||||
//
|
||||
|
||||
import AppKit
|
||||
|
||||
extension NSPasteboard {
|
||||
static func copy(text: String) {
|
||||
general.clearContents()
|
||||
general.setData(text.data(using: .utf8), forType: .string)
|
||||
}
|
||||
}
|
||||
|
||||
extension NSWorkspace {
|
||||
static func reveal(filepath: String) {
|
||||
let filepathURL = URL(fileURLWithPath: filepath)
|
||||
|
||||
shared.activateFileViewerSelecting([filepathURL])
|
||||
}
|
||||
}
|
||||
|
|
@ -22,7 +22,11 @@ struct DeviceTypeView: View {
|
|||
Text("Identifier: \(deviceType.identifier)")
|
||||
Text("Min Runtime: \(deviceType.minRuntimeVersionString)")
|
||||
Text("Max Runtime: \(UInt32.max == deviceType.maxRuntimeVersion ? "-" : deviceType.maxRuntimeVersionString)")
|
||||
Text("Bundle Path: \(deviceType.bundlePath)")
|
||||
HStack {
|
||||
Text("Bundle Path: \(deviceType.bundlePath)")
|
||||
.lineLimit(1)
|
||||
PathActions(path: deviceType.bundlePath)
|
||||
}
|
||||
}
|
||||
.font(.subheadline)
|
||||
.textSelection(.enabled)
|
||||
|
|
|
|||
39
SimDirs/Views/PathActions.swift
Normal file
39
SimDirs/Views/PathActions.swift
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
//
|
||||
// PathActions.swift
|
||||
// SimDirs
|
||||
//
|
||||
// Created by Casey Fleser on 5/31/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct PathActions: View {
|
||||
var path : String
|
||||
|
||||
var body: some View {
|
||||
// ControlGroup almost but not quite what we want
|
||||
HStack {
|
||||
Button(action: { NSPasteboard.copy(text: path) }) {
|
||||
Image(systemName: "doc.on.doc") }
|
||||
Divider()
|
||||
.frame(height: 16.0)
|
||||
Button(action: { NSWorkspace.reveal(filepath: path) }) {
|
||||
Image(systemName: "arrow.right.circle.fill") }
|
||||
}
|
||||
.buttonStyle(.borderless)
|
||||
.padding(.vertical, 4.0)
|
||||
.padding(.horizontal, 8.0)
|
||||
.overlay(RoundedRectangle(cornerRadius: 6.0)
|
||||
.stroke(.white.opacity(0.4), lineWidth: 1.0))
|
||||
.background(.black.opacity(0.4))
|
||||
.cornerRadius(6.0)
|
||||
// based on scenePhase?
|
||||
// .shadow(color: .black.opacity(0.4), radius: 8.0, x: 4.0, y: 4.0)
|
||||
}
|
||||
}
|
||||
|
||||
struct PathActions_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
PathActions(path: "~/Desktop")
|
||||
}
|
||||
}
|
||||
|
|
@ -11,17 +11,19 @@ extension SimRuntime {
|
|||
var contentView : AnyView? { return AnyView(RuntimeView(runtime: self)) }
|
||||
}
|
||||
|
||||
struct UniqueItem: Identifiable {
|
||||
let name : String
|
||||
var id : String { return name }
|
||||
}
|
||||
|
||||
struct RuntimeView: View {
|
||||
var runtime : SimRuntime
|
||||
struct SupportedItem: Identifiable {
|
||||
let name : String
|
||||
var id : String { return name }
|
||||
}
|
||||
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
|
||||
var runtime : SimRuntime
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 2.0) {
|
||||
let items = runtime.supportedDeviceTypes.map({ UniqueItem(name: $0.name) })
|
||||
let items = runtime.supportedDeviceTypes.map({ SupportedItem(name: $0.name) })
|
||||
|
||||
Group {
|
||||
if !runtime.buildversion.isEmpty {
|
||||
|
|
@ -31,9 +33,10 @@ struct RuntimeView: View {
|
|||
if !runtime.bundlePath.isEmpty {
|
||||
HStack {
|
||||
Text("Bundle Path: \(runtime.bundlePath)")
|
||||
RuntimeActionGroup(runtime: runtime)
|
||||
PathActions(path: runtime.bundlePath)
|
||||
}
|
||||
}
|
||||
|
||||
Text(runtime.isAvailable ? "Available" : "Unavailable")
|
||||
.foregroundColor(runtime.isAvailable ? .green : .red)
|
||||
if !runtime.isAvailable {
|
||||
|
|
@ -65,36 +68,3 @@ struct RuntimeView_Previews: PreviewProvider {
|
|||
RuntimeView(runtime: model.runtimes[0])
|
||||
}
|
||||
}
|
||||
|
||||
struct RuntimeActionGroup: View {
|
||||
var runtime : SimRuntime
|
||||
|
||||
var body: some View {
|
||||
// ControlGroup almost but not quite what we want
|
||||
HStack {
|
||||
Button(action: { print("Go!") }) {
|
||||
Image(systemName: "doc.on.doc")
|
||||
}
|
||||
Divider()
|
||||
.frame(height: 16.0)
|
||||
Button(action: { print("Copy") }) {
|
||||
Image(systemName: "arrow.right.circle.fill")
|
||||
}
|
||||
}
|
||||
.buttonStyle(.borderless)
|
||||
.padding(.vertical, 4.0)
|
||||
.padding(.horizontal, 8.0)
|
||||
.background(.black.opacity(0.4))
|
||||
.font(.headline)
|
||||
.cornerRadius(6.0)
|
||||
}
|
||||
}
|
||||
|
||||
struct RuntimeActionGroup_Previews: PreviewProvider {
|
||||
static let model = SimModel()
|
||||
|
||||
static var previews: some View {
|
||||
RuntimeActionGroup(runtime: model.runtimes[0])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue