struct WBVistsAvatar: View {
@Environment(\.colorScheme) var colorScheme
// @Environment(\.isLuminanceReduced) var isLuminanceReduced //屏幕长显变暗
var model: WBVisitsCardModel?
var body: some View {
GeometryReader { proxy in
let width = proxy.size.width
let red_width = 7.0
let v_width = 14.0
let b_color = colorScheme == .dark ? Color(hex: 0x000000, alpha: 0.05) : Color(hex: 0x000000, alpha: 0.05)
ZStack {
//头像
Image(uiImage: model?.user?.avatar ?? UIImage())
.resizable(resizingMode: .stretch)
.aspectRatio(contentMode: .fill)
.frame(width: width, height: width)
.clipShape(Circle())
.overlay(
Circle().strokeBorder(b_color, lineWidth: 1)
, alignment: .center
)
//红点
if model?.user?.recently_unread ?? 0 > 0 {
Image(colorScheme == .dark ? "wb_visits_dot_dark" : "wb_visits_dot")
.resizable(resizingMode: .stretch)
.aspectRatio(contentMode: .fit)
.frame(width: red_width, height: red_width)
.clipShape(Circle())
.padding(.leading, width-red_width-2)
.padding(.bottom, (width-red_width-2))
}
//v标识
if model?.user?.verified_icon != nil {
Image(uiImage: colorScheme == .dark ? model?.user?.verified_icon_dark ?? UIImage() : model?.user?.verified_icon ?? UIImage())
.resizable(resizingMode: .stretch)
.aspectRatio(contentMode: .fit)
.frame(width: v_width, height: v_width)
.clipShape(Circle())
.padding(.leading, width-v_width)
.padding(.top, width-v_width)
}
}
}
}
}
2024年12月30日