Reuse card content across macOS and iOS with platform-sized icons and matching card heights. Add the shared Color field below Package and preserve selection, drag, and execution behavior. Migrate stored snippets to V51 and write color in Vault V2 while retaining V1 decoding and guarding against lossy V1 writes. Validation: macOS focused snippet, migration, architecture, and localization tests pass; 30 iOS focused tests pass; Swift format and localization checks pass. Full macOS testing also reports failures in unchanged KeyExport, MCP, and Agent suites.
52 lines
1.5 KiB
Swift
52 lines
1.5 KiB
Swift
import SwiftUI
|
|
import TermindDomain
|
|
|
|
public struct SnippetOrganizationSection<PackageField: View>: View {
|
|
@Binding private var name: String
|
|
@Binding private var color: TagColor
|
|
private let packageField: PackageField
|
|
|
|
public init(name: Binding<String>, color: Binding<TagColor>, @ViewBuilder packageField: () -> PackageField) {
|
|
_name = name
|
|
_color = color
|
|
self.packageField = packageField()
|
|
}
|
|
|
|
public var body: some View {
|
|
Section {
|
|
VaultNameField(text: $name)
|
|
packageField
|
|
VaultColorField(selection: $color)
|
|
}
|
|
}
|
|
}
|
|
|
|
public struct SnippetScriptSection<Assessment: View>: View {
|
|
@Binding private var script: String
|
|
private let minHeight: CGFloat
|
|
private let assessment: Assessment
|
|
|
|
public init(
|
|
script: Binding<String>, minHeight: CGFloat,
|
|
@ViewBuilder assessment: () -> Assessment
|
|
) {
|
|
_script = script
|
|
self.minHeight = minHeight
|
|
self.assessment = assessment()
|
|
}
|
|
|
|
public var body: some View {
|
|
Section(AppStrings.Snippets.script.swiftUIKey) {
|
|
TextEditor(text: $script)
|
|
.multilineTextAlignment(.leading)
|
|
.font(.body.monospaced())
|
|
.frame(minHeight: minHeight)
|
|
#if os(iOS)
|
|
.textInputAutocapitalization(.never)
|
|
.autocorrectionDisabled()
|
|
#endif
|
|
assessment
|
|
}
|
|
}
|
|
}
|