add WorkoutIconSelector, change the way adding ExerciseTemplate works to in-List
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// WorkoutIconSelector.swift
|
||||
// WorkoutsPlus
|
||||
//
|
||||
// Created by Felix Förtsch on 26.08.24.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct WorkoutIconSelector: View {
|
||||
|
||||
@State private var selectedColor: Color = .black
|
||||
@State private var selectedIcon: String?
|
||||
@State private var searchText: String = ""
|
||||
|
||||
var filteredIcons: [String] {
|
||||
if searchText.isEmpty {
|
||||
return fitnessIcons
|
||||
} else {
|
||||
return fitnessIcons.filter { $0.contains(searchText.lowercased()) }
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
LazyVGrid(columns: [GridItem(.adaptive(minimum: 50))]) {
|
||||
ForEach(systemColors, id: \.self) { color in
|
||||
Button(action: {
|
||||
selectedColor = color
|
||||
}) {
|
||||
Circle()
|
||||
.fill(color)
|
||||
.frame(width: 40, height: 40)
|
||||
.overlay(
|
||||
Circle()
|
||||
.stroke(Color.white, lineWidth: selectedColor == color ? 4 : 0)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
LazyVGrid(columns: [GridItem(.adaptive(minimum: 50, maximum: 100))]) {
|
||||
ForEach(filteredIcons, id: \.self) { iconName in
|
||||
Button(action: {
|
||||
selectedIcon = iconName
|
||||
}) {
|
||||
Image(systemName: iconName)
|
||||
.foregroundStyle(selectedColor)
|
||||
.padding()
|
||||
.background()
|
||||
.cornerRadius(8)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.searchable(text: $searchText)
|
||||
}
|
||||
|
||||
.navigationTitle("Select a Workout Icon")
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
NavigationView() {
|
||||
WorkoutIconSelector()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user