Skip to content

Instantly share code, notes, and snippets.

import SwiftUI
// MARK: - ProgressRingScreen
/// A screen demonstrating a circular progress ring with a slider and control panel.
/// Uses a `ProgressRingViewModel` to track and animate the progress state.
struct ProgressRingScreen: View {
/// A view model that tracks and animates the progress value.
@State var viewModel = ProgressRingViewModel()
@Erica-Iris
Erica-Iris / ContentView.swift
Created March 1, 2025 12:04 — forked from 1998code/ContentView.swift
Shimmer Effect 2025
// Copyright © 2025 MING
// MIT License
import SwiftUI
struct ContentView: View {
@State private var colorful: Bool = true
@State private var dragLocation: CGPoint = .zero
var body: some View {
#include <metal_stdlib>
using namespace metal;
float smoothMin(float x1, float x2, float k) {
float h = clamp(0.5 - 0.5 * (x2 - x1) / k, 0.0, 1.0);
return mix(x1, x2, h) - k * h * (1.0 - h);
}
float circleSDF(float2 point, float2 center, float radius) {
return length(point - center) - radius;
@Erica-Iris
Erica-Iris / swiftui.swift
Created January 28, 2025 09:33
VisualEffectView
import SwiftUI
struct VisualEffectView: NSViewRepresentable {
let material: NSVisualEffectView.Material
let blendingMode: NSVisualEffectView.BlendingMode
func makeNSView(context _: Context) -> NSVisualEffectView {
let visualEffectView = NSVisualEffectView()
visualEffectView.material = material
visualEffectView.blendingMode = blendingMode
@Erica-Iris
Erica-Iris / a.swift
Last active February 24, 2025 20:45
保存到app default
private let defaults = UserDefaults.standard
private let usernameKey = "username"
private let passwordKey = "password"
func saveLoginInfo(username: String, password: String) {
defaults.set(username, forKey: usernameKey)
defaults.set(password, forKey: passwordKey)
}
func getSavedUsername() -> String {
@Erica-Iris
Erica-Iris / dnsLookup.swift
Created February 2, 2024 12:48 — forked from stropdale/dnsLookup.swift
DNS IP Address Lookup from Host name in Swift
import UIKit
// You many want to run this in the background
func getIPs(dnsName: String) -> String? {
let host = CFHostCreateWithName(nil, dnsName as CFString).takeRetainedValue()
CFHostStartInfoResolution(host, .addresses, nil)
var success: DarwinBoolean = false
if let addresses = CFHostGetAddressing(host, &success)?.takeUnretainedValue() as NSArray? {
for case let theAddress as NSData in addresses {
var hostname = [CChar](repeating: 0, count: Int(NI_MAXHOST))
@Erica-Iris
Erica-Iris / sizeof_fmt.py
Created January 26, 2023 13:13
sizeof_fmt
def sizeof_fmt(num, suffix="iB"):
for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]:
if abs(num) < 1024.0:
return "%3.2f%s%s" % (num, unit, suffix)
num /= 1024.0
return "%.2f%s%s" % (num, "Y", suffix)
@Erica-Iris
Erica-Iris / listen1_aha_playlist.md
Last active December 31, 2020 01:13
updated by Listen1(http://listen1.github.io/listen1/) at 2020/12/31 上午9:13:02

本歌单由Listen1创建, 歌曲数:489,歌单数:4,点击查看更多