view LazyBear/Views/Global Helpers/RowShape.swift @ 438:7f2a24a774eb

Implement CompanyView networking
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Sun, 20 Jun 2021 13:20:19 +0200
parents 8c58ce834d95
children
line wrap: on
line source

//
//  RowShape.swift
//  LazyBear
//
//  Created by Dennis Concepción Martín on 5/6/21.
//

import SwiftUI

struct RowShape: View {
    @Environment(\.colorScheme) var colorScheme
    
    var body: some View {
        RoundedRectangle(cornerRadius: 25)
            .foregroundColor(Color("customSecondaryBackground"))
            .if(colorScheme == .light) { content in  /// Apply shadow only when is not dark mode
                content
                    .shadow(color: Color(.gray).opacity(0.15), radius: 10)
            }
    }
}

/*
 Apply modifiers to the passed view on some condition
 */
extension View {
   @ViewBuilder
   func `if`<Content: View>(_ conditional: Bool, content: (Self) -> Content) -> some View {
        if conditional {
            content(self)
        } else {
            self
        }
    }
}

struct RowShape_Previews: PreviewProvider {
    static var previews: some View {
        RowShape()
    }
}