view LazyBear/Views/Global Helpers/RowShape.swift @ 428:8c58ce834d95

Bug fixes and change assets
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Fri, 18 Jun 2021 12:43:17 +0200
parents 6dd97877f575
children 7f2a24a774eb
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()
    }
}