Files
Reflect/Shared/Models/Shapes.swift
2022-03-20 02:45:51 -05:00

66 lines
2.1 KiB
Swift

//
// Shapes.swift
// Feels
//
// 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)
case .diamond:
Diamond()
.fill(bgColor)
.frame(minWidth: 5,
maxWidth: 500,
minHeight: 5,
maxHeight: 500)
.aspectRatio(contentMode: .fit)
case .rectangle:
Rectangle()
.fill(bgColor)
.frame(minWidth: 5,
maxWidth: 500,
minHeight: 5,
maxHeight: 500,
alignment: .center)
case .roundedRectangle:
RoundedRectangle(cornerRadius: 8, style: .continuous)
.fill(bgColor)
.frame(minWidth: 5,
maxWidth: 500,
minHeight: 5,
maxHeight: 500,
alignment: .center)
}
text
.font(.title2)
.fontWeight(.bold)
.lineLimit(1)
.foregroundColor(textColor)
.minimumScaleFactor(0.7)
.padding(10)
.frame(maxWidth: .infinity, alignment: .center)
})
}
}