add shape picker for backgrounds
This commit is contained in:
65
Shared/Models/Shapes.swift
Normal file
65
Shared/Models/Shapes.swift
Normal file
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// 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)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user