Files
e-party-iOS/yana/Views/Components/UserIDDisplay.swift
edwinQQQ 02a8ae8531 feat: 更新Podfile和Podfile.lock,升级NEChatKit和NEChatUIKit版本
- 在Podfile中将NEChatKit和NEChatUIKit的版本更新至10.8.3,确保使用最新功能和修复。
- 更新Podfile.lock以反映新的依赖关系和版本信息。
- 在AppDelegate中引入NIMSDK,准备集成即时通讯功能。
- 移除Info.plist中的相机使用描述,添加新的隐私描述以符合最新需求。
- 在UserIDDisplay组件中更新文本,增强用户信息展示的清晰度。
- 在项目配置中添加相机和麦克风使用描述,确保符合隐私政策要求。
2025-08-07 16:47:29 +08:00

75 lines
2.2 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import SwiftUI
struct UserIDDisplay: View {
let uid: Int
let fontSize: CGFloat
let textColor: Color
let isDisplayCopy: Bool
@State private var showCopiedFeedback: Bool = false
init(uid: Int, fontSize: CGFloat = 14, textColor: Color = .white.opacity(0.7), isDisplayCopy: Bool = false) {
self.uid = uid
self.fontSize = fontSize
self.textColor = textColor
self.isDisplayCopy = isDisplayCopy
}
var body: some View {
HStack(spacing: 4) {
Text("ID: \(String(uid)) 数据没有返回 erban no")
.font(.system(size: fontSize))
.foregroundColor(textColor)
if isDisplayCopy {
Image("icon_copy")
.resizable()
.frame(width: 14, height: 14)
.foregroundColor(textColor)
}
}
.onTapGesture {
if isDisplayCopy {
copyToClipboard()
}
}
.overlay(
Group {
if isDisplayCopy && showCopiedFeedback {
Text("已复制")
.font(.system(size: 12))
.foregroundColor(.white)
.padding(.horizontal, 8)
.padding(.vertical, 4)
.background(Color.black.opacity(0.7))
.cornerRadius(4)
.offset(y: -30)
.transition(.opacity)
}
}
)
}
private func copyToClipboard() {
UIPasteboard.general.string = String(uid)
withAnimation(.easeInOut(duration: 0.2)) {
showCopiedFeedback = true
}
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
withAnimation(.easeInOut(duration: 0.2)) {
showCopiedFeedback = false
}
}
}
}
#Preview {
VStack(spacing: 20) {
UserIDDisplay(uid: 123456789, isDisplayCopy: true)
UserIDDisplay(uid: 987654321, fontSize: 16, textColor: .black, isDisplayCopy: false)
}
.padding()
}