//
//  ListRowViewModifier.swift
//  PadelClub
//
//  Created by Razmig Sarkissian on 27/03/2024.
//

import SwiftUI

struct ListRowViewModifier: ViewModifier {
    let isActive: Bool
    let color: Color
    
    func body(content: Content) -> some View {
        if isActive {
            content
                .listRowBackground(
                    color.variation()
                        .overlay(alignment: .leading, content: {
                            color.frame(width: 8)
                        })
                )
        } else {
            content
        }
    }
}

extension View {
    func listRowView(isActive: Bool = false, color: Color) -> some View {
        modifier(ListRowViewModifier(isActive: isActive, color: color))
    }
}
