本歌单由Listen1创建, 歌曲数:489,歌单数:4,点击查看更多
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |