Wotrack
Workout tracker (SwiftUI + MVVM + CoreData + CloudKit).
Also used: Relationships, Multilingual, Drag and Drop reordered Grid.
Icons made by Ultimatearm from flaticon.com
CoreData + MVVM
MVVM makes work with CoreData clearer. You will find all the logic with detailed comments in the file:
ViewModel/ExercisesViewModel.swift
Drag and Drop reordered Grid
Just use ReorderableForEach (Views/CustomViewsExtenssions/ReorderableForEach) and moveAction in LazyVGrid() to activate Drag and Drop reordered Grid:
LazyVGrid(columns: columns, spacing: spacing) {
ReorderableForEach(items: viewModel.items) { item in
Text(item.title)
} moveAction: { source, destination in
move(sourceOffsets: source, destinationOffset: destination)
}
}
Add new parent-item with custom icon picker
ScrollView(.horizontal){
HStack {
ForEach(K.Icons.Default.iconSet, id: \.self) { icon in
IconToChooseFromView(icon: icon)
.onTapGesture {
iconValue = icon
}
}
}
}
You can change the default icon set with your own in Contants.swift file
struct Icons {
struct SystemSet {
static let plus = "plus"
static let trash = "trash"
}
struct Default {
static let authorURL = "https://www.flaticon.com/authors/ultimatearm"
static let authorCitation = "Icons made by Ultimatearm from www.flaticon.com"
static let icon = "default"
static let iconSet = []
}
}
Core Data relationships
Relationships allows you to create child lists.
Switch language
I use just Eng/Rus, but you can add more. The user’s choice is stored in userDefaults.