change folders to the "feature" mindset
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// WorkoutIconSelector.swift
|
||||
// WorkoutsPlus
|
||||
//
|
||||
// Created by Felix Förtsch on 26.08.24.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct WorkoutIconSelector: View {
|
||||
|
||||
@State var workout: Workout
|
||||
|
||||
@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: {
|
||||
workout.workoutIconColorName = Workout.ColorName.fromColor(color)!
|
||||
}) {
|
||||
Circle()
|
||||
.fill(color)
|
||||
.frame(width: 40, height: 40)
|
||||
.overlay(
|
||||
Circle()
|
||||
// TODO: change this from stroke to checkmark symbol in the circle
|
||||
.stroke(Color.black, lineWidth: workout.workoutIconColorName.color == color ? 4 : 0)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
LazyVGrid(columns: [GridItem(.adaptive(minimum: 50, maximum: 100))]) {
|
||||
ForEach(filteredIcons, id: \.self) { iconName in
|
||||
Button(action: {
|
||||
workout.workoutIconSystemName = iconName
|
||||
}) {
|
||||
Image(systemName: iconName)
|
||||
.foregroundStyle(workout.workoutIconColorName.color)
|
||||
.padding()
|
||||
.background()
|
||||
.cornerRadius(8)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.searchable(text: $searchText)
|
||||
}
|
||||
.overlay {
|
||||
if filteredIcons.isEmpty {
|
||||
ContentUnavailableView.search(text: searchText)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
NavigationStack() {
|
||||
WorkoutIconSelector(workout: Workout.sampleData.first!)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user