79437502

Date: 2025-02-13 19:17:35
Score: 0.5
Natty:
Report link
struct ButtonBadgeView: View {
@State var showFavList = false
@State var items: [String] = []
var body: some View{
    HStack{
        BadgeView
            .frame(width: 44,height: 44)
            .onTapGesture {
                showFavList = true
            }
    }
}
var BadgeView: some View {
    GeometryReader { geometry in
        ZStack(alignment: .bottomLeading) {
            Image("heart_icon")
                .resizable()
                .scaledToFit()
                .padding(.top,4)
            
            // Badge View
            ZStack {
                Circle()
                    .foregroundColor(.red)
                Text("\(self.items.count)")
                    .foregroundColor(.white)
                    .font(Font.system(size: 12))
            }
            .frame(width: 20, height: 20)
            .offset(x: geometry.size.width / 2, y: -16)
            .opacity(self.items.count == 0 ? 0 : 1)
        }
    }
}

enter image description here

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Rahul Patel