Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 13313a32d3 | |||
| 2bfeb6a165 |
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(mkdir:*)",
|
||||
"Bash(find:*)",
|
||||
"Bash(xargs cat:*)",
|
||||
"WebFetch(domain:git.rzen.dev)",
|
||||
"Bash(xcodebuild:*)",
|
||||
"Bash(xcrun simctl boot:*)",
|
||||
"Bash(xcrun simctl install:*)",
|
||||
"Bash(xcrun simctl launch:*)",
|
||||
"Bash(xcrun simctl get_app_container:*)",
|
||||
"Bash(log show:*)"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
# ---> Xcode
|
||||
## User settings
|
||||
xcuserdata/
|
||||
|
||||
*.local.md
|
||||
@@ -1,108 +0,0 @@
|
||||
# General Guidelines
|
||||
|
||||
## Technology Stack
|
||||
|
||||
Technology stack is described in TECH.md file.
|
||||
|
||||
## Data Model
|
||||
|
||||
Data model is defined in MODEL.md file.
|
||||
|
||||
## Persistence
|
||||
|
||||
When implementing an edit form for a SwiftData model, ensure proper loading:
|
||||
|
||||
1. BEFORE PRESENTING THE FORM:
|
||||
- Ensure the model is fully loaded with all its relationships
|
||||
- Use a deep fetch pattern to eagerly load all relationships
|
||||
- Access each property to force SwiftData to materialize lazy-loaded relationships
|
||||
- Consider creating a deep copy of the model if relationships are complex
|
||||
|
||||
2. IN THE EDIT VIEW:
|
||||
- Accept the model as a @State parameter (e.g., @State var modelObject: ModelType)
|
||||
- Create separate @State variables for each editable field
|
||||
- Initialize each state variable in the init() method using State(initialValue:)
|
||||
- Use the modelContext for persisting changes back to the data store
|
||||
|
||||
3. SAVING CHANGES:
|
||||
- When saving, update the model object properties from state variables
|
||||
- Use modelContext.save() to persist changes
|
||||
- Handle errors appropriately
|
||||
|
||||
|
||||
## User Interface and User Experience
|
||||
|
||||
Each view struct should be placed in its own file under "Views" directory.
|
||||
|
||||
The user interface and user experience should follow Apple's Human Interface Guidelines (HIG) and best practices for iOS development.
|
||||
|
||||
Avoid custom UI components, instead rely on available SwiftUI views and modifiers.
|
||||
|
||||
When creating a add/edit functionality for a model, unless otherwise instructed use a single Add/Edit View for both add and edit functionality.
|
||||
|
||||
Unless otherwise instructed, use a sheet to present both add and edit views.
|
||||
|
||||
Whenever a list view has no entries, show a placeholder view with text "No [ListName] yet." and a button "Add [ListName]".
|
||||
|
||||
Before presenting an add/edit view, ensure the model is fully loaded with all its relationships. Make use of async/await mechanism to load the model. Show an overlay with a loading indicator while the model is being loaded.
|
||||
|
||||
## Logger
|
||||
|
||||
Use custom logger instead of print statements.
|
||||
|
||||
Make a custom logger as follows:
|
||||
|
||||
```swift
|
||||
import OSLog
|
||||
|
||||
struct AppLogger {
|
||||
private let logger: Logger
|
||||
private let subsystem: String
|
||||
private let category: String
|
||||
|
||||
init(subsystem: String, category: String) {
|
||||
self.subsystem = subsystem
|
||||
self.category = category
|
||||
self.logger = Logger(subsystem: subsystem, category: category)
|
||||
}
|
||||
|
||||
func timestamp () -> String {
|
||||
Date.now.formatDateET(format: "yyyy-MM-dd HH:mm:ss")
|
||||
}
|
||||
|
||||
func formattedMessage (_ message: String) -> String {
|
||||
"\(timestamp()) [\(subsystem):\(category)] \(message)"
|
||||
}
|
||||
|
||||
func debug(_ message: String) {
|
||||
logger.debug("\(formattedMessage(message))")
|
||||
}
|
||||
|
||||
func info(_ message: String) {
|
||||
logger.info("\(formattedMessage(message))")
|
||||
}
|
||||
|
||||
func warning(_ message: String) {
|
||||
logger.warning("\(formattedMessage(message))")
|
||||
}
|
||||
|
||||
func error(_ message: String) {
|
||||
logger.error("\(formattedMessage(message))")
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```swift
|
||||
extension Date {
|
||||
func formatDateET(format: String = "MMMM, d yyyy @ h:mm a z") -> String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.timeZone = TimeZone(identifier: "America/New_York")
|
||||
formatter.dateFormat = format
|
||||
return formatter.string(from: self)
|
||||
}
|
||||
|
||||
static var ISO8601: String {
|
||||
"yyyy-MM-dd'T'HH:mm:ssZ"
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -14,68 +14,68 @@ This is a workout tracking iOS app built with Swift/SwiftUI, featuring both iPho
|
||||
- **Build the project**: Open `Workouts.xcodeproj` in Xcode and build (Cmd+B)
|
||||
- **Run on iOS Simulator**: Select the Workouts scheme and run (Cmd+R)
|
||||
- **Run on Apple Watch Simulator**: Select the "Workouts Watch App" scheme and run
|
||||
- **Dependencies**: The project uses Swift Package Manager. Dependencies are resolved automatically via `Package.resolved`
|
||||
|
||||
### Key Dependencies
|
||||
- **Yams**: For parsing YAML exercise definition files in `Resources/`
|
||||
- **SwiftUIReorderableForEach**: For reorderable lists in UI components
|
||||
|
||||
## Architecture
|
||||
|
||||
### Data Layer
|
||||
- **SwiftData**: Core persistence framework with CloudKit sync
|
||||
- **Schema Management**: Versioned schemas in `Schema/` directory with migration support
|
||||
- **Models**: Located in `Models/` directory, following single-file-per-model convention
|
||||
- **CoreData**: Core persistence framework with CloudKit sync via `NSPersistentCloudKitContainer`
|
||||
- **CloudKit Container**: `iCloud.dev.rzen.indie.Workouts`
|
||||
- **PersistenceController**: Manages CoreData stack initialization, CloudKit configuration, and context access
|
||||
- **Models**: Located in `Models/` directory as NSManagedObject subclasses
|
||||
|
||||
### Core Models
|
||||
- **Split**: Workout routine templates with exercises, colors, and system images
|
||||
- **Exercise**: Individual exercises within splits (sets, reps, weight, load type)
|
||||
- **Workout**: Active workout sessions linked to splits
|
||||
- **WorkoutLog**: Historical exercise completion records
|
||||
- **WorkoutStatus**: Enum for tracking workout/exercise completion states
|
||||
|
||||
### Model Relationships
|
||||
```
|
||||
Split (1) ──cascade──> (many) Exercise
|
||||
Split (1) ──nullify──> (many) Workout
|
||||
Workout (1) ──cascade──> (many) WorkoutLog
|
||||
```
|
||||
|
||||
### App Structure
|
||||
- **Dual targets**: Main iOS app (`Workouts/`) and Watch companion (`Workouts Watch App/`)
|
||||
- **Shared components**: Both apps share similar structure but have platform-specific implementations
|
||||
- **Shared components**: Both apps have similar structure with platform-specific implementations
|
||||
- **TabView navigation**: Main app uses tabs (Workouts, Logs, Reports, Achievements)
|
||||
|
||||
### Exercise Data Management
|
||||
- **YAML-based exercise definitions**: Located in `Resources/*.exercises.yaml`
|
||||
- **ExerciseListLoader**: Parses YAML files into structured exercise data
|
||||
- **Preset exercise libraries**: Starter sets for bodyweight and Planet Fitness routines
|
||||
|
||||
### CloudKit Integration
|
||||
- **Automatic sync**: Configured via `ModelConfiguration(cloudKitDatabase: .automatic)`
|
||||
- **Change observation**: App observes CloudKit sync events for UI refresh
|
||||
- **Automatic sync**: Configured via `NSPersistentCloudKitContainerOptions`
|
||||
- **History tracking**: Enabled for CloudKit sync via `NSPersistentHistoryTrackingKey`
|
||||
- **Remote change notifications**: Enabled for real-time sync updates
|
||||
- **Cross-device sync**: Data syncs between iPhone and Apple Watch
|
||||
|
||||
### UI Patterns
|
||||
- **SwiftUI-first**: Modern declarative UI throughout
|
||||
- **Environment injection**: ManagedObjectContext passed via `.environment(\.managedObjectContext)`
|
||||
- **Navigation**: Uses NavigationStack for hierarchical navigation
|
||||
- **Form-based editing**: Consistent form patterns for data entry
|
||||
- **Reorderable lists**: Custom sortable components for exercise ordering
|
||||
|
||||
### Key Directories
|
||||
- `Models/`: SwiftData model definitions
|
||||
- `Models/`: CoreData NSManagedObject subclasses
|
||||
- `Persistence/`: PersistenceController for CoreData stack management
|
||||
- `Views/`: UI components organized by feature (Splits, Exercises, Workouts, etc.)
|
||||
- `Schema/`: Database schema management and versioning
|
||||
- `Utils/`: Shared utilities (logging, date formatting, colors)
|
||||
- `Resources/`: YAML exercise definitions and static assets
|
||||
- `Utils/`: Shared utilities (date formatting, colors)
|
||||
- `*.xcdatamodeld`: CoreData model definition
|
||||
|
||||
### Schema Guidelines
|
||||
### CoreData Guidelines
|
||||
- Each model gets its own file in `Models/`
|
||||
- Schema versions managed in `Schema/` directory
|
||||
- Migration plans handle schema evolution
|
||||
- No circular relationships in data model
|
||||
- Use appropriate delete rules for relationships
|
||||
- Use `@NSManaged` for all persistent properties
|
||||
- Implement `fetchRequest()` class methods for type-safe fetching
|
||||
- Use `NSSet` for to-many relationships with convenience array accessors
|
||||
- Implement add/remove helper methods for relationship management
|
||||
- Use appropriate delete rules: cascade for owned children, nullify for references
|
||||
|
||||
### UI Guidelines (from UI.md)
|
||||
### UI Guidelines
|
||||
- Tab-based root navigation with independent navigation stacks
|
||||
- Consistent form patterns for add/edit operations
|
||||
- Sheet presentations for modal operations
|
||||
- Swipe gestures for common actions (edit, complete, navigate)
|
||||
|
||||
### Development Notes
|
||||
- **Auto-lock disabled**: App prevents device sleep during workouts
|
||||
- **Preview support**: ModelContainer.preview for SwiftUI previews
|
||||
- **Logging**: Structured logging via AppLogger throughout the app
|
||||
- **Color system**: Custom color extensions for consistent theming
|
||||
- **Preview support**: `PersistenceController.preview` for SwiftUI previews
|
||||
- **Color system**: Custom color extensions for consistent theming (`Color.color(from:)`)
|
||||
- **Date formatting**: Extensions in `Date+Extensions.swift`
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
# Data Model
|
||||
|
||||
## Guidelines
|
||||
|
||||
### General
|
||||
|
||||
- When implementing a SwiftData model, allocate each model into its own file under "Models" directory.
|
||||
|
||||
### Schema Versioning
|
||||
|
||||
- Keep schema configurations in a separate folder called "Schema"
|
||||
- Setup an enum for schema versioning
|
||||
- Create SchemaMigrationPlan struct in Schema/SchemaMigrationPlan.swift for managing schema migrations
|
||||
- Use schema versioning to manage changes to the data model
|
||||
- When adding a new model, increment the schema version
|
||||
- When removing a model, increment the schema version
|
||||
- When modifying a model, increment the schema version
|
||||
|
||||
### SwiftData Relationship Rules
|
||||
|
||||
- DO NOT create any relationships that are not explicitly defined in the data model
|
||||
- AVOID circular references in all cases
|
||||
- Infer type of relationship from the property name (to many for plural, to one for singular)
|
||||
|
||||
## Models
|
||||
|
||||
ExerciseType
|
||||
- name (String)
|
||||
- descr (String)
|
||||
- exercises (Set<Exercise>?) // deleteRule: nullify
|
||||
|
||||
MuscleGroup
|
||||
- name (String)
|
||||
- descr (String)
|
||||
- muscles (Set<Muscle>?) // deleteRule: nullify
|
||||
|
||||
Muscle
|
||||
- name (String)
|
||||
- descr (String)
|
||||
- muscleGroup (MuscleGroup?) // deleteRule: nullify, inverse: MuscleGroup.muscles
|
||||
- exercises (Set<Exercise>?) // deleteRule: nullify
|
||||
|
||||
Exercise
|
||||
- type (ExerciseType?) // deleteRule: .nullify, inverse: ExerciseType.exercises
|
||||
- name (String)
|
||||
- setup (String)
|
||||
- descr (String)
|
||||
- muscles (Set<Muscle>?) // deleteRule: .nullify, inverse: Muscle.exercises
|
||||
- sets (Int)
|
||||
- reps (Int)
|
||||
- weight (Int)
|
||||
- splits (Set<SplitExerciseAssignment>?) // deleteRule: .nullify, inverse: SplitExerciseAssignment.exercise
|
||||
- logs (Set<WorkoutLog>?) // deleteRule: .nullify, inverse: WorkoutLog.exercise
|
||||
|
||||
SplitExerciseAssignment
|
||||
- split (Split?) // deleteRule: .nullify
|
||||
- exercise (Exercise?) // deleteRule: .nullify
|
||||
- order (Int)
|
||||
- sets (Int)
|
||||
- reps (Int)
|
||||
- weight (Int)
|
||||
|
||||
Split
|
||||
- name (String)
|
||||
- intro (String)
|
||||
- exercises (Set<SplitExerciseAssignment>?) // deleteRule: .cascade, inverse: SplitExerciseAssignment.split
|
||||
|
||||
WorkoutLog
|
||||
- workout (Workout?) // deleteRule: .nullify
|
||||
- exercise (Exercise?) // deleteRule: .nullify
|
||||
- date (Date)
|
||||
- sets (Int)
|
||||
- reps (Int)
|
||||
- weight (Int)
|
||||
- completed (Bool)
|
||||
|
||||
Workout
|
||||
- split (Split?) // deleteRule: .nullify
|
||||
- start (Date)
|
||||
- end (Date?)
|
||||
- logs (Set<WorkoutLog>?) // deleteRule: .cascade, inverse: WorkoutLog.workout
|
||||
@@ -0,0 +1,187 @@
|
||||
# Workouts App Requirements
|
||||
|
||||
## Overview
|
||||
A workout tracking iOS application with Apple Watch companion that helps users manage workout splits, track exercise logs, and sync data across devices using CloudKit.
|
||||
|
||||
## Platform Requirements
|
||||
- iOS app (iPhone)
|
||||
- watchOS app (Apple Watch companion)
|
||||
- CloudKit sync between devices
|
||||
- SwiftData for persistence with CloudKit automatic sync
|
||||
|
||||
## Core Data Models
|
||||
|
||||
### Split
|
||||
- `name: String` - Name of the workout split
|
||||
- `color: String` - Color theme for the split
|
||||
- `systemImage: String` - SF Symbol icon
|
||||
- `order: Int` - Display order
|
||||
- Relationship: One-to-many with Exercise
|
||||
|
||||
### Exercise
|
||||
- `name: String` - Exercise name
|
||||
- `order: Int` - Order within split
|
||||
- `sets: Int` - Number of sets
|
||||
- `reps: Int` - Number of repetitions
|
||||
- `weight: Int` - Weight amount
|
||||
- `loadType: Int` - Type of load (weight units)
|
||||
- Relationship: Many-to-one with Split
|
||||
|
||||
### Workout
|
||||
- `start: Date` - Workout start time
|
||||
- `end: Date?` - Workout end time (optional)
|
||||
- `status: WorkoutStatus` - Enum (notStarted, inProgress, completed, skipped)
|
||||
- Relationship: Many-to-one with Split (optional)
|
||||
- Relationship: One-to-many with WorkoutLog
|
||||
|
||||
### WorkoutLog
|
||||
- `exerciseName: String` - Name of the exercise
|
||||
- `date: Date` - When performed
|
||||
- `order: Int` - Order in workout
|
||||
- `sets: Int` - Number of sets completed
|
||||
- `reps: Int` - Number of reps completed
|
||||
- `weight: Int` - Weight used
|
||||
- `status: WorkoutStatus?` - Completion status
|
||||
- `completed: Bool` - Whether exercise was completed
|
||||
- Relationship: Many-to-one with Workout
|
||||
|
||||
## iOS App Features
|
||||
|
||||
### Main Navigation (TabView)
|
||||
1. **Workouts Tab**
|
||||
- List all workouts sorted by start date (newest first)
|
||||
- Create new workout from split
|
||||
- Edit/delete existing workouts
|
||||
- Navigate to workout logs
|
||||
|
||||
2. **Logs Tab**
|
||||
- Historical exercise completion records
|
||||
- Grouped by workout
|
||||
|
||||
3. **Reports Tab**
|
||||
- Workout statistics and progress tracking
|
||||
|
||||
4. **Achievements Tab**
|
||||
- User achievements and milestones
|
||||
|
||||
### Split Management
|
||||
- Create/edit/delete workout splits
|
||||
- Assign colors and system images
|
||||
- Reorder splits
|
||||
- Add/remove/reorder exercises within splits
|
||||
|
||||
### Exercise Management
|
||||
- Add exercises to splits
|
||||
- Set default sets, reps, weight
|
||||
- Reorderable list within each split
|
||||
- Support for different load types
|
||||
|
||||
### Workout Flow
|
||||
- Start workout from selected split
|
||||
- Auto-populate exercises from split template
|
||||
- Track exercise completion status
|
||||
- Update sets/reps/weight during workout
|
||||
- Mark exercises as completed/skipped
|
||||
- Auto-prevent device sleep during workouts
|
||||
|
||||
## Watch App Features
|
||||
|
||||
### Main View
|
||||
- List active workouts
|
||||
- Show "No Workouts" state when empty
|
||||
- Sync button to pull from CloudKit
|
||||
- Display sync status and last sync time
|
||||
|
||||
### Workout Display
|
||||
- Show workout name and status
|
||||
- List exercises with completion indicators
|
||||
- Quick completion toggles
|
||||
|
||||
### CloudKit Sync
|
||||
- Manual sync trigger
|
||||
- Hybrid approach: SwiftData for local storage + direct CloudKit API for sync
|
||||
- Sync from `com.apple.coredata.cloudkit.zone`
|
||||
- Fetch and save Splits, Exercises, Workouts, and WorkoutLogs
|
||||
|
||||
## Data Management
|
||||
|
||||
### Exercise Library
|
||||
- YAML-based exercise definitions in `Resources/` directory
|
||||
- `ExerciseListLoader` to parse YAML files
|
||||
- Preset libraries:
|
||||
- Bodyweight exercises (`bodyweight-exercises.yaml`)
|
||||
- Planet Fitness starter (`pf-starter-exercises.yaml`)
|
||||
|
||||
### CloudKit Configuration
|
||||
- Container ID: `iCloud.com.dev.rzen.indie.WorkoutsV2`
|
||||
- Automatic sync via `ModelConfiguration(cloudKitDatabase: .automatic)`
|
||||
- Development environment for debug builds
|
||||
- Production environment for release/TestFlight builds
|
||||
|
||||
## UI/UX Requirements
|
||||
|
||||
### Design Patterns
|
||||
- SwiftUI throughout
|
||||
- NavigationStack for hierarchical navigation
|
||||
- Form-based editing interfaces
|
||||
- Sheet presentations for modal operations
|
||||
- Swipe gestures for edit/delete/complete actions
|
||||
|
||||
### Visual Design
|
||||
- Custom color system via Color extensions
|
||||
- Consistent use of SF Symbols
|
||||
- Reorderable lists using SwiftUIReorderableForEach
|
||||
- Calendar-style list items for workouts
|
||||
- Checkbox components for completion tracking
|
||||
|
||||
### Key UI Components
|
||||
- `CalendarListItem` - Formatted date/time display
|
||||
- `Checkbox` - Visual completion indicators
|
||||
- `SplitListItemView` - Split display with icon and color
|
||||
- `ExerciseListItemView` - Exercise display with sets/reps/weight
|
||||
- `WorkoutLogListItemView` - Log entry display
|
||||
|
||||
## Technical Architecture
|
||||
|
||||
### Project Structure
|
||||
```
|
||||
Workouts/
|
||||
├── Models/ # SwiftData models
|
||||
├── Schema/ # Database schema and migrations
|
||||
├── Views/ # UI components by feature
|
||||
│ ├── Splits/
|
||||
│ ├── Exercises/
|
||||
│ ├── Workouts/
|
||||
│ └── WorkoutLog/
|
||||
├── Utils/ # Shared utilities
|
||||
└── Resources/ # YAML exercise definitions
|
||||
|
||||
Workouts Watch App/
|
||||
├── Schema/ # Watch-specific container
|
||||
├── Views/ # Watch UI components
|
||||
└── CloudKitSyncManager.swift # Direct CloudKit sync
|
||||
```
|
||||
|
||||
### Key Technical Decisions
|
||||
- SwiftData with CloudKit automatic sync
|
||||
- Versioned schema with migration support
|
||||
- Single file per model convention
|
||||
- No circular relationships in data model
|
||||
- Platform-specific implementations for iOS/watchOS
|
||||
- Shared model definitions between platforms
|
||||
|
||||
## Dependencies
|
||||
- **Yams**: YAML parsing for exercise definitions
|
||||
- **SwiftUIReorderableForEach**: Drag-to-reorder lists
|
||||
|
||||
## Entitlements Required
|
||||
- CloudKit
|
||||
- Push Notifications (aps-environment)
|
||||
- App Sandbox
|
||||
- File access (read-only for user-selected files)
|
||||
|
||||
## Build Configuration
|
||||
- Swift Package Manager for dependencies
|
||||
- Separate targets for iOS and watchOS
|
||||
- Shared CloudKit container between apps
|
||||
- Automatic provisioning and code signing
|
||||
@@ -1,33 +1,35 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
## IMPORTANT ##
|
||||
# Add the following files to Input Files configuraiton of the build phase
|
||||
# $(TARGET_BUILD_DIR)/$(INFOPLIST_PATH)
|
||||
# $(DWARF_DSYM_FOLDER_PATH)/$(DWARF_DSYM_FILE_NAME)/Contents/Info.plist
|
||||
|
||||
update_plist_key() {
|
||||
local plist=$1
|
||||
local key=$2
|
||||
local value=$3
|
||||
|
||||
if /usr/libexec/PlistBuddy -c "Print :$key" "$plist" > /dev/null 2>&1; then
|
||||
/usr/libexec/PlistBuddy -c "Set :$key string $value" "$plist"
|
||||
else
|
||||
/usr/libexec/PlistBuddy -c "Add :$key string $value" "$plist"
|
||||
fi
|
||||
}
|
||||
|
||||
git=$(sh /etc/profile; which git)
|
||||
commit_hash=$("$git" rev-parse --short HEAD)
|
||||
build_time=$(date "+%-d/%b/%Y")
|
||||
number_of_commits=$("$git" rev-list HEAD --count)
|
||||
git_release_version=$("$git" describe --tags --always --abbrev=0)
|
||||
|
||||
target_plist="$TARGET_BUILD_DIR/$INFOPLIST_PATH"
|
||||
dsym_plist="$DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME/Contents/Info.plist"
|
||||
|
||||
git_commit=`"$git" rev-parse --short HEAD`
|
||||
bundle_version=`/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$target_plist"`
|
||||
build_date=`date +%F`
|
||||
|
||||
build="v$bundle_version-$git_commit b$number_of_commits $build_date"
|
||||
|
||||
#echo "version=$bundle_version-$git_commit build $number_of_commits"
|
||||
|
||||
"$git" tag "$bundle_version"
|
||||
|
||||
for plist in "$target_plist" "$dsym_plist"; do
|
||||
if [ -f "$plist" ]; then
|
||||
echo "updating $plist"
|
||||
update_plist_key "$plist" "BuildTime" "$build_time"
|
||||
update_plist_key "$plist" "CommitHash" "$commit_hash"
|
||||
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $number_of_commits" "$plist"
|
||||
# /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${version}" "$plist"
|
||||
# /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${git_release_version#*v}" "$plist"
|
||||
|
||||
# Add build date for AppInfoKit
|
||||
/usr/libexec/PlistBuddy -c "Set :BuildDate $build_date" "$plist" 2>/dev/null || \
|
||||
/usr/libexec/PlistBuddy -c "Add :BuildDate string $build_date" "$plist"
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
# User Interface
|
||||
|
||||
## Tabs
|
||||
|
||||
Each tab is a root of its own navigation stack.
|
||||
|
||||
- Workouts
|
||||
- Reports
|
||||
- Settings
|
||||
|
||||
## Workout Log
|
||||
|
||||
- toolbar
|
||||
- left bar button: none
|
||||
- title: Workout Log
|
||||
- right bar button: Add Workout
|
||||
- main view:
|
||||
- List of WorkoutLog objects
|
||||
- Grouped by date, in descending order
|
||||
- Group header shows date and split name
|
||||
- Each row shows:
|
||||
- Time
|
||||
- Exercise
|
||||
- Sets
|
||||
- Reps
|
||||
- Weight
|
||||
|
||||
- When main view list has no entries, show a placeholder view with text "No workouts yet." and a button "Start Split"
|
||||
|
||||
### Start Split View
|
||||
|
||||
Start Split View slides on top of Workout Log View navigation stack.
|
||||
|
||||
- left bar button: default (back to Workout Log)
|
||||
- title: Start Split
|
||||
- right bar button: none
|
||||
|
||||
- main view:
|
||||
- list of available splits
|
||||
- button "Start [SplitName] Split" -> Workout Split
|
||||
|
||||
### Workout Split View
|
||||
|
||||
Workout Split View slides on top of Workout Log View navigation stack.
|
||||
|
||||
- left bar button: default (back to Start Split)
|
||||
- title: [SplitName] Split
|
||||
- right bar button: Add Exercise
|
||||
|
||||
- main view:
|
||||
- list of exercises in the split
|
||||
- actions:
|
||||
- on row slide to left
|
||||
- button "Edit"
|
||||
- on row slide to right
|
||||
- button "Completed"
|
||||
- on row tap
|
||||
- open Exercise View
|
||||
|
||||
### Exercise View
|
||||
|
||||
Exercise View slides on top of Workout Split View navigation stack.
|
||||
|
||||
- left bar button: default (back to Workout Split)
|
||||
- title: [ExerciseName]
|
||||
- right bar button: Edit (pencil icon)
|
||||
- action: open Add/Edit Exercise Assignment View
|
||||
|
||||
- main view:
|
||||
- form
|
||||
sections:
|
||||
- split
|
||||
- split name
|
||||
- exercise assignment (titled "Planned")
|
||||
- exercise
|
||||
- name
|
||||
- setup
|
||||
- description
|
||||
- muscles
|
||||
- weight
|
||||
- sets (read only)
|
||||
- reps (read only)
|
||||
- weight (read only)
|
||||
- workout log (titled "Actual")
|
||||
- date (date/time picker)
|
||||
- sets (integer picker)
|
||||
- reps (integer picker)
|
||||
- weight (integer picker)
|
||||
- status
|
||||
- Completed (checkbox)
|
||||
|
||||
- actions:
|
||||
- swipe left
|
||||
- open Exercise View for the previous ExerciseAssignment
|
||||
- swipe right
|
||||
- open Exercise View for the next ExerciseAssignment
|
||||
|
||||
### Add/Edit Exercise to Split View
|
||||
|
||||
This view should be opened as a sheet.
|
||||
|
||||
- left bar button: default (back to Workout Split)
|
||||
- title: Add/Edit Exercise to Split
|
||||
- right bar button: Save
|
||||
|
||||
- main view:
|
||||
- before an exercise is selected
|
||||
- list of available exercises
|
||||
- button "Add [ExerciseName]"
|
||||
- after an exercise is selected
|
||||
- a form for model SplitExerciseAssignment
|
||||
- sets
|
||||
- reps
|
||||
- weight
|
||||
|
||||
## Settings
|
||||
|
||||
- left bar button: none
|
||||
- title: Settings
|
||||
- right bar button: none
|
||||
|
||||
- main view:
|
||||
- list
|
||||
- Splits
|
||||
- Exercises
|
||||
- Muscle Groups
|
||||
- Muscles
|
||||
- Exercise Types
|
||||
|
||||
- actions:
|
||||
- on row tap
|
||||
- open corresponding list view (e.g. for "Splits" open "Splits List View")
|
||||
|
||||
### (Splits|Exercises|Muscle Groups|Muscles|Exercise Types) List View
|
||||
|
||||
- left bar button: default (back to Settings)
|
||||
- title: [ListName]
|
||||
- right bar button: Add (plus icon)
|
||||
- action: open corresponding add/edit view (e.g. for "Splits" open "Splits Add/Edit View")
|
||||
|
||||
- main view:
|
||||
- list of [ListName]
|
||||
- actions:
|
||||
- on row tap
|
||||
- open corresponding add/edit view (e.g. for "Splits" open "Splits Add/Edit View")
|
||||
|
||||
### (Splits|Exercises|Muscle Groups|Muscles|Exercise Types) Add/Edit View
|
||||
|
||||
Add/Edit views typically open as sheets.
|
||||
|
||||
- left bar button: default (back to Settings)
|
||||
- title: [Add/Edit] [ListName]
|
||||
- right bar button: Save
|
||||
|
||||
- main view:
|
||||
- form with editable fields
|
||||
|
||||
|
Before Width: | Height: | Size: 49 KiB |
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "1024.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "watchos",
|
||||
"size" : "1024x1024"
|
||||
|
||||
@@ -1,60 +1,25 @@
|
||||
//
|
||||
// ContentView.swift
|
||||
// Workouts
|
||||
// Workouts Watch App
|
||||
//
|
||||
// Created by rzen on 7/15/25 at 7:09 PM.
|
||||
// Created by rzen on 8/13/25 at 11:10 AM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
|
||||
import SwiftUI
|
||||
import SwiftData
|
||||
import CoreData
|
||||
|
||||
struct ContentView: View {
|
||||
@Environment(\.modelContext) private var modelContext
|
||||
|
||||
@State var workouts: [Workout] = []
|
||||
@Environment(\.managedObjectContext) private var viewContext
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
if workouts.isEmpty {
|
||||
NoWorkoutView()
|
||||
} else {
|
||||
ActiveWorkoutListView(workouts: workouts)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
loadWorkouts()
|
||||
}
|
||||
}
|
||||
|
||||
func loadWorkouts () {
|
||||
do {
|
||||
self.workouts = try modelContext.fetch(FetchDescriptor<Workout>(
|
||||
sortBy: [
|
||||
SortDescriptor(\Workout.start, order: .reverse)
|
||||
]
|
||||
))
|
||||
} catch {
|
||||
print("ERROR: failed to load workouts \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct NoWorkoutView: View {
|
||||
var body: some View {
|
||||
VStack(spacing: 16) {
|
||||
VStack {
|
||||
Image(systemName: "dumbbell.fill")
|
||||
.font(.system(size: 40))
|
||||
.foregroundStyle(.gray)
|
||||
|
||||
Text("No Workouts")
|
||||
.font(.headline)
|
||||
|
||||
Text("Create a workout in the main app")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.gray)
|
||||
.multilineTextAlignment(.center)
|
||||
.imageScale(.large)
|
||||
.foregroundStyle(.tint)
|
||||
Text("Workouts")
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
@@ -62,5 +27,5 @@ struct NoWorkoutView: View {
|
||||
|
||||
#Preview {
|
||||
ContentView()
|
||||
.modelContainer(AppContainer.preview)
|
||||
.environment(\.managedObjectContext, PersistenceController.preview.viewContext)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
@objc(Exercise)
|
||||
public class Exercise: NSManagedObject, Identifiable {
|
||||
@NSManaged public var name: String
|
||||
@NSManaged public var loadType: Int32
|
||||
@NSManaged public var order: Int32
|
||||
@NSManaged public var sets: Int32
|
||||
@NSManaged public var reps: Int32
|
||||
@NSManaged public var weight: Int32
|
||||
@NSManaged public var duration: Date?
|
||||
@NSManaged public var weightLastUpdated: Date?
|
||||
@NSManaged public var weightReminderTimeIntervalWeeks: Int32
|
||||
|
||||
@NSManaged public var split: Split?
|
||||
|
||||
public var id: NSManagedObjectID { objectID }
|
||||
|
||||
var loadTypeEnum: LoadType {
|
||||
get { LoadType(rawValue: Int(loadType)) ?? .weight }
|
||||
set { loadType = Int32(newValue.rawValue) }
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Fetch Request
|
||||
|
||||
extension Exercise {
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<Exercise> {
|
||||
return NSFetchRequest<Exercise>(entityName: "Exercise")
|
||||
}
|
||||
|
||||
static func orderedFetchRequest(for split: Split) -> NSFetchRequest<Exercise> {
|
||||
let request = fetchRequest()
|
||||
request.predicate = NSPredicate(format: "split == %@", split)
|
||||
request.sortDescriptors = [NSSortDescriptor(keyPath: \Exercise.order, ascending: true)]
|
||||
return request
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum LoadType: Int, CaseIterable {
|
||||
case none = 0
|
||||
case weight = 1
|
||||
case duration = 2
|
||||
|
||||
var name: String {
|
||||
switch self {
|
||||
case .none: "None"
|
||||
case .weight: "Weight"
|
||||
case .duration: "Duration"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import Foundation
|
||||
import CoreData
|
||||
import SwiftUI
|
||||
|
||||
@objc(Split)
|
||||
public class Split: NSManagedObject, Identifiable {
|
||||
@NSManaged public var name: String
|
||||
@NSManaged public var color: String
|
||||
@NSManaged public var systemImage: String
|
||||
@NSManaged public var order: Int32
|
||||
|
||||
@NSManaged public var exercises: NSSet?
|
||||
@NSManaged public var workouts: NSSet?
|
||||
|
||||
public var id: NSManagedObjectID { objectID }
|
||||
|
||||
static let unnamed = "Unnamed Split"
|
||||
}
|
||||
|
||||
// MARK: - Convenience Accessors
|
||||
|
||||
extension Split {
|
||||
var exercisesArray: [Exercise] {
|
||||
let set = exercises as? Set<Exercise> ?? []
|
||||
return set.sorted { $0.order < $1.order }
|
||||
}
|
||||
|
||||
var workoutsArray: [Workout] {
|
||||
let set = workouts as? Set<Workout> ?? []
|
||||
return set.sorted { $0.start > $1.start }
|
||||
}
|
||||
|
||||
func addToExercises(_ exercise: Exercise) {
|
||||
let items = mutableSetValue(forKey: "exercises")
|
||||
items.add(exercise)
|
||||
}
|
||||
|
||||
func removeFromExercises(_ exercise: Exercise) {
|
||||
let items = mutableSetValue(forKey: "exercises")
|
||||
items.remove(exercise)
|
||||
}
|
||||
|
||||
func addToWorkouts(_ workout: Workout) {
|
||||
let items = mutableSetValue(forKey: "workouts")
|
||||
items.add(workout)
|
||||
}
|
||||
|
||||
func removeFromWorkouts(_ workout: Workout) {
|
||||
let items = mutableSetValue(forKey: "workouts")
|
||||
items.remove(workout)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Fetch Request
|
||||
|
||||
extension Split {
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<Split> {
|
||||
return NSFetchRequest<Split>(entityName: "Split")
|
||||
}
|
||||
|
||||
static func orderedFetchRequest() -> NSFetchRequest<Split> {
|
||||
let request = fetchRequest()
|
||||
request.sortDescriptors = [NSSortDescriptor(keyPath: \Split.order, ascending: true)]
|
||||
return request
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
@objc(Workout)
|
||||
public class Workout: NSManagedObject, Identifiable {
|
||||
@NSManaged public var start: Date
|
||||
@NSManaged public var end: Date?
|
||||
@NSManaged private var statusRaw: String
|
||||
|
||||
@NSManaged public var split: Split?
|
||||
@NSManaged public var logs: NSSet?
|
||||
|
||||
public var id: NSManagedObjectID { objectID }
|
||||
|
||||
var status: WorkoutStatus {
|
||||
get { WorkoutStatus(rawValue: statusRaw) ?? .notStarted }
|
||||
set { statusRaw = newValue.rawValue }
|
||||
}
|
||||
|
||||
var label: String {
|
||||
if status == .completed, let endDate = end {
|
||||
return "\(start.formattedDate())—\(endDate.formattedDate())"
|
||||
} else {
|
||||
return start.formattedDate()
|
||||
}
|
||||
}
|
||||
|
||||
var statusName: String {
|
||||
return status.displayName
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Convenience Accessors
|
||||
|
||||
extension Workout {
|
||||
var logsArray: [WorkoutLog] {
|
||||
let set = logs as? Set<WorkoutLog> ?? []
|
||||
return set.sorted { $0.order < $1.order }
|
||||
}
|
||||
|
||||
func addToLogs(_ log: WorkoutLog) {
|
||||
let items = mutableSetValue(forKey: "logs")
|
||||
items.add(log)
|
||||
}
|
||||
|
||||
func removeFromLogs(_ log: WorkoutLog) {
|
||||
let items = mutableSetValue(forKey: "logs")
|
||||
items.remove(log)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Fetch Request
|
||||
|
||||
extension Workout {
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<Workout> {
|
||||
return NSFetchRequest<Workout>(entityName: "Workout")
|
||||
}
|
||||
|
||||
static func recentFetchRequest() -> NSFetchRequest<Workout> {
|
||||
let request = fetchRequest()
|
||||
request.sortDescriptors = [NSSortDescriptor(keyPath: \Workout.start, ascending: false)]
|
||||
return request
|
||||
}
|
||||
|
||||
static func fetchRequest(for split: Split) -> NSFetchRequest<Workout> {
|
||||
let request = fetchRequest()
|
||||
request.predicate = NSPredicate(format: "split == %@", split)
|
||||
request.sortDescriptors = [NSSortDescriptor(keyPath: \Workout.start, ascending: false)]
|
||||
return request
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
@objc(WorkoutLog)
|
||||
public class WorkoutLog: NSManagedObject, Identifiable {
|
||||
@NSManaged public var date: Date
|
||||
@NSManaged public var sets: Int32
|
||||
@NSManaged public var reps: Int32
|
||||
@NSManaged public var weight: Int32
|
||||
@NSManaged private var statusRaw: String?
|
||||
@NSManaged public var order: Int32
|
||||
@NSManaged public var exerciseName: String
|
||||
@NSManaged public var currentStateIndex: Int32
|
||||
@NSManaged public var elapsedSeconds: Int32
|
||||
@NSManaged public var completed: Bool
|
||||
|
||||
@NSManaged public var workout: Workout?
|
||||
|
||||
public var id: NSManagedObjectID { objectID }
|
||||
|
||||
var status: WorkoutStatus? {
|
||||
get {
|
||||
guard let raw = statusRaw else { return nil }
|
||||
return WorkoutStatus(rawValue: raw)
|
||||
}
|
||||
set { statusRaw = newValue?.rawValue }
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Fetch Request
|
||||
|
||||
extension WorkoutLog {
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<WorkoutLog> {
|
||||
return NSFetchRequest<WorkoutLog>(entityName: "WorkoutLog")
|
||||
}
|
||||
|
||||
static func orderedFetchRequest(for workout: Workout) -> NSFetchRequest<WorkoutLog> {
|
||||
let request = fetchRequest()
|
||||
request.predicate = NSPredicate(format: "workout == %@", workout)
|
||||
request.sortDescriptors = [NSSortDescriptor(keyPath: \WorkoutLog.order, ascending: true)]
|
||||
return request
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import Foundation
|
||||
|
||||
enum WorkoutStatus: String, CaseIterable, Codable {
|
||||
case notStarted = "notStarted"
|
||||
case inProgress = "inProgress"
|
||||
case completed = "completed"
|
||||
case skipped = "skipped"
|
||||
|
||||
var displayName: String {
|
||||
switch self {
|
||||
case .notStarted:
|
||||
return "Not Started"
|
||||
case .inProgress:
|
||||
return "In Progress"
|
||||
case .completed:
|
||||
return "Completed"
|
||||
case .skipped:
|
||||
return "Skipped"
|
||||
}
|
||||
}
|
||||
|
||||
var name: String { displayName }
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
import CoreData
|
||||
import CloudKit
|
||||
|
||||
struct PersistenceController {
|
||||
static let shared = PersistenceController()
|
||||
|
||||
let container: NSPersistentCloudKitContainer
|
||||
|
||||
// CloudKit container identifier - same as iOS app for sync
|
||||
static let cloudKitContainerIdentifier = "iCloud.dev.rzen.indie.Workouts"
|
||||
|
||||
var viewContext: NSManagedObjectContext {
|
||||
container.viewContext
|
||||
}
|
||||
|
||||
// MARK: - Preview Support
|
||||
|
||||
static var preview: PersistenceController = {
|
||||
let controller = PersistenceController(inMemory: true)
|
||||
let viewContext = controller.container.viewContext
|
||||
|
||||
// Create sample data for previews
|
||||
let split = Split(context: viewContext)
|
||||
split.name = "Upper Body"
|
||||
split.color = "blue"
|
||||
split.systemImage = "dumbbell.fill"
|
||||
split.order = 0
|
||||
|
||||
let exercise = Exercise(context: viewContext)
|
||||
exercise.name = "Bench Press"
|
||||
exercise.sets = 3
|
||||
exercise.reps = 10
|
||||
exercise.weight = 135
|
||||
exercise.order = 0
|
||||
exercise.loadType = Int32(LoadType.weight.rawValue)
|
||||
exercise.split = split
|
||||
|
||||
do {
|
||||
try viewContext.save()
|
||||
} catch {
|
||||
let nsError = error as NSError
|
||||
fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
|
||||
}
|
||||
|
||||
return controller
|
||||
}()
|
||||
|
||||
// MARK: - Initialization
|
||||
|
||||
init(inMemory: Bool = false, cloudKitEnabled: Bool = true) {
|
||||
container = NSPersistentCloudKitContainer(name: "Workouts")
|
||||
|
||||
guard let description = container.persistentStoreDescriptions.first else {
|
||||
fatalError("Failed to retrieve a persistent store description.")
|
||||
}
|
||||
|
||||
if inMemory {
|
||||
description.url = URL(fileURLWithPath: "/dev/null")
|
||||
description.cloudKitContainerOptions = nil
|
||||
} else if cloudKitEnabled {
|
||||
// Check if CloudKit is available before enabling
|
||||
let cloudKitAvailable = FileManager.default.ubiquityIdentityToken != nil
|
||||
|
||||
if cloudKitAvailable {
|
||||
// Set CloudKit container options
|
||||
let cloudKitOptions = NSPersistentCloudKitContainerOptions(
|
||||
containerIdentifier: Self.cloudKitContainerIdentifier
|
||||
)
|
||||
description.cloudKitContainerOptions = cloudKitOptions
|
||||
} else {
|
||||
// CloudKit not available (not signed in, etc.)
|
||||
description.cloudKitContainerOptions = nil
|
||||
print("CloudKit not available - using local storage only")
|
||||
}
|
||||
|
||||
// Enable persistent history tracking (useful even without CloudKit)
|
||||
description.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
|
||||
description.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey)
|
||||
} else {
|
||||
// CloudKit explicitly disabled
|
||||
description.cloudKitContainerOptions = nil
|
||||
}
|
||||
|
||||
container.loadPersistentStores { storeDescription, error in
|
||||
if let error = error as NSError? {
|
||||
// In production, handle this more gracefully
|
||||
print("CoreData error: \(error), \(error.userInfo)")
|
||||
#if DEBUG
|
||||
fatalError("Unresolved error \(error), \(error.userInfo)")
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Configure view context
|
||||
container.viewContext.automaticallyMergesChangesFromParent = true
|
||||
container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
|
||||
|
||||
// Pin the viewContext to the current generation token
|
||||
do {
|
||||
try container.viewContext.setQueryGenerationFrom(.current)
|
||||
} catch {
|
||||
print("Failed to pin viewContext to the current generation: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Save Context
|
||||
|
||||
func save() {
|
||||
let context = container.viewContext
|
||||
if context.hasChanges {
|
||||
do {
|
||||
try context.save()
|
||||
} catch {
|
||||
let nsError = error as NSError
|
||||
print("Save error: \(nsError), \(nsError.userInfo)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,205 +0,0 @@
|
||||
import Foundation
|
||||
import SwiftData
|
||||
|
||||
final class AppContainer {
|
||||
static let logger = AppLogger(
|
||||
subsystem: Bundle.main.bundleIdentifier ?? "dev.rzen.indie.Workouts.watchkitapp",
|
||||
category: "AppContainer"
|
||||
)
|
||||
|
||||
static func create() -> ModelContainer {
|
||||
// Using the current models directly without migration plan to avoid reference errors
|
||||
let schema = Schema(SchemaVersion.models)
|
||||
|
||||
#if targetEnvironment(simulator) && os(watchOS)
|
||||
// Use local-only storage for watchOS simulator
|
||||
let configuration = ModelConfiguration(isStoredInMemoryOnly: false)
|
||||
logger.info("Creating local-only database for watchOS simulator")
|
||||
|
||||
do {
|
||||
let container = try ModelContainer(for: schema, configurations: configuration)
|
||||
|
||||
// Populate with test data if needed
|
||||
Task { @MainActor in
|
||||
await populateSimulatorData(container: container)
|
||||
}
|
||||
|
||||
return container
|
||||
} catch {
|
||||
logger.error("Failed to create simulator ModelContainer: \(error.localizedDescription)")
|
||||
fatalError("Failed to create simulator ModelContainer: \(error.localizedDescription)")
|
||||
}
|
||||
#else
|
||||
// Use CloudKit for real devices
|
||||
let configuration = ModelConfiguration(cloudKitDatabase: .automatic)
|
||||
logger.info("Creating CloudKit database for real device")
|
||||
|
||||
let container = try! ModelContainer(for: schema, configurations: configuration)
|
||||
return container
|
||||
#endif
|
||||
}
|
||||
|
||||
@MainActor
|
||||
static var preview: ModelContainer {
|
||||
let configuration = ModelConfiguration(isStoredInMemoryOnly: true)
|
||||
|
||||
do {
|
||||
let schema = Schema(SchemaVersion.models)
|
||||
let container = try ModelContainer(for: schema, configurations: configuration)
|
||||
return container
|
||||
} catch {
|
||||
fatalError("Failed to create preview ModelContainer: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private static func populateSimulatorData(container: ModelContainer) async {
|
||||
let context = container.mainContext
|
||||
|
||||
// Check if data already exists
|
||||
let fetchDescriptor = FetchDescriptor<Split>()
|
||||
guard (try? context.fetch(fetchDescriptor))?.isEmpty ?? true else {
|
||||
logger.info("Simulator database already has data, skipping population")
|
||||
return // Data already exists
|
||||
}
|
||||
|
||||
logger.info("Populating simulator database with test data from pf-starter-exercises.yaml")
|
||||
|
||||
// Create splits
|
||||
let upperBodySplit = Split(name: "Upper Body", color: "blue", systemImage: "figure.strengthtraining.traditional", order: 0)
|
||||
let lowerBodySplit = Split(name: "Lower Body", color: "green", systemImage: "figure.run", order: 1)
|
||||
let fullBodySplit = Split(name: "Full Body", color: "purple", systemImage: "figure.mixed.cardio", order: 2)
|
||||
let coreSplit = Split(name: "Core", color: "red", systemImage: "figure.core.training", order: 3)
|
||||
|
||||
context.insert(upperBodySplit)
|
||||
context.insert(lowerBodySplit)
|
||||
context.insert(fullBodySplit)
|
||||
context.insert(coreSplit)
|
||||
|
||||
// Create exercises based on pf-starter-exercises.yaml
|
||||
|
||||
// Upper Body Exercises
|
||||
let latPullDown = Exercise(split: upperBodySplit, exerciseName: "Lat Pull Down", order: 0, sets: 3, reps: 12, weight: 120)
|
||||
let seatedRow = Exercise(split: upperBodySplit, exerciseName: "Seated Row", order: 1, sets: 3, reps: 12, weight: 110)
|
||||
let shoulderPress = Exercise(split: upperBodySplit, exerciseName: "Shoulder Press", order: 2, sets: 3, reps: 10, weight: 90)
|
||||
let chestPress = Exercise(split: upperBodySplit, exerciseName: "Chest Press", order: 3, sets: 3, reps: 10, weight: 130)
|
||||
let tricepPress = Exercise(split: upperBodySplit, exerciseName: "Tricep Press", order: 4, sets: 3, reps: 12, weight: 70)
|
||||
let armCurl = Exercise(split: upperBodySplit, exerciseName: "Arm Curl", order: 5, sets: 3, reps: 12, weight: 60)
|
||||
|
||||
context.insert(latPullDown)
|
||||
context.insert(seatedRow)
|
||||
context.insert(shoulderPress)
|
||||
context.insert(chestPress)
|
||||
context.insert(tricepPress)
|
||||
context.insert(armCurl)
|
||||
|
||||
// Core Exercises
|
||||
let abdominal = Exercise(split: coreSplit, exerciseName: "Abdominal", order: 0, sets: 3, reps: 15, weight: 80)
|
||||
let rotary = Exercise(split: coreSplit, exerciseName: "Rotary", order: 1, sets: 3, reps: 15, weight: 70)
|
||||
let plank = Exercise(split: coreSplit, exerciseName: "Plank", order: 2, sets: 3, reps: 1, weight: 0) // Reps as time in minutes
|
||||
let russianTwists = Exercise(split: coreSplit, exerciseName: "Russian Twists", order: 3, sets: 3, reps: 20, weight: 25)
|
||||
|
||||
context.insert(abdominal)
|
||||
context.insert(rotary)
|
||||
context.insert(plank)
|
||||
context.insert(russianTwists)
|
||||
|
||||
// Lower Body Exercises
|
||||
let legPress = Exercise(split: lowerBodySplit, exerciseName: "Leg Press", order: 0, sets: 3, reps: 12, weight: 200)
|
||||
let legExtension = Exercise(split: lowerBodySplit, exerciseName: "Leg Extension", order: 1, sets: 3, reps: 12, weight: 110)
|
||||
let legCurl = Exercise(split: lowerBodySplit, exerciseName: "Leg Curl", order: 2, sets: 3, reps: 12, weight: 90)
|
||||
let adductor = Exercise(split: lowerBodySplit, exerciseName: "Adductor", order: 3, sets: 3, reps: 15, weight: 100)
|
||||
let abductor = Exercise(split: lowerBodySplit, exerciseName: "Abductor", order: 4, sets: 3, reps: 15, weight: 90)
|
||||
let calfs = Exercise(split: lowerBodySplit, exerciseName: "Calfs", order: 5, sets: 3, reps: 15, weight: 120)
|
||||
|
||||
context.insert(legPress)
|
||||
context.insert(legExtension)
|
||||
context.insert(legCurl)
|
||||
context.insert(adductor)
|
||||
context.insert(abductor)
|
||||
context.insert(calfs)
|
||||
|
||||
// Full Body Exercises (selected from both upper and lower)
|
||||
let fullBodyChestPress = Exercise(split: fullBodySplit, exerciseName: "Chest Press", order: 0, sets: 3, reps: 10, weight: 130)
|
||||
let fullBodyLatPullDown = Exercise(split: fullBodySplit, exerciseName: "Lat Pull Down", order: 1, sets: 3, reps: 12, weight: 120)
|
||||
let fullBodyLegPress = Exercise(split: fullBodySplit, exerciseName: "Leg Press", order: 2, sets: 3, reps: 12, weight: 200)
|
||||
let fullBodyAbdominal = Exercise(split: fullBodySplit, exerciseName: "Abdominal", order: 3, sets: 3, reps: 15, weight: 80)
|
||||
|
||||
context.insert(fullBodyChestPress)
|
||||
context.insert(fullBodyLatPullDown)
|
||||
context.insert(fullBodyLegPress)
|
||||
context.insert(fullBodyAbdominal)
|
||||
|
||||
// Create workouts
|
||||
let now = Date()
|
||||
|
||||
// Upper Body Workout (in progress)
|
||||
let upperBodyWorkout = Workout(start: now, end: now, split: upperBodySplit)
|
||||
upperBodyWorkout.status = 2
|
||||
// upperBodyWorkout.status = .inProgress
|
||||
upperBodyWorkout.end = nil
|
||||
context.insert(upperBodyWorkout)
|
||||
|
||||
// Lower Body Workout (scheduled for tomorrow)
|
||||
let tomorrow = Calendar.current.date(byAdding: .day, value: 1, to: now) ?? now
|
||||
let lowerBodyWorkout = Workout(start: tomorrow, end: tomorrow, split: lowerBodySplit)
|
||||
lowerBodyWorkout.status = 1
|
||||
// lowerBodyWorkout.status = .notStarted
|
||||
context.insert(lowerBodyWorkout)
|
||||
|
||||
// Full Body Workout (completed yesterday)
|
||||
let yesterday = Calendar.current.date(byAdding: .day, value: -1, to: now) ?? now
|
||||
let fullBodyWorkout = Workout(start: yesterday, end: yesterday, split: fullBodySplit)
|
||||
fullBodyWorkout.status = 3
|
||||
// fullBodyWorkout.status = .completed
|
||||
context.insert(fullBodyWorkout)
|
||||
|
||||
// Create workout logs for Upper Body workout (in progress)
|
||||
let chestPressLog = WorkoutLog(workout: upperBodyWorkout, exerciseName: chestPress.name, date: now, order: 0, sets: chestPress.sets, reps: chestPress.reps, weight: chestPress.weight, status: .completed, completed: true)
|
||||
let shoulderPressLog = WorkoutLog(workout: upperBodyWorkout, exerciseName: shoulderPress.name, date: now, order: 1, sets: shoulderPress.sets, reps: shoulderPress.reps, weight: shoulderPress.weight, status: .completed, completed: true)
|
||||
let latPullDownLog = WorkoutLog(workout: upperBodyWorkout, exerciseName: latPullDown.name, date: now, order: 2, sets: latPullDown.sets, reps: latPullDown.reps, weight: latPullDown.weight, status: .inProgress, completed: false)
|
||||
let seatedRowLog = WorkoutLog(workout: upperBodyWorkout, exerciseName: seatedRow.name, date: now, order: 3, sets: seatedRow.sets, reps: seatedRow.reps, weight: seatedRow.weight, status: .notStarted, completed: false)
|
||||
let tricepPressLog = WorkoutLog(workout: upperBodyWorkout, exerciseName: tricepPress.name, date: now, order: 4, sets: tricepPress.sets, reps: tricepPress.reps, weight: tricepPress.weight, status: .notStarted, completed: false)
|
||||
let armCurlLog = WorkoutLog(workout: upperBodyWorkout, exerciseName: armCurl.name, date: now, order: 5, sets: armCurl.sets, reps: armCurl.reps, weight: armCurl.weight, status: .notStarted, completed: false)
|
||||
|
||||
context.insert(chestPressLog)
|
||||
context.insert(shoulderPressLog)
|
||||
context.insert(latPullDownLog)
|
||||
context.insert(seatedRowLog)
|
||||
context.insert(tricepPressLog)
|
||||
context.insert(armCurlLog)
|
||||
|
||||
// Create workout logs for Lower Body workout (scheduled)
|
||||
let legPressLog = WorkoutLog(workout: lowerBodyWorkout, exerciseName: legPress.name, date: tomorrow, order: 0, sets: legPress.sets, reps: legPress.reps, weight: legPress.weight, status: .notStarted, completed: false)
|
||||
let legExtensionLog = WorkoutLog(workout: lowerBodyWorkout, exerciseName: legExtension.name, date: tomorrow, order: 1, sets: legExtension.sets, reps: legExtension.reps, weight: legExtension.weight, status: .notStarted, completed: false)
|
||||
let legCurlLog = WorkoutLog(workout: lowerBodyWorkout, exerciseName: legCurl.name, date: tomorrow, order: 2, sets: legCurl.sets, reps: legCurl.reps, weight: legCurl.weight, status: .notStarted, completed: false)
|
||||
let adductorLog = WorkoutLog(workout: lowerBodyWorkout, exerciseName: adductor.name, date: tomorrow, order: 3, sets: adductor.sets, reps: adductor.reps, weight: adductor.weight, status: .notStarted, completed: false)
|
||||
let abductorLog = WorkoutLog(workout: lowerBodyWorkout, exerciseName: abductor.name, date: tomorrow, order: 4, sets: abductor.sets, reps: abductor.reps, weight: abductor.weight, status: .notStarted, completed: false)
|
||||
let calfsLog = WorkoutLog(workout: lowerBodyWorkout, exerciseName: calfs.name, date: tomorrow, order: 5, sets: calfs.sets, reps: calfs.reps, weight: calfs.weight, status: .notStarted, completed: false)
|
||||
|
||||
context.insert(legPressLog)
|
||||
context.insert(legExtensionLog)
|
||||
context.insert(legCurlLog)
|
||||
context.insert(adductorLog)
|
||||
context.insert(abductorLog)
|
||||
context.insert(calfsLog)
|
||||
|
||||
// Create workout logs for Full Body workout (completed)
|
||||
let fullBodyChestPressLog = WorkoutLog(workout: fullBodyWorkout, exerciseName: fullBodyChestPress.name, date: yesterday, order: 0, sets: fullBodyChestPress.sets, reps: fullBodyChestPress.reps, weight: fullBodyChestPress.weight, status: .completed, completed: true)
|
||||
let fullBodyLatPullDownLog = WorkoutLog(workout: fullBodyWorkout, exerciseName: fullBodyLatPullDown.name, date: yesterday, order: 1, sets: fullBodyLatPullDown.sets, reps: fullBodyLatPullDown.reps, weight: fullBodyLatPullDown.weight, status: .completed, completed: true)
|
||||
let fullBodyLegPressLog = WorkoutLog(workout: fullBodyWorkout, exerciseName: fullBodyLegPress.name, date: yesterday, order: 2, sets: fullBodyLegPress.sets, reps: fullBodyLegPress.reps, weight: fullBodyLegPress.weight, status: .completed, completed: true)
|
||||
let fullBodyAbdominalLog = WorkoutLog(workout: fullBodyWorkout, exerciseName: fullBodyAbdominal.name, date: yesterday, order: 3, sets: fullBodyAbdominal.sets, reps: fullBodyAbdominal.reps, weight: fullBodyAbdominal.weight, status: .completed, completed: true)
|
||||
|
||||
context.insert(fullBodyChestPressLog)
|
||||
context.insert(fullBodyLatPullDownLog)
|
||||
context.insert(fullBodyLegPressLog)
|
||||
context.insert(fullBodyAbdominalLog)
|
||||
|
||||
do {
|
||||
try context.save()
|
||||
logger.info("Successfully populated simulator database with test data from pf-starter-exercises.yaml")
|
||||
} catch {
|
||||
logger.error("Failed to save test data: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import SwiftData
|
||||
|
||||
enum SchemaVersion {
|
||||
static var models: [any PersistentModel.Type] = [
|
||||
// Split.self,
|
||||
// Exercise.self,
|
||||
Workout.self,
|
||||
WorkoutLog.self
|
||||
]
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
import Foundation
|
||||
import OSLog
|
||||
|
||||
struct AppLogger {
|
||||
private let logger: Logger
|
||||
|
||||
init(subsystem: String, category: String) {
|
||||
self.logger = Logger(subsystem: subsystem, category: category)
|
||||
}
|
||||
|
||||
func debug(_ message: String) {
|
||||
logger.debug("\(message)")
|
||||
}
|
||||
|
||||
func info(_ message: String) {
|
||||
logger.info("\(message)")
|
||||
}
|
||||
|
||||
func error(_ message: String) {
|
||||
logger.error("\(message)")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import SwiftUI
|
||||
|
||||
extension Color {
|
||||
static func color(from name: String) -> Color {
|
||||
switch name.lowercased() {
|
||||
case "red": return .red
|
||||
case "orange": return .orange
|
||||
case "yellow": return .yellow
|
||||
case "green": return .green
|
||||
case "mint": return .mint
|
||||
case "teal": return .teal
|
||||
case "cyan": return .cyan
|
||||
case "blue": return .blue
|
||||
case "indigo": return .indigo
|
||||
case "purple": return .purple
|
||||
case "pink": return .pink
|
||||
case "brown": return .brown
|
||||
default: return .indigo
|
||||
}
|
||||
}
|
||||
|
||||
func darker(by percentage: CGFloat = 0.2) -> Color {
|
||||
return self.opacity(1.0 - percentage)
|
||||
}
|
||||
}
|
||||
|
||||
// Available colors for splits
|
||||
let availableColors = ["red", "orange", "yellow", "green", "mint", "teal", "cyan", "blue", "indigo", "purple", "pink", "brown"]
|
||||
|
||||
// Available system images for splits
|
||||
let availableIcons = ["dumbbell.fill", "figure.strengthtraining.traditional", "figure.run", "figure.hiking", "figure.cooldown", "figure.boxing", "figure.wrestling", "figure.gymnastics", "figure.handball", "figure.core.training", "heart.fill", "bolt.fill"]
|
||||
@@ -1,21 +0,0 @@
|
||||
import SwiftUI
|
||||
|
||||
extension Color {
|
||||
static func color(from name: String) -> Color {
|
||||
switch name {
|
||||
case "red": return .red
|
||||
case "orange": return .orange
|
||||
case "yellow": return .yellow
|
||||
case "green": return .green
|
||||
case "mint": return .mint
|
||||
case "teal": return .teal
|
||||
case "cyan": return .cyan
|
||||
case "blue": return .blue
|
||||
case "indigo": return .indigo
|
||||
case "purple": return .purple
|
||||
case "pink": return .pink
|
||||
case "brown": return .brown
|
||||
default: return .indigo
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import Foundation
|
||||
|
||||
extension Date {
|
||||
func formattedDate() -> String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .short
|
||||
formatter.timeStyle = .short
|
||||
return formatter.string(from: self)
|
||||
}
|
||||
|
||||
func formattedTime() -> String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .none
|
||||
formatter.timeStyle = .short
|
||||
return formatter.string(from: self)
|
||||
}
|
||||
|
||||
func isSameDay(as other: Date) -> Bool {
|
||||
Calendar.current.isDate(self, inSameDayAs: other)
|
||||
}
|
||||
|
||||
func formatDate() -> String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .medium
|
||||
formatter.timeStyle = .none
|
||||
return formatter.string(from: self)
|
||||
}
|
||||
|
||||
var abbreviatedMonth: String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateFormat = "MMM"
|
||||
return formatter.string(from: self)
|
||||
}
|
||||
|
||||
var dayOfMonth: Int {
|
||||
Calendar.current.component(.day, from: self)
|
||||
}
|
||||
|
||||
var abbreviatedWeekday: String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateFormat = "EEE"
|
||||
return formatter.string(from: self)
|
||||
}
|
||||
|
||||
func humanTimeInterval(to other: Date) -> String {
|
||||
let interval = other.timeIntervalSince(self)
|
||||
let hours = Int(interval) / 3600
|
||||
let minutes = (Int(interval) % 3600) / 60
|
||||
|
||||
if hours > 0 {
|
||||
return "\(hours)h \(minutes)m"
|
||||
} else {
|
||||
return "\(minutes)m"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import Foundation
|
||||
|
||||
extension Date {
|
||||
func formatDate() -> String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .short
|
||||
return formatter.string(from: self)
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import Foundation
|
||||
|
||||
extension Date {
|
||||
func formatDateET(format: String = "MMMM, d yyyy @ h:mm a z") -> String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.timeZone = TimeZone(identifier: "America/New_York")
|
||||
formatter.dateFormat = format
|
||||
return formatter.string(from: self)
|
||||
}
|
||||
|
||||
static var ISO8601: String {
|
||||
"yyyy-MM-dd'T'HH:mm:ssZ"
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import Foundation
|
||||
|
||||
extension Date {
|
||||
func formattedDate() -> String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .short
|
||||
return formatter.string(from: self)
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
import Foundation
|
||||
import WatchKit
|
||||
|
||||
struct HapticFeedback {
|
||||
static func success() {
|
||||
WKInterfaceDevice.current().play(.success)
|
||||
}
|
||||
|
||||
static func notification() {
|
||||
WKInterfaceDevice.current().play(.notification)
|
||||
}
|
||||
|
||||
static func click() {
|
||||
WKInterfaceDevice.current().play(.click)
|
||||
}
|
||||
|
||||
static func doubleTap() {
|
||||
WKInterfaceDevice.current().play(.click)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
WKInterfaceDevice.current().play(.click)
|
||||
}
|
||||
}
|
||||
|
||||
static func tripleTap() {
|
||||
WKInterfaceDevice.current().play(.notification)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
WKInterfaceDevice.current().play(.notification)
|
||||
}
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {
|
||||
WKInterfaceDevice.current().play(.notification)
|
||||
}
|
||||
}
|
||||
|
||||
static func longTap() {
|
||||
WKInterfaceDevice.current().play(.start)
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
//
|
||||
// TimeInterval+minutesSecons.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/23/25 at 4:22 PM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension Int {
|
||||
var secondsFormatted: String {
|
||||
let minutes = self / 60
|
||||
let seconds = self % 60
|
||||
return String(format: "%02d:%02d", minutes, seconds)
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
//
|
||||
// ExerciseDoneCard.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/23/25 at 4:29 PM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ExerciseDoneCard: View {
|
||||
let elapsedSeconds: Int
|
||||
let onComplete: () -> Void
|
||||
let onOneMoreSet: () -> Void
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 12) {
|
||||
Text("Exercise Complete!")
|
||||
.font(.headline)
|
||||
.foregroundColor(.green)
|
||||
|
||||
Button(action: onComplete) {
|
||||
Text("Done in \(10 - elapsedSeconds)s")
|
||||
.font(.subheadline)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.tint(.green)
|
||||
.padding(.horizontal)
|
||||
|
||||
Button(action: onOneMoreSet) {
|
||||
Text("One More Set")
|
||||
.font(.subheadline)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.tint(.blue)
|
||||
.padding(.horizontal)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
|
||||
private var timeFormatted: String {
|
||||
let minutes = elapsedSeconds / 60
|
||||
let seconds = elapsedSeconds % 60
|
||||
return String(format: "%02d:%02d", minutes, seconds)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
//
|
||||
// ExerciseIntroView.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/23/25 at 4:19 PM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ExerciseIntroCard: View {
|
||||
let log: WorkoutLog
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .center, spacing: 16) {
|
||||
Text(log.exerciseName)
|
||||
.font(.title)
|
||||
.lineLimit(1)
|
||||
.minimumScaleFactor(0.5)
|
||||
.layoutPriority(1)
|
||||
|
||||
HStack(alignment: .bottom) {
|
||||
Text("\(log.weight)")
|
||||
Text("lbs")
|
||||
.fontWeight(.light)
|
||||
.padding([.trailing], 10)
|
||||
|
||||
Text("\(log.sets)")
|
||||
Text("×")
|
||||
.fontWeight(.light)
|
||||
Text("\(log.reps)")
|
||||
}
|
||||
.font(.title3)
|
||||
.lineLimit(1)
|
||||
.minimumScaleFactor(0.5)
|
||||
.layoutPriority(1)
|
||||
|
||||
Text(log.status?.name ?? "Not Started")
|
||||
.foregroundStyle(Color.accentColor)
|
||||
}
|
||||
.padding()
|
||||
|
||||
// VStack(spacing: 20) {
|
||||
// Text(title)
|
||||
// .font(.title)
|
||||
//
|
||||
// Text(elapsedSeconds.secondsFormatted)
|
||||
// .font(.system(size: 48, weight: .semibold, design: .monospaced))
|
||||
// .foregroundStyle(Color.accentColor)
|
||||
// }
|
||||
// .padding()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
//
|
||||
// ExerciseRestCard.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/23/25 at 4:28 PM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ExerciseRestCard: View {
|
||||
let elapsedSeconds: Int
|
||||
let afterSet: Int
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 20) {
|
||||
Text("Resting after set #\(afterSet)")
|
||||
.font(.title3)
|
||||
.lineLimit(2)
|
||||
.minimumScaleFactor(0.5)
|
||||
.layoutPriority(1)
|
||||
|
||||
Text(elapsedSeconds.secondsFormatted)
|
||||
.font(.system(size: 48, weight: .semibold, design: .monospaced))
|
||||
.foregroundStyle(Color.green)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
//
|
||||
// ExerciseSetCard.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/23/25 at 4:26 PM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ExerciseSetCard: View {
|
||||
let set: Int
|
||||
let elapsedSeconds: Int
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 20) {
|
||||
Text("Set \(set)")
|
||||
.font(.title)
|
||||
|
||||
Text(elapsedSeconds.secondsFormatted)
|
||||
.font(.system(size: 48, weight: .semibold, design: .monospaced))
|
||||
.foregroundStyle(Color.accentColor)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
//
|
||||
// ExerciseProgressControlView 2.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/23/25 at 9:15 AM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ExerciseProgressControlView: View {
|
||||
let log: WorkoutLog
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@Environment(\.modelContext) private var modelContext
|
||||
|
||||
@State private var exerciseStates: [ExerciseState] = []
|
||||
@State private var currentStateIndex: Int = 0
|
||||
@State private var elapsedSeconds: Int = 0
|
||||
@State private var timer: Timer? = nil
|
||||
@State private var previousStateIndex: Int = 0
|
||||
@State private var hapticCounter: Int = 0
|
||||
|
||||
var body: some View {
|
||||
TabView(selection: $currentStateIndex) {
|
||||
ForEach(Array(exerciseStates.enumerated()), id: \.element.id) { index, state in
|
||||
if state.isIntro {
|
||||
ExerciseIntroCard(log: log)
|
||||
.tag(index)
|
||||
|
||||
} else if state.isSet {
|
||||
ExerciseSetCard(set: state.setNumber ?? 0, elapsedSeconds: elapsedSeconds)
|
||||
.tag(index)
|
||||
|
||||
} else if state.isRest {
|
||||
ExerciseRestCard(elapsedSeconds: elapsedSeconds, afterSet: state.afterSet ?? 0)
|
||||
.tag(index)
|
||||
|
||||
} else if state.isDone {
|
||||
ExerciseDoneCard(elapsedSeconds: elapsedSeconds, onComplete: completeExercise, onOneMoreSet: addOneMoreSet)
|
||||
.tag(index)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
.tabViewStyle(.page(indexDisplayMode: .never))
|
||||
.gesture(
|
||||
DragGesture()
|
||||
.onEnded { value in
|
||||
// Detect swipe left when on the Done card (last index)
|
||||
if currentStateIndex == exerciseStates.count - 1 && value.translation.width < -50 {
|
||||
// User swiped left from Done card - add one more set
|
||||
addOneMoreSet()
|
||||
}
|
||||
}
|
||||
)
|
||||
.onChange(of: currentStateIndex) { oldValue, newValue in
|
||||
if oldValue != newValue {
|
||||
elapsedSeconds = 0
|
||||
hapticCounter = 0 // Reset haptic pattern when changing phases
|
||||
// Update the log's current state but don't auto-advance
|
||||
log.currentStateIndex = currentStateIndex
|
||||
log.elapsedSeconds = elapsedSeconds
|
||||
try? modelContext.save()
|
||||
|
||||
// Update status based on current state
|
||||
if currentStateIndex > 0 && currentStateIndex < exerciseStates.count - 1 {
|
||||
log.status = .inProgress
|
||||
}
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
setupExerciseStates()
|
||||
currentStateIndex = log.currentStateIndex ?? 0
|
||||
startTimer()
|
||||
}
|
||||
.onChange(of: log.sets) { oldValue, newValue in
|
||||
// Reconstruct exercise states if sets count changed
|
||||
if oldValue != newValue {
|
||||
setupExerciseStates()
|
||||
}
|
||||
}
|
||||
.onDisappear {
|
||||
stopTimer()
|
||||
}
|
||||
}
|
||||
|
||||
private func setupExerciseStates() {
|
||||
var states: [ExerciseState] = []
|
||||
states.append(.intro)
|
||||
for i in 1...log.sets {
|
||||
states.append(.set(number: i))
|
||||
if i < log.sets {
|
||||
states.append(.rest(afterSet: i))
|
||||
}
|
||||
}
|
||||
states.append(.done)
|
||||
exerciseStates = states
|
||||
}
|
||||
|
||||
private func startTimer() {
|
||||
timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { _ in
|
||||
elapsedSeconds += 1
|
||||
|
||||
// Check if we need to provide haptic feedback
|
||||
if currentStateIndex >= 0 && currentStateIndex < exerciseStates.count {
|
||||
let currentState = exerciseStates[currentStateIndex]
|
||||
if currentState.isRest || currentState.isSet {
|
||||
provideHapticFeedback()
|
||||
} else if currentState.isDone && elapsedSeconds >= 10 {
|
||||
// Auto-complete after 10 seconds on the DONE state
|
||||
completeExercise()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func stopTimer() {
|
||||
timer?.invalidate()
|
||||
timer = nil
|
||||
}
|
||||
|
||||
|
||||
private func provideHapticFeedback() {
|
||||
// Provide haptic feedback every 15 seconds in a cycling pattern: 1 → 2 → 3 → long
|
||||
if elapsedSeconds % 15 == 0 && elapsedSeconds > 0 {
|
||||
hapticCounter += 1
|
||||
|
||||
switch hapticCounter % 4 {
|
||||
case 1:
|
||||
// First 15 seconds: single tap
|
||||
HapticFeedback.click()
|
||||
case 2:
|
||||
// Second 15 seconds: double tap
|
||||
HapticFeedback.doubleTap()
|
||||
case 3:
|
||||
// Third 15 seconds: triple tap
|
||||
HapticFeedback.tripleTap()
|
||||
case 0:
|
||||
// Fourth 15 seconds: long tap, then reset pattern
|
||||
HapticFeedback.longTap()
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func addOneMoreSet() {
|
||||
// Increment total sets
|
||||
log.sets += 1
|
||||
|
||||
// Reconstruct exercise states (will trigger onChange)
|
||||
setupExerciseStates()
|
||||
|
||||
// Calculate the state index for the additional set
|
||||
// States: intro(0) → set1(1) → rest1(2) → ... → setN(2N-1) → done(2N)
|
||||
// For the additional set, we want to go to setN which is at index 2N-1
|
||||
let additionalSetStateIndex = (log.sets * 2) - 1
|
||||
|
||||
log.status = .inProgress
|
||||
log.currentStateIndex = additionalSetStateIndex
|
||||
log.elapsedSeconds = 0
|
||||
elapsedSeconds = 0
|
||||
hapticCounter = 0
|
||||
|
||||
// Update the current state index for the TabView
|
||||
currentStateIndex = additionalSetStateIndex
|
||||
|
||||
try? modelContext.save()
|
||||
}
|
||||
|
||||
private func completeExercise() {
|
||||
// Update the workout log status to completed
|
||||
log.status = .completed
|
||||
|
||||
// reset index in case we wish to re-run the exercise
|
||||
log.currentStateIndex = 0
|
||||
|
||||
// Provide "tada" haptic feedback
|
||||
HapticFeedback.tripleTap()
|
||||
|
||||
// Dismiss this view to return to WorkoutDetailView
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@@ -1,317 +0,0 @@
|
||||
import SwiftUI
|
||||
import SwiftData
|
||||
import WatchKit
|
||||
|
||||
// Enum to track the current phase of the exercise
|
||||
enum ExercisePhase {
|
||||
case notStarted
|
||||
case exercising(setNumber: Int)
|
||||
case resting(setNumber: Int, elapsedSeconds: Int)
|
||||
case completed
|
||||
}
|
||||
|
||||
struct ExerciseProgressView: View {
|
||||
@Environment(\.modelContext) private var modelContext
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
let log: WorkoutLog
|
||||
|
||||
@State private var phase: ExercisePhase = .notStarted
|
||||
@State private var hapticSeconds: Int = 0
|
||||
@State private var restSeconds: Int = 0
|
||||
@State private var hapticTimer: Timer? = nil
|
||||
@State private var restTimer: Timer? = nil
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
VStack(spacing: 15) {
|
||||
exerciseHeader
|
||||
|
||||
switch phase {
|
||||
case .notStarted:
|
||||
startPhaseView
|
||||
case .exercising(let setNumber):
|
||||
exercisingPhaseView(setNumber: setNumber)
|
||||
case .resting(let setNumber, let elapsedSeconds):
|
||||
restingPhaseView(setNumber: setNumber, elapsedSeconds: elapsedSeconds)
|
||||
case .completed:
|
||||
completedPhaseView
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
.navigationTitle(log.exerciseName)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.onDisappear {
|
||||
stopTimers()
|
||||
}
|
||||
.gesture(
|
||||
DragGesture(minimumDistance: 50)
|
||||
.onEnded { gesture in
|
||||
if gesture.translation.width < 0 {
|
||||
// Swipe left - progress to next phase
|
||||
handleSwipeLeft()
|
||||
} else if gesture.translation.height < 0 && gesture.translation.height < -50 {
|
||||
// Swipe up - cancel current set
|
||||
handleSwipeUp()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - View Components
|
||||
|
||||
private var exerciseHeader: some View {
|
||||
VStack(alignment: .leading, spacing: 5) {
|
||||
Text(log.exerciseName)
|
||||
.font(.headline)
|
||||
.foregroundColor(.primary)
|
||||
|
||||
Text("\(log.sets) sets × \(log.reps) reps")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
Text("\(log.weight) lbs")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.bottom, 5)
|
||||
}
|
||||
|
||||
private var startPhaseView: some View {
|
||||
VStack(spacing: 20) {
|
||||
Text("Ready to start?")
|
||||
.font(.headline)
|
||||
|
||||
Button(action: startFirstSet) {
|
||||
Text("Start First Set")
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.tint(.blue)
|
||||
}
|
||||
}
|
||||
|
||||
private func exercisingPhaseView(setNumber: Int) -> some View {
|
||||
VStack(spacing: 20) {
|
||||
Text("Set \(setNumber) of \(log.sets)")
|
||||
.font(.headline)
|
||||
|
||||
Text("Exercising...")
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
HStack(spacing: 20) {
|
||||
Button(action: completeSet) {
|
||||
Text("Complete")
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.tint(.green)
|
||||
|
||||
Button(action: cancelSet) {
|
||||
Text("Cancel")
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.tint(.red)
|
||||
}
|
||||
|
||||
Text("Or swipe left to complete")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
Text("Swipe up to cancel")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
|
||||
private func restingPhaseView(setNumber: Int, elapsedSeconds: Int) -> some View {
|
||||
VStack(spacing: 20) {
|
||||
Text("Rest after Set \(setNumber)")
|
||||
.font(.headline)
|
||||
|
||||
Text("Rest time: \(formatSeconds(elapsedSeconds))")
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
if setNumber < (log.sets) {
|
||||
Button(action: { startNextSet(after: setNumber) }) {
|
||||
Text("Start Set \(setNumber + 1)")
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.tint(.blue)
|
||||
|
||||
Text("Or swipe left to start next set")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
} else {
|
||||
Button(action: completeExercise) {
|
||||
Text("Complete Exercise")
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.tint(.green)
|
||||
|
||||
Text("Or swipe left to complete")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var completedPhaseView: some View {
|
||||
VStack(spacing: 20) {
|
||||
Text("Exercise Completed!")
|
||||
.font(.headline)
|
||||
.foregroundColor(.green)
|
||||
|
||||
Image(systemName: "checkmark.circle.fill")
|
||||
.font(.system(size: 50))
|
||||
.foregroundColor(.green)
|
||||
|
||||
Button(action: { dismiss() }) {
|
||||
Text("Return to Workout")
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.tint(.blue)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Action Handlers
|
||||
|
||||
private func handleSwipeLeft() {
|
||||
switch phase {
|
||||
case .notStarted:
|
||||
startFirstSet()
|
||||
case .exercising:
|
||||
completeSet()
|
||||
case .resting(let setNumber, _):
|
||||
if setNumber < (log.sets) {
|
||||
startNextSet(after: setNumber)
|
||||
} else {
|
||||
completeExercise()
|
||||
}
|
||||
case .completed:
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
private func handleSwipeUp() {
|
||||
if case .exercising = phase {
|
||||
cancelSet()
|
||||
}
|
||||
}
|
||||
|
||||
private func startFirstSet() {
|
||||
phase = .exercising(setNumber: 1)
|
||||
startHapticTimer()
|
||||
}
|
||||
|
||||
private func startNextSet(after completedSetNumber: Int) {
|
||||
stopTimers()
|
||||
let nextSetNumber = completedSetNumber + 1
|
||||
phase = .exercising(setNumber: nextSetNumber)
|
||||
startHapticTimer()
|
||||
}
|
||||
|
||||
private func completeSet() {
|
||||
stopTimers()
|
||||
|
||||
if case .exercising(let setNumber) = phase {
|
||||
// Start rest timer
|
||||
phase = .resting(setNumber: setNumber, elapsedSeconds: 0)
|
||||
startRestTimer()
|
||||
startHapticTimer()
|
||||
|
||||
// Play completion haptic
|
||||
HapticFeedback.success()
|
||||
}
|
||||
}
|
||||
|
||||
private func cancelSet() {
|
||||
// Just go back to the previous state
|
||||
stopTimers()
|
||||
phase = .notStarted
|
||||
}
|
||||
|
||||
private func completeExercise() {
|
||||
stopTimers()
|
||||
|
||||
// Update workout log
|
||||
log.completed = true
|
||||
log.status = .completed
|
||||
try? modelContext.save()
|
||||
|
||||
// Show completion screen
|
||||
phase = .completed
|
||||
|
||||
// Play completion haptic
|
||||
HapticFeedback.success()
|
||||
}
|
||||
|
||||
// MARK: - Timer Management
|
||||
|
||||
private func startHapticTimer() {
|
||||
hapticSeconds = 0
|
||||
hapticTimer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { _ in
|
||||
hapticSeconds += 1
|
||||
|
||||
// Provide haptic feedback based on time intervals
|
||||
if hapticSeconds % 60 == 0 {
|
||||
// Triple tap every 60 seconds
|
||||
HapticFeedback.tripleTap()
|
||||
} else if hapticSeconds % 30 == 0 {
|
||||
// Double tap every 30 seconds
|
||||
HapticFeedback.doubleTap()
|
||||
} else if hapticSeconds % 10 == 0 {
|
||||
// Light tap every 10 seconds
|
||||
HapticFeedback.click()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func startRestTimer() {
|
||||
restSeconds = 0
|
||||
restTimer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { _ in
|
||||
restSeconds += 1
|
||||
|
||||
if case .resting(let setNumber, _) = phase {
|
||||
phase = .resting(setNumber: setNumber, elapsedSeconds: restSeconds)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func stopTimers() {
|
||||
hapticTimer?.invalidate()
|
||||
hapticTimer = nil
|
||||
|
||||
restTimer?.invalidate()
|
||||
restTimer = nil
|
||||
}
|
||||
|
||||
// MARK: - Helper Functions
|
||||
|
||||
private func formatSeconds(_ seconds: Int) -> String {
|
||||
let minutes = seconds / 60
|
||||
let remainingSeconds = seconds % 60
|
||||
return String(format: "%d:%02d", minutes, remainingSeconds)
|
||||
}
|
||||
}
|
||||
|
||||
//#Preview {
|
||||
// let config = ModelConfiguration(isStoredInMemoryOnly: true)
|
||||
// let container = try! ModelContainer(for: SchemaV1.models, configurations: config)
|
||||
//
|
||||
// // Create sample data
|
||||
// let exercise = Exercise(name: "Bench Press", sets: 3, reps: 8, weight: 60.0)
|
||||
// let workout = Workout(name: "Chest Day", date: Date())
|
||||
// let log = WorkoutLog(exercise: exercise, workout: workout)
|
||||
//
|
||||
// NavigationStack {
|
||||
// ExerciseProgressView(log: log)
|
||||
// .modelContainer(container)
|
||||
// }
|
||||
//}
|
||||
@@ -1,72 +0,0 @@
|
||||
//
|
||||
// ExerciseState.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/23/25 at 9:14 AM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
|
||||
|
||||
enum ExerciseState: Identifiable {
|
||||
case intro
|
||||
case set(number: Int)
|
||||
case rest(afterSet: Int)
|
||||
case done
|
||||
|
||||
var id: String {
|
||||
switch self {
|
||||
case .intro:
|
||||
return "detail"
|
||||
case .set(let number):
|
||||
return "set_\(number)"
|
||||
case .rest(let afterSet):
|
||||
return "rest_\(afterSet)"
|
||||
case .done:
|
||||
return "done"
|
||||
}
|
||||
}
|
||||
|
||||
var setNumber: Int? {
|
||||
switch self {
|
||||
case .intro, .rest, .done: return nil
|
||||
case .set (let number): return number
|
||||
}
|
||||
}
|
||||
|
||||
var afterSet: Int? {
|
||||
switch self {
|
||||
case .intro, .set, .done: return nil
|
||||
case .rest (let afterSet): return afterSet
|
||||
}
|
||||
}
|
||||
|
||||
var isIntro: Bool {
|
||||
if case .intro = self {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var isSet: Bool {
|
||||
if case .set = self {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var isRest: Bool {
|
||||
if case .rest = self {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var isDone: Bool {
|
||||
if case .done = self {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
//
|
||||
// ExerciseStateView 2.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/23/25 at 9:15 AM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ExerciseStateView: View {
|
||||
let title: String
|
||||
let isRest: Bool
|
||||
let isDone: Bool
|
||||
let elapsedSeconds: Int
|
||||
let onComplete: () -> Void
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 20) {
|
||||
Text(title)
|
||||
.font(.title)
|
||||
|
||||
Text(timeFormatted)
|
||||
.font(.system(size: 48, weight: .semibold, design: .monospaced))
|
||||
.foregroundStyle(isRest ? .orange : .accentColor)
|
||||
|
||||
if isDone {
|
||||
Button(action: onComplete) {
|
||||
Text("Done in \(10 - elapsedSeconds)s")
|
||||
.font(.headline)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.tint(.green)
|
||||
.padding(.horizontal)
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
|
||||
private var timeFormatted: String {
|
||||
let minutes = elapsedSeconds / 60
|
||||
let seconds = elapsedSeconds % 60
|
||||
return String(format: "%02d:%02d", minutes, seconds)
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
//
|
||||
// ActiveWorkoutListView.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/20/25 at 6:35 PM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import SwiftData
|
||||
|
||||
struct ActiveWorkoutListView: View {
|
||||
@Environment(\.modelContext) private var modelContext
|
||||
let workouts: [Workout]
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
ForEach(workouts) { workout in
|
||||
NavigationLink {
|
||||
WorkoutDetailView(workout: workout)
|
||||
} label: {
|
||||
WorkoutCardView(workout: workout)
|
||||
}
|
||||
.listRowBackground(
|
||||
RoundedRectangle(cornerRadius: 12)
|
||||
.fill(Color.secondary.opacity(0.2))
|
||||
.padding(
|
||||
EdgeInsets(
|
||||
top: 4,
|
||||
leading: 8,
|
||||
bottom: 4,
|
||||
trailing: 8
|
||||
)
|
||||
)
|
||||
)
|
||||
// .swipeActions (edge: .trailing, allowsFullSwipe: false) {
|
||||
// Button {
|
||||
// //
|
||||
// } label: {
|
||||
// Label("Delete", systemImage: "trash")
|
||||
// .frame(height: 40)
|
||||
// }
|
||||
// .tint(.red)
|
||||
// }
|
||||
}
|
||||
}
|
||||
.listStyle(.carousel)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
let container = AppContainer.preview
|
||||
let split = Split(name: "Upper Body", color: "blue", systemImage: "figure.strengthtraining.traditional")
|
||||
let workout1 = Workout(start: Date(), end: Date(), split: split)
|
||||
|
||||
let split2 = Split(name: "Lower Body", color: "red", systemImage: "figure.run")
|
||||
let workout2 = Workout(start: Date().addingTimeInterval(-3600), end: Date(), split: split2)
|
||||
|
||||
ActiveWorkoutListView(workouts: [workout1, workout2])
|
||||
.modelContainer(container)
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
//
|
||||
// WorkoutCardView.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/22/25 at 9:54 PM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct WorkoutCardView: View {
|
||||
let workout: Workout
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
if let split = workout.split {
|
||||
Image(systemName: split.systemImage)
|
||||
.font(.system(size: 48))
|
||||
.foregroundStyle(split.getColor())
|
||||
} else {
|
||||
Image(systemName: "dumbbell.fill")
|
||||
.font(.system(size: 24))
|
||||
.foregroundStyle(.gray)
|
||||
}
|
||||
|
||||
Text(workout.split?.name ?? "Workout")
|
||||
.font(.headline)
|
||||
.foregroundStyle(.white)
|
||||
|
||||
Text("\(workout.statusName)~")
|
||||
.font(.caption)
|
||||
.foregroundStyle(Color.accentColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
//
|
||||
// WorkoutDetailView.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/22/25 at 9:54 PM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import SwiftData
|
||||
|
||||
struct WorkoutDetailView: View {
|
||||
let workout: Workout
|
||||
@Environment(\.modelContext) private var modelContext
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
@State private var showingCompletedDialog = false
|
||||
@State private var selectedLog: WorkoutLog? = nil
|
||||
@State private var navigateToExercise = false
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .center, spacing: 8) {
|
||||
if let logs = workout.logs?.sorted(by: { $0.order < $1.order }), !logs.isEmpty {
|
||||
List {
|
||||
ForEach(logs) { log in
|
||||
Button {
|
||||
handleExerciseTap(log)
|
||||
} label: {
|
||||
WorkoutLogCardView(log: log)
|
||||
}
|
||||
.listRowBackground(
|
||||
RoundedRectangle(cornerRadius: 12)
|
||||
.fill(Color.secondary.opacity(0.2))
|
||||
.padding(
|
||||
EdgeInsets(
|
||||
top: 4,
|
||||
leading: 8,
|
||||
bottom: 4,
|
||||
trailing: 8
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
.listStyle(.carousel)
|
||||
} else {
|
||||
Text("No exercises in this workout")
|
||||
.font(.body)
|
||||
.foregroundStyle(.secondary)
|
||||
.padding()
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.navigationDestination(isPresented: $navigateToExercise) {
|
||||
if let selectedLog = selectedLog {
|
||||
ExerciseProgressControlView(log: selectedLog)
|
||||
}
|
||||
}
|
||||
.alert("Exercise Completed", isPresented: $showingCompletedDialog) {
|
||||
Button("Cancel", role: .cancel) {
|
||||
// Do nothing, just dismiss
|
||||
}
|
||||
Button("Restart") {
|
||||
if let log = selectedLog {
|
||||
restartExercise(log)
|
||||
}
|
||||
}
|
||||
Button("One More Set") {
|
||||
if let log = selectedLog {
|
||||
addOneMoreSet(log)
|
||||
}
|
||||
}
|
||||
} message: {
|
||||
Text("This exercise is already completed. What would you like to do?")
|
||||
}
|
||||
}
|
||||
|
||||
private func handleExerciseTap(_ log: WorkoutLog) {
|
||||
selectedLog = log
|
||||
|
||||
switch log.status {
|
||||
case .notStarted:
|
||||
// Start from beginning
|
||||
log.currentStateIndex = 0
|
||||
try? modelContext.save()
|
||||
navigateToExercise = true
|
||||
|
||||
case .inProgress:
|
||||
// If we're in a rest state, advance to the next set
|
||||
if let currentStateIndex = log.currentStateIndex, isRestState(currentStateIndex) {
|
||||
log.currentStateIndex = currentStateIndex + 1
|
||||
try? modelContext.save()
|
||||
}
|
||||
// Continue from current (possibly updated) position
|
||||
navigateToExercise = true
|
||||
|
||||
case .completed:
|
||||
// Show dialog for completed exercise
|
||||
showingCompletedDialog = true
|
||||
|
||||
default:
|
||||
// Default to not started behavior
|
||||
log.currentStateIndex = 0
|
||||
try? modelContext.save()
|
||||
navigateToExercise = true
|
||||
}
|
||||
}
|
||||
|
||||
private func restartExercise(_ log: WorkoutLog) {
|
||||
log.status = .notStarted
|
||||
log.currentStateIndex = 0
|
||||
log.elapsedSeconds = 0
|
||||
try? modelContext.save()
|
||||
navigateToExercise = true
|
||||
}
|
||||
|
||||
private func addOneMoreSet(_ log: WorkoutLog) {
|
||||
// Increment total sets
|
||||
log.sets += 1
|
||||
|
||||
// Calculate the state index for the additional set
|
||||
// States: intro(0) → set1(1) → rest1(2) → ... → setN(2N-1) → done(2N)
|
||||
// For the additional set, we want to go to setN+1 which is at index 2N+1
|
||||
let additionalSetStateIndex = (log.sets * 2) - 1
|
||||
|
||||
log.status = .inProgress
|
||||
log.currentStateIndex = additionalSetStateIndex
|
||||
log.elapsedSeconds = 0
|
||||
|
||||
try? modelContext.save()
|
||||
navigateToExercise = true
|
||||
}
|
||||
|
||||
private func isRestState(_ stateIndex: Int) -> Bool {
|
||||
// Rest states are at even indices > 0
|
||||
return stateIndex > 0 && stateIndex % 2 == 0
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
//
|
||||
// WorkoutLogCardView.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/22/25 at 9:56 PM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct WorkoutLogCardView: View {
|
||||
let log: WorkoutLog
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Text(log.exerciseName)
|
||||
.font(.headline)
|
||||
.lineLimit(1)
|
||||
|
||||
Text(getStatusText(for: log))
|
||||
.font(.caption)
|
||||
.foregroundStyle(Color.accentColor)
|
||||
|
||||
HStack(spacing: 12) {
|
||||
Text("\(log.weight) lbs")
|
||||
|
||||
Spacer()
|
||||
|
||||
Text("\(log.sets) × \(log.reps)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func getStatusText(for log: WorkoutLog) -> String {
|
||||
guard let status = log.status else {
|
||||
return "Not Started"
|
||||
}
|
||||
|
||||
if status == .inProgress, let currentStateIndex = log.currentStateIndex {
|
||||
let currentSet = getCurrentSetNumber(stateIndex: currentStateIndex, totalSets: log.sets)
|
||||
if currentSet > 0 {
|
||||
return "In Progress, Set #\(currentSet)"
|
||||
}
|
||||
}
|
||||
|
||||
return status.name
|
||||
}
|
||||
|
||||
private func getCurrentSetNumber(stateIndex: Int, totalSets: Int) -> Int {
|
||||
// Exercise states are structured as: intro(0) → set1(1) → rest1(2) → set2(3) → rest2(4) → ... → done
|
||||
// For each set number n, set state index = 2n-1, rest state index = 2n
|
||||
|
||||
if stateIndex <= 0 {
|
||||
return 0 // intro or invalid
|
||||
}
|
||||
|
||||
// Check if we're in a rest state (even indices > 0)
|
||||
let isRestState = stateIndex > 0 && stateIndex % 2 == 0
|
||||
|
||||
if isRestState {
|
||||
// During rest, show the next set number
|
||||
let nextSetNumber = (stateIndex / 2) + 1
|
||||
return min(nextSetNumber, totalSets)
|
||||
} else {
|
||||
// During set, show current set number
|
||||
let currentSetNumber = (stateIndex + 1) / 2
|
||||
return min(currentSetNumber, totalSets)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
//
|
||||
// WorkoutLogDetailView.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/22/25 at 9:57 PM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct WorkoutLogDetailView: View {
|
||||
let log: WorkoutLog
|
||||
|
||||
var body: some View {
|
||||
NavigationLink {
|
||||
ExerciseProgressControlView(log: log)
|
||||
} label: {
|
||||
VStack(alignment: .center) {
|
||||
Text(log.exerciseName)
|
||||
.font(.title)
|
||||
.lineLimit(1)
|
||||
.minimumScaleFactor(0.5)
|
||||
.layoutPriority(1)
|
||||
|
||||
HStack (alignment: .bottom) {
|
||||
Text("\(log.weight)")
|
||||
Text( "lbs")
|
||||
.fontWeight(.light)
|
||||
.padding([.trailing], 10)
|
||||
|
||||
Text("\(log.sets)")
|
||||
Text("×")
|
||||
.fontWeight(.light)
|
||||
Text("\(log.reps)")
|
||||
}
|
||||
.font(.title3)
|
||||
.lineLimit(1)
|
||||
.minimumScaleFactor(0.5)
|
||||
.layoutPriority(1)
|
||||
|
||||
Text(log.status?.name ?? "Not Started")
|
||||
.foregroundStyle(Color.accentColor)
|
||||
|
||||
Text("Tap to start")
|
||||
.foregroundStyle(Color.accentColor)
|
||||
|
||||
}
|
||||
.padding()
|
||||
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
|
||||
private func statusColor(for status: WorkoutStatus?) -> Color {
|
||||
guard let status = status else { return .secondary }
|
||||
|
||||
switch status {
|
||||
case .notStarted:
|
||||
return .secondary
|
||||
case .inProgress:
|
||||
return .blue
|
||||
case .completed:
|
||||
return .green
|
||||
case .skipped:
|
||||
return .red
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
import SwiftUI
|
||||
import SwiftData
|
||||
|
||||
struct WorkoutLogListView: View {
|
||||
@Environment(\.modelContext) private var modelContext
|
||||
let workout: Workout
|
||||
|
||||
@State private var selectedLogIndex: Int = 0
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
if let logs = workout.logs?.sorted(by: { $0.order < $1.order }), !logs.isEmpty {
|
||||
TabView(selection: $selectedLogIndex) {
|
||||
ForEach(Array(logs.enumerated()), id: \.element.id) { index, log in
|
||||
WorkoutLogCard(log: log, index: index)
|
||||
.tag(index)
|
||||
}
|
||||
}
|
||||
.tabViewStyle(.page)
|
||||
// .indexViewStyle(.page(backgroundDisplayMode: .always))
|
||||
} else {
|
||||
Text("No exercises in this workout")
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
.navigationTitle(workout.split?.name ?? "Workout")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
}
|
||||
}
|
||||
|
||||
struct WorkoutLogCard: View {
|
||||
let log: WorkoutLog
|
||||
let index: Int
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 12) {
|
||||
Text(log.exerciseName)
|
||||
.font(.headline)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
HStack {
|
||||
VStack {
|
||||
Text("\(log.sets)")
|
||||
.font(.title2)
|
||||
Text("Sets")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
VStack {
|
||||
Text("\(log.reps)")
|
||||
.font(.title2)
|
||||
Text("Reps")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
VStack {
|
||||
Text("\(log.weight)")
|
||||
.font(.title2)
|
||||
Text("Weight")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
|
||||
NavigationLink {
|
||||
ExerciseProgressView(log: log)
|
||||
} label: {
|
||||
Text("Start")
|
||||
.font(.headline)
|
||||
.foregroundStyle(.white)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.vertical, 8)
|
||||
.background(Color.blue)
|
||||
.cornerRadius(8)
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
|
||||
Text(log.status?.name ?? "Not Started")
|
||||
.font(.caption)
|
||||
.foregroundStyle(statusColor(for: log.status))
|
||||
}
|
||||
.padding()
|
||||
.background(Color.secondary.opacity(0.2))
|
||||
.cornerRadius(12)
|
||||
.padding(.horizontal)
|
||||
}
|
||||
|
||||
private func statusColor(for status: WorkoutStatus?) -> Color {
|
||||
guard let status = status else { return .secondary }
|
||||
|
||||
switch status {
|
||||
case .notStarted:
|
||||
return .secondary
|
||||
case .inProgress:
|
||||
return .blue
|
||||
case .completed:
|
||||
return .green
|
||||
case .skipped:
|
||||
return .red
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
let container = AppContainer.preview
|
||||
let workout = Workout(start: Date(), end: Date(), split: nil)
|
||||
let log1 = WorkoutLog(workout: workout, exerciseName: "Bench Press", date: Date(), sets: 3, reps: 10, weight: 135)
|
||||
let log2 = WorkoutLog(workout: workout, exerciseName: "Squats", date: Date(), order: 1, sets: 3, reps: 8, weight: 225)
|
||||
|
||||
return WorkoutLogListView(workout: workout)
|
||||
.modelContainer(container)
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
<string>development</string>
|
||||
<key>com.apple.developer.icloud-container-identifiers</key>
|
||||
<array>
|
||||
<string>iCloud.com.dev.rzen.indie.Workouts</string>
|
||||
<string>iCloud.dev.rzen.indie.Workouts</string>
|
||||
</array>
|
||||
<key>com.apple.developer.icloud-services</key>
|
||||
<array>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>UIBackgroundModes</key>
|
||||
<array/>
|
||||
<key>_XCCurrentVersionName</key>
|
||||
<string>Workouts.xcdatamodel</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="23231" systemVersion="24D5034f" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithCloudKit="YES" userDefinedModelVersionIdentifier="">
|
||||
<entity name="Split" representedClassName="Split" syncable="YES">
|
||||
<attribute name="color" attributeType="String" defaultValueString="indigo"/>
|
||||
<attribute name="name" attributeType="String" defaultValueString=""/>
|
||||
<attribute name="order" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="systemImage" attributeType="String" defaultValueString="dumbbell.fill"/>
|
||||
<relationship name="exercises" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="Exercise" inverseName="split" inverseEntity="Exercise"/>
|
||||
<relationship name="workouts" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Workout" inverseName="split" inverseEntity="Workout"/>
|
||||
</entity>
|
||||
<entity name="Exercise" representedClassName="Exercise" syncable="YES">
|
||||
<attribute name="duration" attributeType="Date" defaultDateTimeInterval="0" usesScalarValueType="NO"/>
|
||||
<attribute name="loadType" attributeType="Integer 32" defaultValueString="1" usesScalarValueType="YES"/>
|
||||
<attribute name="name" attributeType="String" defaultValueString=""/>
|
||||
<attribute name="order" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="reps" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="sets" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="weight" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="weightLastUpdated" attributeType="Date" defaultDateTimeInterval="0" usesScalarValueType="NO"/>
|
||||
<attribute name="weightReminderTimeIntervalWeeks" attributeType="Integer 32" defaultValueString="2" usesScalarValueType="YES"/>
|
||||
<relationship name="split" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Split" inverseName="exercises" inverseEntity="Split"/>
|
||||
</entity>
|
||||
<entity name="Workout" representedClassName="Workout" syncable="YES">
|
||||
<attribute name="end" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
||||
<attribute name="start" attributeType="Date" defaultDateTimeInterval="0" usesScalarValueType="NO"/>
|
||||
<attribute name="status" attributeType="String" defaultValueString="notStarted"/>
|
||||
<relationship name="logs" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="WorkoutLog" inverseName="workout" inverseEntity="WorkoutLog"/>
|
||||
<relationship name="split" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Split" inverseName="workouts" inverseEntity="Split"/>
|
||||
</entity>
|
||||
<entity name="WorkoutLog" representedClassName="WorkoutLog" syncable="YES">
|
||||
<attribute name="completed" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||
<attribute name="currentStateIndex" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="date" attributeType="Date" defaultDateTimeInterval="0" usesScalarValueType="NO"/>
|
||||
<attribute name="elapsedSeconds" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="exerciseName" attributeType="String" defaultValueString=""/>
|
||||
<attribute name="order" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="reps" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="sets" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="status" optional="YES" attributeType="String" defaultValueString="notStarted"/>
|
||||
<attribute name="weight" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<relationship name="workout" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Workout" inverseName="logs" inverseEntity="Workout"/>
|
||||
</entity>
|
||||
</model>
|
||||
@@ -1,23 +1,24 @@
|
||||
//
|
||||
// WorksoutsApp.swift
|
||||
// Workouts
|
||||
// WorkoutsApp.swift
|
||||
// Workouts Watch App
|
||||
//
|
||||
// Created by rzen on 7/15/25 at 7:09 PM.
|
||||
// Created by rzen on 8/13/25 at 11:10 AM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
|
||||
import SwiftUI
|
||||
import SwiftData
|
||||
import CoreData
|
||||
|
||||
@main
|
||||
struct Workouts_Watch_AppApp: App {
|
||||
let container = AppContainer.create()
|
||||
struct WorkoutsWatchApp: App {
|
||||
let persistenceController = PersistenceController.shared
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
.modelContainer(container)
|
||||
.environment(\.managedObjectContext, persistenceController.viewContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
////
|
||||
//// ExerciseDetailView.swift
|
||||
//// Workouts
|
||||
////
|
||||
//// Created by rzen on 7/23/25 at 9:17 AM.
|
||||
////
|
||||
//// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
////
|
||||
//
|
||||
//import SwiftUI
|
||||
//
|
||||
//struct ExerciseDetailView: View {
|
||||
// let log: WorkoutLog
|
||||
// let onStart: () -> Void
|
||||
//
|
||||
// var body: some View {
|
||||
// VStack(alignment: .center, spacing: 16) {
|
||||
// Text(log.exerciseName)
|
||||
// .font(.title)
|
||||
// .lineLimit(1)
|
||||
// .minimumScaleFactor(0.5)
|
||||
// .layoutPriority(1)
|
||||
//
|
||||
// HStack(alignment: .bottom) {
|
||||
// Text("\(log.weight)")
|
||||
// Text("lbs")
|
||||
// .fontWeight(.light)
|
||||
// .padding([.trailing], 10)
|
||||
//
|
||||
// Text("\(log.sets)")
|
||||
// Text("×")
|
||||
// .fontWeight(.light)
|
||||
// Text("\(log.reps)")
|
||||
// }
|
||||
// .font(.title3)
|
||||
// .lineLimit(1)
|
||||
// .minimumScaleFactor(0.5)
|
||||
// .layoutPriority(1)
|
||||
//
|
||||
// Text(log.status?.name ?? "Not Started")
|
||||
// .foregroundStyle(Color.accentColor)
|
||||
// }
|
||||
// .padding()
|
||||
// }
|
||||
//}
|
||||
@@ -1,35 +0,0 @@
|
||||
////
|
||||
//// ExerciseProgressControlView.swift
|
||||
//// Workouts
|
||||
////
|
||||
//// Created by rzen on 7/20/25 at 7:19 PM.
|
||||
////
|
||||
//// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
////
|
||||
//
|
||||
//import SwiftUI
|
||||
//import SwiftData
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//// Detail view shown as the first item in the exercise progress carousel
|
||||
//
|
||||
//
|
||||
//// Helper extension to safely access array elements
|
||||
////extension Array {
|
||||
//// subscript(safe index: Index) -> Element? {
|
||||
//// return indices.contains(index) ? self[index] : nil
|
||||
//// }
|
||||
////}
|
||||
//
|
||||
////#Preview {
|
||||
//// let container = AppContainer.preview
|
||||
//// let workout = Workout(start: Date(), end: nil, split: nil)
|
||||
//// let log = WorkoutLog(workout: workout, exerciseName: "Bench Press", date: Date(), sets: 3, reps: 10, weight: 135)
|
||||
////
|
||||
//// ExerciseProgressControlView(log: log)
|
||||
//// .modelContainer(container)
|
||||
////}
|
||||
@@ -7,28 +7,29 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
A45FA1FE2E27171B00581607 /* Workouts Watch App.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = A45FA1F12E27171A00581607 /* Workouts Watch App.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
A45FA2732E29B12500581607 /* Yams in Frameworks */ = {isa = PBXBuildFile; productRef = A45FA2722E29B12500581607 /* Yams */; };
|
||||
A473BF022E4CE278003EAD6F /* Workouts Watch App.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = A473BF012E4CE278003EAD6F /* Workouts Watch App.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
A47512C12F1DACCF001A9C6F /* Yams in Frameworks */ = {isa = PBXBuildFile; productRef = A47512C02F1DACCF001A9C6F /* Yams */; };
|
||||
A47513342F1DADBE001A9C6F /* IndieAbout in Frameworks */ = {isa = PBXBuildFile; productRef = A47513332F1DADBE001A9C6F /* IndieAbout */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
A45FA1FC2E27171B00581607 /* PBXContainerItemProxy */ = {
|
||||
A473BF032E4CE278003EAD6F /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = A45FA0892E21B3DC00581607 /* Project object */;
|
||||
containerPortal = A473BEE92E4CE276003EAD6F /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = A45FA1F02E27171A00581607;
|
||||
remoteGlobalIDString = A473BF002E4CE278003EAD6F;
|
||||
remoteInfo = "Workouts Watch App";
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
A45FA2022E27171B00581607 /* Embed Watch Content */ = {
|
||||
A473BF142E4CE279003EAD6F /* Embed Watch Content */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "$(CONTENTS_FOLDER_PATH)/Watch";
|
||||
dstSubfolderSpec = 16;
|
||||
files = (
|
||||
A45FA1FE2E27171B00581607 /* Workouts Watch App.app in Embed Watch Content */,
|
||||
A473BF022E4CE278003EAD6F /* Workouts Watch App.app in Embed Watch Content */,
|
||||
);
|
||||
name = "Embed Watch Content";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -36,50 +37,17 @@
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
A45FA0912E21B3DD00581607 /* Workouts.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Workouts.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A45FA1F12E27171A00581607 /* Workouts Watch App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Workouts Watch App.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A473BB712E46441B003EAD6F /* CLAUDE.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CLAUDE.md; sourceTree = "<group>"; };
|
||||
A473BEF12E4CE276003EAD6F /* Workouts.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Workouts.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A473BF012E4CE278003EAD6F /* Workouts Watch App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Workouts Watch App.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||
A45FA0A12E21B3DE00581607 /* Exceptions for "Workouts" folder in "Workouts" target */ = {
|
||||
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||
membershipExceptions = (
|
||||
_ATTIC_/ContentView_backup.swift,
|
||||
_ATTIC_/ExerciseProgressView_backup.swift,
|
||||
Info.plist,
|
||||
);
|
||||
target = A45FA0902E21B3DD00581607 /* Workouts */;
|
||||
};
|
||||
A45FA2C52E2D3CBD00581607 /* Exceptions for "Workouts" folder in "Workouts Watch App" target */ = {
|
||||
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||
membershipExceptions = (
|
||||
_ATTIC_/ContentView_backup.swift,
|
||||
_ATTIC_/ExerciseProgressView_backup.swift,
|
||||
Models/Exercise.swift,
|
||||
Models/ExerciseType.swift,
|
||||
Models/Split.swift,
|
||||
Models/Workout.swift,
|
||||
Models/WorkoutLog.swift,
|
||||
Schema/SchemaV1.swift,
|
||||
Views/Common/CheckboxStatus.swift,
|
||||
Views/WorkoutLog/WorkoutStatus.swift,
|
||||
);
|
||||
target = A45FA1F02E27171A00581607 /* Workouts Watch App */;
|
||||
};
|
||||
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||
|
||||
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
||||
A45FA0932E21B3DD00581607 /* Workouts */ = {
|
||||
A473BEF32E4CE276003EAD6F /* Workouts */ = {
|
||||
isa = PBXFileSystemSynchronizedRootGroup;
|
||||
exceptions = (
|
||||
A45FA0A12E21B3DE00581607 /* Exceptions for "Workouts" folder in "Workouts" target */,
|
||||
A45FA2C52E2D3CBD00581607 /* Exceptions for "Workouts" folder in "Workouts Watch App" target */,
|
||||
);
|
||||
path = Workouts;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A45FA1F22E27171A00581607 /* Workouts Watch App */ = {
|
||||
A473BF052E4CE278003EAD6F /* Workouts Watch App */ = {
|
||||
isa = PBXFileSystemSynchronizedRootGroup;
|
||||
path = "Workouts Watch App";
|
||||
sourceTree = "<group>";
|
||||
@@ -87,15 +55,16 @@
|
||||
/* End PBXFileSystemSynchronizedRootGroup section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
A45FA08E2E21B3DD00581607 /* Frameworks */ = {
|
||||
A473BEEE2E4CE276003EAD6F /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
A45FA2732E29B12500581607 /* Yams in Frameworks */,
|
||||
A47513342F1DADBE001A9C6F /* IndieAbout in Frameworks */,
|
||||
A47512C12F1DACCF001A9C6F /* Yams in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
A45FA1EE2E27171A00581607 /* Frameworks */ = {
|
||||
A473BEFE2E4CE278003EAD6F /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
@@ -105,21 +74,20 @@
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
A45FA0882E21B3DC00581607 = {
|
||||
A473BEE82E4CE276003EAD6F = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A45FA0932E21B3DD00581607 /* Workouts */,
|
||||
A45FA1F22E27171A00581607 /* Workouts Watch App */,
|
||||
A45FA0922E21B3DD00581607 /* Products */,
|
||||
A473BB712E46441B003EAD6F /* CLAUDE.md */,
|
||||
A473BEF32E4CE276003EAD6F /* Workouts */,
|
||||
A473BF052E4CE278003EAD6F /* Workouts Watch App */,
|
||||
A473BEF22E4CE276003EAD6F /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A45FA0922E21B3DD00581607 /* Products */ = {
|
||||
A473BEF22E4CE276003EAD6F /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A45FA0912E21B3DD00581607 /* Workouts.app */,
|
||||
A45FA1F12E27171A00581607 /* Workouts Watch App.app */,
|
||||
A473BEF12E4CE276003EAD6F /* Workouts.app */,
|
||||
A473BF012E4CE278003EAD6F /* Workouts Watch App.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@@ -127,104 +95,106 @@
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
A45FA0902E21B3DD00581607 /* Workouts */ = {
|
||||
A473BEF02E4CE276003EAD6F /* Workouts */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = A45FA0A22E21B3DE00581607 /* Build configuration list for PBXNativeTarget "Workouts" */;
|
||||
buildConfigurationList = A473BF152E4CE279003EAD6F /* Build configuration list for PBXNativeTarget "Workouts" */;
|
||||
buildPhases = (
|
||||
A45FA08D2E21B3DD00581607 /* Sources */,
|
||||
A45FA08E2E21B3DD00581607 /* Frameworks */,
|
||||
A45FA08F2E21B3DD00581607 /* Resources */,
|
||||
A45FA2022E27171B00581607 /* Embed Watch Content */,
|
||||
A473BBC52E46D68C003EAD6F /* Update Build Number */,
|
||||
A47512C22F1DB000001A9C6F /* Update Build Number */,
|
||||
A473BEED2E4CE276003EAD6F /* Sources */,
|
||||
A473BEEE2E4CE276003EAD6F /* Frameworks */,
|
||||
A473BEEF2E4CE276003EAD6F /* Resources */,
|
||||
A473BF142E4CE279003EAD6F /* Embed Watch Content */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
A45FA1FD2E27171B00581607 /* PBXTargetDependency */,
|
||||
A473BF042E4CE278003EAD6F /* PBXTargetDependency */,
|
||||
);
|
||||
fileSystemSynchronizedGroups = (
|
||||
A45FA0932E21B3DD00581607 /* Workouts */,
|
||||
A473BEF32E4CE276003EAD6F /* Workouts */,
|
||||
);
|
||||
name = Workouts;
|
||||
packageProductDependencies = (
|
||||
A45FA2722E29B12500581607 /* Yams */,
|
||||
A47512C02F1DACCF001A9C6F /* Yams */,
|
||||
A47513332F1DADBE001A9C6F /* IndieAbout */,
|
||||
);
|
||||
productName = Workouts;
|
||||
productReference = A45FA0912E21B3DD00581607 /* Workouts.app */;
|
||||
productReference = A473BEF12E4CE276003EAD6F /* Workouts.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
A45FA1F02E27171A00581607 /* Workouts Watch App */ = {
|
||||
A473BF002E4CE278003EAD6F /* Workouts Watch App */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = A45FA1FF2E27171B00581607 /* Build configuration list for PBXNativeTarget "Workouts Watch App" */;
|
||||
buildConfigurationList = A473BF112E4CE279003EAD6F /* Build configuration list for PBXNativeTarget "Workouts Watch App" */;
|
||||
buildPhases = (
|
||||
A45FA1ED2E27171A00581607 /* Sources */,
|
||||
A45FA1EE2E27171A00581607 /* Frameworks */,
|
||||
A45FA1EF2E27171A00581607 /* Resources */,
|
||||
A473BEFD2E4CE278003EAD6F /* Sources */,
|
||||
A473BEFE2E4CE278003EAD6F /* Frameworks */,
|
||||
A473BEFF2E4CE278003EAD6F /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
fileSystemSynchronizedGroups = (
|
||||
A45FA1F22E27171A00581607 /* Workouts Watch App */,
|
||||
A473BF052E4CE278003EAD6F /* Workouts Watch App */,
|
||||
);
|
||||
name = "Workouts Watch App";
|
||||
packageProductDependencies = (
|
||||
);
|
||||
productName = "Workouts Watch App";
|
||||
productReference = A45FA1F12E27171A00581607 /* Workouts Watch App.app */;
|
||||
productReference = A473BF012E4CE278003EAD6F /* Workouts Watch App.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
A45FA0892E21B3DC00581607 /* Project object */ = {
|
||||
A473BEE92E4CE276003EAD6F /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = 1;
|
||||
LastSwiftUpdateCheck = 1620;
|
||||
LastUpgradeCheck = 1620;
|
||||
LastUpgradeCheck = 2620;
|
||||
TargetAttributes = {
|
||||
A45FA0902E21B3DD00581607 = {
|
||||
A473BEF02E4CE276003EAD6F = {
|
||||
CreatedOnToolsVersion = 16.2;
|
||||
};
|
||||
A45FA1F02E27171A00581607 = {
|
||||
A473BF002E4CE278003EAD6F = {
|
||||
CreatedOnToolsVersion = 16.2;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = A45FA08C2E21B3DC00581607 /* Build configuration list for PBXProject "Workouts" */;
|
||||
buildConfigurationList = A473BEEC2E4CE276003EAD6F /* Build configuration list for PBXProject "Workouts" */;
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = A45FA0882E21B3DC00581607;
|
||||
mainGroup = A473BEE82E4CE276003EAD6F;
|
||||
minimizedProjectReferenceProxies = 1;
|
||||
packageReferences = (
|
||||
A45FA26B2E297F5B00581607 /* XCRemoteSwiftPackageReference "Yams" */,
|
||||
A47512BF2F1DACCF001A9C6F /* XCRemoteSwiftPackageReference "Yams" */,
|
||||
A47513322F1DADBE001A9C6F /* XCRemoteSwiftPackageReference "indie-about" */,
|
||||
);
|
||||
preferredProjectObjectVersion = 77;
|
||||
productRefGroup = A45FA0922E21B3DD00581607 /* Products */;
|
||||
productRefGroup = A473BEF22E4CE276003EAD6F /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
A45FA0902E21B3DD00581607 /* Workouts */,
|
||||
A45FA1F02E27171A00581607 /* Workouts Watch App */,
|
||||
A473BEF02E4CE276003EAD6F /* Workouts */,
|
||||
A473BF002E4CE278003EAD6F /* Workouts Watch App */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
A45FA08F2E21B3DD00581607 /* Resources */ = {
|
||||
A473BEEF2E4CE276003EAD6F /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
A45FA1EF2E27171A00581607 /* Resources */ = {
|
||||
A473BEFF2E4CE278003EAD6F /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
@@ -234,7 +204,7 @@
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
A473BBC52E46D68C003EAD6F /* Update Build Number */ = {
|
||||
A47512C22F1DB000001A9C6F /* Update Build Number */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
alwaysOutOfDate = 1;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -243,8 +213,6 @@
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
"$(TARGET_BUILD_DIR)/$(INFOPLIST_PATH)",
|
||||
"$(DWARF_DSYM_FOLDER_PATH)/$(DWARF_DSYM_FILE_NAME)/Contents/Info.plist",
|
||||
);
|
||||
name = "Update Build Number";
|
||||
outputFileListPaths = (
|
||||
@@ -253,19 +221,19 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "${PROJECT_DIR}/Scripts/update_build_number.sh\n";
|
||||
shellScript = "\"${PROJECT_DIR}/Scripts/update_build_number.sh\"\n";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
A45FA08D2E21B3DD00581607 /* Sources */ = {
|
||||
A473BEED2E4CE276003EAD6F /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
A45FA1ED2E27171A00581607 /* Sources */ = {
|
||||
A473BEFD2E4CE278003EAD6F /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
@@ -275,77 +243,15 @@
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
A45FA1FD2E27171B00581607 /* PBXTargetDependency */ = {
|
||||
A473BF042E4CE278003EAD6F /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = A45FA1F02E27171A00581607 /* Workouts Watch App */;
|
||||
targetProxy = A45FA1FC2E27171B00581607 /* PBXContainerItemProxy */;
|
||||
target = A473BF002E4CE278003EAD6F /* Workouts Watch App */;
|
||||
targetProxy = A473BF032E4CE278003EAD6F /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
A45FA0A32E21B3DE00581607 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = Workouts/Workouts.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Workouts/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = C32Z8JNLG6;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = Workouts/Info.plist;
|
||||
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = dev.rzen.indie.Workouts;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
A45FA0A42E21B3DE00581607 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = Workouts/Workouts.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Workouts/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = C32Z8JNLG6;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = Workouts/Info.plist;
|
||||
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = dev.rzen.indie.Workouts;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
A45FA0A52E21B3DE00581607 /* Debug */ = {
|
||||
A473BF0F2E4CE279003EAD6F /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
@@ -379,11 +285,12 @@
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEVELOPMENT_TEAM = C32Z8JNLG6;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
EXCLUDED_SOURCE_FILE_NAMES = "_ATTIC_/*";
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
@@ -398,18 +305,17 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 18.2;
|
||||
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
A45FA0A62E21B3DE00581607 /* Release */ = {
|
||||
A473BF102E4CE279003EAD6F /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
@@ -443,11 +349,12 @@
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEVELOPMENT_TEAM = C32Z8JNLG6;
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
EXCLUDED_SOURCE_FILE_NAMES = "_ATTIC_/*";
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
@@ -456,32 +363,27 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 18.2;
|
||||
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
A45FA2002E27171B00581607 /* Debug */ = {
|
||||
A473BF122E4CE279003EAD6F /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = "Workouts Watch App/Workouts Watch App.entitlements";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Workouts Watch App/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = C32Z8JNLG6;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = Workouts;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
|
||||
INFOPLIST_KEY_WKCompanionAppBundleIdentifier = dev.rzen.indie.Workouts;
|
||||
INFOPLIST_KEY_WKRunsIndependentlyOfCompanionApp = YES;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
@@ -494,26 +396,23 @@
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 4;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 11.0;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 11.2;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
A45FA2012E27171B00581607 /* Release */ = {
|
||||
A473BF132E4CE279003EAD6F /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = "Workouts Watch App/Workouts Watch App.entitlements";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Workouts Watch App/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = C32Z8JNLG6;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = Workouts;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
|
||||
INFOPLIST_KEY_WKCompanionAppBundleIdentifier = dev.rzen.indie.Workouts;
|
||||
INFOPLIST_KEY_WKRunsIndependentlyOfCompanionApp = YES;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
@@ -526,36 +425,106 @@
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 4;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 11.0;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 11.2;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
A473BF162E4CE279003EAD6F /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = Workouts/Workouts.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Workouts/Preview Content\"";
|
||||
ENABLE_APP_SANDBOX = YES;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
ENABLE_USER_SELECTED_FILES = readonly;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = Workouts;
|
||||
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 18.2;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = dev.rzen.indie.Workouts;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
A473BF172E4CE279003EAD6F /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = Workouts/Workouts.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Workouts/Preview Content\"";
|
||||
ENABLE_APP_SANDBOX = YES;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
ENABLE_USER_SELECTED_FILES = readonly;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = Workouts;
|
||||
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 18.2;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = dev.rzen.indie.Workouts;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
A45FA08C2E21B3DC00581607 /* Build configuration list for PBXProject "Workouts" */ = {
|
||||
A473BEEC2E4CE276003EAD6F /* Build configuration list for PBXProject "Workouts" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
A45FA0A52E21B3DE00581607 /* Debug */,
|
||||
A45FA0A62E21B3DE00581607 /* Release */,
|
||||
A473BF0F2E4CE279003EAD6F /* Debug */,
|
||||
A473BF102E4CE279003EAD6F /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
A45FA0A22E21B3DE00581607 /* Build configuration list for PBXNativeTarget "Workouts" */ = {
|
||||
A473BF112E4CE279003EAD6F /* Build configuration list for PBXNativeTarget "Workouts Watch App" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
A45FA0A32E21B3DE00581607 /* Debug */,
|
||||
A45FA0A42E21B3DE00581607 /* Release */,
|
||||
A473BF122E4CE279003EAD6F /* Debug */,
|
||||
A473BF132E4CE279003EAD6F /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
A45FA1FF2E27171B00581607 /* Build configuration list for PBXNativeTarget "Workouts Watch App" */ = {
|
||||
A473BF152E4CE279003EAD6F /* Build configuration list for PBXNativeTarget "Workouts" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
A45FA2002E27171B00581607 /* Debug */,
|
||||
A45FA2012E27171B00581607 /* Release */,
|
||||
A473BF162E4CE279003EAD6F /* Debug */,
|
||||
A473BF172E4CE279003EAD6F /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
@@ -563,23 +532,36 @@
|
||||
/* End XCConfigurationList section */
|
||||
|
||||
/* Begin XCRemoteSwiftPackageReference section */
|
||||
A45FA26B2E297F5B00581607 /* XCRemoteSwiftPackageReference "Yams" */ = {
|
||||
A47512BF2F1DACCF001A9C6F /* XCRemoteSwiftPackageReference "Yams" */ = {
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://github.com/jpsim/Yams";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
minimumVersion = 6.0.2;
|
||||
minimumVersion = 6.2.0;
|
||||
};
|
||||
};
|
||||
A47513322F1DADBE001A9C6F /* XCRemoteSwiftPackageReference "indie-about" */ = {
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://git.rzen.dev/rzen/indie-about";
|
||||
requirement = {
|
||||
branch = main;
|
||||
kind = branch;
|
||||
};
|
||||
};
|
||||
/* End XCRemoteSwiftPackageReference section */
|
||||
|
||||
/* Begin XCSwiftPackageProductDependency section */
|
||||
A45FA2722E29B12500581607 /* Yams */ = {
|
||||
A47512C02F1DACCF001A9C6F /* Yams */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = A45FA26B2E297F5B00581607 /* XCRemoteSwiftPackageReference "Yams" */;
|
||||
package = A47512BF2F1DACCF001A9C6F /* XCRemoteSwiftPackageReference "Yams" */;
|
||||
productName = Yams;
|
||||
};
|
||||
A47513332F1DADBE001A9C6F /* IndieAbout */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = A47513322F1DADBE001A9C6F /* XCRemoteSwiftPackageReference "indie-about" */;
|
||||
productName = IndieAbout;
|
||||
};
|
||||
/* End XCSwiftPackageProductDependency section */
|
||||
};
|
||||
rootObject = A45FA0892E21B3DC00581607 /* Project object */;
|
||||
rootObject = A473BEE92E4CE276003EAD6F /* Project object */;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
{
|
||||
"originHash" : "81702b8f7fa6fc73458821cd4dfa7dde6684a9d1d4b6d63ecde0b6b832d8d75e",
|
||||
"originHash" : "9d613082dd8a405ef810326218a4d81fdfd9ecb33be867afbc9700e52ec96e4b",
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "indie-about",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://git.rzen.dev/rzen/indie-about",
|
||||
"state" : {
|
||||
"branch" : "main",
|
||||
"revision" : "ed73ffcc5488b37ec0838ecaaa27ce050807093f"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "yams",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/jpsim/Yams",
|
||||
"state" : {
|
||||
"revision" : "f4d4d6827d36092d151ad7f6fef1991c1b7192f6",
|
||||
"version" : "6.0.2"
|
||||
"revision" : "51b5127c7fb6ffac106ad6d199aaa33c5024895f",
|
||||
"version" : "6.2.0"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Bucket
|
||||
uuid = "EEDBFE9D-0066-4E41-BFBC-8B95DBCF47E3"
|
||||
type = "1"
|
||||
version = "2.0">
|
||||
</Bucket>
|
||||
@@ -5,16 +5,11 @@
|
||||
<key>SchemeUserState</key>
|
||||
<dict>
|
||||
<key>Workouts Watch App.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<key>Workouts.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<key>Worksouts Watch App.xcscheme_^#shared#^_</key>
|
||||
<key>Workouts.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
|
||||
|
Before Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 49 KiB |
@@ -1,34 +1,112 @@
|
||||
{
|
||||
"images": [
|
||||
{
|
||||
"filename" : "1024.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
"filename": "icon-20@2x.png",
|
||||
"idiom": "iphone",
|
||||
"size": "20x20",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"filename" : "1024 1.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
"filename": "icon-20@3x.png",
|
||||
"idiom": "iphone",
|
||||
"size": "20x20",
|
||||
"scale": "3x"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
"filename": "icon-29@2x.png",
|
||||
"idiom": "iphone",
|
||||
"size": "29x29",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "tinted"
|
||||
}
|
||||
],
|
||||
"filename" : "1024 2.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
"filename": "icon-29@3x.png",
|
||||
"idiom": "iphone",
|
||||
"size": "29x29",
|
||||
"scale": "3x"
|
||||
},
|
||||
{
|
||||
"filename": "icon-40@2x.png",
|
||||
"idiom": "iphone",
|
||||
"size": "40x40",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"filename": "icon-40@3x.png",
|
||||
"idiom": "iphone",
|
||||
"size": "40x40",
|
||||
"scale": "3x"
|
||||
},
|
||||
{
|
||||
"filename": "icon-60@2x.png",
|
||||
"idiom": "iphone",
|
||||
"size": "60x60",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"filename": "icon-60@3x.png",
|
||||
"idiom": "iphone",
|
||||
"size": "60x60",
|
||||
"scale": "3x"
|
||||
},
|
||||
{
|
||||
"filename": "icon-20.png",
|
||||
"idiom": "ipad",
|
||||
"size": "20x20",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"filename": "icon-20@2x.png",
|
||||
"idiom": "ipad",
|
||||
"size": "20x20",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"filename": "icon-29.png",
|
||||
"idiom": "ipad",
|
||||
"size": "29x29",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"filename": "icon-29@2x.png",
|
||||
"idiom": "ipad",
|
||||
"size": "29x29",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"filename": "icon-40.png",
|
||||
"idiom": "ipad",
|
||||
"size": "40x40",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"filename": "icon-40@2x.png",
|
||||
"idiom": "ipad",
|
||||
"size": "40x40",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"filename": "icon-76.png",
|
||||
"idiom": "ipad",
|
||||
"size": "76x76",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"filename": "icon-76@2x.png",
|
||||
"idiom": "ipad",
|
||||
"size": "76x76",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"filename": "icon-83.5@2x.png",
|
||||
"idiom": "ipad",
|
||||
"size": "83.5x83.5",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"filename": "icon-1024.png",
|
||||
"idiom": "ios-marketing",
|
||||
"size": "1024x1024",
|
||||
"scale": "1x"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
|
||||
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 923 B |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 8.0 KiB |
|
After Width: | Height: | Size: 8.0 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 11 KiB |
@@ -2,56 +2,39 @@
|
||||
// ContentView.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/11/25 at 5:04 PM.
|
||||
// Created by rzen on 8/13/25 at 11:10 AM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
|
||||
import SwiftUI
|
||||
import SwiftData
|
||||
import CoreData
|
||||
|
||||
struct ContentView: View {
|
||||
@Environment(\.modelContext) private var modelContext
|
||||
@Environment(\.managedObjectContext) private var viewContext
|
||||
|
||||
var body: some View {
|
||||
TabView {
|
||||
WorkoutLogsView()
|
||||
.tabItem {
|
||||
Label("Workout Logs", systemImage: "list.bullet.clipboard")
|
||||
}
|
||||
|
||||
SplitsView()
|
||||
.tabItem {
|
||||
Label("Workouts", systemImage: "figure.strengthtraining.traditional")
|
||||
Label("Splits", systemImage: "dumbbell.fill")
|
||||
}
|
||||
|
||||
WorkoutListView()
|
||||
SettingsView()
|
||||
.tabItem {
|
||||
Label("Logs", systemImage: "list.bullet.clipboard.fill")
|
||||
Label("Settings", systemImage: "gear")
|
||||
}
|
||||
|
||||
|
||||
NavigationStack {
|
||||
Text("Reports Placeholder")
|
||||
.navigationTitle("Reports")
|
||||
}
|
||||
.tabItem {
|
||||
Label("Reports", systemImage: "chart.bar")
|
||||
}
|
||||
|
||||
NavigationStack {
|
||||
Text("Achievements")
|
||||
.navigationTitle("Achievements")
|
||||
}
|
||||
.tabItem {
|
||||
Label("Achievements", systemImage: "star.fill")
|
||||
}
|
||||
|
||||
// SettingsView()
|
||||
// .tabItem {
|
||||
// Label("Settings", systemImage: "gear")
|
||||
// }
|
||||
}
|
||||
.observeCloudKitChanges()
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
ContentView()
|
||||
.environment(\.managedObjectContext, PersistenceController.preview.viewContext)
|
||||
}
|
||||
|
||||
@@ -1,29 +1,40 @@
|
||||
import Foundation
|
||||
import SwiftData
|
||||
import CoreData
|
||||
|
||||
@Model
|
||||
final class Exercise {
|
||||
var name: String = ""
|
||||
var loadType: Int = LoadType.weight.rawValue
|
||||
var order: Int = 0
|
||||
var sets: Int = 0
|
||||
var reps: Int = 0
|
||||
var weight: Int = 0
|
||||
var duration: Date = Date.distantPast
|
||||
var weightLastUpdated: Date = Date()
|
||||
var weightReminderTimeIntervalWeeks: Int = 2
|
||||
@objc(Exercise)
|
||||
public class Exercise: NSManagedObject, Identifiable {
|
||||
@NSManaged public var name: String
|
||||
@NSManaged public var loadType: Int32
|
||||
@NSManaged public var order: Int32
|
||||
@NSManaged public var sets: Int32
|
||||
@NSManaged public var reps: Int32
|
||||
@NSManaged public var weight: Int32
|
||||
@NSManaged public var duration: Date?
|
||||
@NSManaged public var weightLastUpdated: Date?
|
||||
@NSManaged public var weightReminderTimeIntervalWeeks: Int32
|
||||
|
||||
@Relationship(deleteRule: .nullify)
|
||||
var split: Split?
|
||||
@NSManaged public var split: Split?
|
||||
|
||||
init(split: Split, exerciseName: String, order: Int, sets: Int, reps: Int, weight: Int, weightReminderTimeIntervalWeeks: Int = 2) {
|
||||
self.split = split
|
||||
self.name = exerciseName
|
||||
self.order = order
|
||||
self.sets = sets
|
||||
self.reps = reps
|
||||
self.weight = weight
|
||||
self.weightReminderTimeIntervalWeeks = weightReminderTimeIntervalWeeks
|
||||
public var id: NSManagedObjectID { objectID }
|
||||
|
||||
var loadTypeEnum: LoadType {
|
||||
get { LoadType(rawValue: Int(loadType)) ?? .weight }
|
||||
set { loadType = Int32(newValue.rawValue) }
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Fetch Request
|
||||
|
||||
extension Exercise {
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<Exercise> {
|
||||
return NSFetchRequest<Exercise>(entityName: "Exercise")
|
||||
}
|
||||
|
||||
static func orderedFetchRequest(for split: Split) -> NSFetchRequest<Exercise> {
|
||||
let request = fetchRequest()
|
||||
request.predicate = NSPredicate(format: "split == %@", split)
|
||||
request.sortDescriptors = [NSSortDescriptor(keyPath: \Exercise.order, ascending: true)]
|
||||
return request
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
//
|
||||
// ExerciseType.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/26/25 at 9:16 AM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
|
||||
@@ -1,98 +1,66 @@
|
||||
import Foundation
|
||||
import SwiftData
|
||||
import CoreData
|
||||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
@Model
|
||||
final class Split {
|
||||
var name: String = ""
|
||||
var color: String = "indigo"
|
||||
var systemImage: String = "dumbbell.fill"
|
||||
var order: Int = 0
|
||||
@objc(Split)
|
||||
public class Split: NSManagedObject, Identifiable {
|
||||
@NSManaged public var name: String
|
||||
@NSManaged public var color: String
|
||||
@NSManaged public var systemImage: String
|
||||
@NSManaged public var order: Int32
|
||||
|
||||
// Returns the SwiftUI Color for the stored color name
|
||||
func getColor () -> Color {
|
||||
return Color.color(from: self.color)
|
||||
}
|
||||
@NSManaged public var exercises: NSSet?
|
||||
@NSManaged public var workouts: NSSet?
|
||||
|
||||
@Relationship(deleteRule: .cascade, inverse: \Exercise.split)
|
||||
var exercises: [Exercise]? = []
|
||||
|
||||
@Relationship(deleteRule: .nullify, inverse: \Workout.split)
|
||||
var workouts: [Workout]? = []
|
||||
|
||||
init(name: String, color: String = "indigo", systemImage: String = "dumbbell.fill", order: Int = 0) {
|
||||
self.name = name
|
||||
self.color = color
|
||||
self.systemImage = systemImage
|
||||
self.order = order
|
||||
}
|
||||
public var id: NSManagedObjectID { objectID }
|
||||
|
||||
static let unnamed = "Unnamed Split"
|
||||
}
|
||||
|
||||
// MARK: - Identifiable Conformance
|
||||
// MARK: - Convenience Accessors
|
||||
|
||||
extension Split: Identifiable {
|
||||
public var id: String {
|
||||
// Use the name as a unique identifier for the split
|
||||
// This is sufficient for UI purposes
|
||||
return self.name
|
||||
extension Split {
|
||||
var exercisesArray: [Exercise] {
|
||||
let set = exercises as? Set<Exercise> ?? []
|
||||
return set.sorted { $0.order < $1.order }
|
||||
}
|
||||
|
||||
var workoutsArray: [Workout] {
|
||||
let set = workouts as? Set<Workout> ?? []
|
||||
return set.sorted { $0.start > $1.start }
|
||||
}
|
||||
|
||||
func addToExercises(_ exercise: Exercise) {
|
||||
let items = mutableSetValue(forKey: "exercises")
|
||||
items.add(exercise)
|
||||
}
|
||||
|
||||
func removeFromExercises(_ exercise: Exercise) {
|
||||
let items = mutableSetValue(forKey: "exercises")
|
||||
items.remove(exercise)
|
||||
}
|
||||
|
||||
func addToWorkouts(_ workout: Workout) {
|
||||
let items = mutableSetValue(forKey: "workouts")
|
||||
items.add(workout)
|
||||
}
|
||||
|
||||
func removeFromWorkouts(_ workout: Workout) {
|
||||
let items = mutableSetValue(forKey: "workouts")
|
||||
items.remove(workout)
|
||||
}
|
||||
}
|
||||
|
||||
//// MARK: - Private Form View
|
||||
//
|
||||
//fileprivate struct SplitFormView: View {
|
||||
// @Binding var model: Split
|
||||
//
|
||||
// // Available colors for splits
|
||||
// private let availableColors = ["red", "orange", "yellow", "green", "mint", "teal", "cyan", "blue", "indigo", "purple", "pink", "brown"]
|
||||
//
|
||||
// // Available system images for splits
|
||||
// private let availableIcons = ["dumbbell.fill", "figure.strengthtraining.traditional", "figure.run", "figure.hiking", "figure.cooldown", "figure.boxing", "figure.wrestling", "figure.gymnastics", "figure.handball", "figure.core.training", "heart.fill", "bolt.fill"]
|
||||
//
|
||||
// var body: some View {
|
||||
// Section(header: Text("Name")) {
|
||||
// TextField("Name", text: $model.name)
|
||||
// .bold()
|
||||
// }
|
||||
//
|
||||
// Section(header: Text("Appearance")) {
|
||||
// Picker("Color", selection: $model.color) {
|
||||
// ForEach(availableColors, id: \.self) { colorName in
|
||||
// let tempSplit = Split(name: "", color: colorName)
|
||||
// HStack {
|
||||
// Circle()
|
||||
// .fill(tempSplit.getColor())
|
||||
// .frame(width: 20, height: 20)
|
||||
// Text(colorName.capitalized)
|
||||
// }
|
||||
// .tag(colorName)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Picker("Icon", selection: $model.systemImage) {
|
||||
// ForEach(availableIcons, id: \.self) { iconName in
|
||||
// HStack {
|
||||
// Image(systemName: iconName)
|
||||
// .frame(width: 24, height: 24)
|
||||
// Text(iconName.replacingOccurrences(of: ".fill", with: "").replacingOccurrences(of: "figure.", with: "").capitalized)
|
||||
// }
|
||||
// .tag(iconName)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Section(header: Text("Exercises")) {
|
||||
// NavigationLink {
|
||||
// ExerciseListView(split: model)
|
||||
// } label: {
|
||||
// ListItem(
|
||||
// text: "Exercises",
|
||||
// count: model.exercises?.count ?? 0
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// MARK: - Fetch Request
|
||||
|
||||
extension Split {
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<Split> {
|
||||
return NSFetchRequest<Split>(entityName: "Split")
|
||||
}
|
||||
|
||||
static func orderedFetchRequest() -> NSFetchRequest<Split> {
|
||||
let request = fetchRequest()
|
||||
request.sortDescriptors = [NSSortDescriptor(keyPath: \Split.order, ascending: true)]
|
||||
return request
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +1,83 @@
|
||||
import Foundation
|
||||
import SwiftData
|
||||
import CoreData
|
||||
|
||||
@Model
|
||||
final class Workout {
|
||||
var start: Date = Date()
|
||||
var end: Date?
|
||||
var status: Int = 1
|
||||
// var status: WorkoutStatus = WorkoutStatus.notStarted
|
||||
@objc(Workout)
|
||||
public class Workout: NSManagedObject, Identifiable {
|
||||
@NSManaged public var start: Date
|
||||
@NSManaged public var end: Date?
|
||||
|
||||
//case notStarted = 1
|
||||
//case inProgress = 2
|
||||
//case completed = 3
|
||||
//case skipped = 4
|
||||
@NSManaged public var split: Split?
|
||||
@NSManaged public var logs: NSSet?
|
||||
|
||||
public var id: NSManagedObjectID { objectID }
|
||||
|
||||
@Relationship(deleteRule: .nullify)
|
||||
var split: Split?
|
||||
|
||||
@Relationship(deleteRule: .cascade, inverse: \WorkoutLog.workout)
|
||||
var logs: [WorkoutLog]? = []
|
||||
|
||||
init(start: Date, end: Date, split: Split?) {
|
||||
self.start = start
|
||||
self.end = end
|
||||
self.split = split
|
||||
var status: WorkoutStatus {
|
||||
get {
|
||||
willAccessValue(forKey: "status")
|
||||
let raw = primitiveValue(forKey: "status") as? String ?? "notStarted"
|
||||
didAccessValue(forKey: "status")
|
||||
return WorkoutStatus(rawValue: raw) ?? .notStarted
|
||||
}
|
||||
set {
|
||||
willChangeValue(forKey: "status")
|
||||
setPrimitiveValue(newValue.rawValue, forKey: "status")
|
||||
didChangeValue(forKey: "status")
|
||||
}
|
||||
}
|
||||
|
||||
var label: String {
|
||||
if status == 3, let endDate = end {
|
||||
// if status == .completed, let endDate = end {
|
||||
if status == .completed, let endDate = end {
|
||||
if start.isSameDay(as: endDate) {
|
||||
return "\(start.formattedDate())—\(endDate.formattedTime())"
|
||||
} else {
|
||||
return "\(start.formattedDate())—\(endDate.formattedDate())"
|
||||
}
|
||||
} else {
|
||||
return start.formattedDate()
|
||||
}
|
||||
}
|
||||
|
||||
var statusName: String {
|
||||
if status == 1 {
|
||||
return "Not Started"
|
||||
} else if status == 2 {
|
||||
return "In Progress"
|
||||
} else if status == 3 {
|
||||
return "Completed"
|
||||
} else if status == 4 {
|
||||
return "Skipped"
|
||||
} else {
|
||||
return "In progress"
|
||||
return status.displayName
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Convenience Accessors
|
||||
|
||||
extension Workout {
|
||||
var logsArray: [WorkoutLog] {
|
||||
let set = logs as? Set<WorkoutLog> ?? []
|
||||
return set.sorted { $0.order < $1.order }
|
||||
}
|
||||
|
||||
func addToLogs(_ log: WorkoutLog) {
|
||||
let items = mutableSetValue(forKey: "logs")
|
||||
items.add(log)
|
||||
}
|
||||
|
||||
func removeFromLogs(_ log: WorkoutLog) {
|
||||
let items = mutableSetValue(forKey: "logs")
|
||||
items.remove(log)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Fetch Request
|
||||
|
||||
extension Workout {
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<Workout> {
|
||||
return NSFetchRequest<Workout>(entityName: "Workout")
|
||||
}
|
||||
|
||||
static func recentFetchRequest() -> NSFetchRequest<Workout> {
|
||||
let request = fetchRequest()
|
||||
request.sortDescriptors = [NSSortDescriptor(keyPath: \Workout.start, ascending: false)]
|
||||
return request
|
||||
}
|
||||
|
||||
static func fetchRequest(for split: Split) -> NSFetchRequest<Workout> {
|
||||
let request = fetchRequest()
|
||||
request.predicate = NSPredicate(format: "split == %@", split)
|
||||
request.sortDescriptors = [NSSortDescriptor(keyPath: \Workout.start, ascending: false)]
|
||||
return request
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,48 @@
|
||||
import Foundation
|
||||
import SwiftData
|
||||
import CoreData
|
||||
|
||||
@Model
|
||||
final class WorkoutLog {
|
||||
var date: Date = Date()
|
||||
var sets: Int = 0
|
||||
var reps: Int = 0
|
||||
var weight: Int = 0
|
||||
var status: WorkoutStatus? = WorkoutStatus.notStarted
|
||||
var order: Int = 0
|
||||
var exerciseName: String = ""
|
||||
@objc(WorkoutLog)
|
||||
public class WorkoutLog: NSManagedObject, Identifiable {
|
||||
@NSManaged public var date: Date
|
||||
@NSManaged public var sets: Int32
|
||||
@NSManaged public var reps: Int32
|
||||
@NSManaged public var weight: Int32
|
||||
@NSManaged public var order: Int32
|
||||
@NSManaged public var exerciseName: String
|
||||
@NSManaged public var currentStateIndex: Int32
|
||||
@NSManaged public var elapsedSeconds: Int32
|
||||
@NSManaged public var completed: Bool
|
||||
|
||||
var currentStateIndex: Int? = nil
|
||||
var elapsedSeconds: Int? = nil
|
||||
@NSManaged public var workout: Workout?
|
||||
|
||||
var completed: Bool = false
|
||||
public var id: NSManagedObjectID { objectID }
|
||||
|
||||
@Relationship(deleteRule: .nullify)
|
||||
var workout: Workout?
|
||||
|
||||
init(workout: Workout, exerciseName: String, date: Date, order: Int = 0, sets: Int, reps: Int, weight: Int, status: WorkoutStatus = .notStarted, completed: Bool = false) {
|
||||
self.date = date
|
||||
self.order = order
|
||||
self.sets = sets
|
||||
self.reps = reps
|
||||
self.weight = weight
|
||||
self.status = status
|
||||
self.workout = workout
|
||||
self.exerciseName = exerciseName
|
||||
self.completed = completed
|
||||
var status: WorkoutStatus {
|
||||
get {
|
||||
willAccessValue(forKey: "status")
|
||||
let raw = primitiveValue(forKey: "status") as? String ?? "notStarted"
|
||||
didAccessValue(forKey: "status")
|
||||
return WorkoutStatus(rawValue: raw) ?? .notStarted
|
||||
}
|
||||
set {
|
||||
willChangeValue(forKey: "status")
|
||||
setPrimitiveValue(newValue.rawValue, forKey: "status")
|
||||
didChangeValue(forKey: "status")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Fetch Request
|
||||
|
||||
extension WorkoutLog {
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<WorkoutLog> {
|
||||
return NSFetchRequest<WorkoutLog>(entityName: "WorkoutLog")
|
||||
}
|
||||
|
||||
static func orderedFetchRequest(for workout: Workout) -> NSFetchRequest<WorkoutLog> {
|
||||
let request = fetchRequest()
|
||||
request.predicate = NSPredicate(format: "workout == %@", workout)
|
||||
request.sortDescriptors = [NSSortDescriptor(keyPath: \WorkoutLog.order, ascending: true)]
|
||||
return request
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import Foundation
|
||||
|
||||
enum WorkoutStatus: String, CaseIterable, Codable {
|
||||
case notStarted = "notStarted"
|
||||
case inProgress = "inProgress"
|
||||
case completed = "completed"
|
||||
case skipped = "skipped"
|
||||
|
||||
var displayName: String {
|
||||
switch self {
|
||||
case .notStarted:
|
||||
return "Not Started"
|
||||
case .inProgress:
|
||||
return "In Progress"
|
||||
case .completed:
|
||||
return "Completed"
|
||||
case .skipped:
|
||||
return "Skipped"
|
||||
}
|
||||
}
|
||||
|
||||
var name: String { displayName }
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
import CoreData
|
||||
import CloudKit
|
||||
|
||||
struct PersistenceController {
|
||||
static let shared = PersistenceController()
|
||||
|
||||
let container: NSPersistentCloudKitContainer
|
||||
|
||||
// CloudKit container identifier
|
||||
static let cloudKitContainerIdentifier = "iCloud.dev.rzen.indie.Workouts"
|
||||
|
||||
var viewContext: NSManagedObjectContext {
|
||||
container.viewContext
|
||||
}
|
||||
|
||||
// MARK: - Preview Support
|
||||
|
||||
static var preview: PersistenceController = {
|
||||
let controller = PersistenceController(inMemory: true)
|
||||
let viewContext = controller.container.viewContext
|
||||
|
||||
// Create sample data for previews
|
||||
let split = Split(context: viewContext)
|
||||
split.name = "Upper Body"
|
||||
split.color = "blue"
|
||||
split.systemImage = "dumbbell.fill"
|
||||
split.order = 0
|
||||
|
||||
let exercise = Exercise(context: viewContext)
|
||||
exercise.name = "Bench Press"
|
||||
exercise.sets = 3
|
||||
exercise.reps = 10
|
||||
exercise.weight = 135
|
||||
exercise.order = 0
|
||||
exercise.loadType = Int32(LoadType.weight.rawValue)
|
||||
exercise.split = split
|
||||
|
||||
do {
|
||||
try viewContext.save()
|
||||
} catch {
|
||||
let nsError = error as NSError
|
||||
fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
|
||||
}
|
||||
|
||||
return controller
|
||||
}()
|
||||
|
||||
// MARK: - Initialization
|
||||
|
||||
init(inMemory: Bool = false, cloudKitEnabled: Bool = true) {
|
||||
container = NSPersistentCloudKitContainer(name: "Workouts")
|
||||
|
||||
guard let description = container.persistentStoreDescriptions.first else {
|
||||
fatalError("Failed to retrieve a persistent store description.")
|
||||
}
|
||||
|
||||
if inMemory {
|
||||
description.url = URL(fileURLWithPath: "/dev/null")
|
||||
description.cloudKitContainerOptions = nil
|
||||
} else if cloudKitEnabled {
|
||||
// Check if CloudKit is available before enabling
|
||||
let cloudKitAvailable = FileManager.default.ubiquityIdentityToken != nil
|
||||
|
||||
if cloudKitAvailable {
|
||||
// Set CloudKit container options
|
||||
let cloudKitOptions = NSPersistentCloudKitContainerOptions(
|
||||
containerIdentifier: Self.cloudKitContainerIdentifier
|
||||
)
|
||||
description.cloudKitContainerOptions = cloudKitOptions
|
||||
} else {
|
||||
// CloudKit not available (not signed in, etc.)
|
||||
description.cloudKitContainerOptions = nil
|
||||
print("CloudKit not available - using local storage only")
|
||||
}
|
||||
|
||||
// Enable persistent history tracking (useful even without CloudKit)
|
||||
description.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
|
||||
description.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey)
|
||||
} else {
|
||||
// CloudKit explicitly disabled
|
||||
description.cloudKitContainerOptions = nil
|
||||
}
|
||||
|
||||
container.loadPersistentStores { storeDescription, error in
|
||||
if let error = error as NSError? {
|
||||
// In production, handle this more gracefully
|
||||
print("CoreData error: \(error), \(error.userInfo)")
|
||||
#if DEBUG
|
||||
fatalError("Unresolved error \(error), \(error.userInfo)")
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Configure view context
|
||||
container.viewContext.automaticallyMergesChangesFromParent = true
|
||||
container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
|
||||
|
||||
// Pin the viewContext to the current generation token
|
||||
do {
|
||||
try container.viewContext.setQueryGenerationFrom(.current)
|
||||
} catch {
|
||||
print("Failed to pin viewContext to the current generation: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Save Context
|
||||
|
||||
func save() {
|
||||
let context = container.viewContext
|
||||
if context.hasChanges {
|
||||
do {
|
||||
try context.save()
|
||||
} catch {
|
||||
let nsError = error as NSError
|
||||
print("Save error: \(nsError), \(nsError.userInfo)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "Bodyweight",
|
||||
"descr": "Exercises that use your own body as resistance, requiring no equipment."
|
||||
},
|
||||
{
|
||||
"name": "Free Weight",
|
||||
"descr": "Exercises using handheld weights such as dumbbells, barbells, or kettlebells."
|
||||
},
|
||||
{
|
||||
"name": "Resistance Band",
|
||||
"descr": "Exercises performed with elastic bands that provide variable resistance."
|
||||
},
|
||||
{
|
||||
"name": "Machine-Based",
|
||||
"descr": "Exercises performed on gym equipment with guided movement paths."
|
||||
},
|
||||
{
|
||||
"name": "Suspension",
|
||||
"descr": "Exercises using bodyweight and adjustable straps anchored to a point."
|
||||
},
|
||||
{
|
||||
"name": "Calisthenics",
|
||||
"descr": "Advanced bodyweight movements focusing on control, balance, and strength."
|
||||
},
|
||||
{
|
||||
"name": "Stretching - Static",
|
||||
"descr": "Stretching muscles by holding a position for a prolonged time."
|
||||
},
|
||||
{
|
||||
"name": "Stretching - Dynamic",
|
||||
"descr": "Active movements that stretch muscles and joints through full range of motion."
|
||||
},
|
||||
{
|
||||
"name": "Plyometric",
|
||||
"descr": "Explosive movements designed to build power and speed."
|
||||
},
|
||||
{
|
||||
"name": "Isometric",
|
||||
"descr": "Exercises that involve holding a position under tension without movement."
|
||||
}
|
||||
]
|
||||
@@ -1,151 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "Lat Pull Down",
|
||||
"setup": "Seat: 3, Thigh Pad: 4",
|
||||
"descr": "Sit upright with your knees secured under the pad. Grip the bar wider than shoulder-width. Pull the bar down to your chest, squeezing your shoulder blades together. Avoid leaning back excessively or using momentum.",
|
||||
"sets": 3,
|
||||
"reps": 10,
|
||||
"weight": 60,
|
||||
"type": "Machine-Based",
|
||||
"muscles": ["Latissimus Dorsi", "Trapezius", "Rhomboids", "Biceps Brachii"]
|
||||
},
|
||||
{
|
||||
"name": "Seated Row",
|
||||
"setup": "Seat: 2, Chest Pad: 3",
|
||||
"descr": "With your chest firmly against the pad, grip the handles and pull straight back while keeping your elbows close to your body. Focus on retracting your shoulder blades and avoid rounding your back.",
|
||||
"sets": 3,
|
||||
"reps": 10,
|
||||
"weight": 60,
|
||||
"type": "Machine-Based",
|
||||
"muscles": ["Latissimus Dorsi", "Rhomboids", "Trapezius", "Biceps Brachii"]
|
||||
},
|
||||
{
|
||||
"name": "Shoulder Press",
|
||||
"setup": "Seat: 4",
|
||||
"descr": "Sit with your back against the pad, grip the handles just outside shoulder-width. Press upward without locking out your elbows. Keep your neck relaxed and avoid shrugging your shoulders.",
|
||||
"sets": 3,
|
||||
"reps": 10,
|
||||
"weight": 30,
|
||||
"type": "Machine-Based",
|
||||
"muscles": ["Deltoid (Anterior)", "Deltoid (Lateral)", "Triceps Brachii"]
|
||||
},
|
||||
{
|
||||
"name": "Chest Press",
|
||||
"setup": "Seat: 3",
|
||||
"descr": "Adjust the seat so the handles are at mid-chest height. Push forward until arms are nearly extended, then return slowly. Keep wrists straight and don’t let your elbows drop too low.",
|
||||
"sets": 3,
|
||||
"reps": 10,
|
||||
"weight": 40,
|
||||
"type": "Machine-Based",
|
||||
"muscles": ["Pectoralis Major", "Triceps Brachii", "Deltoid (Anterior)"]
|
||||
},
|
||||
{
|
||||
"name": "Tricep Press",
|
||||
"setup": "Seat: 2",
|
||||
"descr": "With elbows close to your sides, press the handles downward in a controlled motion. Avoid flaring your elbows or using your shoulders to assist the motion.",
|
||||
"sets": 3,
|
||||
"reps": 10,
|
||||
"weight": 60,
|
||||
"type": "Machine-Based",
|
||||
"muscles": ["Triceps Brachii"]
|
||||
},
|
||||
{
|
||||
"name": "Arm Curl",
|
||||
"setup": "Seat: 3",
|
||||
"descr": "Position your arms over the pad and grip the handles. Curl the weight upward while keeping your upper arms stationary. Avoid using momentum and fully control the lowering phase.",
|
||||
"sets": 3,
|
||||
"reps": 10,
|
||||
"weight": 30,
|
||||
"type": "Machine-Based",
|
||||
"muscles": ["Biceps Brachii", "Brachialis"]
|
||||
},
|
||||
{
|
||||
"name": "Abdominal",
|
||||
"setup": "Seat: 2, Back Pad: 3",
|
||||
"descr": "Sit with the pads resting against your chest. Contract your abs to curl forward, keeping your lower back in contact with the pad. Avoid pulling with your arms or hips.",
|
||||
"sets": 3,
|
||||
"reps": 10,
|
||||
"weight": 60,
|
||||
"type": "Machine-Based",
|
||||
"muscles": ["Rectus Abdominis", "Internal Obliques"]
|
||||
},
|
||||
{
|
||||
"name": "Rotary",
|
||||
"setup": "Seat: 3, Start Angle: Centered",
|
||||
"descr": "Rotate your torso from side to side in a controlled motion, keeping your hips still. Focus on using your obliques to generate the twist, not momentum or the arms.",
|
||||
"sets": 3,
|
||||
"reps": 10,
|
||||
"weight": 60,
|
||||
"type": "Machine-Based",
|
||||
"muscles": ["Internal Obliques", "External Obliques"]
|
||||
},
|
||||
{
|
||||
"name": "Leg Press",
|
||||
"setup": "Seat Angle: 4, Platform: Middle",
|
||||
"descr": "Place your feet shoulder-width on the platform. Press upward through your heels without locking your knees. Keep your back flat against the pad throughout the motion.",
|
||||
"sets": 3,
|
||||
"reps": 10,
|
||||
"weight": 130,
|
||||
"type": "Machine-Based",
|
||||
"muscles": [
|
||||
"Gluteus Maximus",
|
||||
"Rectus Femoris",
|
||||
"Vastus Lateralis",
|
||||
"Vastus Medialis",
|
||||
"Vastus Intermedius",
|
||||
"Biceps Femoris",
|
||||
"Semitendinosus",
|
||||
"Semimembranosus"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Leg Extension",
|
||||
"setup": "Seat: 3, Pad: Above ankle",
|
||||
"descr": "Sit upright and align your knees with the pivot point. Extend your legs to a straightened position, then lower with control. Avoid jerky movements or lifting your hips off the seat.",
|
||||
"sets": 3,
|
||||
"reps": 10,
|
||||
"weight": 70,
|
||||
"type": "Machine-Based",
|
||||
"muscles": ["Rectus Femoris", "Vastus Lateralis", "Vastus Medialis", "Vastus Intermedius"]
|
||||
},
|
||||
{
|
||||
"name": "Leg Curl",
|
||||
"setup": "Seat: 2, Pad: Above ankle",
|
||||
"descr": "Lie face down or sit depending on the version. Curl your legs toward your glutes, focusing on hamstring engagement. Avoid arching your back or using momentum.",
|
||||
"sets": 3,
|
||||
"reps": 10,
|
||||
"weight": 60,
|
||||
"type": "Machine-Based",
|
||||
"muscles": ["Biceps Femoris", "Semitendinosus", "Semimembranosus"]
|
||||
},
|
||||
{
|
||||
"name": "Adductor",
|
||||
"setup": "Seat: 3, Start Position: Wide",
|
||||
"descr": "Sit with legs placed outside the pads. Bring your legs together using inner thigh muscles. Control the motion both in and out, avoiding fast swings.",
|
||||
"sets": 3,
|
||||
"reps": 10,
|
||||
"weight": 110,
|
||||
"type": "Machine-Based",
|
||||
"muscles": ["Adductor Longus", "Adductor Brevis", "Adductor Magnus", "Gracilis"]
|
||||
},
|
||||
{
|
||||
"name": "Abductor",
|
||||
"setup": "Seat: 3, Start Position: Narrow",
|
||||
"descr": "Sit with legs inside the pads and push outward to engage outer thighs and glutes. Avoid leaning forward and keep the motion controlled throughout.",
|
||||
"sets": 3,
|
||||
"reps": 10,
|
||||
"weight": 110,
|
||||
"type": "Machine-Based",
|
||||
"muscles": ["Gluteus Medius", "Tensor Fasciae Latae"]
|
||||
},
|
||||
{
|
||||
"name": "Calfs",
|
||||
"setup": "Seat: 3, Toe Bar: Midfoot",
|
||||
"descr": "Place the balls of your feet on the platform with heels hanging off. Raise your heels by contracting your calves, then slowly lower them below the platform level for a full stretch.",
|
||||
"sets": 3,
|
||||
"reps": 10,
|
||||
"weight": 60,
|
||||
"type": "Machine-Based",
|
||||
"muscles": ["Gastrocnemius", "Soleus"]
|
||||
}
|
||||
]
|
||||
@@ -1,183 +0,0 @@
|
||||
name: Beginner
|
||||
source: Planet Fitness
|
||||
exercises:
|
||||
- name: Lat Pull Down
|
||||
setup: 'Seat: 3, Thigh Pad: 4'
|
||||
descr: Sit upright with your knees secured under the pad. Grip the bar wider than
|
||||
shoulder-width. Pull the bar down to your chest, squeezing your shoulder blades
|
||||
together. Avoid leaning back excessively or using momentum.
|
||||
sets: 3
|
||||
reps: 10
|
||||
weight: 60
|
||||
type: Machine-Based
|
||||
muscles:
|
||||
- Latissimus Dorsi
|
||||
- Trapezius
|
||||
- Rhomboids
|
||||
- Biceps Brachii
|
||||
- name: Seated Row
|
||||
setup: 'Seat: 2, Chest Pad: 3'
|
||||
descr: With your chest firmly against the pad, grip the handles and pull straight
|
||||
back while keeping your elbows close to your body. Focus on retracting your shoulder
|
||||
blades and avoid rounding your back.
|
||||
sets: 3
|
||||
reps: 10
|
||||
weight: 60
|
||||
type: Machine-Based
|
||||
muscles:
|
||||
- Latissimus Dorsi
|
||||
- Rhomboids
|
||||
- Trapezius
|
||||
- Biceps Brachii
|
||||
- name: Shoulder Press
|
||||
setup: 'Seat: 4'
|
||||
descr: Sit with your back against the pad, grip the handles just outside shoulder-width.
|
||||
Press upward without locking out your elbows. Keep your neck relaxed and avoid
|
||||
shrugging your shoulders.
|
||||
sets: 3
|
||||
reps: 10
|
||||
weight: 30
|
||||
type: Machine-Based
|
||||
muscles:
|
||||
- Deltoid (Anterior)
|
||||
- Deltoid (Lateral)
|
||||
- Triceps Brachii
|
||||
- name: Chest Press
|
||||
setup: 'Seat: 3'
|
||||
descr: Adjust the seat so the handles are at mid-chest height. Push forward until
|
||||
arms are nearly extended, then return slowly. Keep wrists straight and don’t let
|
||||
your elbows drop too low.
|
||||
sets: 3
|
||||
reps: 10
|
||||
weight: 40
|
||||
type: Machine-Based
|
||||
muscles:
|
||||
- Pectoralis Major
|
||||
- Triceps Brachii
|
||||
- Deltoid (Anterior)
|
||||
- name: Tricep Press
|
||||
setup: 'Seat: 2'
|
||||
descr: With elbows close to your sides, press the handles downward in a controlled
|
||||
motion. Avoid flaring your elbows or using your shoulders to assist the motion.
|
||||
sets: 3
|
||||
reps: 10
|
||||
weight: 60
|
||||
type: Machine-Based
|
||||
muscles:
|
||||
- Triceps Brachii
|
||||
- name: Arm Curl
|
||||
setup: 'Seat: 3'
|
||||
descr: Position your arms over the pad and grip the handles. Curl the weight upward
|
||||
while keeping your upper arms stationary. Avoid using momentum and fully control
|
||||
the lowering phase.
|
||||
sets: 3
|
||||
reps: 10
|
||||
weight: 30
|
||||
type: Machine-Based
|
||||
muscles:
|
||||
- Biceps Brachii
|
||||
- Brachialis
|
||||
- name: Abdominal
|
||||
setup: 'Seat: 2, Back Pad: 3'
|
||||
descr: Sit with the pads resting against your chest. Contract your abs to curl forward,
|
||||
keeping your lower back in contact with the pad. Avoid pulling with your arms
|
||||
or hips.
|
||||
sets: 3
|
||||
reps: 10
|
||||
weight: 60
|
||||
type: Machine-Based
|
||||
muscles:
|
||||
- Rectus Abdominis
|
||||
- Internal Obliques
|
||||
- name: Rotary
|
||||
setup: 'Seat: 3, Start Angle: Centered'
|
||||
descr: Rotate your torso from side to side in a controlled motion, keeping your
|
||||
hips still. Focus on using your obliques to generate the twist, not momentum or
|
||||
the arms.
|
||||
sets: 3
|
||||
reps: 10
|
||||
weight: 60
|
||||
type: Machine-Based
|
||||
muscles:
|
||||
- Internal Obliques
|
||||
- External Obliques
|
||||
- name: Leg Press
|
||||
setup: 'Seat Angle: 4, Platform: Middle'
|
||||
descr: Place your feet shoulder-width on the platform. Press upward through your
|
||||
heels without locking your knees. Keep your back flat against the pad throughout
|
||||
the motion.
|
||||
sets: 3
|
||||
reps: 10
|
||||
weight: 130
|
||||
type: Machine-Based
|
||||
muscles:
|
||||
- Gluteus Maximus
|
||||
- Rectus Femoris
|
||||
- Vastus Lateralis
|
||||
- Vastus Medialis
|
||||
- Vastus Intermedius
|
||||
- Biceps Femoris
|
||||
- Semitendinosus
|
||||
- Semimembranosus
|
||||
- name: Leg Extension
|
||||
setup: 'Seat: 3, Pad: Above ankle'
|
||||
descr: Sit upright and align your knees with the pivot point. Extend your legs to
|
||||
a straightened position, then lower with control. Avoid jerky movements or lifting
|
||||
your hips off the seat.
|
||||
sets: 3
|
||||
reps: 10
|
||||
weight: 70
|
||||
type: Machine-Based
|
||||
muscles:
|
||||
- Rectus Femoris
|
||||
- Vastus Lateralis
|
||||
- Vastus Medialis
|
||||
- Vastus Intermedius
|
||||
- name: Leg Curl
|
||||
setup: 'Seat: 2, Pad: Above ankle'
|
||||
descr: Lie face down or sit depending on the version. Curl your legs toward your
|
||||
glutes, focusing on hamstring engagement. Avoid arching your back or using momentum.
|
||||
sets: 3
|
||||
reps: 10
|
||||
weight: 60
|
||||
type: Machine-Based
|
||||
muscles:
|
||||
- Biceps Femoris
|
||||
- Semitendinosus
|
||||
- Semimembranosus
|
||||
- name: Adductor
|
||||
setup: 'Seat: 3, Start Position: Wide'
|
||||
descr: Sit with legs placed outside the pads. Bring your legs together using inner
|
||||
thigh muscles. Control the motion both in and out, avoiding fast swings.
|
||||
sets: 3
|
||||
reps: 10
|
||||
weight: 110
|
||||
type: Machine-Based
|
||||
muscles:
|
||||
- Adductor Longus
|
||||
- Adductor Brevis
|
||||
- Adductor Magnus
|
||||
- Gracilis
|
||||
- name: Abductor
|
||||
setup: 'Seat: 3, Start Position: Narrow'
|
||||
descr: Sit with legs inside the pads and push outward to engage outer thighs and
|
||||
glutes. Avoid leaning forward and keep the motion controlled throughout.
|
||||
sets: 3
|
||||
reps: 10
|
||||
weight: 110
|
||||
type: Machine-Based
|
||||
muscles:
|
||||
- Gluteus Medius
|
||||
- Tensor Fasciae Latae
|
||||
- name: Calfs
|
||||
setup: 'Seat: 3, Toe Bar: Midfoot'
|
||||
descr: Place the balls of your feet on the platform with heels hanging off. Raise
|
||||
your heels by contracting your calves, then slowly lower them below the platform
|
||||
level for a full stretch.
|
||||
sets: 3
|
||||
reps: 10
|
||||
weight: 60
|
||||
type: Machine-Based
|
||||
muscles:
|
||||
- Gastrocnemius
|
||||
- Soleus
|
||||
@@ -1,58 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "Chest",
|
||||
"descr": "Muscles at the front of the upper torso responsible for pushing movements."
|
||||
},
|
||||
{
|
||||
"name": "Back",
|
||||
"descr": "Muscles along the spine and upper back involved in pulling, posture, and lifting."
|
||||
},
|
||||
{
|
||||
"name": "Shoulders",
|
||||
"descr": "Muscles surrounding the shoulder joint, enabling arm rotation and elevation."
|
||||
},
|
||||
{
|
||||
"name": "Arms",
|
||||
"descr": "Upper limb muscles responsible for flexion, extension, and grip strength."
|
||||
},
|
||||
{
|
||||
"name": "Abdominals",
|
||||
"descr": "Core muscles on the front and sides of the torso, key for stability and trunk movement."
|
||||
},
|
||||
{
|
||||
"name": "Glutes",
|
||||
"descr": "Powerful hip muscles that drive hip extension, rotation, and posture."
|
||||
},
|
||||
{
|
||||
"name": "Quadriceps",
|
||||
"descr": "Four muscles at the front of the thigh responsible for knee extension."
|
||||
},
|
||||
{
|
||||
"name": "Hamstrings",
|
||||
"descr": "Muscles at the back of the thigh that bend the knee and extend the hip."
|
||||
},
|
||||
{
|
||||
"name": "Calves",
|
||||
"descr": "Muscles of the lower leg that control ankle movement and propulsion."
|
||||
},
|
||||
{
|
||||
"name": "Forearms",
|
||||
"descr": "Muscles between the elbow and wrist that manage wrist and finger motion."
|
||||
},
|
||||
{
|
||||
"name": "Neck",
|
||||
"descr": "Muscles supporting the head and enabling neck movement and posture."
|
||||
},
|
||||
{
|
||||
"name": "Hip Flexors",
|
||||
"descr": "Muscles at the front of the hip that lift the thigh toward the torso."
|
||||
},
|
||||
{
|
||||
"name": "Adductors",
|
||||
"descr": "Inner thigh muscles that pull the legs toward the midline of the body."
|
||||
},
|
||||
{
|
||||
"name": "Abductors",
|
||||
"descr": "Outer hip muscles that move the legs away from the body’s midline."
|
||||
}
|
||||
]
|
||||
@@ -1,60 +0,0 @@
|
||||
[
|
||||
{ "name": "Pectoralis Major", "muscleGroup": "Chest", "descr": "Large chest muscle located on the front of the upper torso, responsible for arm flexion and pushing." },
|
||||
{ "name": "Pectoralis Minor", "muscleGroup": "Chest", "descr": "Thin, triangular muscle beneath the pectoralis major, stabilizes the scapula." },
|
||||
|
||||
{ "name": "Latissimus Dorsi", "muscleGroup": "Back", "descr": "Broad muscle on the mid to lower back, responsible for pulling and shoulder extension." },
|
||||
{ "name": "Trapezius", "muscleGroup": "Back", "descr": "Large muscle covering the upper back and neck, involved in shoulder movement and posture." },
|
||||
{ "name": "Rhomboids", "muscleGroup": "Back", "descr": "Muscles between the shoulder blades, responsible for scapular retraction." },
|
||||
{ "name": "Erector Spinae", "muscleGroup": "Back", "descr": "Long vertical muscles along the spine that maintain posture and extend the back." },
|
||||
|
||||
{ "name": "Deltoid (Anterior)", "muscleGroup": "Shoulders", "descr": "Front portion of the shoulder muscle, raises the arm forward." },
|
||||
{ "name": "Deltoid (Lateral)", "muscleGroup": "Shoulders", "descr": "Middle portion of the shoulder muscle, raises the arm to the side." },
|
||||
{ "name": "Deltoid (Posterior)", "muscleGroup": "Shoulders", "descr": "Rear portion of the shoulder muscle, moves the arm backward." },
|
||||
{ "name": "Rotator Cuff Muscles", "muscleGroup": "Shoulders", "descr": "Group of four muscles surrounding the shoulder joint, stabilizing and rotating the arm." },
|
||||
|
||||
{ "name": "Biceps Brachii", "muscleGroup": "Arms", "descr": "Front upper arm muscle, responsible for elbow flexion and forearm rotation." },
|
||||
{ "name": "Triceps Brachii", "muscleGroup": "Arms", "descr": "Back upper arm muscle, responsible for elbow extension." },
|
||||
{ "name": "Brachialis", "muscleGroup": "Arms", "descr": "Muscle beneath the biceps, assists in elbow flexion." },
|
||||
{ "name": "Brachioradialis", "muscleGroup": "Arms", "descr": "Forearm muscle on the thumb side, aids in elbow flexion." },
|
||||
|
||||
{ "name": "Rectus Abdominis", "muscleGroup": "Abdominals", "descr": "Vertical muscle on the front of the abdomen, responsible for trunk flexion (the 'six-pack')." },
|
||||
{ "name": "Transverse Abdominis", "muscleGroup": "Abdominals", "descr": "Deepest abdominal muscle, wraps around the torso to stabilize the core." },
|
||||
{ "name": "Internal Obliques", "muscleGroup": "Abdominals", "descr": "Muscles located beneath the external obliques, involved in trunk rotation and lateral flexion." },
|
||||
{ "name": "External Obliques", "muscleGroup": "Abdominals", "descr": "Muscles on the sides of the abdomen, responsible for trunk twisting and side bending." },
|
||||
|
||||
{ "name": "Gluteus Maximus", "muscleGroup": "Glutes", "descr": "Largest glute muscle located in the buttocks, responsible for hip extension and rotation." },
|
||||
{ "name": "Gluteus Medius", "muscleGroup": "Glutes", "descr": "Muscle on the outer surface of the pelvis, important for hip abduction and stability." },
|
||||
{ "name": "Gluteus Minimus", "muscleGroup": "Glutes", "descr": "Smallest glute muscle, located beneath the medius, assists in hip abduction." },
|
||||
|
||||
{ "name": "Rectus Femoris", "muscleGroup": "Quadriceps", "descr": "Front thigh muscle, part of the quadriceps group, helps extend the knee and flex the hip." },
|
||||
{ "name": "Vastus Lateralis", "muscleGroup": "Quadriceps", "descr": "Outer thigh muscle, part of the quadriceps, involved in knee extension." },
|
||||
{ "name": "Vastus Medialis", "muscleGroup": "Quadriceps", "descr": "Inner thigh muscle, part of the quadriceps, assists in knee extension and stabilization." },
|
||||
{ "name": "Vastus Intermedius", "muscleGroup": "Quadriceps", "descr": "Deep thigh muscle beneath rectus femoris, assists in knee extension." },
|
||||
|
||||
{ "name": "Biceps Femoris", "muscleGroup": "Hamstrings", "descr": "Muscle on the back of the thigh, responsible for knee flexion and hip extension." },
|
||||
{ "name": "Semitendinosus", "muscleGroup": "Hamstrings", "descr": "Medial hamstring muscle, assists in knee flexion and internal rotation." },
|
||||
{ "name": "Semimembranosus", "muscleGroup": "Hamstrings", "descr": "Deep medial hamstring muscle, also assists in knee flexion and hip extension." },
|
||||
|
||||
{ "name": "Gastrocnemius", "muscleGroup": "Calves", "descr": "Large calf muscle visible on the back of the lower leg, responsible for plantar flexion of the foot." },
|
||||
{ "name": "Soleus", "muscleGroup": "Calves", "descr": "Flat muscle beneath the gastrocnemius, aids in plantar flexion when the knee is bent." },
|
||||
|
||||
{ "name": "Flexor Carpi Radialis", "muscleGroup": "Forearms", "descr": "Muscle on the front of the forearm, flexes and abducts the wrist." },
|
||||
{ "name": "Flexor Carpi Ulnaris", "muscleGroup": "Forearms", "descr": "Forearm muscle that flexes and adducts the wrist." },
|
||||
{ "name": "Extensor Carpi Radialis", "muscleGroup": "Forearms", "descr": "Posterior forearm muscle that extends and abducts the wrist." },
|
||||
{ "name": "Pronator Teres", "muscleGroup": "Forearms", "descr": "Muscle running across the forearm that pronates the forearm (palm down)." },
|
||||
|
||||
{ "name": "Sternocleidomastoid", "muscleGroup": "Neck", "descr": "Prominent neck muscle responsible for rotating and flexing the head." },
|
||||
{ "name": "Splenius Capitis", "muscleGroup": "Neck", "descr": "Back of neck muscle that extends and rotates the head." },
|
||||
{ "name": "Scalenes", "muscleGroup": "Neck", "descr": "Lateral neck muscles that assist in neck flexion and elevate the ribs during breathing." },
|
||||
|
||||
{ "name": "Iliopsoas", "muscleGroup": "Hip Flexors", "descr": "Deep muscle group connecting the lower spine to the femur, main hip flexor." },
|
||||
{ "name": "Rectus Femoris", "muscleGroup": "Hip Flexors", "descr": "Also part of the quadriceps, helps flex the hip and extend the knee." },
|
||||
{ "name": "Sartorius", "muscleGroup": "Hip Flexors", "descr": "Longest muscle in the body, crosses the thigh to flex and rotate the hip and knee." },
|
||||
|
||||
{ "name": "Adductor Longus", "muscleGroup": "Adductors", "descr": "Medial thigh muscle that adducts the leg and assists with hip flexion." },
|
||||
{ "name": "Adductor Brevis", "muscleGroup": "Adductors", "descr": "Short adductor muscle that helps pull the thigh inward." },
|
||||
{ "name": "Adductor Magnus", "muscleGroup": "Adductors", "descr": "Large, deep inner thigh muscle that performs hip adduction and extension." },
|
||||
{ "name": "Gracilis", "muscleGroup": "Adductors", "descr": "Thin inner thigh muscle that assists in adduction and knee flexion." },
|
||||
|
||||
{ "name": "Tensor Fasciae Latae", "muscleGroup": "Abductors", "descr": "Lateral hip muscle that abducts and medially rotates the thigh." }
|
||||
]
|
||||
@@ -1,135 +0,0 @@
|
||||
- name: Pectoralis Major
|
||||
muscleGroup: Chest
|
||||
descr: Large chest muscle located on the front of the upper torso, responsible for arm flexion and pushing.
|
||||
- name: Pectoralis Minor
|
||||
muscleGroup: Chest
|
||||
descr: Thin, triangular muscle beneath the pectoralis major, stabilizes the scapula.
|
||||
- name: Latissimus Dorsi
|
||||
muscleGroup: Back
|
||||
descr: Broad muscle on the mid to lower back, responsible for pulling and shoulder extension.
|
||||
- name: Trapezius
|
||||
muscleGroup: Back
|
||||
descr: Large muscle covering the upper back and neck, involved in shoulder movement and posture.
|
||||
- name: Rhomboids
|
||||
muscleGroup: Back
|
||||
descr: Muscles between the shoulder blades, responsible for scapular retraction.
|
||||
- name: Erector Spinae
|
||||
muscleGroup: Back
|
||||
descr: Long vertical muscles along the spine that maintain posture and extend the back.
|
||||
- name: Deltoid (Anterior)
|
||||
muscleGroup: Shoulders
|
||||
descr: Front portion of the shoulder muscle, raises the arm forward.
|
||||
- name: Deltoid (Lateral)
|
||||
muscleGroup: Shoulders
|
||||
descr: Middle portion of the shoulder muscle, raises the arm to the side.
|
||||
- name: Deltoid (Posterior)
|
||||
muscleGroup: Shoulders
|
||||
descr: Rear portion of the shoulder muscle, moves the arm backward.
|
||||
- name: Rotator Cuff Muscles
|
||||
muscleGroup: Shoulders
|
||||
descr: Group of four muscles surrounding the shoulder joint, stabilizing and rotating the arm.
|
||||
- name: Biceps Brachii
|
||||
muscleGroup: Arms
|
||||
descr: Front upper arm muscle, responsible for elbow flexion and forearm rotation.
|
||||
- name: Triceps Brachii
|
||||
muscleGroup: Arms
|
||||
descr: Back upper arm muscle, responsible for elbow extension.
|
||||
- name: Brachialis
|
||||
muscleGroup: Arms
|
||||
descr: Muscle beneath the biceps, assists in elbow flexion.
|
||||
- name: Brachioradialis
|
||||
muscleGroup: Arms
|
||||
descr: Forearm muscle on the thumb side, aids in elbow flexion.
|
||||
- name: Rectus Abdominis
|
||||
muscleGroup: Abdominals
|
||||
descr: Vertical muscle on the front of the abdomen, responsible for trunk flexion (the 'six-pack').
|
||||
- name: Transverse Abdominis
|
||||
muscleGroup: Abdominals
|
||||
descr: Deepest abdominal muscle, wraps around the torso to stabilize the core.
|
||||
- name: Internal Obliques
|
||||
muscleGroup: Abdominals
|
||||
descr: Muscles located beneath the external obliques, involved in trunk rotation and lateral flexion.
|
||||
- name: External Obliques
|
||||
muscleGroup: Abdominals
|
||||
descr: Muscles on the sides of the abdomen, responsible for trunk twisting and side bending.
|
||||
- name: Gluteus Maximus
|
||||
muscleGroup: Glutes
|
||||
descr: Largest glute muscle located in the buttocks, responsible for hip extension and rotation.
|
||||
- name: Gluteus Medius
|
||||
muscleGroup: Glutes
|
||||
descr: Muscle on the outer surface of the pelvis, important for hip abduction and stability.
|
||||
- name: Gluteus Minimus
|
||||
muscleGroup: Glutes
|
||||
descr: Smallest glute muscle, located beneath the medius, assists in hip abduction.
|
||||
- name: Rectus Femoris
|
||||
muscleGroup: Quadriceps
|
||||
descr: Front thigh muscle, part of the quadriceps group, helps extend the knee and flex the hip.
|
||||
- name: Vastus Lateralis
|
||||
muscleGroup: Quadriceps
|
||||
descr: Outer thigh muscle, part of the quadriceps, involved in knee extension.
|
||||
- name: Vastus Medialis
|
||||
muscleGroup: Quadriceps
|
||||
descr: Inner thigh muscle, part of the quadriceps, assists in knee extension and stabilization.
|
||||
- name: Vastus Intermedius
|
||||
muscleGroup: Quadriceps
|
||||
descr: Deep thigh muscle beneath rectus femoris, assists in knee extension.
|
||||
- name: Biceps Femoris
|
||||
muscleGroup: Hamstrings
|
||||
descr: Muscle on the back of the thigh, responsible for knee flexion and hip extension.
|
||||
- name: Semitendinosus
|
||||
muscleGroup: Hamstrings
|
||||
descr: Medial hamstring muscle, assists in knee flexion and internal rotation.
|
||||
- name: Semimembranosus
|
||||
muscleGroup: Hamstrings
|
||||
descr: Deep medial hamstring muscle, also assists in knee flexion and hip extension.
|
||||
- name: Gastrocnemius
|
||||
muscleGroup: Calves
|
||||
descr: Large calf muscle visible on the back of the lower leg, responsible for plantar flexion of the foot.
|
||||
- name: Soleus
|
||||
muscleGroup: Calves
|
||||
descr: Flat muscle beneath the gastrocnemius, aids in plantar flexion when the knee is bent.
|
||||
- name: Flexor Carpi Radialis
|
||||
muscleGroup: Forearms
|
||||
descr: Muscle on the front of the forearm, flexes and abducts the wrist.
|
||||
- name: Flexor Carpi Ulnaris
|
||||
muscleGroup: Forearms
|
||||
descr: Forearm muscle that flexes and adducts the wrist.
|
||||
- name: Extensor Carpi Radialis
|
||||
muscleGroup: Forearms
|
||||
descr: Posterior forearm muscle that extends and abducts the wrist.
|
||||
- name: Pronator Teres
|
||||
muscleGroup: Forearms
|
||||
descr: Muscle running across the forearm that pronates the forearm (palm down).
|
||||
- name: Sternocleidomastoid
|
||||
muscleGroup: Neck
|
||||
descr: Prominent neck muscle responsible for rotating and flexing the head.
|
||||
- name: Splenius Capitis
|
||||
muscleGroup: Neck
|
||||
descr: Back of neck muscle that extends and rotates the head.
|
||||
- name: Scalenes
|
||||
muscleGroup: Neck
|
||||
descr: Lateral neck muscles that assist in neck flexion and elevate the ribs during breathing.
|
||||
- name: Iliopsoas
|
||||
muscleGroup: Hip Flexors
|
||||
descr: Deep muscle group connecting the lower spine to the femur, main hip flexor.
|
||||
- name: Rectus Femoris
|
||||
muscleGroup: Hip Flexors
|
||||
descr: Also part of the quadriceps, helps flex the hip and extend the knee.
|
||||
- name: Sartorius
|
||||
muscleGroup: Hip Flexors
|
||||
descr: Longest muscle in the body, crosses the thigh to flex and rotate the hip and knee.
|
||||
- name: Adductor Longus
|
||||
muscleGroup: Adductors
|
||||
descr: Medial thigh muscle that adducts the leg and assists with hip flexion.
|
||||
- name: Adductor Brevis
|
||||
muscleGroup: Adductors
|
||||
descr: Short adductor muscle that helps pull the thigh inward.
|
||||
- name: Adductor Magnus
|
||||
muscleGroup: Adductors
|
||||
descr: Large, deep inner thigh muscle that performs hip adduction and extension.
|
||||
- name: Gracilis
|
||||
muscleGroup: Adductors
|
||||
descr: Thin inner thigh muscle that assists in adduction and knee flexion.
|
||||
- name: Tensor Fasciae Latae
|
||||
muscleGroup: Abductors
|
||||
descr: Lateral hip muscle that abducts and medially rotates the thigh.
|
||||
@@ -1,50 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "Upper Body",
|
||||
"intro": "Focuses on muscles of the chest, back, shoulders, arms, and core. Ideal for developing strength and symmetry above the waist.",
|
||||
"splitExerciseAssignments": [
|
||||
{ "exercise": "Lat Pull Down", "weight": 70, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Seated Row", "weight": 80, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Shoulder Press", "weight": 40, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Chest Press", "weight": 50, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Tricep Press", "weight": 40, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Arm Curl", "weight": 35, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Abdominal", "weight": 50, "sets": 3, "reps": 15 },
|
||||
{ "exercise": "Rotary", "weight": 40, "sets": 3, "reps": 12 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Lower Body",
|
||||
"intro": "Targets the legs, glutes, calves, and lower core. Essential for building power, stability, and balanced physique.",
|
||||
"splitExerciseAssignments": [
|
||||
{ "exercise": "Leg Press", "weight": 120, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Leg Extension", "weight": 60, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Leg Curl", "weight": 55, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Adductor", "weight": 50, "sets": 3, "reps": 12 },
|
||||
{ "exercise": "Abductor", "weight": 50, "sets": 3, "reps": 12 },
|
||||
{ "exercise": "Calfs", "weight": 70, "sets": 3, "reps": 15 },
|
||||
{ "exercise": "Abdominal", "weight": 50, "sets": 3, "reps": 15 },
|
||||
{ "exercise": "Rotary", "weight": 40, "sets": 3, "reps": 12 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Full Body",
|
||||
"intro": "Combines upper and lower body exercises to target all major muscle groups in a single session. Ideal for general fitness and efficient training.",
|
||||
"splitExerciseAssignments": [
|
||||
{ "exercise": "Lat Pull Down", "weight": 70, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Seated Row", "weight": 80, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Shoulder Press", "weight": 40, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Chest Press", "weight": 50, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Tricep Press", "weight": 40, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Arm Curl", "weight": 35, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Lat Pull Down", "weight": 70, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Shoulder Press", "weight": 40, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Chest Press", "weight": 50, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Leg Press", "weight": 120, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Leg Curl", "weight": 55, "sets": 3, "reps": 10 },
|
||||
{ "exercise": "Calfs", "weight": 70, "sets": 3, "reps": 15 },
|
||||
{ "exercise": "Abdominal", "weight": 50, "sets": 3, "reps": 15 },
|
||||
{ "exercise": "Rotary", "weight": 40, "sets": 3, "reps": 12 }
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -1,30 +0,0 @@
|
||||
import Foundation
|
||||
import SwiftData
|
||||
|
||||
final class AppContainer {
|
||||
static let logger = AppLogger(
|
||||
subsystem: Bundle.main.bundleIdentifier ?? "dev.rzen.indie.Workouts",
|
||||
category: "AppContainer"
|
||||
)
|
||||
|
||||
static func create() -> ModelContainer {
|
||||
// Using the current models directly without migration plan to avoid reference errors
|
||||
let schema = Schema(SchemaVersion.models)
|
||||
let configuration = ModelConfiguration(cloudKitDatabase: .automatic)
|
||||
let container = try! ModelContainer(for: schema, configurations: configuration)
|
||||
return container
|
||||
}
|
||||
|
||||
@MainActor
|
||||
static var preview: ModelContainer {
|
||||
let configuration = ModelConfiguration(isStoredInMemoryOnly: true)
|
||||
|
||||
do {
|
||||
let schema = Schema(SchemaVersion.models)
|
||||
let container = try ModelContainer(for: schema, configurations: configuration)
|
||||
return container
|
||||
} catch {
|
||||
fatalError("Failed to create preview ModelContainer: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
import SwiftUI
|
||||
import SwiftData
|
||||
|
||||
/// A view modifier that refreshes the view when CloudKit data changes
|
||||
struct CloudKitSyncObserver: ViewModifier {
|
||||
@Environment(\.modelContext) private var modelContext
|
||||
@State private var refreshID = UUID()
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
content
|
||||
.id(refreshID) // Force view refresh when this changes
|
||||
.onReceive(NotificationCenter.default.publisher(for: .cloudKitDataDidChange)) { _ in
|
||||
refreshID = UUID()
|
||||
Task { @MainActor in
|
||||
do {
|
||||
let _ = try await fetchAll(of: Exercise.self, from: modelContext)
|
||||
let _ = try await fetchAll(of: Split.self, from: modelContext)
|
||||
let _ = try await fetchAll(of: Workout.self, from: modelContext)
|
||||
let _ = try await fetchAll(of: WorkoutLog.self, from: modelContext)
|
||||
} catch {
|
||||
print("ERROR: failed to fetch \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func fetchAll<T: PersistentModel>(of type: T.Type,from modelContext: ModelContext) async throws -> [T]? {
|
||||
try modelContext.fetch(FetchDescriptor<T>())
|
||||
}
|
||||
}
|
||||
|
||||
// Extension to make it easier to use the modifier
|
||||
extension View {
|
||||
/// Adds observation for CloudKit sync changes and refreshes the view when changes occur
|
||||
func observeCloudKitChanges() -> some View {
|
||||
self.modifier(CloudKitSyncObserver())
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import SwiftData
|
||||
|
||||
enum SchemaV1: VersionedSchema {
|
||||
static var versionIdentifier: Schema.Version = .init(1, 0, 0)
|
||||
|
||||
static var models: [any PersistentModel.Type] = [
|
||||
Split.self,
|
||||
Exercise.self,
|
||||
Workout.self,
|
||||
WorkoutLog.self
|
||||
]
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import SwiftData
|
||||
|
||||
enum SchemaVersion: Int {
|
||||
case v1
|
||||
|
||||
static var current: SchemaVersion { .v1 }
|
||||
|
||||
static var schemas: [VersionedSchema.Type] {
|
||||
[
|
||||
SchemaV1.self
|
||||
]
|
||||
}
|
||||
|
||||
static var models: [any PersistentModel.Type] {
|
||||
switch (Self.current) {
|
||||
case .v1: SchemaV1.models
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import SwiftData
|
||||
import Foundation
|
||||
|
||||
struct WorkoutsMigrationPlan: SchemaMigrationPlan {
|
||||
static var schemas: [VersionedSchema.Type] = SchemaVersion.schemas
|
||||
|
||||
static var stages: [MigrationStage] = [
|
||||
MigrationStage.custom(
|
||||
fromVersion: SchemaV1.self,
|
||||
toVersion: SchemaV1.self,
|
||||
willMigrate: { context in
|
||||
print("migrating from v1 to v1")
|
||||
},
|
||||
didMigrate: { _ in
|
||||
// No additional actions needed after migration
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
import OSLog
|
||||
import SwiftUI
|
||||
|
||||
struct AppLogger {
|
||||
private let logger: Logger
|
||||
private let subsystem: String
|
||||
private let category: String
|
||||
|
||||
init(subsystem: String, category: String) {
|
||||
self.subsystem = subsystem
|
||||
self.category = category
|
||||
self.logger = Logger(subsystem: subsystem, category: category)
|
||||
}
|
||||
|
||||
func timestamp () -> String {
|
||||
Date.now.formatDateET(format: "yyyy-MM-dd HH:mm:ss")
|
||||
}
|
||||
|
||||
func formattedMessage (_ message: String) -> String {
|
||||
"\(timestamp()) [\(subsystem):\(category)] \(message)"
|
||||
}
|
||||
|
||||
func debug(_ message: String) {
|
||||
logger.debug("\(formattedMessage(message))")
|
||||
}
|
||||
|
||||
func info(_ message: String) {
|
||||
logger.info("\(formattedMessage(message))")
|
||||
}
|
||||
|
||||
func warning(_ message: String) {
|
||||
logger.warning("\(formattedMessage(message))")
|
||||
}
|
||||
|
||||
func error(_ message: String) {
|
||||
logger.error("\(formattedMessage(message))")
|
||||
}
|
||||
|
||||
func vdebug(_ message: String) -> any View {
|
||||
logger.debug("\(formattedMessage(message))")
|
||||
return EmptyView()
|
||||
}
|
||||
|
||||
func vinfo(_ message: String) -> any View {
|
||||
logger.info("\(formattedMessage(message))")
|
||||
return EmptyView()
|
||||
}
|
||||
|
||||
func vwarning(_ message: String) -> any View {
|
||||
logger.warning("\(formattedMessage(message))")
|
||||
return EmptyView()
|
||||
}
|
||||
|
||||
func verror(_ message: String) -> any View {
|
||||
logger.error("\(formattedMessage(message))")
|
||||
return EmptyView()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import SwiftUI
|
||||
|
||||
extension Color {
|
||||
static func color(from name: String) -> Color {
|
||||
switch name.lowercased() {
|
||||
case "red": return .red
|
||||
case "orange": return .orange
|
||||
case "yellow": return .yellow
|
||||
case "green": return .green
|
||||
case "mint": return .mint
|
||||
case "teal": return .teal
|
||||
case "cyan": return .cyan
|
||||
case "blue": return .blue
|
||||
case "indigo": return .indigo
|
||||
case "purple": return .purple
|
||||
case "pink": return .pink
|
||||
case "brown": return .brown
|
||||
default: return .indigo
|
||||
}
|
||||
}
|
||||
|
||||
func darker(by percentage: CGFloat = 0.2) -> Color {
|
||||
return self.opacity(1.0 - percentage)
|
||||
}
|
||||
}
|
||||
|
||||
// Available colors for splits
|
||||
let availableColors = ["red", "orange", "yellow", "green", "mint", "teal", "cyan", "blue", "indigo", "purple", "pink", "brown"]
|
||||
|
||||
// Available system images for splits
|
||||
let availableIcons = ["dumbbell.fill", "figure.strengthtraining.traditional", "figure.run", "figure.hiking", "figure.cooldown", "figure.boxing", "figure.wrestling", "figure.gymnastics", "figure.handball", "figure.core.training", "heart.fill", "bolt.fill"]
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// Color+color.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/17/25 at 10:41 AM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
import SwiftUICore
|
||||
|
||||
extension Color {
|
||||
static func color (from: String) -> Color {
|
||||
switch from {
|
||||
case "red": return .red
|
||||
case "orange": return .orange
|
||||
case "yellow": return .yellow
|
||||
case "green": return .green
|
||||
case "mint": return .mint
|
||||
case "teal": return .teal
|
||||
case "cyan": return .cyan
|
||||
case "blue": return .blue
|
||||
case "indigo": return .indigo
|
||||
case "purple": return .purple
|
||||
case "pink": return .pink
|
||||
case "brown": return .brown
|
||||
default: return .black
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// Color+darker.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/17/25 at 9:20 AM.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
extension Color {
|
||||
func darker(by percentage: CGFloat) -> Color {
|
||||
let uiColor = UIColor(self)
|
||||
var hue: CGFloat = 0
|
||||
var saturation: CGFloat = 0
|
||||
var brightness: CGFloat = 0
|
||||
var alpha: CGFloat = 0
|
||||
|
||||
if uiColor.getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: &alpha) {
|
||||
let newBrightness = max(brightness * (1 - percentage), 0)
|
||||
let darkerUIColor = UIColor(hue: hue, saturation: saturation, brightness: newBrightness, alpha: alpha)
|
||||
return Color(darkerUIColor)
|
||||
}
|
||||
|
||||
return self // Fallback if color can't be converted
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
//
|
||||
// Constants.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by Claude on 8/8/25.
|
||||
//
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Application-wide constants
|
||||
struct Constants {
|
||||
|
||||
/// Default values for new exercises
|
||||
struct ExerciseDefaults {
|
||||
static let sets = 3
|
||||
static let reps = 10
|
||||
static let weight = 40
|
||||
static let weightReminderTimeIntervalWeeks = 2
|
||||
}
|
||||
|
||||
/// UI Constants
|
||||
struct UI {
|
||||
static let defaultSplitColor = "indigo"
|
||||
static let defaultSplitSystemImage = "dumbbell.fill"
|
||||
}
|
||||
}
|
||||