mirror of
https://github.com/somegeekintn/SimDirs.git
synced 2026-04-26 14:47:41 +00:00
More item specific content views and other assorted refinements
This commit is contained in:
parent
350a2aa3ac
commit
623e8cd975
10 changed files with 323 additions and 74 deletions
|
|
@ -7,6 +7,10 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
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 */; };
|
||||
C94C52CB2844EAAC00E2129E /* RuntimeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C94C52CA2844EAAC00E2129E /* RuntimeView.swift */; };
|
||||
C982F859283B9F9000D491F4 /* SimDirsApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C982F858283B9F9000D491F4 /* SimDirsApp.swift */; };
|
||||
C982F85B283B9F9000D491F4 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C982F85A283B9F9000D491F4 /* ContentView.swift */; };
|
||||
C982F85D283B9F9200D491F4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C982F85C283B9F9200D491F4 /* Assets.xcassets */; };
|
||||
|
|
@ -24,6 +28,10 @@
|
|||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
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>"; };
|
||||
C94C52CA2844EAAC00E2129E /* RuntimeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuntimeView.swift; sourceTree = "<group>"; };
|
||||
C982F855283B9F9000D491F4 /* SimDirs.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SimDirs.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
C982F858283B9F9000D491F4 /* SimDirsApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimDirsApp.swift; sourceTree = "<group>"; };
|
||||
C982F85A283B9F9000D491F4 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -119,6 +127,10 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
C982F882283E813F00D491F4 /* DeviceTypeView.swift */,
|
||||
C94C52CA2844EAAC00E2129E /* RuntimeView.swift */,
|
||||
C94C52C82844E99B00E2129E /* SimItemContent.swift */,
|
||||
C94C52C42844E7D400E2129E /* SimItemList.swift */,
|
||||
C94C52C62844E80A00E2129E /* SimItemRow.swift */,
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -194,16 +206,20 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C982F883283E813F00D491F4 /* DeviceTypeView.swift in Sources */,
|
||||
C94C52C92844E99B00E2129E /* SimItemContent.swift in Sources */,
|
||||
C982F85B283B9F9000D491F4 /* ContentView.swift in Sources */,
|
||||
C982F875283CEEBB00D491F4 /* SimDevice.swift in Sources */,
|
||||
C982F873283CE9AD00D491F4 /* SimDeviceType.swift in Sources */,
|
||||
C982F877283D020C00D491F4 /* SimProductFamily.swift in Sources */,
|
||||
C982F859283B9F9000D491F4 /* SimDirsApp.swift in Sources */,
|
||||
C982F871283CE7B800D491F4 /* SimRuntime.swift in Sources */,
|
||||
C94C52C72844E80A00E2129E /* SimItemRow.swift in Sources */,
|
||||
C982F86B283BA22100D491F4 /* SimPlatform.swift in Sources */,
|
||||
C982F87E283E57B200D491F4 /* PresentableModel.swift in Sources */,
|
||||
C94C52CB2844EAAC00E2129E /* RuntimeView.swift in Sources */,
|
||||
C982F880283E57E600D491F4 /* PresentationItem.swift in Sources */,
|
||||
C982F879283D042E00D491F4 /* SimModel.swift in Sources */,
|
||||
C94C52C52844E7D400E2129E /* SimItemList.swift in Sources */,
|
||||
C982F87B283E40C800D491F4 /* SimCtl.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
|
|
|||
78
SimDirs.xcodeproj/xcshareddata/xcschemes/SimDirs.xcscheme
Normal file
78
SimDirs.xcodeproj/xcshareddata/xcschemes/SimDirs.xcscheme
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1340"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "C982F854283B9F9000D491F4"
|
||||
BuildableName = "SimDirs.app"
|
||||
BlueprintName = "SimDirs"
|
||||
ReferencedContainer = "container:SimDirs.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "C982F854283B9F9000D491F4"
|
||||
BuildableName = "SimDirs.app"
|
||||
BlueprintName = "SimDirs"
|
||||
ReferencedContainer = "container:SimDirs.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "C982F854283B9F9000D491F4"
|
||||
BuildableName = "SimDirs.app"
|
||||
BlueprintName = "SimDirs"
|
||||
ReferencedContainer = "container:SimDirs.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
|
|
@ -7,68 +7,10 @@
|
|||
|
||||
import SwiftUI
|
||||
|
||||
struct Item: Identifiable {
|
||||
var id: Int
|
||||
var name: String
|
||||
|
||||
init(id: Int) {
|
||||
self.id = id
|
||||
self.name = "\(id)"
|
||||
}
|
||||
}
|
||||
|
||||
struct ContentView: View {
|
||||
@EnvironmentObject var modelData : PresentableModel
|
||||
@State private var toggleVal = false
|
||||
|
||||
let testItems = (0..<10).map({ Item(id: $0) })
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
List {
|
||||
OutlineGroup(modelData.items, children: \.children) { item in
|
||||
NavigationLink {
|
||||
VStack {
|
||||
HStack {
|
||||
switch item.underlying {
|
||||
case let deviceType as SimDeviceType:
|
||||
DeviceTypeView(deviceType: deviceType)
|
||||
|
||||
default:
|
||||
Text("\(item.title)")
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
.padding(.all)
|
||||
.navigationTitle(item.title)
|
||||
} label: {
|
||||
Label(item.title, systemImage: item.imageName)
|
||||
}
|
||||
}
|
||||
.padding(.leading, 2.0)
|
||||
}
|
||||
.frame(minWidth: 200)
|
||||
.toolbar {
|
||||
ToolbarItem {
|
||||
Menu {
|
||||
// Picker("Category", selection: $filter) {
|
||||
// ForEach(FilterCategory.allCases) { category in
|
||||
// Text(category.rawValue).tag(category)
|
||||
// }
|
||||
// }
|
||||
// .pickerStyle(.inline)
|
||||
Toggle(isOn: $toggleVal) {
|
||||
Label("Toggle", systemImage: "star.fill")
|
||||
}
|
||||
} label: {
|
||||
Label("Filter", systemImage: "slider.horizontal.3")
|
||||
}
|
||||
}
|
||||
}
|
||||
Text("SimDirs") // If this isn't here things looks weird
|
||||
}
|
||||
SimItemList()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,16 +11,13 @@ protocol PresentableItem {
|
|||
var title : String { get }
|
||||
var id : String { get }
|
||||
var imageName : String { get }
|
||||
var imageColor : Color? { get }
|
||||
var contentView : AnyView? { get }
|
||||
}
|
||||
|
||||
protocol PresentableContent {
|
||||
associatedtype Content : View
|
||||
|
||||
var view : Content { get }
|
||||
}
|
||||
|
||||
struct PresentationContent<T: PresentableContent> {
|
||||
let underlying : T
|
||||
extension PresentableItem {
|
||||
var imageColor : Color? { return nil }
|
||||
var contentView : AnyView? { return nil }
|
||||
}
|
||||
|
||||
struct PresentationItem: Identifiable {
|
||||
|
|
@ -31,6 +28,8 @@ struct PresentationItem: Identifiable {
|
|||
|
||||
var title : String { return underlying.title }
|
||||
var imageName : String { return customImage ?? underlying.imageName }
|
||||
var imageColor : Color { return underlying.imageColor ?? .white }
|
||||
var contentView : AnyView { return underlying.contentView ?? AnyView(Text(title)) }
|
||||
|
||||
init(_ presentable: PresentableItem, image: String? = nil, identifier: String? = nil) {
|
||||
underlying = presentable
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
// Created by Casey Fleser on 5/24/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
struct SimRuntime: Comparable, Decodable {
|
||||
enum CodingKeys: String, CodingKey {
|
||||
|
|
@ -117,6 +117,7 @@ extension SimRuntime: PresentableItem {
|
|||
var title : String { return name }
|
||||
var id : String { return identifier }
|
||||
var imageName : String { return "v.circle" }
|
||||
var imageColor : Color? { return isAvailable ? .green : .red }
|
||||
}
|
||||
|
||||
extension Array where Element == SimRuntime {
|
||||
|
|
|
|||
|
|
@ -7,14 +7,15 @@
|
|||
|
||||
import SwiftUI
|
||||
|
||||
extension SimDeviceType {
|
||||
var contentView : AnyView? { return AnyView(DeviceTypeView(deviceType: self)) }
|
||||
}
|
||||
|
||||
struct DeviceTypeView: View {
|
||||
var deviceType : SimDeviceType
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 2.0) {
|
||||
// Text(deviceType.name)
|
||||
// .font(.title)
|
||||
// .padding(.bottom, 5.0)
|
||||
Group {
|
||||
Text("Product Family: \(deviceType.productFamily.title)")
|
||||
Text("Model ID: \(deviceType.modelIdentifier)")
|
||||
|
|
@ -24,15 +25,15 @@ struct DeviceTypeView: View {
|
|||
Text("Bundle Path: \(deviceType.bundlePath)")
|
||||
}
|
||||
.font(.subheadline)
|
||||
.textSelection(.enabled)
|
||||
}
|
||||
// .background(Color.red)
|
||||
}
|
||||
}
|
||||
|
||||
struct DeviceTypeView_Previews: PreviewProvider {
|
||||
static let model = PresentableModel().baseModel
|
||||
static let model = SimModel()
|
||||
|
||||
static var previews: some View {
|
||||
DeviceTypeView(deviceType: model.deviceTypes[26])
|
||||
DeviceTypeView(deviceType: model.deviceTypes[0])
|
||||
}
|
||||
}
|
||||
|
|
|
|||
95
SimDirs/Views/RuntimeView.swift
Normal file
95
SimDirs/Views/RuntimeView.swift
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
//
|
||||
// RuntimeView.swift
|
||||
// SimDirs
|
||||
//
|
||||
// Created by Casey Fleser on 5/30/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
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
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 2.0) {
|
||||
let items = runtime.supportedDeviceTypes.map({ UniqueItem(name: $0.name) })
|
||||
|
||||
Group {
|
||||
Text("Build Version: \(runtime.buildversion)")
|
||||
HStack {
|
||||
Text("Bundle Path: \(runtime.bundlePath)")
|
||||
RuntimeActionGroup(runtime: runtime)
|
||||
}
|
||||
Text(runtime.isAvailable ? "Available" : "Unavailable")
|
||||
.foregroundColor(runtime.isAvailable ? .green : .red)
|
||||
if !runtime.isAvailable {
|
||||
let errText = runtime.availabilityError ?? "Unknown Error"
|
||||
|
||||
Text(errText)
|
||||
.foregroundColor(.red)
|
||||
.padding(.leading)
|
||||
}
|
||||
|
||||
Divider()
|
||||
.padding(.vertical, 4.0)
|
||||
Text("Supports\(runtime.isPlaceholder ? " (partial list)" : "")")
|
||||
ForEach(items) { item in
|
||||
Text("• \(item.name)")
|
||||
}
|
||||
.padding(.leading)
|
||||
}
|
||||
.font(.subheadline)
|
||||
.textSelection(.enabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct RuntimeView_Previews: PreviewProvider {
|
||||
static let model = SimModel()
|
||||
|
||||
static var previews: some View {
|
||||
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])
|
||||
}
|
||||
}
|
||||
|
||||
34
SimDirs/Views/SimItemContent.swift
Normal file
34
SimDirs/Views/SimItemContent.swift
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
// SimItemContent.swift
|
||||
// SimDirs
|
||||
//
|
||||
// Created by Casey Fleser on 5/30/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SimItemContent: View {
|
||||
var item : PresentationItem
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
VStack {
|
||||
HStack {
|
||||
item.contentView
|
||||
Spacer()
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
.padding(.all)
|
||||
.navigationTitle(item.title)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SimItemContent_Previews: PreviewProvider {
|
||||
static var model = PresentableModel()
|
||||
|
||||
static var previews: some View {
|
||||
SimItemContent(item: model.items[0].children![0])
|
||||
}
|
||||
}
|
||||
54
SimDirs/Views/SimItemList.swift
Normal file
54
SimDirs/Views/SimItemList.swift
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
//
|
||||
// SimItemList.swift
|
||||
// SimDirs
|
||||
//
|
||||
// Created by Casey Fleser on 5/30/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SimItemList: View {
|
||||
@EnvironmentObject var modelData : PresentableModel
|
||||
@State private var toggleVal = false
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
List {
|
||||
OutlineGroup(modelData.items, children: \.children) { item in
|
||||
NavigationLink {
|
||||
SimItemContent(item: item)
|
||||
} label: {
|
||||
SimItemRow(item: item)
|
||||
}
|
||||
}
|
||||
.padding(.leading, 2.0)
|
||||
}
|
||||
.frame(minWidth: 200)
|
||||
.toolbar {
|
||||
ToolbarItem {
|
||||
Menu {
|
||||
// Picker("Category", selection: $filter) {
|
||||
// ForEach(FilterCategory.allCases) { category in
|
||||
// Text(category.rawValue).tag(category)
|
||||
// }
|
||||
// }
|
||||
// .pickerStyle(.inline)
|
||||
Toggle(isOn: $toggleVal) {
|
||||
Label("Toggle", systemImage: "star.fill")
|
||||
}
|
||||
} label: {
|
||||
Label("Filter", systemImage: "slider.horizontal.3")
|
||||
}
|
||||
}
|
||||
}
|
||||
Text("SimDirs") // If this isn't here things looks weird
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SimItemList_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
SimItemList()
|
||||
.environmentObject(PresentableModel())
|
||||
}
|
||||
}
|
||||
29
SimDirs/Views/SimItemRow.swift
Normal file
29
SimDirs/Views/SimItemRow.swift
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// SimItemRow.swift
|
||||
// SimDirs
|
||||
//
|
||||
// Created by Casey Fleser on 5/30/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SimItemRow: View {
|
||||
var item : PresentationItem
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
Image(systemName: item.imageName)
|
||||
.foregroundColor(item.imageColor)
|
||||
.symbolRenderingMode(.hierarchical)
|
||||
Text(item.title)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SimItemRow_Previews: PreviewProvider {
|
||||
static var model = PresentableModel()
|
||||
|
||||
static var previews: some View {
|
||||
SimItemRow(item: model.items[0])
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue