SPB Git

spb/os-vault Public

Self-custody, multi-chain crypto wallet for macOS. One recovery phrase, six chain families, zero API keys — nothing leaves your Mac.

Swift 96% Shell 3.4% Makefile 0.6%
1.4 KB · 52 lines swift
Raw Blame History
1//2//  Shared.swift3//  OS Vault4//5//  Author: Simon-Pierre Boucher6//  Mail: contact@spboucher.ai7//89import SwiftUI1011/// Prominent badge so the user always knows which chain they are on.12struct NetworkBadge: View {13    let network: Network1415    var body: some View {16        Text(network.config.isTestnet ? "TESTNET · \(network.config.displayName)" : network.config.displayName)17            .font(.caption.weight(.bold))18            .padding(.horizontal, 10)19            .padding(.vertical, 4)20            .background(network.config.isTestnet ? Color.orange.opacity(0.25) : Color.blue.opacity(0.18))21            .foregroundStyle(network.config.isTestnet ? Color.orange : Color.blue)22            .clipShape(Capsule())23    }24}2526extension String {27    /// "0x9858…da94" for tight UI spots.28    var shortAddress: String {29        guard count == 42 else { return self }30        return "\(prefix(6))\(suffix(4))"31    }32}3334struct CopyButton: View {35    let text: String36    @State private var copied = false3738    var body: some View {39        Button {40            NSPasteboard.general.clearContents()41            NSPasteboard.general.setString(text, forType: .string)42            copied = true43            Task {44                try? await Task.sleep(for: .seconds(1.5))45                copied = false46            }47        } label: {48            Label(copied ? "Copied" : "Copy", systemImage: copied ? "checkmark" : "doc.on.doc")49        }50    }51}52