// // Shapes.swift // Reflect // // Created by Trey Tartt on 3/20/22. // import SwiftUI enum BGShape: Int, CaseIterable { case circle case diamond case rectangle case roundedRectangle func view(withText text: Text, bgColor: Color, textColor: Color) -> some View{ return AnyView( ZStack { switch self { case .circle: Circle() .fill(bgColor) .frame(minWidth: 5, maxWidth: 500, minHeight: 5, maxHeight: 500, alignment: .center) .overlay( text .font(.title2) .fontWeight(.bold) .lineLimit(1) .foregroundColor(textColor) .minimumScaleFactor(0.2) .padding(10) .frame(maxWidth: .infinity, alignment: .center) ) case .diamond: Diamond() .fill(bgColor) .frame(minWidth: 5, maxWidth: 500, minHeight: 5, maxHeight: 500) .aspectRatio(contentMode: .fit) .overlay( text .font(.title2) .fontWeight(.bold) .lineLimit(1) .foregroundColor(textColor) .minimumScaleFactor(0.2) .padding(10) .frame(maxWidth: .infinity, alignment: .center) ) case .rectangle: Rectangle() .fill(bgColor) .frame(minWidth: 5, maxWidth: 500, minHeight: 5, maxHeight: 500, alignment: .center) .overlay( text .font(.title2) .fontWeight(.bold) .lineLimit(1) .foregroundColor(textColor) .minimumScaleFactor(0.2) .padding(10) .frame(maxWidth: .infinity, alignment: .center) ) case .roundedRectangle: RoundedRectangle(cornerRadius: 8, style: .continuous) .fill(bgColor) .frame(minWidth: 5, maxWidth: 500, minHeight: 5, maxHeight: 500, alignment: .center) .overlay( text .font(.title2) .fontWeight(.bold) .lineLimit(1) .foregroundColor(textColor) .minimumScaleFactor(0.2) .padding(10) .frame(maxWidth: .infinity, alignment: .center) ) } }) } }