Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
11850408be
|
|||
|
37beb4abb6
|
|||
|
d263c6c87e
|
|||
|
aa6ee4ecd4
|
|||
|
c0d9702e54
|
|||
|
0cc576bb12
|
18
.editorconfig
Normal file
@@ -0,0 +1,18 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{json,yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
77
.gitattributes
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
|
||||
# Source code files
|
||||
*.swift text eol=lf
|
||||
*.kt text eol=lf
|
||||
*.kts text eol=lf
|
||||
*.java text eol=lf
|
||||
*.go text eol=lf
|
||||
*.py text eol=lf
|
||||
*.ts text eol=lf
|
||||
*.tsx text eol=lf
|
||||
*.js text eol=lf
|
||||
*.jsx text eol=lf
|
||||
*.mjs text eol=lf
|
||||
*.cjs text eol=lf
|
||||
|
||||
# Configuration files
|
||||
*.json text eol=lf
|
||||
*.yml text eol=lf
|
||||
*.yaml text eol=lf
|
||||
*.toml text eol=lf
|
||||
*.xml text eol=lf
|
||||
*.plist text eol=lf
|
||||
*.properties text eol=lf
|
||||
*.gradle text eol=lf
|
||||
*.md text eol=lf
|
||||
|
||||
# Shell scripts
|
||||
*.sh text eol=lf
|
||||
*.bash text eol=lf
|
||||
*.zsh text eol=lf
|
||||
|
||||
# Windows batch files
|
||||
*.bat text eol=crlf
|
||||
*.cmd text eol=crlf
|
||||
|
||||
# Binary files
|
||||
*.png binary
|
||||
*.jpg binary
|
||||
*.jpeg binary
|
||||
*.gif binary
|
||||
*.ico binary
|
||||
*.webp binary
|
||||
*.pdf binary
|
||||
*.zip binary
|
||||
*.tar binary
|
||||
*.gz binary
|
||||
*.jar binary
|
||||
*.aar binary
|
||||
*.apk binary
|
||||
*.ipa binary
|
||||
*.xcassets binary
|
||||
*.ttf binary
|
||||
*.otf binary
|
||||
*.woff binary
|
||||
*.woff2 binary
|
||||
*.eot binary
|
||||
|
||||
# Xcode files
|
||||
*.pbxproj merge=union
|
||||
*.xcworkspacedata text eol=lf
|
||||
*.xcscheme text eol=lf
|
||||
|
||||
# Gradle wrapper
|
||||
gradlew text eol=lf
|
||||
gradlew.bat text eol=crlf
|
||||
gradle-wrapper.jar binary
|
||||
|
||||
# Lock files
|
||||
*.lock text -diff
|
||||
package-lock.json text -diff
|
||||
pnpm-lock.yaml text -diff
|
||||
|
||||
# Documentation
|
||||
LICENSE text eol=lf
|
||||
README.md text eol=lf
|
||||
46
.gitignore
vendored
@@ -9,6 +9,11 @@ local.properties
|
||||
# Log/OS Files
|
||||
*.log
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
Thumbs.db
|
||||
|
||||
# Android Studio generated files and folders
|
||||
captures/
|
||||
@@ -34,3 +39,44 @@ google-services.json
|
||||
|
||||
# Android Profiling
|
||||
*.hprof
|
||||
|
||||
# iOS/Xcode
|
||||
ios/build/
|
||||
ios/DerivedData/
|
||||
ios/*.xcuserstate
|
||||
ios/**/xcuserdata/
|
||||
ios/**/*.xcuserstate
|
||||
*.xccheckout
|
||||
*.moved-aside
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.dSYM.zip
|
||||
*.dSYM
|
||||
timeline.xctimeline
|
||||
playground.xcworkspace
|
||||
|
||||
# CocoaPods
|
||||
ios/Pods/
|
||||
ios/Podfile.lock
|
||||
|
||||
# Swift Package Manager
|
||||
ios/.swiftpm/
|
||||
ios/Package.resolved
|
||||
.build/
|
||||
|
||||
# fastlane
|
||||
fastlane/report.xml
|
||||
fastlane/Preview.html
|
||||
fastlane/screenshots/**/*.png
|
||||
fastlane/test_output
|
||||
|
||||
# Code Injection
|
||||
iOSInjectionProject/
|
||||
|
||||
90
Makefile
Normal file
@@ -0,0 +1,90 @@
|
||||
# Ascently Makefile
|
||||
|
||||
.PHONY: help android-lint android-format android-build android-test \
|
||||
ios-lint ios-format ios-build ios-test clean
|
||||
|
||||
# Default target
|
||||
help:
|
||||
@echo "Ascently Dev Commands"
|
||||
@echo "=============================="
|
||||
@echo ""
|
||||
@echo "Android:"
|
||||
@echo " make android-lint: Run Detekt static analysis"
|
||||
@echo " make android-format: Check code formatting with Spotless"
|
||||
@echo " make android-format-fix: Auto-fix code formatting"
|
||||
@echo " make android-build: Build debug APK"
|
||||
@echo " make android-release: Build release APK"
|
||||
@echo " make android-test: Run unit tests"
|
||||
@echo ""
|
||||
@echo "iOS:"
|
||||
@echo " make ios-lint: Run SwiftLint"
|
||||
@echo " make ios-lint-fix: Run SwiftLint with auto-fix"
|
||||
@echo " make ios-format: Run SwiftFormat (dry-run)"
|
||||
@echo " make ios-format-fix: Run SwiftFormat with auto-fix"
|
||||
@echo " make ios-build: Build iOS app"
|
||||
@echo ""
|
||||
@echo "General:"
|
||||
@echo " make lint: Run linters for both platforms"
|
||||
@echo " make format: Check formatting for both platforms"
|
||||
@echo " make clean: Clean build artifacts"
|
||||
|
||||
# Android commands
|
||||
android-lint:
|
||||
cd android && ./gradlew detekt
|
||||
|
||||
android-format:
|
||||
cd android && ./gradlew spotlessCheck
|
||||
|
||||
android-format-fix:
|
||||
cd android && ./gradlew spotlessApply
|
||||
|
||||
android-build:
|
||||
cd android && ./gradlew assembleDebug
|
||||
|
||||
android-release:
|
||||
cd android && ./gradlew assembleRelease
|
||||
|
||||
android-test:
|
||||
cd android && ./gradlew test
|
||||
|
||||
# iOS commands (requires SwiftLint and SwiftFormat!!!)
|
||||
ios-lint:
|
||||
@if command -v swiftlint >/dev/null 2>&1; then \
|
||||
cd ios && swiftlint; \
|
||||
else \
|
||||
echo "SwiftLint not installed. Install with: brew install swiftlint"; \
|
||||
fi
|
||||
|
||||
ios-lint-fix:
|
||||
@if command -v swiftlint >/dev/null 2>&1; then \
|
||||
cd ios && swiftlint --fix; \
|
||||
else \
|
||||
echo "SwiftLint not installed. Install with: brew install swiftlint"; \
|
||||
fi
|
||||
|
||||
ios-format:
|
||||
@if command -v swiftformat >/dev/null 2>&1; then \
|
||||
cd ios && swiftformat . --lint; \
|
||||
else \
|
||||
echo "SwiftFormat not installed. Install with: brew install swiftformat"; \
|
||||
fi
|
||||
|
||||
ios-format-fix:
|
||||
@if command -v swiftformat >/dev/null 2>&1; then \
|
||||
cd ios && swiftformat .; \
|
||||
else \
|
||||
echo "SwiftFormat not installed. Install with: brew install swiftformat"; \
|
||||
fi
|
||||
|
||||
ios-build:
|
||||
cd ios && xcodebuild -project Ascently.xcodeproj -scheme Ascently -configuration Debug build
|
||||
|
||||
# Combined commands
|
||||
lint: android-lint ios-lint
|
||||
|
||||
format: android-format ios-format
|
||||
|
||||
# Clean
|
||||
clean:
|
||||
cd android && ./gradlew clean
|
||||
rm -rf ios/build ios/DerivedData
|
||||
31
android/.editorconfig
Normal file
@@ -0,0 +1,31 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.{kt,kts}]
|
||||
indent_size = 4
|
||||
max_line_length = 220
|
||||
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
|
||||
ktlint_standard_no-wildcard-imports = disabled
|
||||
ktlint_standard_package-name = disabled
|
||||
|
||||
[*.{xml,gradle}]
|
||||
indent_size = 4
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.properties]
|
||||
indent_size = 2
|
||||
|
||||
[*.toml]
|
||||
indent_size = 4
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
@@ -6,6 +6,8 @@ plugins {
|
||||
alias(libs.plugins.kotlin.compose)
|
||||
alias(libs.plugins.kotlin.serialization)
|
||||
alias(libs.plugins.ksp)
|
||||
alias(libs.plugins.detekt)
|
||||
alias(libs.plugins.spotless)
|
||||
}
|
||||
|
||||
android {
|
||||
@@ -16,8 +18,8 @@ android {
|
||||
applicationId = "com.atridad.ascently"
|
||||
minSdk = 31
|
||||
targetSdk = 36
|
||||
versionCode = 48
|
||||
versionName = "2.4.0"
|
||||
versionCode = 50
|
||||
versionName = "2.5.0"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@@ -26,8 +28,8 @@ android {
|
||||
release {
|
||||
isMinifyEnabled = true
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro",
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -83,7 +85,7 @@ dependencies {
|
||||
implementation(libs.coil.compose)
|
||||
|
||||
// Health Connect
|
||||
implementation("androidx.health.connect:connect-client:1.1.0-alpha07")
|
||||
implementation(libs.health.connect)
|
||||
|
||||
// Testing
|
||||
testImplementation(libs.junit)
|
||||
@@ -99,6 +101,51 @@ dependencies {
|
||||
androidTestImplementation(libs.androidx.ui.test.junit4)
|
||||
debugImplementation(libs.androidx.ui.tooling)
|
||||
debugImplementation(libs.androidx.ui.test.manifest)
|
||||
debugImplementation(libs.androidx.ui.tooling)
|
||||
debugImplementation(libs.androidx.ui.test.manifest)
|
||||
}
|
||||
|
||||
// Detekt configuration
|
||||
detekt {
|
||||
config.setFrom(files("$rootDir/detekt.yml"))
|
||||
buildUponDefaultConfig = true
|
||||
allRules = false
|
||||
parallel = true
|
||||
}
|
||||
|
||||
// Spotless configuration for code formatting
|
||||
spotless {
|
||||
kotlin {
|
||||
target("**/*.kt")
|
||||
targetExclude("**/build/**/*.kt")
|
||||
ktlint("1.2.1")
|
||||
.editorConfigOverride(
|
||||
mapOf(
|
||||
"ktlint_standard_no-wildcard-imports" to "disabled",
|
||||
"ktlint_standard_package-name" to "disabled",
|
||||
"ktlint_standard_function-naming" to "disabled",
|
||||
"ktlint_standard_filename" to "disabled",
|
||||
"ktlint_standard_value-parameter-comment" to "disabled",
|
||||
"ktlint_standard_comment-wrapping" to "disabled",
|
||||
"ktlint_standard_multiline-expression-wrapping" to "disabled",
|
||||
"ktlint_standard_string-template-indent" to "disabled",
|
||||
"ktlint_standard_property-naming" to "disabled",
|
||||
"ktlint_standard_class-naming" to "disabled",
|
||||
"ktlint_standard_backing-property-naming" to "disabled",
|
||||
"ktlint_standard_function-signature" to "disabled",
|
||||
"ktlint_standard_parameter-list-wrapping" to "disabled",
|
||||
"ktlint_standard_max-line-length" to "disabled",
|
||||
"max_line_length" to "off",
|
||||
),
|
||||
)
|
||||
}
|
||||
kotlinGradle {
|
||||
target("**/*.kts")
|
||||
targetExclude("**/build/**/*.kts")
|
||||
ktlint("1.2.1")
|
||||
.editorConfigOverride(
|
||||
mapOf(
|
||||
"ktlint_standard_no-wildcard-imports" to "disabled",
|
||||
"max_line_length" to "off",
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
62
android/app/proguard-rules.pro
vendored
@@ -5,17 +5,61 @@
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Preserve line number information for debugging stack traces
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# Hide the original source file name
|
||||
-renamesourcefileattribute SourceFile
|
||||
|
||||
# Keep generic signatures for Kotlin
|
||||
-keepattributes Signature
|
||||
|
||||
# Keep annotations
|
||||
-keepattributes *Annotation*
|
||||
|
||||
# Room Database
|
||||
-keep class * extends androidx.room.RoomDatabase
|
||||
-keep @androidx.room.Entity class *
|
||||
-keepclassmembers class * {
|
||||
@androidx.room.* <fields>;
|
||||
@androidx.room.* <methods>;
|
||||
}
|
||||
|
||||
# Kotlinx Serialization
|
||||
-keepattributes *Annotation*, InnerClasses
|
||||
-dontnote kotlinx.serialization.AnnotationsKt
|
||||
|
||||
-keepclassmembers class kotlinx.serialization.json.** {
|
||||
*** Companion;
|
||||
}
|
||||
-keepclasseswithmembers class kotlinx.serialization.json.** {
|
||||
kotlinx.serialization.KSerializer serializer(...);
|
||||
}
|
||||
|
||||
-keep,includedescriptorclasses class com.atridad.ascently.**$$serializer { *; }
|
||||
-keepclassmembers class com.atridad.ascently.** {
|
||||
*** Companion;
|
||||
}
|
||||
-keepclasseswithmembers class com.atridad.ascently.** {
|
||||
kotlinx.serialization.KSerializer serializer(...);
|
||||
}
|
||||
|
||||
# Keep data classes used for serialization
|
||||
-keep class com.atridad.ascently.data.model.** { *; }
|
||||
-keep class com.atridad.ascently.data.format.** { *; }
|
||||
|
||||
# Coroutines
|
||||
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
|
||||
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
|
||||
-keepclassmembers class kotlinx.coroutines.** {
|
||||
volatile <fields>;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
#}
|
||||
@@ -37,9 +37,9 @@ class MainActivity : ComponentActivity() {
|
||||
AscentlyTheme {
|
||||
Surface(modifier = Modifier.fillMaxSize()) {
|
||||
AscentlyApp(
|
||||
shortcutAction = shortcutAction,
|
||||
lastUsedGymId = lastUsedGymId,
|
||||
onShortcutActionProcessed = { clearShortcutAction() }
|
||||
shortcutAction = shortcutAction,
|
||||
lastUsedGymId = lastUsedGymId,
|
||||
onShortcutActionProcessed = { clearShortcutAction() },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,75 +6,74 @@ import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
class Converters {
|
||||
|
||||
|
||||
@TypeConverter
|
||||
fun fromClimbTypeList(value: List<ClimbType>): String {
|
||||
return Json.encodeToString(value)
|
||||
}
|
||||
|
||||
|
||||
@TypeConverter
|
||||
fun toClimbTypeList(value: String): List<ClimbType> {
|
||||
return Json.decodeFromString(value)
|
||||
}
|
||||
|
||||
|
||||
@TypeConverter
|
||||
fun fromDifficultySystemList(value: List<DifficultySystem>): String {
|
||||
return Json.encodeToString(value)
|
||||
}
|
||||
|
||||
|
||||
@TypeConverter
|
||||
fun toDifficultySystemList(value: String): List<DifficultySystem> {
|
||||
return Json.decodeFromString(value)
|
||||
}
|
||||
|
||||
|
||||
@TypeConverter
|
||||
fun fromStringList(value: List<String>): String {
|
||||
return Json.encodeToString(value)
|
||||
}
|
||||
|
||||
|
||||
@TypeConverter
|
||||
fun toStringList(value: String): List<String> {
|
||||
return Json.decodeFromString(value)
|
||||
}
|
||||
|
||||
|
||||
@TypeConverter
|
||||
fun fromDifficultyGrade(value: DifficultyGrade): String {
|
||||
return Json.encodeToString(value)
|
||||
}
|
||||
|
||||
|
||||
@TypeConverter
|
||||
fun toDifficultyGrade(value: String): DifficultyGrade {
|
||||
return Json.decodeFromString(value)
|
||||
}
|
||||
|
||||
|
||||
@TypeConverter
|
||||
fun fromClimbType(value: ClimbType): String {
|
||||
return value.name
|
||||
}
|
||||
|
||||
|
||||
@TypeConverter
|
||||
fun toClimbType(value: String): ClimbType {
|
||||
return ClimbType.valueOf(value)
|
||||
}
|
||||
|
||||
|
||||
@TypeConverter
|
||||
fun fromAttemptResult(value: AttemptResult): String {
|
||||
return value.name
|
||||
}
|
||||
|
||||
|
||||
@TypeConverter
|
||||
fun toAttemptResult(value: String): AttemptResult {
|
||||
return AttemptResult.valueOf(value)
|
||||
}
|
||||
|
||||
|
||||
@TypeConverter
|
||||
fun fromSessionStatus(value: SessionStatus): String {
|
||||
return value.name
|
||||
}
|
||||
|
||||
|
||||
@TypeConverter
|
||||
fun toSessionStatus(value: String): SessionStatus {
|
||||
return SessionStatus.valueOf(value)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ import com.atridad.ascently.data.database.dao.*
|
||||
import com.atridad.ascently.data.model.*
|
||||
|
||||
@Database(
|
||||
entities = [Gym::class, Problem::class, ClimbSession::class, Attempt::class],
|
||||
version = 6,
|
||||
exportSchema = false
|
||||
entities = [Gym::class, Problem::class, ClimbSession::class, Attempt::class],
|
||||
version = 6,
|
||||
exportSchema = false,
|
||||
)
|
||||
@TypeConverters(Converters::class)
|
||||
abstract class AscentlyDatabase : RoomDatabase() {
|
||||
@@ -27,79 +27,79 @@ abstract class AscentlyDatabase : RoomDatabase() {
|
||||
@Volatile private var INSTANCE: AscentlyDatabase? = null
|
||||
|
||||
val MIGRATION_4_5 =
|
||||
object : Migration(4, 5) {
|
||||
override fun migrate(db: SupportSQLiteDatabase) {
|
||||
val cursor = db.query("PRAGMA table_info(climb_sessions)")
|
||||
val existingColumns = mutableSetOf<String>()
|
||||
object : Migration(4, 5) {
|
||||
override fun migrate(db: SupportSQLiteDatabase) {
|
||||
val cursor = db.query("PRAGMA table_info(climb_sessions)")
|
||||
val existingColumns = mutableSetOf<String>()
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
val columnName = cursor.getString(cursor.getColumnIndexOrThrow("name"))
|
||||
existingColumns.add(columnName)
|
||||
}
|
||||
cursor.close()
|
||||
|
||||
if (!existingColumns.contains("startTime")) {
|
||||
db.execSQL("ALTER TABLE climb_sessions ADD COLUMN startTime TEXT")
|
||||
}
|
||||
if (!existingColumns.contains("endTime")) {
|
||||
db.execSQL("ALTER TABLE climb_sessions ADD COLUMN endTime TEXT")
|
||||
}
|
||||
if (!existingColumns.contains("status")) {
|
||||
db.execSQL(
|
||||
"ALTER TABLE climb_sessions ADD COLUMN status TEXT NOT NULL DEFAULT 'COMPLETED'"
|
||||
)
|
||||
}
|
||||
while (cursor.moveToNext()) {
|
||||
val columnName = cursor.getString(cursor.getColumnIndexOrThrow("name"))
|
||||
existingColumns.add(columnName)
|
||||
}
|
||||
cursor.close()
|
||||
|
||||
if (!existingColumns.contains("startTime")) {
|
||||
db.execSQL("ALTER TABLE climb_sessions ADD COLUMN startTime TEXT")
|
||||
}
|
||||
if (!existingColumns.contains("endTime")) {
|
||||
db.execSQL("ALTER TABLE climb_sessions ADD COLUMN endTime TEXT")
|
||||
}
|
||||
if (!existingColumns.contains("status")) {
|
||||
db.execSQL(
|
||||
"UPDATE climb_sessions SET startTime = createdAt WHERE startTime IS NULL"
|
||||
)
|
||||
db.execSQL(
|
||||
"UPDATE climb_sessions SET status = 'COMPLETED' WHERE status IS NULL OR status = ''"
|
||||
"ALTER TABLE climb_sessions ADD COLUMN status TEXT NOT NULL DEFAULT 'COMPLETED'",
|
||||
)
|
||||
}
|
||||
|
||||
db.execSQL(
|
||||
"UPDATE climb_sessions SET startTime = createdAt WHERE startTime IS NULL",
|
||||
)
|
||||
db.execSQL(
|
||||
"UPDATE climb_sessions SET status = 'COMPLETED' WHERE status IS NULL OR status = ''",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val MIGRATION_5_6 =
|
||||
object : Migration(5, 6) {
|
||||
override fun migrate(db: SupportSQLiteDatabase) {
|
||||
// Add updatedAt column to attempts table
|
||||
val cursor = db.query("PRAGMA table_info(attempts)")
|
||||
val existingColumns = mutableSetOf<String>()
|
||||
object : Migration(5, 6) {
|
||||
override fun migrate(db: SupportSQLiteDatabase) {
|
||||
// Add updatedAt column to attempts table
|
||||
val cursor = db.query("PRAGMA table_info(attempts)")
|
||||
val existingColumns = mutableSetOf<String>()
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
val columnName = cursor.getString(cursor.getColumnIndexOrThrow("name"))
|
||||
existingColumns.add(columnName)
|
||||
}
|
||||
cursor.close()
|
||||
while (cursor.moveToNext()) {
|
||||
val columnName = cursor.getString(cursor.getColumnIndexOrThrow("name"))
|
||||
existingColumns.add(columnName)
|
||||
}
|
||||
cursor.close()
|
||||
|
||||
if (!existingColumns.contains("updatedAt")) {
|
||||
db.execSQL(
|
||||
"ALTER TABLE attempts ADD COLUMN updatedAt TEXT NOT NULL DEFAULT ''"
|
||||
)
|
||||
// Set updatedAt to createdAt for existing records
|
||||
db.execSQL(
|
||||
"UPDATE attempts SET updatedAt = createdAt WHERE updatedAt = ''"
|
||||
)
|
||||
}
|
||||
if (!existingColumns.contains("updatedAt")) {
|
||||
db.execSQL(
|
||||
"ALTER TABLE attempts ADD COLUMN updatedAt TEXT NOT NULL DEFAULT ''",
|
||||
)
|
||||
// Set updatedAt to createdAt for existing records
|
||||
db.execSQL(
|
||||
"UPDATE attempts SET updatedAt = createdAt WHERE updatedAt = ''",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getDatabase(context: Context): AscentlyDatabase {
|
||||
return INSTANCE
|
||||
?: synchronized(this) {
|
||||
val instance =
|
||||
Room.databaseBuilder(
|
||||
context.applicationContext,
|
||||
AscentlyDatabase::class.java,
|
||||
"ascently_database"
|
||||
)
|
||||
.addMigrations(MIGRATION_4_5, MIGRATION_5_6)
|
||||
.enableMultiInstanceInvalidation()
|
||||
.fallbackToDestructiveMigration(false)
|
||||
.build()
|
||||
INSTANCE = instance
|
||||
instance
|
||||
}
|
||||
?: synchronized(this) {
|
||||
val instance =
|
||||
Room.databaseBuilder(
|
||||
context.applicationContext,
|
||||
AscentlyDatabase::class.java,
|
||||
"ascently_database",
|
||||
)
|
||||
.addMigrations(MIGRATION_4_5, MIGRATION_5_6)
|
||||
.enableMultiInstanceInvalidation()
|
||||
.fallbackToDestructiveMigration(false)
|
||||
.build()
|
||||
INSTANCE = instance
|
||||
instance
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,70 +7,70 @@ import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface AttemptDao {
|
||||
|
||||
|
||||
@Query("SELECT * FROM attempts ORDER BY timestamp DESC")
|
||||
fun getAllAttempts(): Flow<List<Attempt>>
|
||||
|
||||
|
||||
@Query("SELECT * FROM attempts WHERE id = :id")
|
||||
suspend fun getAttemptById(id: String): Attempt?
|
||||
|
||||
|
||||
@Query("SELECT * FROM attempts WHERE sessionId = :sessionId ORDER BY timestamp ASC")
|
||||
fun getAttemptsBySession(sessionId: String): Flow<List<Attempt>>
|
||||
|
||||
|
||||
@Query("SELECT * FROM attempts WHERE problemId = :problemId ORDER BY timestamp DESC")
|
||||
fun getAttemptsByProblem(problemId: String): Flow<List<Attempt>>
|
||||
|
||||
|
||||
@Query("SELECT * FROM attempts WHERE sessionId = :sessionId AND problemId = :problemId ORDER BY timestamp ASC")
|
||||
fun getAttemptsBySessionAndProblem(sessionId: String, problemId: String): Flow<List<Attempt>>
|
||||
|
||||
|
||||
@Query("SELECT * FROM attempts WHERE result = :result ORDER BY timestamp DESC")
|
||||
fun getAttemptsByResult(result: AttemptResult): Flow<List<Attempt>>
|
||||
|
||||
|
||||
@Query("SELECT * FROM attempts WHERE timestamp BETWEEN :startDate AND :endDate ORDER BY timestamp DESC")
|
||||
fun getAttemptsInDateRange(startDate: String, endDate: String): Flow<List<Attempt>>
|
||||
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertAttempt(attempt: Attempt)
|
||||
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertAttempts(attempts: List<Attempt>)
|
||||
|
||||
|
||||
@Update
|
||||
suspend fun updateAttempt(attempt: Attempt)
|
||||
|
||||
|
||||
@Delete
|
||||
suspend fun deleteAttempt(attempt: Attempt)
|
||||
|
||||
|
||||
@Query("DELETE FROM attempts WHERE id = :id")
|
||||
suspend fun deleteAttemptById(id: String)
|
||||
|
||||
|
||||
@Query("DELETE FROM attempts WHERE sessionId = :sessionId")
|
||||
suspend fun deleteAttemptsBySession(sessionId: String)
|
||||
|
||||
|
||||
@Query("DELETE FROM attempts WHERE problemId = :problemId")
|
||||
suspend fun deleteAttemptsByProblem(problemId: String)
|
||||
|
||||
|
||||
@Query("SELECT COUNT(*) FROM attempts")
|
||||
suspend fun getAttemptsCount(): Int
|
||||
|
||||
|
||||
@Query("DELETE FROM attempts")
|
||||
suspend fun deleteAllAttempts()
|
||||
|
||||
|
||||
@Query("SELECT COUNT(*) FROM attempts WHERE sessionId = :sessionId")
|
||||
suspend fun getAttemptsCountBySession(sessionId: String): Int
|
||||
|
||||
|
||||
@Query("SELECT COUNT(*) FROM attempts WHERE problemId = :problemId")
|
||||
suspend fun getAttemptsCountByProblem(problemId: String): Int
|
||||
|
||||
|
||||
@Query("SELECT COUNT(*) FROM attempts WHERE result = :result")
|
||||
suspend fun getAttemptsCountByResult(result: AttemptResult): Int
|
||||
|
||||
|
||||
@Query("SELECT COUNT(*) FROM attempts WHERE problemId = :problemId AND result IN ('SUCCESS', 'FLASH', 'REDPOINT', 'ONSIGHT')")
|
||||
suspend fun getSuccessfulAttemptsCountByProblem(problemId: String): Int
|
||||
|
||||
|
||||
@Query("SELECT * FROM attempts WHERE problemId = :problemId AND result IN ('SUCCESS', 'FLASH', 'REDPOINT', 'ONSIGHT') ORDER BY timestamp ASC LIMIT 1")
|
||||
suspend fun getFirstSuccessfulAttempt(problemId: String): Attempt?
|
||||
|
||||
|
||||
@Query("SELECT * FROM attempts WHERE problemId = :problemId ORDER BY timestamp DESC LIMIT 1")
|
||||
suspend fun getLatestAttemptForProblem(problemId: String): Attempt?
|
||||
}
|
||||
|
||||
@@ -7,61 +7,61 @@ import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface ClimbSessionDao {
|
||||
|
||||
|
||||
@Query("SELECT * FROM climb_sessions ORDER BY date DESC")
|
||||
fun getAllSessions(): Flow<List<ClimbSession>>
|
||||
|
||||
|
||||
@Query("SELECT * FROM climb_sessions WHERE id = :id")
|
||||
suspend fun getSessionById(id: String): ClimbSession?
|
||||
|
||||
|
||||
@Query("SELECT * FROM climb_sessions WHERE gymId = :gymId ORDER BY date DESC")
|
||||
fun getSessionsByGym(gymId: String): Flow<List<ClimbSession>>
|
||||
|
||||
|
||||
@Query("SELECT * FROM climb_sessions WHERE date = :date ORDER BY createdAt DESC")
|
||||
fun getSessionsByDate(date: String): Flow<List<ClimbSession>>
|
||||
|
||||
|
||||
@Query("SELECT * FROM climb_sessions WHERE date BETWEEN :startDate AND :endDate ORDER BY date DESC")
|
||||
fun getSessionsInDateRange(startDate: String, endDate: String): Flow<List<ClimbSession>>
|
||||
|
||||
|
||||
@Query("SELECT * FROM climb_sessions ORDER BY date DESC LIMIT :limit")
|
||||
fun getRecentSessions(limit: Int = 10): Flow<List<ClimbSession>>
|
||||
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertSession(session: ClimbSession)
|
||||
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertSessions(sessions: List<ClimbSession>)
|
||||
|
||||
|
||||
@Update
|
||||
suspend fun updateSession(session: ClimbSession)
|
||||
|
||||
|
||||
@Delete
|
||||
suspend fun deleteSession(session: ClimbSession)
|
||||
|
||||
|
||||
@Query("DELETE FROM climb_sessions WHERE id = :id")
|
||||
suspend fun deleteSessionById(id: String)
|
||||
|
||||
|
||||
@Query("SELECT COUNT(*) FROM climb_sessions")
|
||||
suspend fun getSessionsCount(): Int
|
||||
|
||||
|
||||
@Query("SELECT COUNT(*) FROM climb_sessions WHERE gymId = :gymId")
|
||||
suspend fun getSessionsCountByGym(gymId: String): Int
|
||||
|
||||
|
||||
@Query("SELECT COUNT(*) FROM climb_sessions WHERE date BETWEEN :startDate AND :endDate")
|
||||
suspend fun getSessionsCountInDateRange(startDate: String, endDate: String): Int
|
||||
|
||||
|
||||
@Query("SELECT DISTINCT date FROM climb_sessions ORDER BY date DESC")
|
||||
suspend fun getUniqueDates(): List<String>
|
||||
|
||||
|
||||
@Query("SELECT * FROM climb_sessions WHERE status = :status ORDER BY date DESC")
|
||||
fun getSessionsByStatus(status: SessionStatus): Flow<List<ClimbSession>>
|
||||
|
||||
|
||||
@Query("SELECT * FROM climb_sessions WHERE status = 'ACTIVE' ORDER BY date DESC LIMIT 1")
|
||||
suspend fun getActiveSession(): ClimbSession?
|
||||
|
||||
|
||||
@Query("DELETE FROM climb_sessions")
|
||||
suspend fun deleteAllSessions()
|
||||
|
||||
|
||||
@Query("SELECT * FROM climb_sessions WHERE status = 'ACTIVE' ORDER BY date DESC LIMIT 1")
|
||||
fun getActiveSessionFlow(): Flow<ClimbSession?>
|
||||
}
|
||||
|
||||
@@ -7,37 +7,37 @@ import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface GymDao {
|
||||
|
||||
|
||||
@Query("SELECT * FROM gyms ORDER BY name ASC")
|
||||
fun getAllGyms(): Flow<List<Gym>>
|
||||
|
||||
|
||||
@Query("SELECT * FROM gyms WHERE id = :id")
|
||||
suspend fun getGymById(id: String): Gym?
|
||||
|
||||
|
||||
@Query("SELECT * FROM gyms WHERE :climbType IN (supportedClimbTypes)")
|
||||
fun getGymsByClimbType(climbType: ClimbType): Flow<List<Gym>>
|
||||
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertGym(gym: Gym)
|
||||
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertGyms(gyms: List<Gym>)
|
||||
|
||||
|
||||
@Update
|
||||
suspend fun updateGym(gym: Gym)
|
||||
|
||||
|
||||
@Delete
|
||||
suspend fun deleteGym(gym: Gym)
|
||||
|
||||
|
||||
@Query("DELETE FROM gyms WHERE id = :id")
|
||||
suspend fun deleteGymById(id: String)
|
||||
|
||||
|
||||
@Query("SELECT COUNT(*) FROM gyms")
|
||||
suspend fun getGymsCount(): Int
|
||||
|
||||
|
||||
@Query("SELECT * FROM gyms WHERE name LIKE '%' || :searchQuery || '%' OR location LIKE '%' || :searchQuery || '%'")
|
||||
fun searchGyms(searchQuery: String): Flow<List<Gym>>
|
||||
|
||||
|
||||
@Query("DELETE FROM gyms")
|
||||
suspend fun deleteAllGyms()
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ interface ProblemDao {
|
||||
@Query("SELECT * FROM problems ORDER BY updatedAt DESC")
|
||||
fun getAllProblems(): Flow<List<Problem>>
|
||||
|
||||
@Query("SELECT * FROM problems WHERE id = :id") suspend fun getProblemById(id: String): Problem?
|
||||
@Query("SELECT * FROM problems WHERE id = :id")
|
||||
suspend fun getProblemById(id: String): Problem?
|
||||
|
||||
@Query("SELECT * FROM problems WHERE gymId = :gymId ORDER BY updatedAt DESC")
|
||||
fun getProblemsByGym(gymId: String): Flow<List<Problem>>
|
||||
@@ -20,7 +21,7 @@ interface ProblemDao {
|
||||
fun getProblemsByClimbType(climbType: ClimbType): Flow<List<Problem>>
|
||||
|
||||
@Query(
|
||||
"SELECT * FROM problems WHERE gymId = :gymId AND climbType = :climbType ORDER BY updatedAt DESC"
|
||||
"SELECT * FROM problems WHERE gymId = :gymId AND climbType = :climbType ORDER BY updatedAt DESC",
|
||||
)
|
||||
fun getProblemsByGymAndType(gymId: String, climbType: ClimbType): Flow<List<Problem>>
|
||||
|
||||
@@ -30,7 +31,8 @@ interface ProblemDao {
|
||||
@Query("SELECT * FROM problems WHERE gymId = :gymId AND isActive = 1 ORDER BY updatedAt DESC")
|
||||
fun getActiveProblemsByGym(gymId: String): Flow<List<Problem>>
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertProblem(problem: Problem)
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertProblem(problem: Problem)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertProblems(problems: List<Problem>)
|
||||
@@ -39,7 +41,8 @@ interface ProblemDao {
|
||||
|
||||
@Delete suspend fun deleteProblem(problem: Problem)
|
||||
|
||||
@Query("DELETE FROM problems WHERE id = :id") suspend fun deleteProblemById(id: String)
|
||||
@Query("DELETE FROM problems WHERE id = :id")
|
||||
suspend fun deleteProblemById(id: String)
|
||||
|
||||
@Query("SELECT COUNT(*) FROM problems WHERE gymId = :gymId")
|
||||
suspend fun getProblemsCountByGym(gymId: String): Int
|
||||
@@ -48,17 +51,19 @@ interface ProblemDao {
|
||||
suspend fun getActiveProblemsCount(): Int
|
||||
|
||||
@Query(
|
||||
"""
|
||||
"""
|
||||
SELECT * FROM problems
|
||||
WHERE (name LIKE '%' || :searchQuery || '%'
|
||||
OR description LIKE '%' || :searchQuery || '%'
|
||||
OR location LIKE '%' || :searchQuery || '%')
|
||||
ORDER BY updatedAt DESC
|
||||
"""
|
||||
""",
|
||||
)
|
||||
fun searchProblems(searchQuery: String): Flow<List<Problem>>
|
||||
|
||||
@Query("SELECT COUNT(*) FROM problems") suspend fun getProblemsCount(): Int
|
||||
@Query("SELECT COUNT(*) FROM problems")
|
||||
suspend fun getProblemsCount(): Int
|
||||
|
||||
@Query("DELETE FROM problems") suspend fun deleteAllProblems()
|
||||
@Query("DELETE FROM problems")
|
||||
suspend fun deleteAllProblems()
|
||||
}
|
||||
|
||||
@@ -6,64 +6,64 @@ import kotlinx.serialization.Serializable
|
||||
// Root structure for Ascently backup data
|
||||
@Serializable
|
||||
data class ClimbDataBackup(
|
||||
val exportedAt: String,
|
||||
val version: String = "2.0",
|
||||
val formatVersion: String = "2.0",
|
||||
val gyms: List<BackupGym>,
|
||||
val problems: List<BackupProblem>,
|
||||
val sessions: List<BackupClimbSession>,
|
||||
val attempts: List<BackupAttempt>,
|
||||
val deletedItems: List<DeletedItem> = emptyList()
|
||||
val exportedAt: String,
|
||||
val version: String = "2.0",
|
||||
val formatVersion: String = "2.0",
|
||||
val gyms: List<BackupGym>,
|
||||
val problems: List<BackupProblem>,
|
||||
val sessions: List<BackupClimbSession>,
|
||||
val attempts: List<BackupAttempt>,
|
||||
val deletedItems: List<DeletedItem> = emptyList(),
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class DeletedItem(
|
||||
val id: String,
|
||||
val type: String, // "gym", "problem", "session", "attempt"
|
||||
val deletedAt: String
|
||||
val id: String,
|
||||
val type: String, // "gym", "problem", "session", "attempt"
|
||||
val deletedAt: String,
|
||||
)
|
||||
|
||||
// Platform-neutral gym representation for backup/restore
|
||||
@Serializable
|
||||
data class BackupGym(
|
||||
val id: String,
|
||||
val name: String,
|
||||
val location: String? = null,
|
||||
val supportedClimbTypes: List<ClimbType>,
|
||||
val difficultySystems: List<DifficultySystem>,
|
||||
@kotlinx.serialization.SerialName("customDifficultyGrades")
|
||||
val customDifficultyGrades: List<String>? = null,
|
||||
val notes: String? = null,
|
||||
val createdAt: String,
|
||||
val updatedAt: String
|
||||
val id: String,
|
||||
val name: String,
|
||||
val location: String? = null,
|
||||
val supportedClimbTypes: List<ClimbType>,
|
||||
val difficultySystems: List<DifficultySystem>,
|
||||
@kotlinx.serialization.SerialName("customDifficultyGrades")
|
||||
val customDifficultyGrades: List<String>? = null,
|
||||
val notes: String? = null,
|
||||
val createdAt: String,
|
||||
val updatedAt: String,
|
||||
) {
|
||||
companion object {
|
||||
fun fromGym(gym: Gym): BackupGym {
|
||||
return BackupGym(
|
||||
id = gym.id,
|
||||
name = gym.name,
|
||||
location = gym.location,
|
||||
supportedClimbTypes = gym.supportedClimbTypes,
|
||||
difficultySystems = gym.difficultySystems,
|
||||
customDifficultyGrades = gym.customDifficultyGrades.ifEmpty { null },
|
||||
notes = gym.notes,
|
||||
createdAt = gym.createdAt,
|
||||
updatedAt = gym.updatedAt
|
||||
id = gym.id,
|
||||
name = gym.name,
|
||||
location = gym.location,
|
||||
supportedClimbTypes = gym.supportedClimbTypes,
|
||||
difficultySystems = gym.difficultySystems,
|
||||
customDifficultyGrades = gym.customDifficultyGrades.ifEmpty { null },
|
||||
notes = gym.notes,
|
||||
createdAt = gym.createdAt,
|
||||
updatedAt = gym.updatedAt,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun toGym(): Gym {
|
||||
return Gym(
|
||||
id = id,
|
||||
name = name,
|
||||
location = location,
|
||||
supportedClimbTypes = supportedClimbTypes,
|
||||
difficultySystems = difficultySystems,
|
||||
customDifficultyGrades = customDifficultyGrades ?: emptyList(),
|
||||
notes = notes,
|
||||
createdAt = createdAt,
|
||||
updatedAt = updatedAt
|
||||
id = id,
|
||||
name = name,
|
||||
location = location,
|
||||
supportedClimbTypes = supportedClimbTypes,
|
||||
difficultySystems = difficultySystems,
|
||||
customDifficultyGrades = customDifficultyGrades ?: emptyList(),
|
||||
notes = notes,
|
||||
createdAt = createdAt,
|
||||
updatedAt = updatedAt,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -71,60 +71,63 @@ data class BackupGym(
|
||||
// Platform-neutral problem representation for backup/restore
|
||||
@Serializable
|
||||
data class BackupProblem(
|
||||
val id: String,
|
||||
val gymId: String,
|
||||
val name: String? = null,
|
||||
val description: String? = null,
|
||||
val climbType: ClimbType,
|
||||
val difficulty: DifficultyGrade,
|
||||
val tags: List<String>? = null,
|
||||
val location: String? = null,
|
||||
val imagePaths: List<String>? = null,
|
||||
val isActive: Boolean = true,
|
||||
val dateSet: String? = null,
|
||||
val notes: String? = null,
|
||||
val createdAt: String,
|
||||
val updatedAt: String
|
||||
val id: String,
|
||||
val gymId: String,
|
||||
val name: String? = null,
|
||||
val description: String? = null,
|
||||
val climbType: ClimbType,
|
||||
val difficulty: DifficultyGrade,
|
||||
val tags: List<String>? = null,
|
||||
val location: String? = null,
|
||||
val imagePaths: List<String>? = null,
|
||||
val isActive: Boolean = true,
|
||||
val dateSet: String? = null,
|
||||
val notes: String? = null,
|
||||
val createdAt: String,
|
||||
val updatedAt: String,
|
||||
) {
|
||||
companion object {
|
||||
fun fromProblem(problem: Problem): BackupProblem {
|
||||
return BackupProblem(
|
||||
id = problem.id,
|
||||
gymId = problem.gymId,
|
||||
name = problem.name,
|
||||
description = problem.description,
|
||||
climbType = problem.climbType,
|
||||
difficulty = problem.difficulty,
|
||||
tags = problem.tags,
|
||||
location = problem.location,
|
||||
imagePaths =
|
||||
if (problem.imagePaths.isEmpty()) null
|
||||
else problem.imagePaths.map { path -> path.substringAfterLast('/') },
|
||||
isActive = problem.isActive,
|
||||
dateSet = problem.dateSet,
|
||||
notes = problem.notes,
|
||||
createdAt = problem.createdAt,
|
||||
updatedAt = problem.updatedAt
|
||||
id = problem.id,
|
||||
gymId = problem.gymId,
|
||||
name = problem.name,
|
||||
description = problem.description,
|
||||
climbType = problem.climbType,
|
||||
difficulty = problem.difficulty,
|
||||
tags = problem.tags,
|
||||
location = problem.location,
|
||||
imagePaths =
|
||||
if (problem.imagePaths.isEmpty()) {
|
||||
null
|
||||
} else {
|
||||
problem.imagePaths.map { path -> path.substringAfterLast('/') }
|
||||
},
|
||||
isActive = problem.isActive,
|
||||
dateSet = problem.dateSet,
|
||||
notes = problem.notes,
|
||||
createdAt = problem.createdAt,
|
||||
updatedAt = problem.updatedAt,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun toProblem(): Problem {
|
||||
return Problem(
|
||||
id = id,
|
||||
gymId = gymId,
|
||||
name = name,
|
||||
description = description,
|
||||
climbType = climbType,
|
||||
difficulty = difficulty,
|
||||
tags = tags ?: emptyList(),
|
||||
location = location,
|
||||
imagePaths = imagePaths ?: emptyList(),
|
||||
isActive = isActive,
|
||||
dateSet = dateSet,
|
||||
notes = notes,
|
||||
createdAt = createdAt,
|
||||
updatedAt = updatedAt
|
||||
id = id,
|
||||
gymId = gymId,
|
||||
name = name,
|
||||
description = description,
|
||||
climbType = climbType,
|
||||
difficulty = difficulty,
|
||||
tags = tags ?: emptyList(),
|
||||
location = location,
|
||||
imagePaths = imagePaths ?: emptyList(),
|
||||
isActive = isActive,
|
||||
dateSet = dateSet,
|
||||
notes = notes,
|
||||
createdAt = createdAt,
|
||||
updatedAt = updatedAt,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -136,46 +139,46 @@ data class BackupProblem(
|
||||
// Platform-neutral climb session representation for backup/restore
|
||||
@Serializable
|
||||
data class BackupClimbSession(
|
||||
val id: String,
|
||||
val gymId: String,
|
||||
val date: String,
|
||||
val startTime: String? = null,
|
||||
val endTime: String? = null,
|
||||
val duration: Long? = null,
|
||||
val status: SessionStatus,
|
||||
val notes: String? = null,
|
||||
val createdAt: String,
|
||||
val updatedAt: String
|
||||
val id: String,
|
||||
val gymId: String,
|
||||
val date: String,
|
||||
val startTime: String? = null,
|
||||
val endTime: String? = null,
|
||||
val duration: Long? = null,
|
||||
val status: SessionStatus,
|
||||
val notes: String? = null,
|
||||
val createdAt: String,
|
||||
val updatedAt: String,
|
||||
) {
|
||||
companion object {
|
||||
fun fromClimbSession(session: ClimbSession): BackupClimbSession {
|
||||
return BackupClimbSession(
|
||||
id = session.id,
|
||||
gymId = session.gymId,
|
||||
date = session.date,
|
||||
startTime = session.startTime,
|
||||
endTime = session.endTime,
|
||||
duration = session.duration,
|
||||
status = session.status,
|
||||
notes = session.notes,
|
||||
createdAt = session.createdAt,
|
||||
updatedAt = session.updatedAt
|
||||
id = session.id,
|
||||
gymId = session.gymId,
|
||||
date = session.date,
|
||||
startTime = session.startTime,
|
||||
endTime = session.endTime,
|
||||
duration = session.duration,
|
||||
status = session.status,
|
||||
notes = session.notes,
|
||||
createdAt = session.createdAt,
|
||||
updatedAt = session.updatedAt,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun toClimbSession(): ClimbSession {
|
||||
return ClimbSession(
|
||||
id = id,
|
||||
gymId = gymId,
|
||||
date = date,
|
||||
startTime = startTime,
|
||||
endTime = endTime,
|
||||
duration = duration,
|
||||
status = status,
|
||||
notes = notes,
|
||||
createdAt = createdAt,
|
||||
updatedAt = updatedAt
|
||||
id = id,
|
||||
gymId = gymId,
|
||||
date = date,
|
||||
startTime = startTime,
|
||||
endTime = endTime,
|
||||
duration = duration,
|
||||
status = status,
|
||||
notes = notes,
|
||||
createdAt = createdAt,
|
||||
updatedAt = updatedAt,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -183,49 +186,49 @@ data class BackupClimbSession(
|
||||
// Platform-neutral attempt representation for backup/restore
|
||||
@Serializable
|
||||
data class BackupAttempt(
|
||||
val id: String,
|
||||
val sessionId: String,
|
||||
val problemId: String,
|
||||
val result: AttemptResult,
|
||||
val highestHold: String? = null,
|
||||
val notes: String? = null,
|
||||
val duration: Long? = null,
|
||||
val restTime: Long? = null,
|
||||
val timestamp: String,
|
||||
val createdAt: String,
|
||||
val updatedAt: String? = null
|
||||
val id: String,
|
||||
val sessionId: String,
|
||||
val problemId: String,
|
||||
val result: AttemptResult,
|
||||
val highestHold: String? = null,
|
||||
val notes: String? = null,
|
||||
val duration: Long? = null,
|
||||
val restTime: Long? = null,
|
||||
val timestamp: String,
|
||||
val createdAt: String,
|
||||
val updatedAt: String? = null,
|
||||
) {
|
||||
companion object {
|
||||
fun fromAttempt(attempt: Attempt): BackupAttempt {
|
||||
return BackupAttempt(
|
||||
id = attempt.id,
|
||||
sessionId = attempt.sessionId,
|
||||
problemId = attempt.problemId,
|
||||
result = attempt.result,
|
||||
highestHold = attempt.highestHold,
|
||||
notes = attempt.notes,
|
||||
duration = attempt.duration,
|
||||
restTime = attempt.restTime,
|
||||
timestamp = attempt.timestamp,
|
||||
createdAt = attempt.createdAt,
|
||||
updatedAt = attempt.updatedAt
|
||||
id = attempt.id,
|
||||
sessionId = attempt.sessionId,
|
||||
problemId = attempt.problemId,
|
||||
result = attempt.result,
|
||||
highestHold = attempt.highestHold,
|
||||
notes = attempt.notes,
|
||||
duration = attempt.duration,
|
||||
restTime = attempt.restTime,
|
||||
timestamp = attempt.timestamp,
|
||||
createdAt = attempt.createdAt,
|
||||
updatedAt = attempt.updatedAt,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun toAttempt(): Attempt {
|
||||
return Attempt(
|
||||
id = id,
|
||||
sessionId = sessionId,
|
||||
problemId = problemId,
|
||||
result = result,
|
||||
highestHold = highestHold,
|
||||
notes = notes,
|
||||
duration = duration,
|
||||
restTime = restTime,
|
||||
timestamp = timestamp,
|
||||
createdAt = createdAt,
|
||||
updatedAt = updatedAt ?: createdAt
|
||||
id = id,
|
||||
sessionId = sessionId,
|
||||
problemId = problemId,
|
||||
result = result,
|
||||
highestHold = highestHold,
|
||||
notes = notes,
|
||||
duration = duration,
|
||||
restTime = restTime,
|
||||
timestamp = timestamp,
|
||||
createdAt = createdAt,
|
||||
updatedAt = updatedAt ?: createdAt,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.atridad.ascently.data.health
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import com.atridad.ascently.utils.AppLogger
|
||||
import androidx.activity.result.contract.ActivityResultContract
|
||||
import androidx.health.connect.client.HealthConnectClient
|
||||
import androidx.health.connect.client.PermissionController
|
||||
@@ -11,17 +10,20 @@ import androidx.health.connect.client.permission.HealthPermission
|
||||
import androidx.health.connect.client.records.ExerciseSessionRecord
|
||||
import androidx.health.connect.client.records.HeartRateRecord
|
||||
import androidx.health.connect.client.records.TotalCaloriesBurnedRecord
|
||||
|
||||
import androidx.health.connect.client.units.Energy
|
||||
import com.atridad.ascently.data.model.ClimbSession
|
||||
import com.atridad.ascently.data.model.SessionStatus
|
||||
import com.atridad.ascently.utils.AppLogger
|
||||
import com.atridad.ascently.utils.DateFormatUtils
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
import java.time.ZoneOffset
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
import java.time.ZoneOffset
|
||||
import androidx.core.content.edit
|
||||
|
||||
/**
|
||||
* Health Connect manager for Ascently that syncs climbing sessions to Samsung Health, Google Fit,
|
||||
@@ -52,7 +54,7 @@ class HealthConnectManager(private val context: Context) {
|
||||
HealthPermission.getReadPermission(HeartRateRecord::class),
|
||||
HealthPermission.getWritePermission(HeartRateRecord::class),
|
||||
HealthPermission.getReadPermission(TotalCaloriesBurnedRecord::class),
|
||||
HealthPermission.getWritePermission(TotalCaloriesBurnedRecord::class)
|
||||
HealthPermission.getWritePermission(TotalCaloriesBurnedRecord::class),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -127,8 +129,9 @@ class HealthConnectManager(private val context: Context) {
|
||||
|
||||
suspend fun isReady(): Boolean {
|
||||
return try {
|
||||
if (!_isEnabled.value || !_isCompatible.value || healthConnectClient == null)
|
||||
if (!_isEnabled.value || !_isCompatible.value || healthConnectClient == null) {
|
||||
return false
|
||||
}
|
||||
|
||||
val isAvailable =
|
||||
HealthConnectClient.getSdkStatus(context) == HealthConnectClient.SDK_AVAILABLE
|
||||
@@ -157,18 +160,18 @@ class HealthConnectManager(private val context: Context) {
|
||||
suspend fun syncCompletedSession(
|
||||
session: ClimbSession,
|
||||
gymName: String,
|
||||
attemptCount: Int = 0
|
||||
attemptCount: Int = 0,
|
||||
): Result<Unit> {
|
||||
return try {
|
||||
if (!isReady() || !_autoSync.value) {
|
||||
return Result.failure(
|
||||
IllegalStateException("Health Connect not ready or auto-sync disabled")
|
||||
IllegalStateException("Health Connect not ready or auto-sync disabled"),
|
||||
)
|
||||
}
|
||||
|
||||
if (session.status != SessionStatus.COMPLETED) {
|
||||
return Result.failure(
|
||||
IllegalArgumentException("Only completed sessions can be synced")
|
||||
IllegalArgumentException("Only completed sessions can be synced"),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -177,7 +180,7 @@ class HealthConnectManager(private val context: Context) {
|
||||
|
||||
if (startTime == null || endTime == null) {
|
||||
return Result.failure(
|
||||
IllegalArgumentException("Session must have valid start and end times")
|
||||
IllegalArgumentException("Session must have valid start and end times"),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -190,12 +193,13 @@ class HealthConnectManager(private val context: Context) {
|
||||
ExerciseSessionRecord(
|
||||
startTime = startTime,
|
||||
startZoneOffset =
|
||||
ZoneOffset.systemDefault().rules.getOffset(startTime),
|
||||
ZoneOffset.systemDefault().rules.getOffset(startTime),
|
||||
endTime = endTime,
|
||||
endZoneOffset = ZoneOffset.systemDefault().rules.getOffset(endTime),
|
||||
exerciseType =
|
||||
ExerciseSessionRecord.EXERCISE_TYPE_STRENGTH_TRAINING,
|
||||
title = "Rock Climbing at $gymName"
|
||||
ExerciseSessionRecord.EXERCISE_TYPE_STRENGTH_TRAINING,
|
||||
title = "Rock Climbing at $gymName",
|
||||
metadata = androidx.health.connect.client.records.metadata.Metadata.manualEntry(),
|
||||
)
|
||||
records.add(exerciseSession)
|
||||
} catch (e: Exception) {
|
||||
@@ -211,11 +215,12 @@ class HealthConnectManager(private val context: Context) {
|
||||
TotalCaloriesBurnedRecord(
|
||||
startTime = startTime,
|
||||
startZoneOffset =
|
||||
ZoneOffset.systemDefault().rules.getOffset(startTime),
|
||||
ZoneOffset.systemDefault().rules.getOffset(startTime),
|
||||
endTime = endTime,
|
||||
endZoneOffset =
|
||||
ZoneOffset.systemDefault().rules.getOffset(endTime),
|
||||
energy = Energy.calories(estimatedCalories)
|
||||
ZoneOffset.systemDefault().rules.getOffset(endTime),
|
||||
energy = Energy.calories(estimatedCalories),
|
||||
metadata = androidx.health.connect.client.records.metadata.Metadata.manualEntry(),
|
||||
)
|
||||
records.add(caloriesRecord)
|
||||
}
|
||||
@@ -238,9 +243,9 @@ class HealthConnectManager(private val context: Context) {
|
||||
}
|
||||
|
||||
preferences
|
||||
.edit()
|
||||
.putString("last_sync_success", DateFormatUtils.nowISO8601())
|
||||
.apply()
|
||||
.edit {
|
||||
putString("last_sync_success", DateFormatUtils.nowISO8601())
|
||||
}
|
||||
} else {
|
||||
val reason =
|
||||
when {
|
||||
@@ -262,7 +267,7 @@ class HealthConnectManager(private val context: Context) {
|
||||
suspend fun autoSyncCompletedSession(
|
||||
session: ClimbSession,
|
||||
gymName: String,
|
||||
attemptCount: Int = 0
|
||||
attemptCount: Int = 0,
|
||||
): Result<Unit> {
|
||||
return if (_autoSync.value && isReady() && session.status == SessionStatus.COMPLETED) {
|
||||
AppLogger.d(TAG) { "Auto-syncing completed session '${session.id}' to Health Connect..." }
|
||||
@@ -295,7 +300,7 @@ class HealthConnectManager(private val context: Context) {
|
||||
private fun createHeartRateRecord(
|
||||
startTime: Instant,
|
||||
endTime: Instant,
|
||||
attemptCount: Int
|
||||
attemptCount: Int,
|
||||
): HeartRateRecord? {
|
||||
return try {
|
||||
val samples = mutableListOf<HeartRateRecord.Sample>()
|
||||
@@ -324,7 +329,8 @@ class HealthConnectManager(private val context: Context) {
|
||||
startZoneOffset = ZoneOffset.systemDefault().rules.getOffset(startTime),
|
||||
endTime = endTime,
|
||||
endZoneOffset = ZoneOffset.systemDefault().rules.getOffset(endTime),
|
||||
samples = samples
|
||||
samples = samples,
|
||||
metadata = androidx.health.connect.client.records.metadata.Metadata.manualEntry(),
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
AppLogger.e(TAG, e) { "Error creating heart rate record" }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.atridad.ascently.data.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
@@ -12,65 +13,67 @@ enum class AttemptResult {
|
||||
SUCCESS,
|
||||
FALL,
|
||||
NO_PROGRESS,
|
||||
FLASH
|
||||
FLASH,
|
||||
}
|
||||
|
||||
@Entity(
|
||||
tableName = "attempts",
|
||||
foreignKeys =
|
||||
[
|
||||
ForeignKey(
|
||||
entity = ClimbSession::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["sessionId"],
|
||||
onDelete = ForeignKey.CASCADE
|
||||
),
|
||||
ForeignKey(
|
||||
entity = Problem::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["problemId"],
|
||||
onDelete = ForeignKey.CASCADE
|
||||
)],
|
||||
indices = [Index(value = ["sessionId"]), Index(value = ["problemId"])]
|
||||
tableName = "attempts",
|
||||
foreignKeys =
|
||||
[
|
||||
ForeignKey(
|
||||
entity = ClimbSession::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["sessionId"],
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
),
|
||||
ForeignKey(
|
||||
entity = Problem::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["problemId"],
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
),
|
||||
],
|
||||
indices = [Index(value = ["sessionId"]), Index(value = ["problemId"])],
|
||||
)
|
||||
@Immutable
|
||||
@Serializable
|
||||
data class Attempt(
|
||||
@PrimaryKey val id: String,
|
||||
val sessionId: String,
|
||||
val problemId: String,
|
||||
val result: AttemptResult,
|
||||
val highestHold: String? = null,
|
||||
val notes: String? = null,
|
||||
val duration: Long? = null,
|
||||
val restTime: Long? = null,
|
||||
val timestamp: String,
|
||||
val createdAt: String,
|
||||
val updatedAt: String
|
||||
@PrimaryKey val id: String,
|
||||
val sessionId: String,
|
||||
val problemId: String,
|
||||
val result: AttemptResult,
|
||||
val highestHold: String? = null,
|
||||
val notes: String? = null,
|
||||
val duration: Long? = null,
|
||||
val restTime: Long? = null,
|
||||
val timestamp: String,
|
||||
val createdAt: String,
|
||||
val updatedAt: String,
|
||||
) {
|
||||
companion object {
|
||||
fun create(
|
||||
sessionId: String,
|
||||
problemId: String,
|
||||
result: AttemptResult,
|
||||
highestHold: String? = null,
|
||||
notes: String? = null,
|
||||
duration: Long? = null,
|
||||
restTime: Long? = null,
|
||||
timestamp: String = DateFormatUtils.nowISO8601()
|
||||
sessionId: String,
|
||||
problemId: String,
|
||||
result: AttemptResult,
|
||||
highestHold: String? = null,
|
||||
notes: String? = null,
|
||||
duration: Long? = null,
|
||||
restTime: Long? = null,
|
||||
timestamp: String = DateFormatUtils.nowISO8601(),
|
||||
): Attempt {
|
||||
val now = DateFormatUtils.nowISO8601()
|
||||
return Attempt(
|
||||
id = java.util.UUID.randomUUID().toString(),
|
||||
sessionId = sessionId,
|
||||
problemId = problemId,
|
||||
result = result,
|
||||
highestHold = highestHold,
|
||||
notes = notes,
|
||||
duration = duration,
|
||||
restTime = restTime,
|
||||
timestamp = timestamp,
|
||||
createdAt = now,
|
||||
updatedAt = now
|
||||
id = java.util.UUID.randomUUID().toString(),
|
||||
sessionId = sessionId,
|
||||
problemId = problemId,
|
||||
result = result,
|
||||
highestHold = highestHold,
|
||||
notes = notes,
|
||||
duration = duration,
|
||||
restTime = restTime,
|
||||
timestamp = timestamp,
|
||||
createdAt = now,
|
||||
updatedAt = now,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.atridad.ascently.data.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
@@ -11,69 +12,75 @@ import kotlinx.serialization.Serializable
|
||||
enum class SessionStatus {
|
||||
ACTIVE,
|
||||
COMPLETED,
|
||||
PAUSED
|
||||
PAUSED,
|
||||
}
|
||||
|
||||
@Entity(
|
||||
tableName = "climb_sessions",
|
||||
foreignKeys =
|
||||
[
|
||||
ForeignKey(
|
||||
entity = Gym::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["gymId"],
|
||||
onDelete = ForeignKey.CASCADE
|
||||
)],
|
||||
indices = [Index(value = ["gymId"])]
|
||||
tableName = "climb_sessions",
|
||||
foreignKeys =
|
||||
[
|
||||
ForeignKey(
|
||||
entity = Gym::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["gymId"],
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
),
|
||||
],
|
||||
indices = [Index(value = ["gymId"])],
|
||||
)
|
||||
@Immutable
|
||||
@Serializable
|
||||
data class ClimbSession(
|
||||
@PrimaryKey val id: String,
|
||||
val gymId: String,
|
||||
val date: String,
|
||||
val startTime: String? = null,
|
||||
val endTime: String? = null,
|
||||
val duration: Long? = null,
|
||||
val status: SessionStatus = SessionStatus.ACTIVE,
|
||||
val notes: String? = null,
|
||||
val createdAt: String,
|
||||
val updatedAt: String
|
||||
@PrimaryKey val id: String,
|
||||
val gymId: String,
|
||||
val date: String,
|
||||
val startTime: String? = null,
|
||||
val endTime: String? = null,
|
||||
val duration: Long? = null,
|
||||
val status: SessionStatus = SessionStatus.ACTIVE,
|
||||
val notes: String? = null,
|
||||
val createdAt: String,
|
||||
val updatedAt: String,
|
||||
) {
|
||||
companion object {
|
||||
fun create(gymId: String, notes: String? = null): ClimbSession {
|
||||
val now = DateFormatUtils.nowISO8601()
|
||||
return ClimbSession(
|
||||
id = java.util.UUID.randomUUID().toString(),
|
||||
gymId = gymId,
|
||||
date = now,
|
||||
startTime = now,
|
||||
status = SessionStatus.ACTIVE,
|
||||
notes = notes,
|
||||
createdAt = now,
|
||||
updatedAt = now
|
||||
id = java.util.UUID.randomUUID().toString(),
|
||||
gymId = gymId,
|
||||
date = now,
|
||||
startTime = now,
|
||||
status = SessionStatus.ACTIVE,
|
||||
notes = notes,
|
||||
createdAt = now,
|
||||
updatedAt = now,
|
||||
)
|
||||
}
|
||||
|
||||
fun ClimbSession.complete(): ClimbSession {
|
||||
val endTime = DateFormatUtils.nowISO8601()
|
||||
val durationMinutes =
|
||||
if (startTime != null) {
|
||||
try {
|
||||
val start = DateFormatUtils.parseISO8601(startTime)
|
||||
val end = DateFormatUtils.parseISO8601(endTime)
|
||||
if (start != null && end != null) {
|
||||
java.time.Duration.between(start, end).toMinutes()
|
||||
} else null
|
||||
} catch (_: Exception) {
|
||||
if (startTime != null) {
|
||||
try {
|
||||
val start = DateFormatUtils.parseISO8601(startTime)
|
||||
val end = DateFormatUtils.parseISO8601(endTime)
|
||||
if (start != null && end != null) {
|
||||
java.time.Duration.between(start, end).toMinutes()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} else null
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
return this.copy(
|
||||
endTime = endTime,
|
||||
duration = durationMinutes,
|
||||
status = SessionStatus.COMPLETED,
|
||||
updatedAt = DateFormatUtils.nowISO8601()
|
||||
endTime = endTime,
|
||||
duration = durationMinutes,
|
||||
status = SessionStatus.COMPLETED,
|
||||
updatedAt = DateFormatUtils.nowISO8601(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,13 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
enum class ClimbType {
|
||||
ROPE,
|
||||
BOULDER;
|
||||
BOULDER,
|
||||
;
|
||||
|
||||
val displayName: String
|
||||
get() =
|
||||
when (this) {
|
||||
ROPE -> "Rope"
|
||||
BOULDER -> "Bouldering"
|
||||
}
|
||||
when (this) {
|
||||
ROPE -> "Rope"
|
||||
BOULDER -> "Bouldering"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,132 +10,133 @@ enum class DifficultySystem {
|
||||
|
||||
// Rope
|
||||
YDS,
|
||||
CUSTOM;
|
||||
CUSTOM,
|
||||
;
|
||||
|
||||
val displayName: String
|
||||
get() =
|
||||
when (this) {
|
||||
V_SCALE -> "V Scale"
|
||||
FONT -> "Font Scale"
|
||||
YDS -> "YDS (Yosemite)"
|
||||
CUSTOM -> "Custom"
|
||||
}
|
||||
when (this) {
|
||||
V_SCALE -> "V Scale"
|
||||
FONT -> "Font Scale"
|
||||
YDS -> "YDS (Yosemite)"
|
||||
CUSTOM -> "Custom"
|
||||
}
|
||||
|
||||
val isBoulderingSystem: Boolean
|
||||
get() =
|
||||
when (this) {
|
||||
V_SCALE, FONT -> true
|
||||
YDS -> false
|
||||
CUSTOM -> true
|
||||
}
|
||||
when (this) {
|
||||
V_SCALE, FONT -> true
|
||||
YDS -> false
|
||||
CUSTOM -> true
|
||||
}
|
||||
|
||||
val isRopeSystem: Boolean
|
||||
get() =
|
||||
when (this) {
|
||||
YDS -> true
|
||||
V_SCALE, FONT -> false
|
||||
CUSTOM -> true
|
||||
}
|
||||
when (this) {
|
||||
YDS -> true
|
||||
V_SCALE, FONT -> false
|
||||
CUSTOM -> true
|
||||
}
|
||||
|
||||
val availableGrades: List<String>
|
||||
get() =
|
||||
when (this) {
|
||||
V_SCALE ->
|
||||
listOf(
|
||||
"VB",
|
||||
"V0",
|
||||
"V1",
|
||||
"V2",
|
||||
"V3",
|
||||
"V4",
|
||||
"V5",
|
||||
"V6",
|
||||
"V7",
|
||||
"V8",
|
||||
"V9",
|
||||
"V10",
|
||||
"V11",
|
||||
"V12",
|
||||
"V13",
|
||||
"V14",
|
||||
"V15",
|
||||
"V16",
|
||||
"V17"
|
||||
)
|
||||
FONT ->
|
||||
listOf(
|
||||
"3",
|
||||
"4A",
|
||||
"4B",
|
||||
"4C",
|
||||
"5A",
|
||||
"5B",
|
||||
"5C",
|
||||
"6A",
|
||||
"6A+",
|
||||
"6B",
|
||||
"6B+",
|
||||
"6C",
|
||||
"6C+",
|
||||
"7A",
|
||||
"7A+",
|
||||
"7B",
|
||||
"7B+",
|
||||
"7C",
|
||||
"7C+",
|
||||
"8A",
|
||||
"8A+",
|
||||
"8B",
|
||||
"8B+",
|
||||
"8C",
|
||||
"8C+"
|
||||
)
|
||||
YDS ->
|
||||
listOf(
|
||||
"5.0",
|
||||
"5.1",
|
||||
"5.2",
|
||||
"5.3",
|
||||
"5.4",
|
||||
"5.5",
|
||||
"5.6",
|
||||
"5.7",
|
||||
"5.8",
|
||||
"5.9",
|
||||
"5.10a",
|
||||
"5.10b",
|
||||
"5.10c",
|
||||
"5.10d",
|
||||
"5.11a",
|
||||
"5.11b",
|
||||
"5.11c",
|
||||
"5.11d",
|
||||
"5.12a",
|
||||
"5.12b",
|
||||
"5.12c",
|
||||
"5.12d",
|
||||
"5.13a",
|
||||
"5.13b",
|
||||
"5.13c",
|
||||
"5.13d",
|
||||
"5.14a",
|
||||
"5.14b",
|
||||
"5.14c",
|
||||
"5.14d",
|
||||
"5.15a",
|
||||
"5.15b",
|
||||
"5.15c",
|
||||
"5.15d"
|
||||
)
|
||||
CUSTOM -> emptyList()
|
||||
}
|
||||
when (this) {
|
||||
V_SCALE ->
|
||||
listOf(
|
||||
"VB",
|
||||
"V0",
|
||||
"V1",
|
||||
"V2",
|
||||
"V3",
|
||||
"V4",
|
||||
"V5",
|
||||
"V6",
|
||||
"V7",
|
||||
"V8",
|
||||
"V9",
|
||||
"V10",
|
||||
"V11",
|
||||
"V12",
|
||||
"V13",
|
||||
"V14",
|
||||
"V15",
|
||||
"V16",
|
||||
"V17",
|
||||
)
|
||||
FONT ->
|
||||
listOf(
|
||||
"3",
|
||||
"4A",
|
||||
"4B",
|
||||
"4C",
|
||||
"5A",
|
||||
"5B",
|
||||
"5C",
|
||||
"6A",
|
||||
"6A+",
|
||||
"6B",
|
||||
"6B+",
|
||||
"6C",
|
||||
"6C+",
|
||||
"7A",
|
||||
"7A+",
|
||||
"7B",
|
||||
"7B+",
|
||||
"7C",
|
||||
"7C+",
|
||||
"8A",
|
||||
"8A+",
|
||||
"8B",
|
||||
"8B+",
|
||||
"8C",
|
||||
"8C+",
|
||||
)
|
||||
YDS ->
|
||||
listOf(
|
||||
"5.0",
|
||||
"5.1",
|
||||
"5.2",
|
||||
"5.3",
|
||||
"5.4",
|
||||
"5.5",
|
||||
"5.6",
|
||||
"5.7",
|
||||
"5.8",
|
||||
"5.9",
|
||||
"5.10a",
|
||||
"5.10b",
|
||||
"5.10c",
|
||||
"5.10d",
|
||||
"5.11a",
|
||||
"5.11b",
|
||||
"5.11c",
|
||||
"5.11d",
|
||||
"5.12a",
|
||||
"5.12b",
|
||||
"5.12c",
|
||||
"5.12d",
|
||||
"5.13a",
|
||||
"5.13b",
|
||||
"5.13c",
|
||||
"5.13d",
|
||||
"5.14a",
|
||||
"5.14b",
|
||||
"5.14c",
|
||||
"5.14d",
|
||||
"5.15a",
|
||||
"5.15b",
|
||||
"5.15c",
|
||||
"5.15d",
|
||||
)
|
||||
CUSTOM -> emptyList()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun systemsForClimbType(climbType: ClimbType): List<DifficultySystem> =
|
||||
when (climbType) {
|
||||
ClimbType.BOULDER -> entries.filter { it.isBoulderingSystem }
|
||||
ClimbType.ROPE -> entries.filter { it.isRopeSystem }
|
||||
}
|
||||
when (climbType) {
|
||||
ClimbType.BOULDER -> entries.filter { it.isBoulderingSystem }
|
||||
ClimbType.ROPE -> entries.filter { it.isRopeSystem }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,8 +144,8 @@ enum class DifficultySystem {
|
||||
data class DifficultyGrade(val system: DifficultySystem, val grade: String, val numericValue: Int) {
|
||||
|
||||
constructor(
|
||||
system: DifficultySystem,
|
||||
grade: String
|
||||
system: DifficultySystem,
|
||||
grade: String,
|
||||
) : this(system = system, grade = grade, numericValue = calculateNumericValue(system, grade))
|
||||
|
||||
companion object {
|
||||
@@ -155,79 +156,80 @@ data class DifficultyGrade(val system: DifficultySystem, val grade: String, val
|
||||
}
|
||||
DifficultySystem.FONT -> {
|
||||
val fontMapping: Map<String, Int> =
|
||||
mapOf(
|
||||
"3" to 3,
|
||||
"4A" to 4,
|
||||
"4B" to 5,
|
||||
"4C" to 6,
|
||||
"5A" to 7,
|
||||
"5B" to 8,
|
||||
"5C" to 9,
|
||||
"6A" to 10,
|
||||
"6A+" to 11,
|
||||
"6B" to 12,
|
||||
"6B+" to 13,
|
||||
"6C" to 14,
|
||||
"6C+" to 15,
|
||||
"7A" to 16,
|
||||
"7A+" to 17,
|
||||
"7B" to 18,
|
||||
"7B+" to 19,
|
||||
"7C" to 20,
|
||||
"7C+" to 21,
|
||||
"8A" to 22,
|
||||
"8A+" to 23,
|
||||
"8B" to 24,
|
||||
"8B+" to 25,
|
||||
"8C" to 26,
|
||||
"8C+" to 27
|
||||
)
|
||||
mapOf(
|
||||
"3" to 3,
|
||||
"4A" to 4,
|
||||
"4B" to 5,
|
||||
"4C" to 6,
|
||||
"5A" to 7,
|
||||
"5B" to 8,
|
||||
"5C" to 9,
|
||||
"6A" to 10,
|
||||
"6A+" to 11,
|
||||
"6B" to 12,
|
||||
"6B+" to 13,
|
||||
"6C" to 14,
|
||||
"6C+" to 15,
|
||||
"7A" to 16,
|
||||
"7A+" to 17,
|
||||
"7B" to 18,
|
||||
"7B+" to 19,
|
||||
"7C" to 20,
|
||||
"7C+" to 21,
|
||||
"8A" to 22,
|
||||
"8A+" to 23,
|
||||
"8B" to 24,
|
||||
"8B+" to 25,
|
||||
"8C" to 26,
|
||||
"8C+" to 27,
|
||||
)
|
||||
fontMapping[grade] ?: 0
|
||||
}
|
||||
DifficultySystem.YDS -> {
|
||||
val ydsMapping: Map<String, Int> =
|
||||
mapOf(
|
||||
"5.0" to 50,
|
||||
"5.1" to 51,
|
||||
"5.2" to 52,
|
||||
"5.3" to 53,
|
||||
"5.4" to 54,
|
||||
"5.5" to 55,
|
||||
"5.6" to 56,
|
||||
"5.7" to 57,
|
||||
"5.8" to 58,
|
||||
"5.9" to 59,
|
||||
"5.10a" to 60,
|
||||
"5.10b" to 61,
|
||||
"5.10c" to 62,
|
||||
"5.10d" to 63,
|
||||
"5.11a" to 64,
|
||||
"5.11b" to 65,
|
||||
"5.11c" to 66,
|
||||
"5.11d" to 67,
|
||||
"5.12a" to 68,
|
||||
"5.12b" to 69,
|
||||
"5.12c" to 70,
|
||||
"5.12d" to 71,
|
||||
"5.13a" to 72,
|
||||
"5.13b" to 73,
|
||||
"5.13c" to 74,
|
||||
"5.13d" to 75,
|
||||
"5.14a" to 76,
|
||||
"5.14b" to 77,
|
||||
"5.14c" to 78,
|
||||
"5.14d" to 79,
|
||||
"5.15a" to 80,
|
||||
"5.15b" to 81,
|
||||
"5.15c" to 82,
|
||||
"5.15d" to 83
|
||||
)
|
||||
mapOf(
|
||||
"5.0" to 50,
|
||||
"5.1" to 51,
|
||||
"5.2" to 52,
|
||||
"5.3" to 53,
|
||||
"5.4" to 54,
|
||||
"5.5" to 55,
|
||||
"5.6" to 56,
|
||||
"5.7" to 57,
|
||||
"5.8" to 58,
|
||||
"5.9" to 59,
|
||||
"5.10a" to 60,
|
||||
"5.10b" to 61,
|
||||
"5.10c" to 62,
|
||||
"5.10d" to 63,
|
||||
"5.11a" to 64,
|
||||
"5.11b" to 65,
|
||||
"5.11c" to 66,
|
||||
"5.11d" to 67,
|
||||
"5.12a" to 68,
|
||||
"5.12b" to 69,
|
||||
"5.12c" to 70,
|
||||
"5.12d" to 71,
|
||||
"5.13a" to 72,
|
||||
"5.13b" to 73,
|
||||
"5.13c" to 74,
|
||||
"5.13d" to 75,
|
||||
"5.14a" to 76,
|
||||
"5.14b" to 77,
|
||||
"5.14c" to 78,
|
||||
"5.14d" to 79,
|
||||
"5.15a" to 80,
|
||||
"5.15b" to 81,
|
||||
"5.15c" to 82,
|
||||
"5.15d" to 83,
|
||||
)
|
||||
ydsMapping[grade] ?: 0
|
||||
}
|
||||
DifficultySystem.CUSTOM -> grade.toIntOrNull() ?: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare this grade with another grade of the same system Returns negative if this grade is
|
||||
* easier, positive if harder, 0 if equal
|
||||
|
||||
@@ -1,43 +1,45 @@
|
||||
package com.atridad.ascently.data.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import com.atridad.ascently.utils.DateFormatUtils
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Immutable
|
||||
@Entity(tableName = "gyms")
|
||||
@Serializable
|
||||
data class Gym(
|
||||
@PrimaryKey val id: String,
|
||||
val name: String,
|
||||
val location: String? = null,
|
||||
val supportedClimbTypes: List<ClimbType>,
|
||||
val difficultySystems: List<DifficultySystem>,
|
||||
val customDifficultyGrades: List<String> = emptyList(),
|
||||
val notes: String? = null,
|
||||
val createdAt: String,
|
||||
val updatedAt: String
|
||||
@PrimaryKey val id: String,
|
||||
val name: String,
|
||||
val location: String? = null,
|
||||
val supportedClimbTypes: List<ClimbType>,
|
||||
val difficultySystems: List<DifficultySystem>,
|
||||
val customDifficultyGrades: List<String> = emptyList(),
|
||||
val notes: String? = null,
|
||||
val createdAt: String,
|
||||
val updatedAt: String,
|
||||
) {
|
||||
companion object {
|
||||
fun create(
|
||||
name: String,
|
||||
location: String? = null,
|
||||
supportedClimbTypes: List<ClimbType>,
|
||||
difficultySystems: List<DifficultySystem>,
|
||||
customDifficultyGrades: List<String> = emptyList(),
|
||||
notes: String? = null
|
||||
name: String,
|
||||
location: String? = null,
|
||||
supportedClimbTypes: List<ClimbType>,
|
||||
difficultySystems: List<DifficultySystem>,
|
||||
customDifficultyGrades: List<String> = emptyList(),
|
||||
notes: String? = null,
|
||||
): Gym {
|
||||
val now = DateFormatUtils.nowISO8601()
|
||||
return Gym(
|
||||
id = java.util.UUID.randomUUID().toString(),
|
||||
name = name,
|
||||
location = location,
|
||||
supportedClimbTypes = supportedClimbTypes,
|
||||
difficultySystems = difficultySystems,
|
||||
customDifficultyGrades = customDifficultyGrades,
|
||||
notes = notes,
|
||||
createdAt = now,
|
||||
updatedAt = now
|
||||
id = java.util.UUID.randomUUID().toString(),
|
||||
name = name,
|
||||
location = location,
|
||||
supportedClimbTypes = supportedClimbTypes,
|
||||
difficultySystems = difficultySystems,
|
||||
customDifficultyGrades = customDifficultyGrades,
|
||||
notes = notes,
|
||||
createdAt = now,
|
||||
updatedAt = now,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.atridad.ascently.data.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
@@ -7,64 +8,66 @@ import androidx.room.PrimaryKey
|
||||
import com.atridad.ascently.utils.DateFormatUtils
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Immutable
|
||||
@Entity(
|
||||
tableName = "problems",
|
||||
foreignKeys =
|
||||
[
|
||||
ForeignKey(
|
||||
entity = Gym::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["gymId"],
|
||||
onDelete = ForeignKey.CASCADE
|
||||
)],
|
||||
indices = [Index(value = ["gymId"])]
|
||||
tableName = "problems",
|
||||
foreignKeys =
|
||||
[
|
||||
ForeignKey(
|
||||
entity = Gym::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["gymId"],
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
),
|
||||
],
|
||||
indices = [Index(value = ["gymId"])],
|
||||
)
|
||||
@Serializable
|
||||
data class Problem(
|
||||
@PrimaryKey val id: String,
|
||||
val gymId: String,
|
||||
val name: String? = null,
|
||||
val description: String? = null,
|
||||
val climbType: ClimbType,
|
||||
val difficulty: DifficultyGrade,
|
||||
val tags: List<String> = emptyList(),
|
||||
val location: String? = null,
|
||||
val imagePaths: List<String> = emptyList(),
|
||||
val isActive: Boolean = true,
|
||||
val dateSet: String? = null,
|
||||
val notes: String? = null,
|
||||
val createdAt: String,
|
||||
val updatedAt: String
|
||||
@PrimaryKey val id: String,
|
||||
val gymId: String,
|
||||
val name: String? = null,
|
||||
val description: String? = null,
|
||||
val climbType: ClimbType,
|
||||
val difficulty: DifficultyGrade,
|
||||
val tags: List<String> = emptyList(),
|
||||
val location: String? = null,
|
||||
val imagePaths: List<String> = emptyList(),
|
||||
val isActive: Boolean = true,
|
||||
val dateSet: String? = null,
|
||||
val notes: String? = null,
|
||||
val createdAt: String,
|
||||
val updatedAt: String,
|
||||
) {
|
||||
companion object {
|
||||
fun create(
|
||||
gymId: String,
|
||||
name: String? = null,
|
||||
description: String? = null,
|
||||
climbType: ClimbType,
|
||||
difficulty: DifficultyGrade,
|
||||
tags: List<String> = emptyList(),
|
||||
location: String? = null,
|
||||
imagePaths: List<String> = emptyList(),
|
||||
dateSet: String? = null,
|
||||
notes: String? = null
|
||||
gymId: String,
|
||||
name: String? = null,
|
||||
description: String? = null,
|
||||
climbType: ClimbType,
|
||||
difficulty: DifficultyGrade,
|
||||
tags: List<String> = emptyList(),
|
||||
location: String? = null,
|
||||
imagePaths: List<String> = emptyList(),
|
||||
dateSet: String? = null,
|
||||
notes: String? = null,
|
||||
): Problem {
|
||||
val now = DateFormatUtils.nowISO8601()
|
||||
return Problem(
|
||||
id = java.util.UUID.randomUUID().toString(),
|
||||
gymId = gymId,
|
||||
name = name,
|
||||
description = description,
|
||||
climbType = climbType,
|
||||
difficulty = difficulty,
|
||||
tags = tags,
|
||||
location = location,
|
||||
imagePaths = imagePaths,
|
||||
isActive = true,
|
||||
dateSet = dateSet,
|
||||
notes = notes,
|
||||
createdAt = now,
|
||||
updatedAt = now
|
||||
id = java.util.UUID.randomUUID().toString(),
|
||||
gymId = gymId,
|
||||
name = name,
|
||||
description = description,
|
||||
climbType = climbType,
|
||||
difficulty = difficulty,
|
||||
tags = tags,
|
||||
location = location,
|
||||
imagePaths = imagePaths,
|
||||
isActive = true,
|
||||
dateSet = dateSet,
|
||||
notes = notes,
|
||||
createdAt = now,
|
||||
updatedAt = now,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@ import com.atridad.ascently.data.format.ClimbDataBackup
|
||||
import com.atridad.ascently.data.format.DeletedItem
|
||||
import com.atridad.ascently.data.model.*
|
||||
import com.atridad.ascently.data.state.DataStateManager
|
||||
import com.atridad.ascently.utils.DateFormatUtils
|
||||
import com.atridad.ascently.utils.AppLogger
|
||||
import com.atridad.ascently.utils.DateFormatUtils
|
||||
import com.atridad.ascently.utils.ZipExportImportUtils
|
||||
import java.io.File
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.serialization.json.Json
|
||||
import java.io.File
|
||||
|
||||
class ClimbRepository(database: AscentlyDatabase, private val context: Context) {
|
||||
private val gymDao = database.gymDao()
|
||||
@@ -161,7 +161,7 @@ class ClimbRepository(database: AscentlyDatabase, private val context: Context)
|
||||
gyms = allGyms.map { BackupGym.fromGym(it) },
|
||||
problems = allProblems.map { BackupProblem.fromProblem(it) },
|
||||
sessions = allSessions.map { BackupClimbSession.fromClimbSession(it) },
|
||||
attempts = allAttempts.map { BackupAttempt.fromAttempt(it) }
|
||||
attempts = allAttempts.map { BackupAttempt.fromAttempt(it) },
|
||||
)
|
||||
|
||||
val referencedImagePaths = allProblems.flatMap { it.imagePaths }.toSet()
|
||||
@@ -172,7 +172,7 @@ class ClimbRepository(database: AscentlyDatabase, private val context: Context)
|
||||
val imageFile =
|
||||
com.atridad.ascently.utils.ImageUtils.getImageFile(
|
||||
context,
|
||||
imagePath
|
||||
imagePath,
|
||||
)
|
||||
imageFile.exists() && imageFile.length() > 0
|
||||
} catch (_: Exception) {
|
||||
@@ -185,7 +185,7 @@ class ClimbRepository(database: AscentlyDatabase, private val context: Context)
|
||||
context = context,
|
||||
uri = uri,
|
||||
exportData = backupData,
|
||||
referencedImagePaths = validImagePaths
|
||||
referencedImagePaths = validImagePaths,
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
throw Exception("Export failed: ${e.message}")
|
||||
@@ -229,7 +229,7 @@ class ClimbRepository(database: AscentlyDatabase, private val context: Context)
|
||||
val updatedBackupProblems =
|
||||
ZipExportImportUtils.updateProblemImagePaths(
|
||||
importData.problems,
|
||||
importResult.importedImagePaths
|
||||
importResult.importedImagePaths,
|
||||
)
|
||||
|
||||
updatedBackupProblems.forEach { backupProblem ->
|
||||
@@ -237,7 +237,7 @@ class ClimbRepository(database: AscentlyDatabase, private val context: Context)
|
||||
problemDao.insertProblem(backupProblem.toProblem())
|
||||
} catch (e: Exception) {
|
||||
throw Exception(
|
||||
"Failed to import problem '${backupProblem.name}': ${e.message}"
|
||||
"Failed to import problem '${backupProblem.name}': ${e.message}",
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -279,7 +279,7 @@ class ClimbRepository(database: AscentlyDatabase, private val context: Context)
|
||||
currentDeletions.add(newDeletion)
|
||||
|
||||
val json = json.encodeToString(newDeletion)
|
||||
deletionPreferences.edit { putString("deleted_${itemId}", json) }
|
||||
deletionPreferences.edit { putString("deleted_$itemId", json) }
|
||||
}
|
||||
|
||||
fun getDeletedItems(): List<DeletedItem> {
|
||||
@@ -308,20 +308,20 @@ class ClimbRepository(database: AscentlyDatabase, private val context: Context)
|
||||
gyms: List<Gym>,
|
||||
problems: List<Problem>,
|
||||
sessions: List<ClimbSession>,
|
||||
attempts: List<Attempt>
|
||||
attempts: List<Attempt>,
|
||||
) {
|
||||
val gymIds = gyms.map { it.id }.toSet()
|
||||
val invalidProblems = problems.filter { it.gymId !in gymIds }
|
||||
if (invalidProblems.isNotEmpty()) {
|
||||
throw Exception(
|
||||
"Data integrity error: ${invalidProblems.size} problems reference non-existent gyms"
|
||||
"Data integrity error: ${invalidProblems.size} problems reference non-existent gyms",
|
||||
)
|
||||
}
|
||||
|
||||
val invalidSessions = sessions.filter { it.gymId !in gymIds }
|
||||
if (invalidSessions.isNotEmpty()) {
|
||||
throw Exception(
|
||||
"Data integrity error: ${invalidSessions.size} sessions reference non-existent gyms"
|
||||
"Data integrity error: ${invalidSessions.size} sessions reference non-existent gyms",
|
||||
)
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ class ClimbRepository(database: AscentlyDatabase, private val context: Context)
|
||||
attempts.filter { it.problemId !in problemIds || it.sessionId !in sessionIds }
|
||||
if (invalidAttempts.isNotEmpty()) {
|
||||
throw Exception(
|
||||
"Data integrity error: ${invalidAttempts.size} attempts reference non-existent problems or sessions"
|
||||
"Data integrity error: ${invalidAttempts.size} attempts reference non-existent problems or sessions",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,11 +17,6 @@ import com.atridad.ascently.utils.AppLogger
|
||||
import com.atridad.ascently.utils.DateFormatUtils
|
||||
import com.atridad.ascently.utils.ImageNamingUtils
|
||||
import com.atridad.ascently.utils.ImageUtils
|
||||
import java.io.IOException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
@@ -34,10 +29,15 @@ import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import java.io.IOException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class AscentlySyncProvider(
|
||||
private val context: Context,
|
||||
private val repository: ClimbRepository
|
||||
private val repository: ClimbRepository,
|
||||
) : SyncProvider {
|
||||
|
||||
override val type: SyncProviderType = SyncProviderType.SERVER
|
||||
@@ -148,15 +148,15 @@ class AscentlySyncProvider(
|
||||
|
||||
val hasLocalData =
|
||||
localBackup.gyms.isNotEmpty() ||
|
||||
localBackup.problems.isNotEmpty() ||
|
||||
localBackup.sessions.isNotEmpty() ||
|
||||
localBackup.attempts.isNotEmpty()
|
||||
localBackup.problems.isNotEmpty() ||
|
||||
localBackup.sessions.isNotEmpty() ||
|
||||
localBackup.attempts.isNotEmpty()
|
||||
|
||||
val hasServerData =
|
||||
serverBackup.gyms.isNotEmpty() ||
|
||||
serverBackup.problems.isNotEmpty() ||
|
||||
serverBackup.sessions.isNotEmpty() ||
|
||||
serverBackup.attempts.isNotEmpty()
|
||||
serverBackup.problems.isNotEmpty() ||
|
||||
serverBackup.sessions.isNotEmpty() ||
|
||||
serverBackup.attempts.isNotEmpty()
|
||||
|
||||
val lastSyncTimeStr = sharedPreferences.getString(Keys.LAST_SYNC_TIME, null)
|
||||
if (hasLocalData && hasServerData && lastSyncTimeStr != null) {
|
||||
@@ -268,7 +268,7 @@ class AscentlySyncProvider(
|
||||
problems = modifiedProblems,
|
||||
sessions = modifiedSessions,
|
||||
attempts = modifiedAttempts,
|
||||
deletedItems = modifiedDeletions
|
||||
deletedItems = modifiedDeletions,
|
||||
)
|
||||
|
||||
val requestBody =
|
||||
@@ -303,7 +303,9 @@ class AscentlySyncProvider(
|
||||
}
|
||||
|
||||
AppLogger.d(TAG) {
|
||||
"Delta sync received: gyms=${deltaResponse.gyms.size}, problems=${deltaResponse.problems.size}, sessions=${deltaResponse.sessions.size}, attempts=${deltaResponse.attempts.size}, deletions=${deltaResponse.deletedItems.size}"
|
||||
"Delta sync received: gyms=${deltaResponse.gyms.size}, " +
|
||||
"problems=${deltaResponse.problems.size}, sessions=${deltaResponse.sessions.size}, " +
|
||||
"attempts=${deltaResponse.attempts.size}, deletions=${deltaResponse.deletedItems.size}"
|
||||
}
|
||||
|
||||
applyDeltaResponse(deltaResponse)
|
||||
@@ -440,7 +442,7 @@ class AscentlySyncProvider(
|
||||
}
|
||||
|
||||
private suspend fun applyDeletions(
|
||||
deletions: List<com.atridad.ascently.data.format.DeletedItem>
|
||||
deletions: List<com.atridad.ascently.data.format.DeletedItem>,
|
||||
) {
|
||||
val existingGyms = repository.getAllGyms().first()
|
||||
val existingProblems = repository.getAllProblems().first()
|
||||
@@ -502,7 +504,7 @@ class AscentlySyncProvider(
|
||||
gyms = emptyList(),
|
||||
problems = emptyList(),
|
||||
sessions = emptyList(),
|
||||
attempts = emptyList()
|
||||
attempts = emptyList(),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
@@ -643,37 +645,37 @@ class AscentlySyncProvider(
|
||||
exportedAt = dataStateManager.getLastModified(),
|
||||
gyms = repository.getAllGyms().first().map { BackupGym.fromGym(it) },
|
||||
problems =
|
||||
repository.getAllProblems().first().map { problem ->
|
||||
val backupProblem = BackupProblem.fromProblem(problem)
|
||||
val normalizedImagePaths =
|
||||
problem.imagePaths.mapIndexed { index, _ ->
|
||||
ImageNamingUtils.generateImageFilename(
|
||||
problem.id,
|
||||
index
|
||||
)
|
||||
}
|
||||
if (normalizedImagePaths.isNotEmpty()) {
|
||||
backupProblem.copy(imagePaths = normalizedImagePaths)
|
||||
} else {
|
||||
backupProblem
|
||||
repository.getAllProblems().first().map { problem ->
|
||||
val backupProblem = BackupProblem.fromProblem(problem)
|
||||
val normalizedImagePaths =
|
||||
problem.imagePaths.mapIndexed { index, _ ->
|
||||
ImageNamingUtils.generateImageFilename(
|
||||
problem.id,
|
||||
index,
|
||||
)
|
||||
}
|
||||
},
|
||||
if (normalizedImagePaths.isNotEmpty()) {
|
||||
backupProblem.copy(imagePaths = normalizedImagePaths)
|
||||
} else {
|
||||
backupProblem
|
||||
}
|
||||
},
|
||||
sessions =
|
||||
repository.getAllSessions().first().map {
|
||||
BackupClimbSession.fromClimbSession(it)
|
||||
},
|
||||
repository.getAllSessions().first().map {
|
||||
BackupClimbSession.fromClimbSession(it)
|
||||
},
|
||||
attempts =
|
||||
repository.getAllAttempts().first().map {
|
||||
BackupAttempt.fromAttempt(it)
|
||||
},
|
||||
deletedItems = repository.getDeletedItems()
|
||||
repository.getAllAttempts().first().map {
|
||||
BackupAttempt.fromAttempt(it)
|
||||
},
|
||||
deletedItems = repository.getDeletedItems(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun importBackupToRepository(
|
||||
backup: ClimbDataBackup,
|
||||
imagePathMapping: Map<String, String>
|
||||
imagePathMapping: Map<String, String>,
|
||||
) {
|
||||
val gyms = backup.gyms.map { it.toGym() }
|
||||
val problems =
|
||||
|
||||
@@ -10,21 +10,21 @@ import kotlinx.serialization.Serializable
|
||||
/** Request structure for delta sync - sends only changes since last sync */
|
||||
@Serializable
|
||||
data class DeltaSyncRequest(
|
||||
val lastSyncTime: String,
|
||||
val gyms: List<BackupGym>,
|
||||
val problems: List<BackupProblem>,
|
||||
val sessions: List<BackupClimbSession>,
|
||||
val attempts: List<BackupAttempt>,
|
||||
val deletedItems: List<DeletedItem>
|
||||
val lastSyncTime: String,
|
||||
val gyms: List<BackupGym>,
|
||||
val problems: List<BackupProblem>,
|
||||
val sessions: List<BackupClimbSession>,
|
||||
val attempts: List<BackupAttempt>,
|
||||
val deletedItems: List<DeletedItem>,
|
||||
)
|
||||
|
||||
/** Response structure for delta sync - receives only changes from server */
|
||||
@Serializable
|
||||
data class DeltaSyncResponse(
|
||||
val serverTime: String,
|
||||
val gyms: List<BackupGym>,
|
||||
val problems: List<BackupProblem>,
|
||||
val sessions: List<BackupClimbSession>,
|
||||
val attempts: List<BackupAttempt>,
|
||||
val deletedItems: List<DeletedItem>
|
||||
val serverTime: String,
|
||||
val gyms: List<BackupGym>,
|
||||
val problems: List<BackupProblem>,
|
||||
val sessions: List<BackupClimbSession>,
|
||||
val attempts: List<BackupAttempt>,
|
||||
val deletedItems: List<DeletedItem>,
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@ interface SyncProvider {
|
||||
val type: SyncProviderType
|
||||
val isConfigured: StateFlow<Boolean>
|
||||
val isConnected: StateFlow<Boolean>
|
||||
|
||||
|
||||
suspend fun sync()
|
||||
suspend fun testConnection()
|
||||
fun disconnect()
|
||||
@@ -14,5 +14,5 @@ interface SyncProvider {
|
||||
|
||||
enum class SyncProviderType {
|
||||
NONE,
|
||||
SERVER
|
||||
SERVER,
|
||||
}
|
||||
|
||||
@@ -101,10 +101,9 @@ class SyncService(private val context: Context, private val repository: ClimbRep
|
||||
|
||||
try {
|
||||
provider.sync()
|
||||
|
||||
|
||||
// Update last sync time from shared prefs (provider updates it)
|
||||
_lastSyncTime.value = sharedPreferences.getString(Keys.LAST_SYNC_TIME, null)
|
||||
|
||||
} catch (e: Exception) {
|
||||
_syncError.value = e.message
|
||||
throw e
|
||||
|
||||
@@ -7,30 +7,30 @@ import androidx.compose.ui.graphics.vector.ImageVector
|
||||
data class BottomNavigationItem(val screen: Screen, val icon: ImageVector, val label: String)
|
||||
|
||||
val bottomNavigationItems =
|
||||
listOf(
|
||||
BottomNavigationItem(
|
||||
screen = Screen.Sessions,
|
||||
icon = Icons.Default.PlayArrow,
|
||||
label = "Sessions"
|
||||
),
|
||||
BottomNavigationItem(
|
||||
screen = Screen.Problems,
|
||||
icon = Icons.Default.Star,
|
||||
label = "Problems"
|
||||
),
|
||||
BottomNavigationItem(
|
||||
screen = Screen.Analytics,
|
||||
icon = Icons.Default.Info,
|
||||
label = "Analytics"
|
||||
),
|
||||
BottomNavigationItem(
|
||||
screen = Screen.Gyms,
|
||||
icon = Icons.Default.LocationOn,
|
||||
label = "Gyms"
|
||||
),
|
||||
BottomNavigationItem(
|
||||
screen = Screen.Settings,
|
||||
icon = Icons.Default.Settings,
|
||||
label = "Settings"
|
||||
)
|
||||
)
|
||||
listOf(
|
||||
BottomNavigationItem(
|
||||
screen = Screen.Sessions,
|
||||
icon = Icons.Default.PlayArrow,
|
||||
label = "Sessions",
|
||||
),
|
||||
BottomNavigationItem(
|
||||
screen = Screen.Problems,
|
||||
icon = Icons.Default.Star,
|
||||
label = "Problems",
|
||||
),
|
||||
BottomNavigationItem(
|
||||
screen = Screen.Analytics,
|
||||
icon = Icons.Default.Info,
|
||||
label = "Analytics",
|
||||
),
|
||||
BottomNavigationItem(
|
||||
screen = Screen.Gyms,
|
||||
icon = Icons.Default.LocationOn,
|
||||
label = "Gyms",
|
||||
),
|
||||
BottomNavigationItem(
|
||||
screen = Screen.Settings,
|
||||
icon = Icons.Default.Settings,
|
||||
label = "Settings",
|
||||
),
|
||||
)
|
||||
|
||||
@@ -15,13 +15,14 @@ import com.atridad.ascently.R
|
||||
import com.atridad.ascently.data.database.AscentlyDatabase
|
||||
import com.atridad.ascently.data.repository.ClimbRepository
|
||||
import com.atridad.ascently.utils.AppLogger
|
||||
import com.atridad.ascently.utils.DateFormatUtils
|
||||
import com.atridad.ascently.widget.ClimbStatsWidgetProvider
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import java.time.temporal.ChronoUnit
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.firstOrNull
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import java.time.temporal.ChronoUnit
|
||||
|
||||
class SessionTrackingService : Service() {
|
||||
|
||||
@@ -224,12 +225,12 @@ class SessionTrackingService : Service() {
|
||||
.addAction(
|
||||
R.drawable.ic_mountains,
|
||||
"Open Session",
|
||||
createOpenAppIntent()
|
||||
createOpenAppIntent(),
|
||||
)
|
||||
.addAction(
|
||||
android.R.drawable.ic_menu_close_clear_cancel,
|
||||
"End Session",
|
||||
createStopPendingIntent(sessionId)
|
||||
createStopPendingIntent(sessionId),
|
||||
)
|
||||
|
||||
// Use Live Update
|
||||
@@ -237,9 +238,8 @@ class SessionTrackingService : Service() {
|
||||
val startTimeMillis =
|
||||
session.startTime?.let { startTime ->
|
||||
try {
|
||||
val start = LocalDateTime.parse(startTime)
|
||||
val zoneId = ZoneId.systemDefault()
|
||||
start.atZone(zoneId).toInstant().toEpochMilli()
|
||||
DateFormatUtils.parseISO8601(startTime)?.toEpochMilli()
|
||||
?: System.currentTimeMillis()
|
||||
} catch (_: Exception) {
|
||||
System.currentTimeMillis()
|
||||
}
|
||||
@@ -249,7 +249,7 @@ class SessionTrackingService : Service() {
|
||||
notificationBuilder
|
||||
.setContentTitle("Climbing Session Active")
|
||||
.setContentText(
|
||||
"${gym?.name ?: "Gym"} • ${attempts.size} attempts"
|
||||
"${gym?.name ?: "Gym"} • ${attempts.size} attempts",
|
||||
)
|
||||
.setWhen(startTimeMillis)
|
||||
.setUsesChronometer(true)
|
||||
@@ -263,9 +263,9 @@ class SessionTrackingService : Service() {
|
||||
val duration =
|
||||
session.startTime?.let { startTime ->
|
||||
try {
|
||||
val start = LocalDateTime.parse(startTime)
|
||||
val now = LocalDateTime.now()
|
||||
val totalSeconds = ChronoUnit.SECONDS.between(start, now)
|
||||
val start = DateFormatUtils.parseISO8601(startTime)
|
||||
val now = java.time.Instant.now()
|
||||
val totalSeconds = if (start != null) ChronoUnit.SECONDS.between(start, now) else 0L
|
||||
val hours = totalSeconds / 3600
|
||||
val minutes = (totalSeconds % 3600) / 60
|
||||
val seconds = totalSeconds % 60
|
||||
@@ -284,7 +284,7 @@ class SessionTrackingService : Service() {
|
||||
notificationBuilder
|
||||
.setContentTitle("Climbing Session Active")
|
||||
.setContentText(
|
||||
"${gym?.name ?: "Gym"} • $duration • ${attempts.size} attempts"
|
||||
"${gym?.name ?: "Gym"} • $duration • ${attempts.size} attempts",
|
||||
)
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ class SessionTrackingService : Service() {
|
||||
this,
|
||||
0,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ class SessionTrackingService : Service() {
|
||||
this,
|
||||
1,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ class SessionTrackingService : Service() {
|
||||
NotificationChannel(
|
||||
CHANNEL_ID,
|
||||
"Session Tracking",
|
||||
NotificationManager.IMPORTANCE_DEFAULT
|
||||
NotificationManager.IMPORTANCE_DEFAULT,
|
||||
)
|
||||
.apply {
|
||||
description = "Shows active climbing session information"
|
||||
|
||||
@@ -35,7 +35,7 @@ import com.atridad.ascently.utils.NotificationPermissionUtils
|
||||
fun AscentlyApp(
|
||||
shortcutAction: String? = null,
|
||||
lastUsedGymId: String? = null,
|
||||
onShortcutActionProcessed: () -> Unit = {}
|
||||
onShortcutActionProcessed: () -> Unit = {},
|
||||
) {
|
||||
val navController = rememberNavController()
|
||||
val context = LocalContext.current
|
||||
@@ -53,7 +53,7 @@ fun AscentlyApp(
|
||||
|
||||
val permissionLauncher =
|
||||
rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.RequestPermission()
|
||||
contract = ActivityResultContracts.RequestPermission(),
|
||||
) { isGranted: Boolean ->
|
||||
if (!isGranted) {
|
||||
showNotificationPermissionDialog = false
|
||||
@@ -90,7 +90,7 @@ fun AscentlyApp(
|
||||
context = context,
|
||||
hasActiveSession = activeSession != null,
|
||||
hasGyms = gyms.isNotEmpty(),
|
||||
lastUsedGym = if (activeSession == null && gyms.size > 1) lastUsedGym else null
|
||||
lastUsedGym = if (activeSession == null && gyms.size > 1) lastUsedGym else null,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ fun AscentlyApp(
|
||||
if (activeSession == null) {
|
||||
if (NotificationPermissionUtils.shouldRequestNotificationPermission() &&
|
||||
!NotificationPermissionUtils.isNotificationPermissionGranted(
|
||||
context
|
||||
context,
|
||||
)
|
||||
) {
|
||||
AppLogger.d("AscentlyApp") { "Showing notification permission dialog" }
|
||||
@@ -160,20 +160,20 @@ fun AscentlyApp(
|
||||
fabConfig?.let { config ->
|
||||
FloatingActionButton(
|
||||
onClick = config.onClick,
|
||||
containerColor = MaterialTheme.colorScheme.primary
|
||||
containerColor = MaterialTheme.colorScheme.primary,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = config.icon,
|
||||
contentDescription = config.contentDescription
|
||||
contentDescription = config.contentDescription,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
) { innerPadding ->
|
||||
NavHost(
|
||||
navController = navController,
|
||||
startDestination = Screen.Sessions,
|
||||
modifier = Modifier.padding(innerPadding)
|
||||
modifier = Modifier.padding(innerPadding),
|
||||
) {
|
||||
composable<Screen.Sessions> {
|
||||
LaunchedEffect(gyms, activeSession) {
|
||||
@@ -187,14 +187,14 @@ fun AscentlyApp(
|
||||
.shouldRequestNotificationPermission() &&
|
||||
!NotificationPermissionUtils
|
||||
.isNotificationPermissionGranted(
|
||||
context
|
||||
context,
|
||||
)
|
||||
) {
|
||||
showNotificationPermissionDialog = true
|
||||
} else {
|
||||
navController.navigate(Screen.AddEditSession())
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
} else {
|
||||
null
|
||||
@@ -204,7 +204,7 @@ fun AscentlyApp(
|
||||
viewModel = viewModel,
|
||||
onNavigateToSessionDetail = { sessionId ->
|
||||
navController.navigate(Screen.SessionDetail(sessionId))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ fun AscentlyApp(
|
||||
contentDescription = "Add Problem",
|
||||
onClick = {
|
||||
navController.navigate(Screen.AddEditProblem())
|
||||
}
|
||||
},
|
||||
)
|
||||
} else {
|
||||
null
|
||||
@@ -227,7 +227,7 @@ fun AscentlyApp(
|
||||
viewModel = viewModel,
|
||||
onNavigateToProblemDetail = { problemId ->
|
||||
navController.navigate(Screen.ProblemDetail(problemId))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -242,14 +242,14 @@ fun AscentlyApp(
|
||||
FabConfig(
|
||||
icon = Icons.Default.Add,
|
||||
contentDescription = "Add Gym",
|
||||
onClick = { navController.navigate(Screen.AddEditGym()) }
|
||||
onClick = { navController.navigate(Screen.AddEditGym()) },
|
||||
)
|
||||
}
|
||||
GymsScreen(
|
||||
viewModel = viewModel,
|
||||
onNavigateToGymDetail = { gymId ->
|
||||
navController.navigate(Screen.GymDetail(gymId))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ fun AscentlyApp(
|
||||
onNavigateBack = { navController.popBackStack() },
|
||||
onNavigateToProblemDetail = { problemId ->
|
||||
navController.navigate(Screen.ProblemDetail(problemId))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ fun AscentlyApp(
|
||||
onNavigateBack = { navController.popBackStack() },
|
||||
onNavigateToEdit = { problemId ->
|
||||
navController.navigate(Screen.AddEditProblem(problemId = problemId))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ fun AscentlyApp(
|
||||
},
|
||||
onNavigateToProblemDetail = { problemId ->
|
||||
navController.navigate(Screen.ProblemDetail(problemId))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ fun AscentlyApp(
|
||||
AddEditGymScreen(
|
||||
gymId = args.gymId,
|
||||
viewModel = viewModel,
|
||||
onNavigateBack = { navController.popBackStack() }
|
||||
onNavigateBack = { navController.popBackStack() },
|
||||
)
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ fun AscentlyApp(
|
||||
problemId = args.problemId,
|
||||
gymId = args.gymId,
|
||||
viewModel = viewModel,
|
||||
onNavigateBack = { navController.popBackStack() }
|
||||
onNavigateBack = { navController.popBackStack() },
|
||||
)
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ fun AscentlyApp(
|
||||
sessionId = args.sessionId,
|
||||
gymId = args.gymId,
|
||||
viewModel = viewModel,
|
||||
onNavigateBack = { navController.popBackStack() }
|
||||
onNavigateBack = { navController.popBackStack() },
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -341,9 +341,9 @@ fun AscentlyApp(
|
||||
onDismiss = { showNotificationPermissionDialog = false },
|
||||
onRequestPermission = {
|
||||
permissionLauncher.launch(
|
||||
NotificationPermissionUtils.getNotificationPermissionString()
|
||||
NotificationPermissionUtils.getNotificationPermissionString(),
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -377,7 +377,7 @@ fun AscentlyBottomNavigation(navController: NavHostController) {
|
||||
// Don't restore state - always start fresh when switching tabs
|
||||
restoreState = false
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -386,5 +386,5 @@ fun AscentlyBottomNavigation(navController: NavHostController) {
|
||||
data class FabConfig(
|
||||
val icon: androidx.compose.ui.graphics.vector.ImageVector,
|
||||
val contentDescription: String,
|
||||
val onClick: () -> Unit
|
||||
val onClick: () -> Unit,
|
||||
)
|
||||
|
||||
@@ -13,8 +13,9 @@ import androidx.compose.ui.unit.dp
|
||||
import com.atridad.ascently.data.model.ClimbSession
|
||||
import com.atridad.ascently.data.model.Gym
|
||||
import com.atridad.ascently.ui.theme.CustomIcons
|
||||
import com.atridad.ascently.utils.DateFormatUtils
|
||||
import kotlinx.coroutines.delay
|
||||
import java.time.LocalDateTime
|
||||
import java.time.Instant
|
||||
import java.time.temporal.ChronoUnit
|
||||
|
||||
@Composable
|
||||
@@ -22,102 +23,113 @@ fun ActiveSessionBanner(
|
||||
activeSession: ClimbSession?,
|
||||
gym: Gym?,
|
||||
onSessionClick: () -> Unit,
|
||||
onEndSession: () -> Unit
|
||||
) {
|
||||
if (activeSession != null) {
|
||||
// Add a timer that updates every second for real-time duration counting
|
||||
var currentTime by remember { mutableStateOf(LocalDateTime.now()) }
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
while (true) {
|
||||
delay(1000) // Update every second
|
||||
currentTime = LocalDateTime.now()
|
||||
}
|
||||
onEndSession: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
if (activeSession == null) return
|
||||
|
||||
val sessionId = activeSession.id
|
||||
val startTimeString = activeSession.startTime
|
||||
val gymName = gym?.name ?: "Unknown Gym"
|
||||
|
||||
var elapsedSeconds by remember(sessionId) { mutableLongStateOf(0L) }
|
||||
|
||||
LaunchedEffect(sessionId, startTimeString) {
|
||||
if (startTimeString == null) return@LaunchedEffect
|
||||
|
||||
while (true) {
|
||||
elapsedSeconds = calculateElapsedSeconds(startTimeString)
|
||||
delay(1000)
|
||||
}
|
||||
|
||||
Card(
|
||||
}
|
||||
|
||||
val durationText = remember(elapsedSeconds) {
|
||||
formatDuration(elapsedSeconds)
|
||||
}
|
||||
|
||||
Card(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { onSessionClick() },
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
||||
),
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { onSessionClick() },
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.primaryContainer
|
||||
)
|
||||
.padding(16.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Icon(
|
||||
Icons.Default.PlayArrow,
|
||||
contentDescription = "Active session",
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.size(16.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(
|
||||
text = "Active Session",
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = MaterialTheme.colorScheme.onPrimaryContainer
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
|
||||
Text(
|
||||
text = gym?.name ?: "Unknown Gym",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onPrimaryContainer
|
||||
)
|
||||
|
||||
activeSession.startTime?.let { startTime ->
|
||||
val duration = calculateDuration(startTime, currentTime)
|
||||
Text(
|
||||
text = duration,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onPrimaryContainer.copy(alpha = 0.8f)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
IconButton(
|
||||
onClick = onEndSession,
|
||||
colors = IconButtonDefaults.iconButtonColors(
|
||||
containerColor = MaterialTheme.colorScheme.error,
|
||||
contentColor = MaterialTheme.colorScheme.onError
|
||||
)
|
||||
) {
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Icon(
|
||||
imageVector = CustomIcons.Stop(MaterialTheme.colorScheme.onError),
|
||||
contentDescription = "End session"
|
||||
Icons.Default.PlayArrow,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.size(16.dp),
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(
|
||||
text = "Active Session",
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
|
||||
Text(
|
||||
text = gymName,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||
)
|
||||
|
||||
if (startTimeString != null) {
|
||||
Text(
|
||||
text = durationText,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onPrimaryContainer.copy(alpha = 0.8f),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
FilledIconButton(
|
||||
onClick = onEndSession,
|
||||
colors = IconButtonDefaults.filledIconButtonColors(
|
||||
containerColor = MaterialTheme.colorScheme.error,
|
||||
contentColor = MaterialTheme.colorScheme.onError,
|
||||
),
|
||||
) {
|
||||
Icon(
|
||||
imageVector = CustomIcons.Stop(MaterialTheme.colorScheme.onError),
|
||||
contentDescription = "End session",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun calculateDuration(startTimeString: String, currentTime: LocalDateTime): String {
|
||||
private fun calculateElapsedSeconds(startTimeString: String): Long {
|
||||
return try {
|
||||
val startTime = LocalDateTime.parse(startTimeString)
|
||||
val totalSeconds = ChronoUnit.SECONDS.between(startTime, currentTime)
|
||||
val hours = totalSeconds / 3600
|
||||
val minutes = (totalSeconds % 3600) / 60
|
||||
val seconds = totalSeconds % 60
|
||||
|
||||
when {
|
||||
hours > 0 -> "${hours}h ${minutes}m ${seconds}s"
|
||||
minutes > 0 -> "${minutes}m ${seconds}s"
|
||||
else -> "${totalSeconds}s"
|
||||
}
|
||||
val startTime = DateFormatUtils.parseISO8601(startTimeString) ?: return 0L
|
||||
val now = Instant.now()
|
||||
ChronoUnit.SECONDS.between(startTime, now).coerceAtLeast(0)
|
||||
} catch (_: Exception) {
|
||||
"Active"
|
||||
0L
|
||||
}
|
||||
}
|
||||
|
||||
private fun formatDuration(totalSeconds: Long): String {
|
||||
val hours = totalSeconds / 3600
|
||||
val minutes = (totalSeconds % 3600) / 60
|
||||
val seconds = totalSeconds % 60
|
||||
|
||||
return when {
|
||||
hours > 0 -> "${hours}h ${minutes}m ${seconds}s"
|
||||
minutes > 0 -> "${minutes}m ${seconds}s"
|
||||
else -> "${seconds}s"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,25 +23,25 @@ data class BarChartDataPoint(val label: String, val value: Int, val gradeNumeric
|
||||
|
||||
/** Configuration for bar chart styling */
|
||||
data class BarChartStyle(
|
||||
val barColor: Color,
|
||||
val gridColor: Color,
|
||||
val textColor: Color,
|
||||
val backgroundColor: Color
|
||||
val barColor: Color,
|
||||
val gridColor: Color,
|
||||
val textColor: Color,
|
||||
val backgroundColor: Color,
|
||||
)
|
||||
|
||||
/** Custom Bar Chart for displaying grade distribution */
|
||||
@Composable
|
||||
fun BarChart(
|
||||
data: List<BarChartDataPoint>,
|
||||
modifier: Modifier = Modifier,
|
||||
style: BarChartStyle =
|
||||
BarChartStyle(
|
||||
barColor = MaterialTheme.colorScheme.primary,
|
||||
gridColor = MaterialTheme.colorScheme.outline.copy(alpha = 0.3f),
|
||||
textColor = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
backgroundColor = MaterialTheme.colorScheme.surface
|
||||
),
|
||||
showGrid: Boolean = true
|
||||
data: List<BarChartDataPoint>,
|
||||
modifier: Modifier = Modifier,
|
||||
style: BarChartStyle =
|
||||
BarChartStyle(
|
||||
barColor = MaterialTheme.colorScheme.primary,
|
||||
gridColor = MaterialTheme.colorScheme.outline.copy(alpha = 0.3f),
|
||||
textColor = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
backgroundColor = MaterialTheme.colorScheme.surface,
|
||||
),
|
||||
showGrid: Boolean = true,
|
||||
) {
|
||||
val textMeasurer = rememberTextMeasurer()
|
||||
val density = LocalDensity.current
|
||||
@@ -68,42 +68,44 @@ fun BarChart(
|
||||
|
||||
// Draw background
|
||||
drawRect(
|
||||
color = style.backgroundColor,
|
||||
topLeft = Offset(padding, padding),
|
||||
size = androidx.compose.ui.geometry.Size(chartWidth, chartHeight)
|
||||
color = style.backgroundColor,
|
||||
topLeft = Offset(padding, padding),
|
||||
size = androidx.compose.ui.geometry.Size(chartWidth, chartHeight),
|
||||
)
|
||||
|
||||
// Draw grid
|
||||
if (showGrid) {
|
||||
drawGrid(
|
||||
padding = padding,
|
||||
chartWidth = chartWidth,
|
||||
chartHeight = chartHeight,
|
||||
gridColor = style.gridColor,
|
||||
maxValue = maxValue,
|
||||
textMeasurer = textMeasurer,
|
||||
textColor = style.textColor
|
||||
padding = padding,
|
||||
chartWidth = chartWidth,
|
||||
chartHeight = chartHeight,
|
||||
gridColor = style.gridColor,
|
||||
maxValue = maxValue,
|
||||
textMeasurer = textMeasurer,
|
||||
textColor = style.textColor,
|
||||
)
|
||||
}
|
||||
|
||||
// Draw bars and labels
|
||||
sortedData.forEachIndexed { index, dataPoint ->
|
||||
val barHeight =
|
||||
if (maxValue > 0) {
|
||||
(dataPoint.value.toFloat() / maxValue.toFloat()) * chartHeight * 0.8f
|
||||
} else 0f
|
||||
if (maxValue > 0) {
|
||||
(dataPoint.value.toFloat() / maxValue.toFloat()) * chartHeight * 0.8f
|
||||
} else {
|
||||
0f
|
||||
}
|
||||
|
||||
val barX =
|
||||
padding +
|
||||
barSpacing +
|
||||
index * (barWidth + barSpacing / (barCount - 1).coerceAtLeast(1))
|
||||
padding +
|
||||
barSpacing +
|
||||
index * (barWidth + barSpacing / (barCount - 1).coerceAtLeast(1))
|
||||
val barY = padding + chartHeight - barHeight
|
||||
|
||||
// Draw bar
|
||||
drawRect(
|
||||
color = style.barColor,
|
||||
topLeft = Offset(barX, barY),
|
||||
size = androidx.compose.ui.geometry.Size(barWidth, barHeight)
|
||||
color = style.barColor,
|
||||
topLeft = Offset(barX, barY),
|
||||
size = androidx.compose.ui.geometry.Size(barWidth, barHeight),
|
||||
)
|
||||
|
||||
// Draw value on bar
|
||||
@@ -114,24 +116,24 @@ fun BarChart(
|
||||
|
||||
// Position text
|
||||
val textY =
|
||||
if (barHeight > textSize.size.height + 8.dp.toPx()) {
|
||||
barY + 8.dp.toPx()
|
||||
} else {
|
||||
barY - 4.dp.toPx()
|
||||
}
|
||||
if (barHeight > textSize.size.height + 8.dp.toPx()) {
|
||||
barY + 8.dp.toPx()
|
||||
} else {
|
||||
barY - 4.dp.toPx()
|
||||
}
|
||||
|
||||
val textColor =
|
||||
if (barHeight > textSize.size.height + 8.dp.toPx()) {
|
||||
Color.White
|
||||
} else {
|
||||
style.textColor
|
||||
}
|
||||
if (barHeight > textSize.size.height + 8.dp.toPx()) {
|
||||
Color.White
|
||||
} else {
|
||||
style.textColor
|
||||
}
|
||||
|
||||
drawText(
|
||||
textMeasurer = textMeasurer,
|
||||
text = valueText,
|
||||
style = textStyle.copy(color = textColor),
|
||||
topLeft = Offset(barX + barWidth / 2f - textSize.size.width / 2f, textY)
|
||||
textMeasurer = textMeasurer,
|
||||
text = valueText,
|
||||
style = textStyle.copy(color = textColor),
|
||||
topLeft = Offset(barX + barWidth / 2f - textSize.size.width / 2f, textY),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -141,14 +143,14 @@ fun BarChart(
|
||||
val labelTextSize = textMeasurer.measure(gradeText, labelTextStyle)
|
||||
|
||||
drawText(
|
||||
textMeasurer = textMeasurer,
|
||||
text = gradeText,
|
||||
style = labelTextStyle,
|
||||
topLeft =
|
||||
Offset(
|
||||
barX + barWidth / 2f - labelTextSize.size.width / 2f,
|
||||
padding + chartHeight + 8.dp.toPx()
|
||||
)
|
||||
textMeasurer = textMeasurer,
|
||||
text = gradeText,
|
||||
style = labelTextStyle,
|
||||
topLeft =
|
||||
Offset(
|
||||
barX + barWidth / 2f - labelTextSize.size.width / 2f,
|
||||
padding + chartHeight + 8.dp.toPx(),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -156,37 +158,37 @@ fun BarChart(
|
||||
}
|
||||
|
||||
private fun DrawScope.drawGrid(
|
||||
padding: Float,
|
||||
chartWidth: Float,
|
||||
chartHeight: Float,
|
||||
gridColor: Color,
|
||||
maxValue: Int,
|
||||
textMeasurer: TextMeasurer,
|
||||
textColor: Color
|
||||
padding: Float,
|
||||
chartWidth: Float,
|
||||
chartHeight: Float,
|
||||
gridColor: Color,
|
||||
maxValue: Int,
|
||||
textMeasurer: TextMeasurer,
|
||||
textColor: Color,
|
||||
) {
|
||||
val textStyle = TextStyle(color = textColor, fontSize = 10.sp)
|
||||
|
||||
// Horizontal grid lines
|
||||
val gridLines =
|
||||
when {
|
||||
maxValue <= 5 -> (0..maxValue).toList()
|
||||
maxValue <= 10 -> (0..maxValue step 2).toList()
|
||||
maxValue <= 20 -> (0..maxValue step 5).toList()
|
||||
else -> {
|
||||
val step = (maxValue / 5).coerceAtLeast(1)
|
||||
(0..maxValue step step).toList()
|
||||
}
|
||||
when {
|
||||
maxValue <= 5 -> (0..maxValue).toList()
|
||||
maxValue <= 10 -> (0..maxValue step 2).toList()
|
||||
maxValue <= 20 -> (0..maxValue step 5).toList()
|
||||
else -> {
|
||||
val step = (maxValue / 5).coerceAtLeast(1)
|
||||
(0..maxValue step step).toList()
|
||||
}
|
||||
}
|
||||
|
||||
gridLines.forEach { value ->
|
||||
val y = padding + chartHeight - (value.toFloat() / maxValue.toFloat()) * chartHeight * 0.8f
|
||||
|
||||
// Draw grid line
|
||||
drawLine(
|
||||
color = gridColor,
|
||||
start = Offset(padding, y),
|
||||
end = Offset(padding + chartWidth, y),
|
||||
strokeWidth = 1.dp.toPx()
|
||||
color = gridColor,
|
||||
start = Offset(padding, y),
|
||||
end = Offset(padding + chartWidth, y),
|
||||
strokeWidth = 1.dp.toPx(),
|
||||
)
|
||||
|
||||
// Draw Y-axis label
|
||||
@@ -194,14 +196,14 @@ private fun DrawScope.drawGrid(
|
||||
val text = value.toString()
|
||||
val textSize = textMeasurer.measure(text, textStyle)
|
||||
drawText(
|
||||
textMeasurer = textMeasurer,
|
||||
text = text,
|
||||
style = textStyle,
|
||||
topLeft =
|
||||
Offset(
|
||||
padding - textSize.size.width - 8.dp.toPx(),
|
||||
y - textSize.size.height / 2f
|
||||
)
|
||||
textMeasurer = textMeasurer,
|
||||
text = text,
|
||||
style = textStyle,
|
||||
topLeft =
|
||||
Offset(
|
||||
padding - textSize.size.width - 8.dp.toPx(),
|
||||
y - textSize.size.height / 2f,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,44 +40,44 @@ fun FullscreenImageViewer(imagePaths: List<String>, initialIndex: Int = 0, onDis
|
||||
LaunchedEffect(pagerState.currentPage) {
|
||||
if (imagePaths.size > 1) {
|
||||
thumbnailListState.animateScrollToItem(
|
||||
index = pagerState.currentPage,
|
||||
scrollOffset = -200
|
||||
index = pagerState.currentPage,
|
||||
scrollOffset = -200,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Dialog(
|
||||
onDismissRequest = onDismiss,
|
||||
properties =
|
||||
DialogProperties(usePlatformDefaultWidth = false, decorFitsSystemWindows = true)
|
||||
onDismissRequest = onDismiss,
|
||||
properties =
|
||||
DialogProperties(usePlatformDefaultWidth = false, decorFitsSystemWindows = true),
|
||||
) {
|
||||
Box(modifier = Modifier.fillMaxSize().background(Color.Black).systemBarsPadding()) {
|
||||
// Main image pager
|
||||
HorizontalPager(state = pagerState, modifier = Modifier.fillMaxSize()) { page ->
|
||||
OrientationAwareImage(
|
||||
imagePath = imagePaths[page],
|
||||
contentDescription = "Full screen image",
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentScale = ContentScale.Fit
|
||||
imagePath = imagePaths[page],
|
||||
contentDescription = "Full screen image",
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentScale = ContentScale.Fit,
|
||||
)
|
||||
}
|
||||
|
||||
// Top bar with back button and counter
|
||||
Surface(
|
||||
modifier = Modifier.fillMaxWidth().align(Alignment.TopStart),
|
||||
color = Color.Black.copy(alpha = 0.6f)
|
||||
modifier = Modifier.fillMaxWidth().align(Alignment.TopStart),
|
||||
color = Color.Black.copy(alpha = 0.6f),
|
||||
) {
|
||||
Row(
|
||||
modifier =
|
||||
Modifier.fillMaxWidth().padding(horizontal = 4.dp, vertical = 8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
modifier =
|
||||
Modifier.fillMaxWidth().padding(horizontal = 4.dp, vertical = 8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
// Back button
|
||||
IconButton(onClick = onDismiss) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
contentDescription = "Close",
|
||||
tint = Color.White
|
||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
contentDescription = "Close",
|
||||
tint = Color.White,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -86,9 +86,9 @@ fun FullscreenImageViewer(imagePaths: List<String>, initialIndex: Int = 0, onDis
|
||||
// Image counter
|
||||
if (imagePaths.size > 1) {
|
||||
Text(
|
||||
text = "${pagerState.currentPage + 1} / ${imagePaths.size}",
|
||||
color = Color.White,
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
text = "${pagerState.currentPage + 1} / ${imagePaths.size}",
|
||||
color = Color.White,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -99,56 +99,56 @@ fun FullscreenImageViewer(imagePaths: List<String>, initialIndex: Int = 0, onDis
|
||||
// Thumbnail strip at bottom (if multiple images)
|
||||
if (imagePaths.size > 1) {
|
||||
Surface(
|
||||
modifier = Modifier.fillMaxWidth().align(Alignment.BottomCenter),
|
||||
color = Color.Black.copy(alpha = 0.6f)
|
||||
modifier = Modifier.fillMaxWidth().align(Alignment.BottomCenter),
|
||||
color = Color.Black.copy(alpha = 0.6f),
|
||||
) {
|
||||
LazyRow(
|
||||
state = thumbnailListState,
|
||||
modifier = Modifier.padding(vertical = 12.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
contentPadding = PaddingValues(horizontal = 16.dp)
|
||||
state = thumbnailListState,
|
||||
modifier = Modifier.padding(vertical = 12.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
contentPadding = PaddingValues(horizontal = 16.dp),
|
||||
) {
|
||||
itemsIndexed(imagePaths) { index, imagePath ->
|
||||
val isSelected = index == pagerState.currentPage
|
||||
|
||||
Box(
|
||||
modifier =
|
||||
Modifier.size(48.dp)
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
.clickable {
|
||||
coroutineScope.launch {
|
||||
pagerState.animateScrollToPage(index)
|
||||
}
|
||||
}
|
||||
modifier =
|
||||
Modifier.size(48.dp)
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
.clickable {
|
||||
coroutineScope.launch {
|
||||
pagerState.animateScrollToPage(index)
|
||||
}
|
||||
},
|
||||
) {
|
||||
OrientationAwareImage(
|
||||
imagePath = imagePath,
|
||||
contentDescription = "Thumbnail ${index + 1}",
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentScale = ContentScale.Crop
|
||||
imagePath = imagePath,
|
||||
contentDescription = "Thumbnail ${index + 1}",
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentScale = ContentScale.Crop,
|
||||
)
|
||||
|
||||
// Selection indicator
|
||||
if (isSelected) {
|
||||
Box(
|
||||
modifier =
|
||||
Modifier.fillMaxSize()
|
||||
.background(
|
||||
Color.White.copy(alpha = 0.3f),
|
||||
RoundedCornerShape(8.dp)
|
||||
)
|
||||
modifier =
|
||||
Modifier.fillMaxSize()
|
||||
.background(
|
||||
Color.White.copy(alpha = 0.3f),
|
||||
RoundedCornerShape(8.dp),
|
||||
),
|
||||
)
|
||||
Box(
|
||||
modifier =
|
||||
Modifier.fillMaxSize()
|
||||
.background(
|
||||
Color.Transparent,
|
||||
RoundedCornerShape(8.dp)
|
||||
)
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
.background(
|
||||
Color.White.copy(alpha = 0.2f)
|
||||
)
|
||||
modifier =
|
||||
Modifier.fillMaxSize()
|
||||
.background(
|
||||
Color.Transparent,
|
||||
RoundedCornerShape(8.dp),
|
||||
)
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
.background(
|
||||
Color.White.copy(alpha = 0.2f),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun ImageDisplay(
|
||||
imagePaths: List<String>,
|
||||
modifier: Modifier = Modifier,
|
||||
imageSize: Int = 120,
|
||||
onImageClick: ((Int) -> Unit)? = null
|
||||
imagePaths: List<String>,
|
||||
modifier: Modifier = Modifier,
|
||||
imageSize: Int = 120,
|
||||
onImageClick: ((Int) -> Unit)? = null,
|
||||
) {
|
||||
LocalContext.current
|
||||
|
||||
@@ -26,15 +26,15 @@ fun ImageDisplay(
|
||||
LazyRow(modifier = modifier, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
itemsIndexed(imagePaths) { index, imagePath ->
|
||||
OrientationAwareImage(
|
||||
imagePath = imagePath,
|
||||
contentDescription = "Problem photo",
|
||||
modifier =
|
||||
Modifier.size(imageSize.dp)
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
.clickable(enabled = onImageClick != null) {
|
||||
onImageClick?.invoke(index)
|
||||
},
|
||||
contentScale = ContentScale.Crop
|
||||
imagePath = imagePath,
|
||||
contentDescription = "Problem photo",
|
||||
modifier =
|
||||
Modifier.size(imageSize.dp)
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
.clickable(enabled = onImageClick != null) {
|
||||
onImageClick?.invoke(index)
|
||||
},
|
||||
contentScale = ContentScale.Crop,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -43,17 +43,17 @@ fun ImageDisplay(
|
||||
|
||||
@Composable
|
||||
fun ImageDisplaySection(
|
||||
imagePaths: List<String>,
|
||||
modifier: Modifier = Modifier,
|
||||
title: String = "Photos",
|
||||
onImageClick: ((Int) -> Unit)? = null
|
||||
imagePaths: List<String>,
|
||||
modifier: Modifier = Modifier,
|
||||
title: String = "Photos",
|
||||
onImageClick: ((Int) -> Unit)? = null,
|
||||
) {
|
||||
if (imagePaths.isNotEmpty()) {
|
||||
Column(modifier = modifier) {
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
text = title,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
@@ -32,10 +32,10 @@ import java.util.*
|
||||
|
||||
@Composable
|
||||
fun ImagePicker(
|
||||
imageUris: List<String>,
|
||||
onImagesChanged: (List<String>) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
maxImages: Int = 5
|
||||
imageUris: List<String>,
|
||||
onImagesChanged: (List<String>) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
maxImages: Int = 5,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
var tempImageUris by remember { mutableStateOf(imageUris) }
|
||||
@@ -44,83 +44,83 @@ fun ImagePicker(
|
||||
|
||||
// Image picker launcher
|
||||
val imagePickerLauncher =
|
||||
rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.GetMultipleContents()
|
||||
) { uris ->
|
||||
if (uris.isNotEmpty()) {
|
||||
val currentCount = tempImageUris.size
|
||||
val remainingSlots = maxImages - currentCount
|
||||
val urisToProcess = uris.take(remainingSlots)
|
||||
rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.GetMultipleContents(),
|
||||
) { uris ->
|
||||
if (uris.isNotEmpty()) {
|
||||
val currentCount = tempImageUris.size
|
||||
val remainingSlots = maxImages - currentCount
|
||||
val urisToProcess = uris.take(remainingSlots)
|
||||
|
||||
// Process images
|
||||
val newImagePaths = mutableListOf<String>()
|
||||
urisToProcess.forEach { uri ->
|
||||
val imagePath = ImageUtils.saveTemporaryImageFromUri(context, uri)
|
||||
if (imagePath != null) {
|
||||
newImagePaths.add(imagePath)
|
||||
}
|
||||
// Process images
|
||||
val newImagePaths = mutableListOf<String>()
|
||||
urisToProcess.forEach { uri ->
|
||||
val imagePath = ImageUtils.saveTemporaryImageFromUri(context, uri)
|
||||
if (imagePath != null) {
|
||||
newImagePaths.add(imagePath)
|
||||
}
|
||||
}
|
||||
|
||||
if (newImagePaths.isNotEmpty()) {
|
||||
val updatedUris = tempImageUris + newImagePaths
|
||||
if (newImagePaths.isNotEmpty()) {
|
||||
val updatedUris = tempImageUris + newImagePaths
|
||||
tempImageUris = updatedUris
|
||||
onImagesChanged(updatedUris)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Camera launcher
|
||||
val cameraLauncher =
|
||||
rememberLauncherForActivityResult(contract = ActivityResultContracts.TakePicture()) {
|
||||
success ->
|
||||
if (success) {
|
||||
cameraImageUri?.let { uri ->
|
||||
val imagePath = ImageUtils.saveTemporaryImageFromUri(context, uri)
|
||||
if (imagePath != null) {
|
||||
val updatedUris = tempImageUris + imagePath
|
||||
tempImageUris = updatedUris
|
||||
onImagesChanged(updatedUris)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Camera launcher
|
||||
val cameraLauncher =
|
||||
rememberLauncherForActivityResult(contract = ActivityResultContracts.TakePicture()) {
|
||||
success ->
|
||||
if (success) {
|
||||
cameraImageUri?.let { uri ->
|
||||
val imagePath = ImageUtils.saveTemporaryImageFromUri(context, uri)
|
||||
if (imagePath != null) {
|
||||
val updatedUris = tempImageUris + imagePath
|
||||
tempImageUris = updatedUris
|
||||
onImagesChanged(updatedUris)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Camera permission launcher
|
||||
val cameraPermissionLauncher =
|
||||
rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.RequestPermission()
|
||||
) { isGranted ->
|
||||
if (isGranted) {
|
||||
// Create image file for camera
|
||||
val imageFile = createImageFile(context)
|
||||
val uri =
|
||||
FileProvider.getUriForFile(
|
||||
context,
|
||||
"${context.packageName}.fileprovider",
|
||||
imageFile
|
||||
)
|
||||
cameraImageUri = uri
|
||||
cameraLauncher.launch(uri)
|
||||
}
|
||||
rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.RequestPermission(),
|
||||
) { isGranted ->
|
||||
if (isGranted) {
|
||||
// Create image file for camera
|
||||
val imageFile = createImageFile(context)
|
||||
val uri =
|
||||
FileProvider.getUriForFile(
|
||||
context,
|
||||
"${context.packageName}.fileprovider",
|
||||
imageFile,
|
||||
)
|
||||
cameraImageUri = uri
|
||||
cameraLauncher.launch(uri)
|
||||
}
|
||||
}
|
||||
|
||||
Column(modifier = modifier) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Text(
|
||||
text = "Photos (${tempImageUris.size}/$maxImages)",
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
text = "Photos (${tempImageUris.size}/$maxImages)",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
)
|
||||
|
||||
if (tempImageUris.size < maxImages) {
|
||||
TextButton(onClick = { showImageSourceDialog = true }) {
|
||||
Icon(
|
||||
Icons.Default.Add,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(16.dp)
|
||||
Icons.Default.Add,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(16.dp),
|
||||
)
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Text("Add Photos")
|
||||
@@ -134,42 +134,42 @@ fun ImagePicker(
|
||||
LazyRow(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
items(tempImageUris) { imagePath ->
|
||||
ImageItem(
|
||||
imagePath = imagePath,
|
||||
onRemove = {
|
||||
val updatedUris = tempImageUris.filter { it != imagePath }
|
||||
tempImageUris = updatedUris
|
||||
onImagesChanged(updatedUris)
|
||||
imagePath = imagePath,
|
||||
onRemove = {
|
||||
val updatedUris = tempImageUris.filter { it != imagePath }
|
||||
tempImageUris = updatedUris
|
||||
onImagesChanged(updatedUris)
|
||||
|
||||
// Delete the image file
|
||||
ImageUtils.deleteImage(context, imagePath)
|
||||
}
|
||||
// Delete the image file
|
||||
ImageUtils.deleteImage(context, imagePath)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth().height(100.dp),
|
||||
colors =
|
||||
CardDefaults.cardColors(
|
||||
containerColor =
|
||||
MaterialTheme.colorScheme.surfaceVariant.copy(
|
||||
alpha = 0.3f
|
||||
)
|
||||
)
|
||||
modifier = Modifier.fillMaxWidth().height(100.dp),
|
||||
colors =
|
||||
CardDefaults.cardColors(
|
||||
containerColor =
|
||||
MaterialTheme.colorScheme.surfaceVariant.copy(
|
||||
alpha = 0.3f,
|
||||
),
|
||||
),
|
||||
) {
|
||||
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Icon(
|
||||
Icons.Default.Add,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
Icons.Default.Add,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = "Add photos of this problem",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
text = "Add photos of this problem",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -179,67 +179,68 @@ fun ImagePicker(
|
||||
// Image Source Selection Dialog
|
||||
if (showImageSourceDialog) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { showImageSourceDialog = false },
|
||||
title = { Text("Add Photo") },
|
||||
text = { Text("Choose how you'd like to add a photo") },
|
||||
confirmButton = {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
TextButton(
|
||||
onClick = {
|
||||
showImageSourceDialog = false
|
||||
imagePickerLauncher.launch("image/*")
|
||||
}
|
||||
) {
|
||||
Icon(
|
||||
Icons.Default.PhotoLibrary,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(16.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Text("Gallery")
|
||||
}
|
||||
|
||||
TextButton(
|
||||
onClick = {
|
||||
showImageSourceDialog = false
|
||||
when (ContextCompat.checkSelfPermission(
|
||||
context,
|
||||
Manifest.permission.CAMERA
|
||||
)
|
||||
) {
|
||||
PackageManager.PERMISSION_GRANTED -> {
|
||||
// Create image file for camera
|
||||
val imageFile = createImageFile(context)
|
||||
val uri =
|
||||
FileProvider.getUriForFile(
|
||||
context,
|
||||
"${context.packageName}.fileprovider",
|
||||
imageFile
|
||||
)
|
||||
cameraImageUri = uri
|
||||
cameraLauncher.launch(uri)
|
||||
}
|
||||
else -> {
|
||||
cameraPermissionLauncher.launch(
|
||||
Manifest.permission.CAMERA
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
Icon(
|
||||
Icons.Default.CameraAlt,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(16.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Text("Camera")
|
||||
}
|
||||
onDismissRequest = { showImageSourceDialog = false },
|
||||
title = { Text("Add Photo") },
|
||||
text = { Text("Choose how you'd like to add a photo") },
|
||||
confirmButton = {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
TextButton(
|
||||
onClick = {
|
||||
showImageSourceDialog = false
|
||||
imagePickerLauncher.launch("image/*")
|
||||
},
|
||||
) {
|
||||
Icon(
|
||||
Icons.Default.PhotoLibrary,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(16.dp),
|
||||
)
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Text("Gallery")
|
||||
}
|
||||
|
||||
TextButton(
|
||||
onClick = {
|
||||
showImageSourceDialog = false
|
||||
when (
|
||||
ContextCompat.checkSelfPermission(
|
||||
context,
|
||||
Manifest.permission.CAMERA,
|
||||
)
|
||||
) {
|
||||
PackageManager.PERMISSION_GRANTED -> {
|
||||
// Create image file for camera
|
||||
val imageFile = createImageFile(context)
|
||||
val uri =
|
||||
FileProvider.getUriForFile(
|
||||
context,
|
||||
"${context.packageName}.fileprovider",
|
||||
imageFile,
|
||||
)
|
||||
cameraImageUri = uri
|
||||
cameraLauncher.launch(uri)
|
||||
}
|
||||
else -> {
|
||||
cameraPermissionLauncher.launch(
|
||||
Manifest.permission.CAMERA,
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
) {
|
||||
Icon(
|
||||
Icons.Default.CameraAlt,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(16.dp),
|
||||
)
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Text("Camera")
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = { showImageSourceDialog = false }) { Text("Cancel") }
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = { showImageSourceDialog = false }) { Text("Cancel") }
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -259,25 +260,25 @@ private fun ImageItem(imagePath: String, onRemove: () -> Unit, modifier: Modifie
|
||||
|
||||
Box(modifier = modifier.size(80.dp)) {
|
||||
OrientationAwareImage(
|
||||
imagePath = imagePath,
|
||||
contentDescription = "Problem photo",
|
||||
modifier = Modifier.fillMaxSize().clip(RoundedCornerShape(8.dp)),
|
||||
contentScale = ContentScale.Crop
|
||||
imagePath = imagePath,
|
||||
contentDescription = "Problem photo",
|
||||
modifier = Modifier.fillMaxSize().clip(RoundedCornerShape(8.dp)),
|
||||
contentScale = ContentScale.Crop,
|
||||
)
|
||||
|
||||
IconButton(onClick = onRemove, modifier = Modifier.align(Alignment.TopEnd).size(24.dp)) {
|
||||
Card(
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
colors =
|
||||
CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.errorContainer
|
||||
)
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
colors =
|
||||
CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.errorContainer,
|
||||
),
|
||||
) {
|
||||
Icon(
|
||||
Icons.Default.Close,
|
||||
contentDescription = "Remove photo",
|
||||
modifier = Modifier.fillMaxSize().padding(2.dp),
|
||||
tint = MaterialTheme.colorScheme.onErrorContainer
|
||||
Icons.Default.Close,
|
||||
contentDescription = "Remove photo",
|
||||
modifier = Modifier.fillMaxSize().padding(2.dp),
|
||||
tint = MaterialTheme.colorScheme.onErrorContainer,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import androidx.compose.ui.unit.sp
|
||||
data class ChartDataPoint(
|
||||
val x: Float,
|
||||
val y: Float,
|
||||
val label: String? = null
|
||||
val label: String? = null,
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,7 @@ data class ChartStyle(
|
||||
val lineWidth: Float = 3f,
|
||||
val gridColor: Color,
|
||||
val textColor: Color,
|
||||
val backgroundColor: Color
|
||||
val backgroundColor: Color,
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -52,59 +52,59 @@ fun LineChart(
|
||||
fillColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.2f),
|
||||
gridColor = MaterialTheme.colorScheme.outline.copy(alpha = 0.3f),
|
||||
textColor = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
backgroundColor = MaterialTheme.colorScheme.surface
|
||||
backgroundColor = MaterialTheme.colorScheme.surface,
|
||||
),
|
||||
showGrid: Boolean = true,
|
||||
xAxisFormatter: (Float) -> String = { it.toString() },
|
||||
yAxisFormatter: (Float) -> String = { it.toString() }
|
||||
yAxisFormatter: (Float) -> String = { it.toString() },
|
||||
) {
|
||||
val textMeasurer = rememberTextMeasurer()
|
||||
val density = LocalDensity.current
|
||||
|
||||
|
||||
Box(modifier = modifier) {
|
||||
Canvas(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(16.dp)
|
||||
.padding(16.dp),
|
||||
) {
|
||||
if (data.isEmpty()) return@Canvas
|
||||
|
||||
|
||||
val padding = with(density) { 32.dp.toPx() }
|
||||
val chartWidth = size.width - padding * 2
|
||||
val chartHeight = size.height - padding * 2
|
||||
|
||||
|
||||
// Calculate data bounds
|
||||
val dataMinY = data.minOf { it.y }
|
||||
val dataMaxY = data.maxOf { it.y }
|
||||
|
||||
|
||||
// Add some padding to Y-axis (10% above and below the data range)
|
||||
val yPadding = if (dataMaxY == dataMinY) 1f else (dataMaxY - dataMinY) * 0.1f
|
||||
val minY = dataMinY - yPadding
|
||||
val maxY = dataMaxY + yPadding
|
||||
|
||||
|
||||
val minX = data.minOf { it.x }
|
||||
val maxX = data.maxOf { it.x }
|
||||
|
||||
|
||||
val xRange = if (maxX - minX == 0f) 1f else maxX - minX // Minimum range of 1 for single points
|
||||
val yRange = maxY - minY
|
||||
|
||||
|
||||
// Ensure we have valid ranges
|
||||
if (yRange == 0f) return@Canvas
|
||||
|
||||
|
||||
// Convert data points to screen coordinates
|
||||
val screenPoints = data.map { point ->
|
||||
val x = padding + (point.x - minX) / xRange * chartWidth
|
||||
val y = padding + chartHeight - (point.y - minY) / yRange * chartHeight
|
||||
Offset(x, y)
|
||||
}
|
||||
|
||||
|
||||
// Draw background
|
||||
drawRect(
|
||||
color = style.backgroundColor,
|
||||
topLeft = Offset(padding, padding),
|
||||
size = androidx.compose.ui.geometry.Size(chartWidth, chartHeight)
|
||||
size = androidx.compose.ui.geometry.Size(chartWidth, chartHeight),
|
||||
)
|
||||
|
||||
|
||||
// Draw grid
|
||||
if (showGrid) {
|
||||
drawGrid(
|
||||
@@ -120,49 +120,49 @@ fun LineChart(
|
||||
textColor = style.textColor,
|
||||
xAxisFormatter = xAxisFormatter,
|
||||
yAxisFormatter = yAxisFormatter,
|
||||
actualDataPoints = data
|
||||
actualDataPoints = data,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
// Draw area fill
|
||||
if (screenPoints.size > 1) {
|
||||
drawAreaFill(
|
||||
points = screenPoints,
|
||||
padding = padding,
|
||||
chartHeight = chartHeight,
|
||||
fillColor = style.fillColor
|
||||
fillColor = style.fillColor,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
// Draw line
|
||||
if (screenPoints.size > 1) {
|
||||
drawLine(
|
||||
points = screenPoints,
|
||||
lineColor = style.lineColor,
|
||||
lineWidth = style.lineWidth
|
||||
lineWidth = style.lineWidth,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
// Draw data points - more pronounced
|
||||
screenPoints.forEach { point ->
|
||||
// Draw outer circle (larger)
|
||||
drawCircle(
|
||||
color = style.lineColor,
|
||||
radius = 8f,
|
||||
center = point
|
||||
center = point,
|
||||
)
|
||||
// Draw inner circle (white center)
|
||||
drawCircle(
|
||||
color = style.backgroundColor,
|
||||
radius = 5f,
|
||||
center = point
|
||||
center = point,
|
||||
)
|
||||
// Draw border for better visibility
|
||||
drawCircle(
|
||||
color = style.lineColor,
|
||||
radius = 8f,
|
||||
center = point,
|
||||
style = Stroke(width = 2f)
|
||||
style = Stroke(width = 2f),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -182,43 +182,43 @@ private fun DrawScope.drawGrid(
|
||||
textColor: Color,
|
||||
xAxisFormatter: (Float) -> String,
|
||||
yAxisFormatter: (Float) -> String,
|
||||
actualDataPoints: List<ChartDataPoint>
|
||||
actualDataPoints: List<ChartDataPoint>,
|
||||
) {
|
||||
val textStyle = TextStyle(
|
||||
color = textColor,
|
||||
fontSize = 10.sp
|
||||
fontSize = 10.sp,
|
||||
)
|
||||
|
||||
|
||||
// Draw vertical grid lines (X-axis) - only at integer values for sessions
|
||||
val xRange = maxX - minX
|
||||
if (xRange > 0) {
|
||||
val startX = kotlin.math.ceil(minX).toInt()
|
||||
val endX = kotlin.math.floor(maxX).toInt()
|
||||
|
||||
|
||||
for (sessionNum in startX..endX) {
|
||||
val x = padding + (sessionNum.toFloat() - minX) / xRange * chartWidth
|
||||
|
||||
|
||||
// Draw grid line
|
||||
drawLine(
|
||||
color = gridColor,
|
||||
start = Offset(x, padding),
|
||||
end = Offset(x, padding + chartHeight),
|
||||
strokeWidth = 1.dp.toPx()
|
||||
strokeWidth = 1.dp.toPx(),
|
||||
)
|
||||
|
||||
|
||||
// X-axis labels removed per user request
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Draw horizontal grid lines (Y-axis) - only at actual data point values
|
||||
val yRange = maxY - minY
|
||||
if (yRange > 0) {
|
||||
// Get unique Y values from actual data points
|
||||
val actualYValues = actualDataPoints.map { kotlin.math.round(it.y).toInt() }.toSet()
|
||||
|
||||
|
||||
actualYValues.forEach { gradeValue ->
|
||||
val y = padding + chartHeight - (gradeValue.toFloat() - minY) / yRange * chartHeight
|
||||
|
||||
|
||||
// Only draw if within chart bounds
|
||||
if (y >= padding && y <= padding + chartHeight) {
|
||||
// Draw grid line
|
||||
@@ -226,9 +226,9 @@ private fun DrawScope.drawGrid(
|
||||
color = gridColor,
|
||||
start = Offset(padding, y),
|
||||
end = Offset(padding + chartWidth, y),
|
||||
strokeWidth = 1.dp.toPx()
|
||||
strokeWidth = 1.dp.toPx(),
|
||||
)
|
||||
|
||||
|
||||
// Draw label
|
||||
val text = yAxisFormatter(gradeValue.toFloat())
|
||||
val textSize = textMeasurer.measure(text, textStyle)
|
||||
@@ -238,8 +238,8 @@ private fun DrawScope.drawGrid(
|
||||
style = textStyle,
|
||||
topLeft = Offset(
|
||||
padding - textSize.size.width - 8.dp.toPx(),
|
||||
y - textSize.size.height / 2f
|
||||
)
|
||||
y - textSize.size.height / 2f,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -250,38 +250,38 @@ private fun DrawScope.drawAreaFill(
|
||||
points: List<Offset>,
|
||||
padding: Float,
|
||||
chartHeight: Float,
|
||||
fillColor: Color
|
||||
fillColor: Color,
|
||||
) {
|
||||
val bottomY = padding + chartHeight // This represents the bottom of the chart area
|
||||
|
||||
|
||||
val path = Path().apply {
|
||||
// Start from bottom-left (at chart bottom level)
|
||||
moveTo(points.first().x, bottomY)
|
||||
|
||||
|
||||
// Draw to first point
|
||||
lineTo(points.first().x, points.first().y)
|
||||
|
||||
|
||||
// Draw line through all points
|
||||
for (i in 1 until points.size) {
|
||||
lineTo(points[i].x, points[i].y)
|
||||
}
|
||||
|
||||
|
||||
// Close the path by going to bottom-right (at chart bottom level) and back to start
|
||||
lineTo(points.last().x, bottomY)
|
||||
lineTo(points.first().x, bottomY)
|
||||
close()
|
||||
}
|
||||
|
||||
|
||||
drawPath(
|
||||
path = path,
|
||||
color = fillColor
|
||||
color = fillColor,
|
||||
)
|
||||
}
|
||||
|
||||
private fun DrawScope.drawLine(
|
||||
points: List<Offset>,
|
||||
lineColor: Color,
|
||||
lineWidth: Float
|
||||
lineWidth: Float,
|
||||
) {
|
||||
val path = Path().apply {
|
||||
moveTo(points.first().x, points.first().y)
|
||||
@@ -289,14 +289,14 @@ private fun DrawScope.drawLine(
|
||||
lineTo(points[i].x, points[i].y)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
drawPath(
|
||||
path = path,
|
||||
color = lineColor,
|
||||
style = Stroke(
|
||||
width = lineWidth,
|
||||
cap = StrokeCap.Round,
|
||||
join = StrokeJoin.Round
|
||||
)
|
||||
join = StrokeJoin.Round,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -15,59 +15,59 @@ import androidx.compose.ui.window.DialogProperties
|
||||
@Composable
|
||||
fun NotificationPermissionDialog(onDismiss: () -> Unit, onRequestPermission: () -> Unit) {
|
||||
Dialog(
|
||||
onDismissRequest = onDismiss,
|
||||
properties = DialogProperties(dismissOnBackPress = false, dismissOnClickOutside = false)
|
||||
onDismissRequest = onDismiss,
|
||||
properties = DialogProperties(dismissOnBackPress = false, dismissOnClickOutside = false),
|
||||
) {
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
||||
shape = MaterialTheme.shapes.medium
|
||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
||||
shape = MaterialTheme.shapes.medium,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.padding(24.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
modifier = Modifier.padding(24.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Notifications,
|
||||
contentDescription = "Notifications",
|
||||
modifier = Modifier.size(48.dp),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
imageVector = Icons.Default.Notifications,
|
||||
contentDescription = "Notifications",
|
||||
modifier = Modifier.size(48.dp),
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
Text(
|
||||
text = "Enable Notifications",
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
fontWeight = MaterialTheme.typography.headlineSmall.fontWeight,
|
||||
textAlign = TextAlign.Center
|
||||
text = "Enable Notifications",
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
fontWeight = MaterialTheme.typography.headlineSmall.fontWeight,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
|
||||
Text(
|
||||
text =
|
||||
"Ascently needs notification permission to show your active climbing session. This helps you track your progress and ensures the session doesn't get interrupted.",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
textAlign = TextAlign.Center,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
text =
|
||||
"Ascently needs notification permission to show your active climbing session. This helps you track your progress and ensures the session doesn't get interrupted.",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
textAlign = TextAlign.Center,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
TextButton(onClick = onDismiss, modifier = Modifier.weight(1f)) {
|
||||
Text("Not Now")
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = {
|
||||
onRequestPermission()
|
||||
onDismiss()
|
||||
},
|
||||
modifier = Modifier.weight(1f)
|
||||
onClick = {
|
||||
onRequestPermission()
|
||||
onDismiss()
|
||||
},
|
||||
modifier = Modifier.weight(1f),
|
||||
) { Text("Enable") }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,39 +16,39 @@ import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import com.atridad.ascently.utils.ImageUtils
|
||||
import java.io.File
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
|
||||
@Composable
|
||||
fun OrientationAwareImage(
|
||||
imagePath: String,
|
||||
modifier: Modifier = Modifier,
|
||||
contentDescription: String? = null,
|
||||
contentScale: ContentScale = ContentScale.Fit
|
||||
imagePath: String,
|
||||
modifier: Modifier = Modifier,
|
||||
contentDescription: String? = null,
|
||||
contentScale: ContentScale = ContentScale.Fit,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
var imageBitmap by
|
||||
remember(imagePath) { mutableStateOf<androidx.compose.ui.graphics.ImageBitmap?>(null) }
|
||||
remember(imagePath) { mutableStateOf<androidx.compose.ui.graphics.ImageBitmap?>(null) }
|
||||
var isLoading by remember(imagePath) { mutableStateOf(true) }
|
||||
|
||||
LaunchedEffect(imagePath) {
|
||||
isLoading = true
|
||||
val bitmap =
|
||||
withContext(Dispatchers.IO) {
|
||||
try {
|
||||
val imageFile = ImageUtils.getImageFile(context, imagePath)
|
||||
if (!imageFile.exists()) return@withContext null
|
||||
withContext(Dispatchers.IO) {
|
||||
try {
|
||||
val imageFile = ImageUtils.getImageFile(context, imagePath)
|
||||
if (!imageFile.exists()) return@withContext null
|
||||
|
||||
val originalBitmap =
|
||||
BitmapFactory.decodeFile(imageFile.absolutePath)
|
||||
?: return@withContext null
|
||||
val correctedBitmap = correctImageOrientation(imageFile, originalBitmap)
|
||||
correctedBitmap.asImageBitmap()
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
val originalBitmap =
|
||||
BitmapFactory.decodeFile(imageFile.absolutePath)
|
||||
?: return@withContext null
|
||||
val correctedBitmap = correctImageOrientation(imageFile, originalBitmap)
|
||||
correctedBitmap.asImageBitmap()
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
imageBitmap = bitmap
|
||||
isLoading = false
|
||||
}
|
||||
@@ -59,10 +59,10 @@ fun OrientationAwareImage(
|
||||
} else {
|
||||
imageBitmap?.let { bitmap ->
|
||||
Image(
|
||||
bitmap = bitmap,
|
||||
contentDescription = contentDescription,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentScale = contentScale
|
||||
bitmap = bitmap,
|
||||
contentDescription = contentDescription,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentScale = contentScale,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -70,16 +70,16 @@ fun OrientationAwareImage(
|
||||
}
|
||||
|
||||
private fun correctImageOrientation(
|
||||
imageFile: File,
|
||||
bitmap: android.graphics.Bitmap
|
||||
imageFile: File,
|
||||
bitmap: android.graphics.Bitmap,
|
||||
): android.graphics.Bitmap {
|
||||
return try {
|
||||
val exif = ExifInterface(imageFile.absolutePath)
|
||||
val orientation =
|
||||
exif.getAttributeInt(
|
||||
ExifInterface.TAG_ORIENTATION,
|
||||
ExifInterface.ORIENTATION_NORMAL
|
||||
)
|
||||
exif.getAttributeInt(
|
||||
ExifInterface.TAG_ORIENTATION,
|
||||
ExifInterface.ORIENTATION_NORMAL,
|
||||
)
|
||||
|
||||
val matrix = Matrix()
|
||||
var needsTransform = false
|
||||
@@ -124,15 +124,15 @@ private fun correctImageOrientation(
|
||||
bitmap
|
||||
} else {
|
||||
val rotatedBitmap =
|
||||
android.graphics.Bitmap.createBitmap(
|
||||
bitmap,
|
||||
0,
|
||||
0,
|
||||
bitmap.width,
|
||||
bitmap.height,
|
||||
matrix,
|
||||
true
|
||||
)
|
||||
android.graphics.Bitmap.createBitmap(
|
||||
bitmap,
|
||||
0,
|
||||
0,
|
||||
bitmap.width,
|
||||
bitmap.height,
|
||||
matrix,
|
||||
true,
|
||||
)
|
||||
if (rotatedBitmap != bitmap) {
|
||||
bitmap.recycle()
|
||||
}
|
||||
|
||||
@@ -26,23 +26,23 @@ fun SyncIndicator(isSyncing: StateFlow<Boolean>, modifier: Modifier = Modifier)
|
||||
val syncing by isSyncing.collectAsState()
|
||||
|
||||
AnimatedVisibility(
|
||||
visible = syncing,
|
||||
enter = scaleIn() + fadeIn(),
|
||||
exit = scaleOut() + fadeOut(),
|
||||
modifier = modifier
|
||||
visible = syncing,
|
||||
enter = scaleIn() + fadeIn(),
|
||||
exit = scaleOut() + fadeOut(),
|
||||
modifier = modifier,
|
||||
) {
|
||||
Box(
|
||||
modifier =
|
||||
Modifier.size(28.dp)
|
||||
.clip(CircleShape)
|
||||
.background(MaterialTheme.colorScheme.primaryContainer, CircleShape)
|
||||
.padding(6.dp),
|
||||
contentAlignment = Alignment.Center
|
||||
modifier =
|
||||
Modifier.size(28.dp)
|
||||
.clip(CircleShape)
|
||||
.background(MaterialTheme.colorScheme.primaryContainer, CircleShape)
|
||||
.padding(6.dp),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier.size(16.dp),
|
||||
strokeWidth = 2.dp,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
modifier = Modifier.size(16.dp),
|
||||
strokeWidth = 2.dp,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,19 +36,19 @@ fun HealthConnectCard(modifier: Modifier = Modifier) {
|
||||
|
||||
// Permission launcher
|
||||
val permissionLauncher =
|
||||
rememberLauncherForActivityResult(
|
||||
contract = healthConnectManager.getPermissionRequestContract()
|
||||
) { _ ->
|
||||
coroutineScope.launch {
|
||||
val allGranted = healthConnectManager.hasAllPermissions()
|
||||
if (!allGranted) {
|
||||
errorMessage =
|
||||
"Some Health Connect permissions were not granted. Please grant all permissions to enable syncing."
|
||||
} else {
|
||||
errorMessage = null
|
||||
}
|
||||
rememberLauncherForActivityResult(
|
||||
contract = healthConnectManager.getPermissionRequestContract(),
|
||||
) { _ ->
|
||||
coroutineScope.launch {
|
||||
val allGranted = healthConnectManager.hasAllPermissions()
|
||||
if (!allGranted) {
|
||||
errorMessage =
|
||||
"Some Health Connect permissions were not granted. Please grant all permissions to enable syncing."
|
||||
} else {
|
||||
errorMessage = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check Health Connect availability on first load
|
||||
LaunchedEffect(Unit) {
|
||||
@@ -62,7 +62,7 @@ fun HealthConnectCard(modifier: Modifier = Modifier) {
|
||||
errorMessage = "Health Connect is not available on this device"
|
||||
} else if (!isCompatible) {
|
||||
errorMessage =
|
||||
"Health Connect API compatibility issue. Please update your device or the app."
|
||||
"Health Connect API compatibility issue. Please update your device or the app."
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
@@ -73,32 +73,32 @@ fun HealthConnectCard(modifier: Modifier = Modifier) {
|
||||
}
|
||||
|
||||
Card(
|
||||
modifier = modifier.fillMaxWidth(),
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
colors =
|
||||
CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceVariant
|
||||
)
|
||||
modifier = modifier.fillMaxWidth(),
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
colors =
|
||||
CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceVariant,
|
||||
),
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth().padding(20.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
modifier = Modifier.fillMaxWidth().padding(20.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
// Header with icon and title
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.HealthAndSafety,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint =
|
||||
if (isHealthConnectAvailable && isEnabled && hasPermissions) {
|
||||
MaterialTheme.colorScheme.primary
|
||||
} else {
|
||||
MaterialTheme.colorScheme.onSurfaceVariant
|
||||
}
|
||||
if (isHealthConnectAvailable && isEnabled && hasPermissions) {
|
||||
MaterialTheme.colorScheme.primary
|
||||
} else {
|
||||
MaterialTheme.colorScheme.onSurfaceVariant
|
||||
},
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.width(12.dp))
|
||||
@@ -108,40 +108,40 @@ fun HealthConnectCard(modifier: Modifier = Modifier) {
|
||||
text = "Health Connect",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
|
||||
Text(
|
||||
text =
|
||||
when {
|
||||
isLoading -> "Checking availability..."
|
||||
!isCompatible -> "API Issue"
|
||||
!isHealthConnectAvailable -> "Not available"
|
||||
isEnabled && hasPermissions -> "Connected"
|
||||
isEnabled && !hasPermissions -> "Needs permissions"
|
||||
else -> "Disabled"
|
||||
},
|
||||
when {
|
||||
isLoading -> "Checking availability..."
|
||||
!isCompatible -> "API Issue"
|
||||
!isHealthConnectAvailable -> "Not available"
|
||||
isEnabled && hasPermissions -> "Connected"
|
||||
isEnabled && !hasPermissions -> "Needs permissions"
|
||||
else -> "Disabled"
|
||||
},
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color =
|
||||
when {
|
||||
isLoading ->
|
||||
MaterialTheme.colorScheme.onSurfaceVariant.copy(
|
||||
alpha = 0.7f
|
||||
)
|
||||
when {
|
||||
isLoading ->
|
||||
MaterialTheme.colorScheme.onSurfaceVariant.copy(
|
||||
alpha = 0.7f,
|
||||
)
|
||||
|
||||
!isCompatible -> MaterialTheme.colorScheme.error
|
||||
!isHealthConnectAvailable -> MaterialTheme.colorScheme.error
|
||||
isEnabled && hasPermissions ->
|
||||
MaterialTheme.colorScheme.primary
|
||||
!isCompatible -> MaterialTheme.colorScheme.error
|
||||
!isHealthConnectAvailable -> MaterialTheme.colorScheme.error
|
||||
isEnabled && hasPermissions ->
|
||||
MaterialTheme.colorScheme.primary
|
||||
|
||||
isEnabled && !hasPermissions ->
|
||||
MaterialTheme.colorScheme.tertiary
|
||||
isEnabled && !hasPermissions ->
|
||||
MaterialTheme.colorScheme.tertiary
|
||||
|
||||
else ->
|
||||
MaterialTheme.colorScheme.onSurfaceVariant.copy(
|
||||
alpha = 0.7f
|
||||
)
|
||||
}
|
||||
else ->
|
||||
MaterialTheme.colorScheme.onSurfaceVariant.copy(
|
||||
alpha = 0.7f,
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ fun HealthConnectCard(modifier: Modifier = Modifier) {
|
||||
}
|
||||
}
|
||||
},
|
||||
enabled = isHealthConnectAvailable && !isLoading && isCompatible
|
||||
enabled = isHealthConnectAvailable && !isLoading && isCompatible,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ fun HealthConnectCard(modifier: Modifier = Modifier) {
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
|
||||
if (!hasPermissions) {
|
||||
@@ -187,12 +187,12 @@ fun HealthConnectCard(modifier: Modifier = Modifier) {
|
||||
Card(
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
colors =
|
||||
CardDefaults.cardColors(
|
||||
containerColor =
|
||||
MaterialTheme.colorScheme.errorContainer.copy(
|
||||
alpha = 0.3f
|
||||
)
|
||||
)
|
||||
CardDefaults.cardColors(
|
||||
containerColor =
|
||||
MaterialTheme.colorScheme.errorContainer.copy(
|
||||
alpha = 0.3f,
|
||||
),
|
||||
),
|
||||
) {
|
||||
Column(modifier = Modifier.fillMaxWidth().padding(16.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
@@ -200,7 +200,7 @@ fun HealthConnectCard(modifier: Modifier = Modifier) {
|
||||
imageVector = Icons.Default.Warning,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(20.dp),
|
||||
tint = MaterialTheme.colorScheme.error
|
||||
tint = MaterialTheme.colorScheme.error,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
@@ -209,7 +209,7 @@ fun HealthConnectCard(modifier: Modifier = Modifier) {
|
||||
text = "Permissions needed",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
fontWeight = FontWeight.Medium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -217,12 +217,12 @@ fun HealthConnectCard(modifier: Modifier = Modifier) {
|
||||
|
||||
Text(
|
||||
text =
|
||||
"Grant Health Connect permissions to sync your climbing sessions",
|
||||
"Grant Health Connect permissions to sync your climbing sessions",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color =
|
||||
MaterialTheme.colorScheme.onSurfaceVariant.copy(
|
||||
alpha = 0.8f
|
||||
)
|
||||
MaterialTheme.colorScheme.onSurfaceVariant.copy(
|
||||
alpha = 0.8f,
|
||||
),
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
@@ -243,7 +243,7 @@ fun HealthConnectCard(modifier: Modifier = Modifier) {
|
||||
}
|
||||
}
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) { Text("Grant Permissions") }
|
||||
}
|
||||
}
|
||||
@@ -251,10 +251,10 @@ fun HealthConnectCard(modifier: Modifier = Modifier) {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Text(
|
||||
text =
|
||||
"Sync your climbing sessions to Samsung Health, Google Fit, and other fitness apps through Health Connect.",
|
||||
"Sync your climbing sessions to Samsung Health, Google Fit, and other fitness apps through Health Connect.",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
textAlign = TextAlign.Center,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.8f)
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.8f),
|
||||
)
|
||||
}
|
||||
errorMessage?.let { error ->
|
||||
@@ -263,22 +263,22 @@ fun HealthConnectCard(modifier: Modifier = Modifier) {
|
||||
Card(
|
||||
shape = RoundedCornerShape(8.dp),
|
||||
colors =
|
||||
CardDefaults.cardColors(
|
||||
containerColor =
|
||||
MaterialTheme.colorScheme.errorContainer.copy(
|
||||
alpha = 0.5f
|
||||
)
|
||||
)
|
||||
CardDefaults.cardColors(
|
||||
containerColor =
|
||||
MaterialTheme.colorScheme.errorContainer.copy(
|
||||
alpha = 0.5f,
|
||||
),
|
||||
),
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().padding(12.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Warning,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(16.dp),
|
||||
tint = MaterialTheme.colorScheme.error
|
||||
tint = MaterialTheme.colorScheme.error,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
@@ -286,7 +286,7 @@ fun HealthConnectCard(modifier: Modifier = Modifier) {
|
||||
Text(
|
||||
text = error,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onErrorContainer
|
||||
color = MaterialTheme.colorScheme.onErrorContainer,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,27 +27,37 @@ fun AnalyticsScreen(viewModel: ClimbViewModel) {
|
||||
val attempts by viewModel.attempts.collectAsState()
|
||||
val gyms by viewModel.gyms.collectAsState()
|
||||
|
||||
val gradeDistributionData = remember(sessions, problems, attempts) {
|
||||
calculateGradeDistribution(sessions, problems, attempts)
|
||||
}
|
||||
|
||||
val favoriteGym = remember(sessions, gyms) {
|
||||
sessions.groupBy { it.gymId }.maxByOrNull { it.value.size }?.let { (gymId, sessionList) ->
|
||||
gyms.find { it.id == gymId }?.name to sessionList.size
|
||||
}
|
||||
}
|
||||
|
||||
LazyColumn(
|
||||
modifier = Modifier.fillMaxSize().padding(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
modifier = Modifier.fillMaxSize().padding(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp),
|
||||
) {
|
||||
item {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_mountains),
|
||||
contentDescription = "Ascently Logo",
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
painter = painterResource(id = R.drawable.ic_mountains),
|
||||
contentDescription = "Ascently Logo",
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
Text(
|
||||
text = "Analytics",
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.weight(1f)
|
||||
text = "Analytics",
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
SyncIndicator(isSyncing = viewModel.syncService.isSyncing)
|
||||
}
|
||||
@@ -56,30 +66,23 @@ fun AnalyticsScreen(viewModel: ClimbViewModel) {
|
||||
// Overall Stats
|
||||
item {
|
||||
OverallStatsCard(
|
||||
totalSessions = sessions.size,
|
||||
totalProblems = problems.size,
|
||||
totalAttempts = attempts.size,
|
||||
totalGyms = gyms.size
|
||||
totalSessions = sessions.size,
|
||||
totalProblems = problems.size,
|
||||
totalAttempts = attempts.size,
|
||||
totalGyms = gyms.size,
|
||||
)
|
||||
}
|
||||
|
||||
// Grade Distribution Chart
|
||||
item {
|
||||
val gradeDistributionData = calculateGradeDistribution(sessions, problems, attempts)
|
||||
GradeDistributionChartCard(gradeDistributionData = gradeDistributionData)
|
||||
}
|
||||
|
||||
// Favorite Gym
|
||||
item {
|
||||
val favoriteGym =
|
||||
sessions.groupBy { it.gymId }.maxByOrNull { it.value.size }?.let {
|
||||
(gymId, sessions) ->
|
||||
gyms.find { it.id == gymId }?.name to sessions.size
|
||||
}
|
||||
|
||||
FavoriteGymCard(
|
||||
gymName = favoriteGym?.first ?: "No sessions yet",
|
||||
sessionCount = favoriteGym?.second ?: 0
|
||||
gymName = favoriteGym?.first ?: "No sessions yet",
|
||||
sessionCount = favoriteGym?.second ?: 0,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -96,16 +99,16 @@ fun OverallStatsCard(totalSessions: Int, totalProblems: Int, totalAttempts: Int,
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(modifier = Modifier.fillMaxWidth().padding(16.dp)) {
|
||||
Text(
|
||||
text = "Overall Stats",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold
|
||||
text = "Overall Stats",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceEvenly
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceEvenly,
|
||||
) {
|
||||
StatItem(label = "Sessions", value = totalSessions.toString())
|
||||
StatItem(label = "Problems", value = totalProblems.toString())
|
||||
@@ -121,113 +124,113 @@ fun OverallStatsCard(totalSessions: Int, totalProblems: Int, totalAttempts: Int,
|
||||
fun GradeDistributionChartCard(gradeDistributionData: List<GradeDistributionDataPoint>) {
|
||||
// Find all grading systems that have been used in the data
|
||||
val usedSystems =
|
||||
remember(gradeDistributionData) {
|
||||
gradeDistributionData.map { it.difficultySystem }.distinct()
|
||||
}
|
||||
remember(gradeDistributionData) {
|
||||
gradeDistributionData.map { it.difficultySystem }.distinct()
|
||||
}
|
||||
|
||||
var selectedSystem by
|
||||
remember(usedSystems) {
|
||||
mutableStateOf(usedSystems.firstOrNull() ?: DifficultySystem.V_SCALE)
|
||||
}
|
||||
remember(usedSystems) {
|
||||
mutableStateOf(usedSystems.firstOrNull() ?: DifficultySystem.V_SCALE)
|
||||
}
|
||||
var expanded by remember { mutableStateOf(false) }
|
||||
var showAllTime by remember { mutableStateOf(true) }
|
||||
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(modifier = Modifier.fillMaxWidth().padding(16.dp)) {
|
||||
Text(
|
||||
text = "Grade Distribution",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold
|
||||
text = "Grade Distribution",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
|
||||
// Toggles section
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
// Time period toggle
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
// All Time button
|
||||
FilterChip(
|
||||
onClick = { showAllTime = true },
|
||||
label = {
|
||||
Text("All Time", style = MaterialTheme.typography.bodySmall)
|
||||
},
|
||||
selected = showAllTime,
|
||||
colors =
|
||||
FilterChipDefaults.filterChipColors(
|
||||
selectedContainerColor =
|
||||
MaterialTheme.colorScheme.primary,
|
||||
selectedLabelColor = MaterialTheme.colorScheme.onPrimary
|
||||
)
|
||||
onClick = { showAllTime = true },
|
||||
label = {
|
||||
Text("All Time", style = MaterialTheme.typography.bodySmall)
|
||||
},
|
||||
selected = showAllTime,
|
||||
colors =
|
||||
FilterChipDefaults.filterChipColors(
|
||||
selectedContainerColor =
|
||||
MaterialTheme.colorScheme.primary,
|
||||
selectedLabelColor = MaterialTheme.colorScheme.onPrimary,
|
||||
),
|
||||
)
|
||||
|
||||
// 7 Days button
|
||||
FilterChip(
|
||||
onClick = { showAllTime = false },
|
||||
label = { Text("7 Days", style = MaterialTheme.typography.bodySmall) },
|
||||
selected = !showAllTime,
|
||||
colors =
|
||||
FilterChipDefaults.filterChipColors(
|
||||
selectedContainerColor =
|
||||
MaterialTheme.colorScheme.primary,
|
||||
selectedLabelColor = MaterialTheme.colorScheme.onPrimary
|
||||
)
|
||||
onClick = { showAllTime = false },
|
||||
label = { Text("7 Days", style = MaterialTheme.typography.bodySmall) },
|
||||
selected = !showAllTime,
|
||||
colors =
|
||||
FilterChipDefaults.filterChipColors(
|
||||
selectedContainerColor =
|
||||
MaterialTheme.colorScheme.primary,
|
||||
selectedLabelColor = MaterialTheme.colorScheme.onPrimary,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
// Scale selector dropdown
|
||||
if (usedSystems.size > 1) {
|
||||
ExposedDropdownMenuBox(
|
||||
expanded = expanded,
|
||||
onExpandedChange = { expanded = !expanded }
|
||||
expanded = expanded,
|
||||
onExpandedChange = { expanded = !expanded },
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value =
|
||||
when (selectedSystem) {
|
||||
DifficultySystem.V_SCALE -> "V-Scale"
|
||||
DifficultySystem.FONT -> "Font"
|
||||
DifficultySystem.YDS -> "YDS"
|
||||
DifficultySystem.CUSTOM -> "Custom"
|
||||
},
|
||||
onValueChange = {},
|
||||
readOnly = true,
|
||||
trailingIcon = {
|
||||
ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded)
|
||||
},
|
||||
modifier =
|
||||
Modifier.menuAnchor(
|
||||
type =
|
||||
ExposedDropdownMenuAnchorType
|
||||
.PrimaryNotEditable,
|
||||
enabled = true
|
||||
)
|
||||
.width(120.dp),
|
||||
textStyle = MaterialTheme.typography.bodyMedium
|
||||
value =
|
||||
when (selectedSystem) {
|
||||
DifficultySystem.V_SCALE -> "V-Scale"
|
||||
DifficultySystem.FONT -> "Font"
|
||||
DifficultySystem.YDS -> "YDS"
|
||||
DifficultySystem.CUSTOM -> "Custom"
|
||||
},
|
||||
onValueChange = {},
|
||||
readOnly = true,
|
||||
trailingIcon = {
|
||||
ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded)
|
||||
},
|
||||
modifier =
|
||||
Modifier.menuAnchor(
|
||||
type =
|
||||
ExposedDropdownMenuAnchorType
|
||||
.PrimaryNotEditable,
|
||||
enabled = true,
|
||||
)
|
||||
.width(120.dp),
|
||||
textStyle = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
ExposedDropdownMenu(
|
||||
expanded = expanded,
|
||||
onDismissRequest = { expanded = false }
|
||||
expanded = expanded,
|
||||
onDismissRequest = { expanded = false },
|
||||
) {
|
||||
usedSystems.forEach { system ->
|
||||
DropdownMenuItem(
|
||||
text = {
|
||||
Text(
|
||||
when (system) {
|
||||
DifficultySystem.V_SCALE -> "V-Scale"
|
||||
DifficultySystem.FONT -> "Font"
|
||||
DifficultySystem.YDS -> "YDS"
|
||||
DifficultySystem.CUSTOM -> "Custom"
|
||||
}
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
selectedSystem = system
|
||||
expanded = false
|
||||
}
|
||||
text = {
|
||||
Text(
|
||||
when (system) {
|
||||
DifficultySystem.V_SCALE -> "V-Scale"
|
||||
DifficultySystem.FONT -> "Font"
|
||||
DifficultySystem.YDS -> "YDS"
|
||||
DifficultySystem.CUSTOM -> "Custom"
|
||||
},
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
selectedSystem = system
|
||||
expanded = false
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -239,89 +242,91 @@ fun GradeDistributionChartCard(gradeDistributionData: List<GradeDistributionData
|
||||
|
||||
// Filter grade distribution data by selected scale and time period
|
||||
val filteredGradeData =
|
||||
remember(gradeDistributionData, selectedSystem, showAllTime) {
|
||||
val systemFiltered =
|
||||
gradeDistributionData.filter {
|
||||
it.difficultySystem == selectedSystem
|
||||
}
|
||||
remember(gradeDistributionData, selectedSystem, showAllTime) {
|
||||
val systemFiltered =
|
||||
gradeDistributionData.filter {
|
||||
it.difficultySystem == selectedSystem
|
||||
}
|
||||
|
||||
if (showAllTime) {
|
||||
systemFiltered
|
||||
} else {
|
||||
// Filter for last 7 days
|
||||
val sevenDaysAgo = LocalDateTime.now().minusDays(7)
|
||||
systemFiltered.filter { dataPoint ->
|
||||
try {
|
||||
val attemptDate =
|
||||
DateFormatUtils.parseToLocalDateTime(dataPoint.date)
|
||||
attemptDate?.isAfter(sevenDaysAgo) == true
|
||||
} catch (_: Exception) {
|
||||
// If date parsing fails, include the data point
|
||||
true
|
||||
}
|
||||
if (showAllTime) {
|
||||
systemFiltered
|
||||
} else {
|
||||
// Filter for last 7 days
|
||||
val sevenDaysAgo = LocalDateTime.now().minusDays(7)
|
||||
systemFiltered.filter { dataPoint ->
|
||||
try {
|
||||
val attemptDate =
|
||||
DateFormatUtils.parseToLocalDateTime(dataPoint.date)
|
||||
attemptDate?.isAfter(sevenDaysAgo) == true
|
||||
} catch (_: Exception) {
|
||||
// If date parsing fails, include the data point
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (filteredGradeData.isNotEmpty()) {
|
||||
// Group by grade and sum counts
|
||||
val gradeGroups =
|
||||
filteredGradeData
|
||||
.groupBy { it.grade }
|
||||
.mapValues { (_, dataPoints) -> dataPoints.sumOf { it.count } }
|
||||
.map { (grade, count) ->
|
||||
val firstDataPoint =
|
||||
filteredGradeData.first { it.grade == grade }
|
||||
BarChartDataPoint(
|
||||
label = grade,
|
||||
value = count,
|
||||
gradeNumeric = firstDataPoint.gradeNumeric
|
||||
)
|
||||
}
|
||||
filteredGradeData
|
||||
.groupBy { it.grade }
|
||||
.mapValues { (_, dataPoints) -> dataPoints.sumOf { it.count } }
|
||||
.map { (grade, count) ->
|
||||
val firstDataPoint =
|
||||
filteredGradeData.first { it.grade == grade }
|
||||
BarChartDataPoint(
|
||||
label = grade,
|
||||
value = count,
|
||||
gradeNumeric = firstDataPoint.gradeNumeric,
|
||||
)
|
||||
}
|
||||
|
||||
BarChart(data = gradeGroups, modifier = Modifier.fillMaxWidth().height(220.dp))
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Text(
|
||||
text =
|
||||
"Successful climbs by ${when(selectedSystem) {
|
||||
text =
|
||||
"Successful climbs by ${when (selectedSystem) {
|
||||
DifficultySystem.V_SCALE -> "V-grade"
|
||||
DifficultySystem.FONT -> "Font grade"
|
||||
DifficultySystem.YDS -> "YDS grade"
|
||||
DifficultySystem.CUSTOM -> "custom grade"
|
||||
}}",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
} else {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth().height(220.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
modifier = Modifier.fillMaxWidth().height(220.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_mountains),
|
||||
contentDescription = "No data",
|
||||
modifier = Modifier.size(48.dp),
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.5f)
|
||||
painter = painterResource(id = R.drawable.ic_mountains),
|
||||
contentDescription = "No data",
|
||||
modifier = Modifier.size(48.dp),
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.5f),
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Text(
|
||||
text = "No data available.",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
text = "No data available.",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
|
||||
Text(
|
||||
text =
|
||||
if (showAllTime)
|
||||
"Complete some climbs to see your grade distribution!"
|
||||
else "No climbs in the last 7 days",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.7f)
|
||||
text =
|
||||
if (showAllTime) {
|
||||
"Complete some climbs to see your grade distribution!"
|
||||
} else {
|
||||
"No climbs in the last 7 days"
|
||||
},
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.7f),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -334,24 +339,24 @@ fun FavoriteGymCard(gymName: String, sessionCount: Int) {
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(modifier = Modifier.fillMaxWidth().padding(16.dp)) {
|
||||
Text(
|
||||
text = "Favorite Gym",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold
|
||||
text = "Favorite Gym",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Text(
|
||||
text = gymName,
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
fontWeight = FontWeight.Medium
|
||||
text = gymName,
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
fontWeight = FontWeight.Medium,
|
||||
)
|
||||
|
||||
if (sessionCount > 0) {
|
||||
Text(
|
||||
text = "$sessionCount sessions",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
text = "$sessionCount sessions",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -363,39 +368,39 @@ fun RecentActivityCard(recentSessions: Int) {
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(modifier = Modifier.fillMaxWidth().padding(16.dp)) {
|
||||
Text(
|
||||
text = "Recent Activity",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold
|
||||
text = "Recent Activity",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Text(
|
||||
text =
|
||||
if (recentSessions > 0) {
|
||||
"You've had $recentSessions recent sessions"
|
||||
} else {
|
||||
"No recent activity"
|
||||
},
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
text =
|
||||
if (recentSessions > 0) {
|
||||
"You've had $recentSessions recent sessions"
|
||||
} else {
|
||||
"No recent activity"
|
||||
},
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class GradeDistributionDataPoint(
|
||||
val date: String,
|
||||
val grade: String,
|
||||
val gradeNumeric: Int,
|
||||
val count: Int,
|
||||
val climbType: ClimbType,
|
||||
val difficultySystem: DifficultySystem
|
||||
val date: String,
|
||||
val grade: String,
|
||||
val gradeNumeric: Int,
|
||||
val count: Int,
|
||||
val climbType: ClimbType,
|
||||
val difficultySystem: DifficultySystem,
|
||||
)
|
||||
|
||||
fun calculateGradeDistribution(
|
||||
sessions: List<com.atridad.ascently.data.model.ClimbSession>,
|
||||
problems: List<com.atridad.ascently.data.model.Problem>,
|
||||
attempts: List<com.atridad.ascently.data.model.Attempt>
|
||||
sessions: List<com.atridad.ascently.data.model.ClimbSession>,
|
||||
problems: List<com.atridad.ascently.data.model.Problem>,
|
||||
attempts: List<com.atridad.ascently.data.model.Attempt>,
|
||||
): List<GradeDistributionDataPoint> {
|
||||
if (sessions.isEmpty() || problems.isEmpty() || attempts.isEmpty()) {
|
||||
return emptyList()
|
||||
@@ -403,9 +408,9 @@ fun calculateGradeDistribution(
|
||||
|
||||
// Get all successful attempts
|
||||
val successfulAttempts =
|
||||
attempts.filter {
|
||||
it.result == AttemptResult.SUCCESS || it.result == AttemptResult.FLASH
|
||||
}
|
||||
attempts.filter {
|
||||
it.result == AttemptResult.SUCCESS || it.result == AttemptResult.FLASH
|
||||
}
|
||||
|
||||
if (successfulAttempts.isEmpty()) {
|
||||
return emptyList()
|
||||
@@ -426,18 +431,18 @@ fun calculateGradeDistribution(
|
||||
gradeDistribution[key] = existing.copy(count = existing.count + 1)
|
||||
} else {
|
||||
gradeDistribution[key] =
|
||||
GradeDistributionDataPoint(
|
||||
date = attempt.timestamp,
|
||||
grade = problem.difficulty.grade,
|
||||
gradeNumeric =
|
||||
gradeToNumeric(
|
||||
problem.difficulty.system,
|
||||
problem.difficulty.grade
|
||||
),
|
||||
count = 1,
|
||||
climbType = problem.climbType,
|
||||
difficultySystem = problem.difficulty.system
|
||||
)
|
||||
GradeDistributionDataPoint(
|
||||
date = attempt.timestamp,
|
||||
grade = problem.difficulty.grade,
|
||||
gradeNumeric =
|
||||
gradeToNumeric(
|
||||
problem.difficulty.system,
|
||||
problem.difficulty.grade,
|
||||
),
|
||||
count = 1,
|
||||
climbType = problem.climbType,
|
||||
difficultySystem = problem.difficulty.system,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,21 +22,21 @@ fun GymsScreen(viewModel: ClimbViewModel, onNavigateToGymDetail: (String) -> Uni
|
||||
|
||||
Column(modifier = Modifier.fillMaxSize().padding(16.dp)) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_mountains),
|
||||
contentDescription = "Ascently Logo",
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
painter = painterResource(id = R.drawable.ic_mountains),
|
||||
contentDescription = "Ascently Logo",
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
Text(
|
||||
text = "Climbing Gyms",
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.weight(1f)
|
||||
text = "Climbing Gyms",
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
SyncIndicator(isSyncing = viewModel.syncService.isSyncing)
|
||||
}
|
||||
@@ -45,14 +45,14 @@ fun GymsScreen(viewModel: ClimbViewModel, onNavigateToGymDetail: (String) -> Uni
|
||||
|
||||
if (gyms.isEmpty()) {
|
||||
EmptyStateMessage(
|
||||
title = "No Gyms Added",
|
||||
message = "Add your favorite climbing gyms to start tracking your progress!",
|
||||
onActionClick = {},
|
||||
actionText = ""
|
||||
title = "No Gyms Added",
|
||||
message = "Add your favorite climbing gyms to start tracking your progress!",
|
||||
onActionClick = {},
|
||||
actionText = "",
|
||||
)
|
||||
} else {
|
||||
LazyColumn {
|
||||
items(gyms) { gym ->
|
||||
items(gyms, key = { it.id }) { gym ->
|
||||
GymCard(gym = gym, onClick = { onNavigateToGymDetail(gym.id) })
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
}
|
||||
@@ -67,17 +67,17 @@ fun GymCard(gym: Gym, onClick: () -> Unit) {
|
||||
Card(onClick = onClick, modifier = Modifier.fillMaxWidth()) {
|
||||
Column(modifier = Modifier.fillMaxWidth().padding(16.dp)) {
|
||||
Text(
|
||||
text = gym.name,
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
fontWeight = FontWeight.Bold
|
||||
text = gym.name,
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
|
||||
gym.location?.let { location ->
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = location,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
text = location,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -86,9 +86,9 @@ fun GymCard(gym: Gym, onClick: () -> Unit) {
|
||||
Row {
|
||||
gym.supportedClimbTypes.forEach { climbType ->
|
||||
AssistChip(
|
||||
onClick = {},
|
||||
label = { Text(climbType.displayName) },
|
||||
modifier = Modifier.padding(end = 4.dp)
|
||||
onClick = {},
|
||||
label = { Text(climbType.displayName) },
|
||||
modifier = Modifier.padding(end = 4.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -96,10 +96,10 @@ fun GymCard(gym: Gym, onClick: () -> Unit) {
|
||||
if (gym.difficultySystems.isNotEmpty()) {
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text =
|
||||
"Systems: ${gym.difficultySystems.joinToString(", ") { it.displayName }}",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
text =
|
||||
"Systems: ${gym.difficultySystems.joinToString(", ") { it.displayName }}",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -107,10 +107,10 @@ fun GymCard(gym: Gym, onClick: () -> Unit) {
|
||||
if (notes.isNotBlank()) {
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Text(
|
||||
text = notes,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 2
|
||||
text = notes,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 2,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,35 +35,36 @@ fun ProblemsScreen(viewModel: ClimbViewModel, onNavigateToProblemDetail: (String
|
||||
var selectedGym by remember { mutableStateOf<Gym?>(null) }
|
||||
|
||||
// Apply filters
|
||||
val filteredProblems =
|
||||
problems.filter { problem ->
|
||||
val climbTypeMatch = selectedClimbType?.let { it == problem.climbType } != false
|
||||
val gymMatch = selectedGym?.let { it.id == problem.gymId } != false
|
||||
climbTypeMatch && gymMatch
|
||||
}
|
||||
val filteredProblems = remember(problems, selectedClimbType, selectedGym) {
|
||||
problems.filter { problem ->
|
||||
val climbTypeMatch = selectedClimbType?.let { it == problem.climbType } != false
|
||||
val gymMatch = selectedGym?.let { it.id == problem.gymId } != false
|
||||
climbTypeMatch && gymMatch
|
||||
}
|
||||
}
|
||||
|
||||
// Separate active and inactive problems
|
||||
val activeProblems = filteredProblems.filter { it.isActive }
|
||||
val inactiveProblems = filteredProblems.filter { !it.isActive }
|
||||
val sortedProblems = activeProblems + inactiveProblems
|
||||
val activeProblems = remember(filteredProblems) { filteredProblems.filter { it.isActive } }
|
||||
val inactiveProblems = remember(filteredProblems) { filteredProblems.filter { !it.isActive } }
|
||||
val sortedProblems = remember(activeProblems, inactiveProblems) { activeProblems + inactiveProblems }
|
||||
|
||||
Column(modifier = Modifier.fillMaxSize().padding(16.dp)) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_mountains),
|
||||
contentDescription = "Ascently Logo",
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
painter = painterResource(id = R.drawable.ic_mountains),
|
||||
contentDescription = "Ascently Logo",
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
Text(
|
||||
text = "Climbing Problems",
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.weight(1f)
|
||||
text = "Climbing Problems",
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
SyncIndicator(isSyncing = viewModel.syncService.isSyncing)
|
||||
}
|
||||
@@ -75,18 +76,18 @@ fun ProblemsScreen(viewModel: ClimbViewModel, onNavigateToProblemDetail: (String
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
Text(
|
||||
text = "Filters",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold
|
||||
text = "Filters",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
|
||||
// Climb Type Filter
|
||||
Text(
|
||||
text = "Climb Type",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
fontWeight = FontWeight.Medium
|
||||
text = "Climb Type",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
fontWeight = FontWeight.Medium,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
@@ -94,16 +95,16 @@ fun ProblemsScreen(viewModel: ClimbViewModel, onNavigateToProblemDetail: (String
|
||||
LazyRow(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
item {
|
||||
FilterChip(
|
||||
onClick = { selectedClimbType = null },
|
||||
label = { Text("All Types") },
|
||||
selected = selectedClimbType == null
|
||||
onClick = { selectedClimbType = null },
|
||||
label = { Text("All Types") },
|
||||
selected = selectedClimbType == null,
|
||||
)
|
||||
}
|
||||
items(ClimbType.entries) { climbType ->
|
||||
FilterChip(
|
||||
onClick = { selectedClimbType = climbType },
|
||||
label = { Text(climbType.displayName) },
|
||||
selected = selectedClimbType == climbType
|
||||
onClick = { selectedClimbType = climbType },
|
||||
label = { Text(climbType.displayName) },
|
||||
selected = selectedClimbType == climbType,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -112,9 +113,9 @@ fun ProblemsScreen(viewModel: ClimbViewModel, onNavigateToProblemDetail: (String
|
||||
|
||||
// Gym Filter
|
||||
Text(
|
||||
text = "Gym",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
fontWeight = FontWeight.Medium
|
||||
text = "Gym",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
fontWeight = FontWeight.Medium,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
@@ -122,16 +123,16 @@ fun ProblemsScreen(viewModel: ClimbViewModel, onNavigateToProblemDetail: (String
|
||||
LazyRow(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
item {
|
||||
FilterChip(
|
||||
onClick = { selectedGym = null },
|
||||
label = { Text("All Gyms") },
|
||||
selected = selectedGym == null
|
||||
onClick = { selectedGym = null },
|
||||
label = { Text("All Gyms") },
|
||||
selected = selectedGym == null,
|
||||
)
|
||||
}
|
||||
items(gyms) { gym ->
|
||||
FilterChip(
|
||||
onClick = { selectedGym = gym },
|
||||
label = { Text(gym.name) },
|
||||
selected = selectedGym?.id == gym.id
|
||||
onClick = { selectedGym = gym },
|
||||
label = { Text(gym.name) },
|
||||
selected = selectedGym?.id == gym.id,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -140,10 +141,10 @@ fun ProblemsScreen(viewModel: ClimbViewModel, onNavigateToProblemDetail: (String
|
||||
if (selectedClimbType != null || selectedGym != null) {
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
Text(
|
||||
text =
|
||||
"Showing ${filteredProblems.size} of ${problems.size} problems (${activeProblems.size} active, ${inactiveProblems.size} reset)",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
text =
|
||||
"Showing ${filteredProblems.size} of ${problems.size} problems (${activeProblems.size} active, ${inactiveProblems.size} reset)",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -154,35 +155,37 @@ fun ProblemsScreen(viewModel: ClimbViewModel, onNavigateToProblemDetail: (String
|
||||
|
||||
if (filteredProblems.isEmpty()) {
|
||||
EmptyStateMessage(
|
||||
title =
|
||||
if (problems.isEmpty()) {
|
||||
if (gyms.isEmpty()) "No Gyms Available" else "No Problems Yet"
|
||||
} else {
|
||||
"No Problems Match Filters"
|
||||
},
|
||||
message =
|
||||
if (problems.isEmpty()) {
|
||||
if (gyms.isEmpty())
|
||||
"Add a gym first to start tracking problems and routes!"
|
||||
else "Start tracking your favorite problems and routes!"
|
||||
} else {
|
||||
"Try adjusting your filters to see more problems."
|
||||
},
|
||||
onActionClick = {},
|
||||
actionText = ""
|
||||
title =
|
||||
if (problems.isEmpty()) {
|
||||
if (gyms.isEmpty()) "No Gyms Available" else "No Problems Yet"
|
||||
} else {
|
||||
"No Problems Match Filters"
|
||||
},
|
||||
message =
|
||||
if (problems.isEmpty()) {
|
||||
if (gyms.isEmpty()) {
|
||||
"Add a gym first to start tracking problems and routes!"
|
||||
} else {
|
||||
"Start tracking your favorite problems and routes!"
|
||||
}
|
||||
} else {
|
||||
"Try adjusting your filters to see more problems."
|
||||
},
|
||||
onActionClick = {},
|
||||
actionText = "",
|
||||
)
|
||||
} else {
|
||||
LazyColumn {
|
||||
items(sortedProblems) { problem ->
|
||||
items(sortedProblems, key = { it.id }) { problem ->
|
||||
ProblemCard(
|
||||
problem = problem,
|
||||
gymName = gyms.find { it.id == problem.gymId }?.name ?: "Unknown Gym",
|
||||
attempts = attempts,
|
||||
onClick = { onNavigateToProblemDetail(problem.id) },
|
||||
onToggleActive = {
|
||||
val updatedProblem = problem.copy(isActive = !problem.isActive)
|
||||
viewModel.updateProblem(updatedProblem)
|
||||
}
|
||||
problem = problem,
|
||||
gymName = gyms.find { it.id == problem.gymId }?.name ?: "Unknown Gym",
|
||||
attempts = attempts,
|
||||
onClick = { onNavigateToProblemDetail(problem.id) },
|
||||
onToggleActive = {
|
||||
val updatedProblem = problem.copy(isActive = !problem.isActive)
|
||||
viewModel.updateProblem(updatedProblem)
|
||||
},
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
}
|
||||
@@ -194,81 +197,86 @@ fun ProblemsScreen(viewModel: ClimbViewModel, onNavigateToProblemDetail: (String
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ProblemCard(
|
||||
problem: Problem,
|
||||
gymName: String,
|
||||
attempts: List<Attempt>,
|
||||
onClick: () -> Unit,
|
||||
onToggleActive: (() -> Unit)? = null
|
||||
problem: Problem,
|
||||
gymName: String,
|
||||
attempts: List<Attempt>,
|
||||
onClick: () -> Unit,
|
||||
onToggleActive: (() -> Unit)? = null,
|
||||
) {
|
||||
val isCompleted =
|
||||
attempts.any { attempt ->
|
||||
attempt.problemId == problem.id &&
|
||||
(attempt.result == AttemptResult.SUCCESS ||
|
||||
attempt.result == AttemptResult.FLASH)
|
||||
}
|
||||
attempts.any { attempt ->
|
||||
attempt.problemId == problem.id &&
|
||||
(
|
||||
attempt.result == AttemptResult.SUCCESS ||
|
||||
attempt.result == AttemptResult.FLASH
|
||||
)
|
||||
}
|
||||
|
||||
Card(onClick = onClick, modifier = Modifier.fillMaxWidth()) {
|
||||
Column(modifier = Modifier.fillMaxWidth().padding(16.dp)) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.Top
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.Top,
|
||||
) {
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
text = problem.name ?: "Unnamed Problem",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color =
|
||||
if (problem.isActive) MaterialTheme.colorScheme.onSurface
|
||||
else MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)
|
||||
text = problem.name ?: "Unnamed Problem",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color =
|
||||
if (problem.isActive) {
|
||||
MaterialTheme.colorScheme.onSurface
|
||||
} else {
|
||||
MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)
|
||||
},
|
||||
)
|
||||
|
||||
Text(
|
||||
text = gymName,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color =
|
||||
MaterialTheme.colorScheme.onSurfaceVariant.copy(
|
||||
alpha = if (problem.isActive) 1f else 0.6f
|
||||
)
|
||||
text = gymName,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color =
|
||||
MaterialTheme.colorScheme.onSurfaceVariant.copy(
|
||||
alpha = if (problem.isActive) 1f else 0.6f,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
Column(horizontalAlignment = Alignment.End) {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
if (problem.imagePaths.isNotEmpty()) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Image,
|
||||
contentDescription = "Has images",
|
||||
modifier = Modifier.size(16.dp),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
imageVector = Icons.Default.Image,
|
||||
contentDescription = "Has images",
|
||||
modifier = Modifier.size(16.dp),
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
}
|
||||
|
||||
if (isCompleted) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.CheckCircle,
|
||||
contentDescription = "Completed",
|
||||
modifier = Modifier.size(16.dp),
|
||||
tint = MaterialTheme.colorScheme.tertiary
|
||||
imageVector = Icons.Default.CheckCircle,
|
||||
contentDescription = "Completed",
|
||||
modifier = Modifier.size(16.dp),
|
||||
tint = MaterialTheme.colorScheme.tertiary,
|
||||
)
|
||||
}
|
||||
|
||||
Text(
|
||||
text = problem.difficulty.grade,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
text = problem.difficulty.grade,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
}
|
||||
|
||||
Text(
|
||||
text = problem.climbType.displayName,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
text = problem.climbType.displayName,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -276,9 +284,9 @@ fun ProblemCard(
|
||||
problem.location?.let { location ->
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = "Location: $location",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
text = "Location: $location",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -287,9 +295,9 @@ fun ProblemCard(
|
||||
Row {
|
||||
problem.tags.take(3).forEach { tag ->
|
||||
AssistChip(
|
||||
onClick = {},
|
||||
label = { Text(tag) },
|
||||
modifier = Modifier.padding(end = 4.dp)
|
||||
onClick = {},
|
||||
label = { Text(tag) },
|
||||
modifier = Modifier.padding(end = 4.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -298,10 +306,10 @@ fun ProblemCard(
|
||||
if (!problem.isActive) {
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Text(
|
||||
text = "Reset / No Longer Set",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.tertiary,
|
||||
fontWeight = FontWeight.Medium
|
||||
text = "Reset / No Longer Set",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.tertiary,
|
||||
fontWeight = FontWeight.Medium,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -309,19 +317,21 @@ fun ProblemCard(
|
||||
if (onToggleActive != null) {
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
OutlinedButton(
|
||||
onClick = onToggleActive,
|
||||
colors =
|
||||
ButtonDefaults.outlinedButtonColors(
|
||||
contentColor =
|
||||
if (problem.isActive)
|
||||
MaterialTheme.colorScheme.tertiary
|
||||
else MaterialTheme.colorScheme.primary
|
||||
),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
onClick = onToggleActive,
|
||||
colors =
|
||||
ButtonDefaults.outlinedButtonColors(
|
||||
contentColor =
|
||||
if (problem.isActive) {
|
||||
MaterialTheme.colorScheme.tertiary
|
||||
} else {
|
||||
MaterialTheme.colorScheme.primary
|
||||
},
|
||||
),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
Text(
|
||||
text = if (problem.isActive) "Mark as Reset" else "Mark as Active",
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
text = if (problem.isActive) "Mark as Reset" else "Mark as Active",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.content.edit
|
||||
import com.atridad.ascently.R
|
||||
import com.atridad.ascently.data.model.ClimbSession
|
||||
import com.atridad.ascently.data.model.SessionStatus
|
||||
@@ -36,11 +37,10 @@ import java.time.YearMonth
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.format.TextStyle
|
||||
import java.util.Locale
|
||||
import androidx.core.content.edit
|
||||
|
||||
enum class ViewMode {
|
||||
LIST,
|
||||
CALENDAR
|
||||
CALENDAR,
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@@ -53,7 +53,7 @@ fun SessionsScreen(viewModel: ClimbViewModel, onNavigateToSessionDetail: (String
|
||||
val uiState by viewModel.uiState.collectAsState()
|
||||
|
||||
val sharedPreferences =
|
||||
context.getSharedPreferences("SessionsPreferences", Context.MODE_PRIVATE)
|
||||
context.getSharedPreferences("SessionsPreferences", Context.MODE_PRIVATE)
|
||||
val savedViewMode = sharedPreferences.getString("view_mode", "LIST")
|
||||
var viewMode by remember {
|
||||
mutableStateOf(if (savedViewMode == "CALENDAR") ViewMode.CALENDAR else ViewMode.LIST)
|
||||
@@ -61,43 +61,50 @@ fun SessionsScreen(viewModel: ClimbViewModel, onNavigateToSessionDetail: (String
|
||||
var selectedMonth by remember { mutableStateOf(YearMonth.now()) }
|
||||
var selectedDate by remember { mutableStateOf<LocalDate?>(LocalDate.now()) }
|
||||
|
||||
val completedSessions = sessions.filter { it.status == SessionStatus.COMPLETED }
|
||||
val activeSessionGym = activeSession?.let { session -> gyms.find { it.id == session.gymId } }
|
||||
val completedSessions = remember(sessions) {
|
||||
sessions.filter { it.status == SessionStatus.COMPLETED }
|
||||
}
|
||||
val activeSessionGym = remember(activeSession, gyms) {
|
||||
activeSession?.let { session -> gyms.find { it.id == session.gymId } }
|
||||
}
|
||||
|
||||
Column(modifier = Modifier.fillMaxSize().padding(16.dp)) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_mountains),
|
||||
contentDescription = "Ascently Logo",
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
painter = painterResource(id = R.drawable.ic_mountains),
|
||||
contentDescription = "Ascently Logo",
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
Text(
|
||||
text = "Climbing Sessions",
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.weight(1f)
|
||||
text = "Climbing Sessions",
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
|
||||
IconButton(
|
||||
onClick = {
|
||||
viewMode =
|
||||
if (viewMode == ViewMode.LIST) ViewMode.CALENDAR else ViewMode.LIST
|
||||
selectedDate = null
|
||||
sharedPreferences.edit { putString("view_mode", viewMode.name) }
|
||||
}
|
||||
onClick = {
|
||||
viewMode =
|
||||
if (viewMode == ViewMode.LIST) ViewMode.CALENDAR else ViewMode.LIST
|
||||
selectedDate = null
|
||||
sharedPreferences.edit { putString("view_mode", viewMode.name) }
|
||||
},
|
||||
) {
|
||||
Icon(
|
||||
imageVector =
|
||||
if (viewMode == ViewMode.LIST) Icons.Default.CalendarMonth
|
||||
else Icons.AutoMirrored.Filled.List,
|
||||
contentDescription =
|
||||
if (viewMode == ViewMode.LIST) "Calendar View" else "List View",
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
imageVector =
|
||||
if (viewMode == ViewMode.LIST) {
|
||||
Icons.Default.CalendarMonth
|
||||
} else {
|
||||
Icons.AutoMirrored.Filled.List
|
||||
},
|
||||
contentDescription =
|
||||
if (viewMode == ViewMode.LIST) "Calendar View" else "List View",
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -107,10 +114,10 @@ fun SessionsScreen(viewModel: ClimbViewModel, onNavigateToSessionDetail: (String
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
ActiveSessionBanner(
|
||||
activeSession = activeSession,
|
||||
gym = activeSessionGym,
|
||||
onSessionClick = { activeSession?.let { onNavigateToSessionDetail(it.id) } },
|
||||
onEndSession = { activeSession?.let { viewModel.endSession(context, it.id) } }
|
||||
activeSession = activeSession,
|
||||
gym = activeSessionGym,
|
||||
onSessionClick = { activeSession?.let { onNavigateToSessionDetail(it.id) } },
|
||||
onEndSession = { activeSession?.let { viewModel.endSession(context, it.id) } },
|
||||
)
|
||||
|
||||
if (activeSession != null) {
|
||||
@@ -119,24 +126,26 @@ fun SessionsScreen(viewModel: ClimbViewModel, onNavigateToSessionDetail: (String
|
||||
|
||||
if (completedSessions.isEmpty() && activeSession == null) {
|
||||
EmptyStateMessage(
|
||||
title = if (gyms.isEmpty()) "No Gyms Available" else "No Sessions Yet",
|
||||
message =
|
||||
if (gyms.isEmpty())
|
||||
"Add a gym first to start tracking your climbing sessions!"
|
||||
else "Start your first climbing session!",
|
||||
onActionClick = {},
|
||||
actionText = ""
|
||||
title = if (gyms.isEmpty()) "No Gyms Available" else "No Sessions Yet",
|
||||
message =
|
||||
if (gyms.isEmpty()) {
|
||||
"Add a gym first to start tracking your climbing sessions!"
|
||||
} else {
|
||||
"Start your first climbing session!"
|
||||
},
|
||||
onActionClick = {},
|
||||
actionText = "",
|
||||
)
|
||||
} else {
|
||||
when (viewMode) {
|
||||
ViewMode.LIST -> {
|
||||
LazyColumn {
|
||||
items(completedSessions) { session ->
|
||||
items(completedSessions, key = { it.id }) { session ->
|
||||
SessionCard(
|
||||
session = session,
|
||||
gymName = gyms.find { it.id == session.gymId }?.name
|
||||
?: "Unknown Gym",
|
||||
onClick = { onNavigateToSessionDetail(session.id) }
|
||||
session = session,
|
||||
gymName = gyms.find { it.id == session.gymId }?.name
|
||||
?: "Unknown Gym",
|
||||
onClick = { onNavigateToSessionDetail(session.id) },
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
}
|
||||
@@ -144,13 +153,13 @@ fun SessionsScreen(viewModel: ClimbViewModel, onNavigateToSessionDetail: (String
|
||||
}
|
||||
ViewMode.CALENDAR -> {
|
||||
CalendarView(
|
||||
sessions = completedSessions,
|
||||
gyms = gyms,
|
||||
sessions = completedSessions,
|
||||
gyms = gyms,
|
||||
selectedMonth = selectedMonth,
|
||||
onMonthChange = { selectedMonth = it },
|
||||
selectedDate = selectedDate,
|
||||
onDateSelected = { selectedDate = it },
|
||||
onNavigateToSessionDetail = onNavigateToSessionDetail
|
||||
onMonthChange = { selectedMonth = it },
|
||||
selectedDate = selectedDate,
|
||||
onDateSelected = { selectedDate = it },
|
||||
onNavigateToSessionDetail = onNavigateToSessionDetail,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -164,27 +173,27 @@ fun SessionsScreen(viewModel: ClimbViewModel, onNavigateToSessionDetail: (String
|
||||
}
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
||||
colors =
|
||||
CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.primaryContainer
|
||||
),
|
||||
shape = RoundedCornerShape(12.dp)
|
||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
||||
colors =
|
||||
CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
||||
),
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Icon(
|
||||
Icons.Default.CheckCircle,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
Icons.Default.CheckCircle,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(
|
||||
text = message,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onPrimaryContainer
|
||||
text = message,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -197,27 +206,27 @@ fun SessionsScreen(viewModel: ClimbViewModel, onNavigateToSessionDetail: (String
|
||||
}
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
||||
colors =
|
||||
CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.errorContainer
|
||||
),
|
||||
shape = RoundedCornerShape(12.dp)
|
||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
||||
colors =
|
||||
CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.errorContainer,
|
||||
),
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Icon(
|
||||
Icons.Default.Warning,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.error
|
||||
Icons.Default.Warning,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.error,
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(
|
||||
text = error,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onErrorContainer
|
||||
text = error,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onErrorContainer,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -227,21 +236,25 @@ fun SessionsScreen(viewModel: ClimbViewModel, onNavigateToSessionDetail: (String
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SessionCard(session: ClimbSession, gymName: String, onClick: () -> Unit) {
|
||||
val formattedDate = remember(session.date) {
|
||||
DateFormatUtils.formatDateForDisplay(session.date)
|
||||
}
|
||||
|
||||
Card(onClick = onClick, modifier = Modifier.fillMaxWidth()) {
|
||||
Column(modifier = Modifier.fillMaxWidth().padding(16.dp)) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
) {
|
||||
Text(
|
||||
text = gymName,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold
|
||||
text = gymName,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
Text(
|
||||
text = formatDate(session.date),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
text = formattedDate,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -249,8 +262,8 @@ fun SessionCard(session: ClimbSession, gymName: String, onClick: () -> Unit) {
|
||||
|
||||
session.duration?.let { duration ->
|
||||
Text(
|
||||
text = "Duration: $duration minutes",
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
text = "Duration: $duration minutes",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -258,10 +271,10 @@ fun SessionCard(session: ClimbSession, gymName: String, onClick: () -> Unit) {
|
||||
if (notes.isNotBlank()) {
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = notes,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 2
|
||||
text = notes,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 2,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -271,30 +284,30 @@ fun SessionCard(session: ClimbSession, gymName: String, onClick: () -> Unit) {
|
||||
|
||||
@Composable
|
||||
fun EmptyStateMessage(
|
||||
title: String,
|
||||
message: String,
|
||||
onActionClick: () -> Unit,
|
||||
actionText: String
|
||||
title: String,
|
||||
message: String,
|
||||
onActionClick: () -> Unit,
|
||||
actionText: String,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
fontWeight = FontWeight.Bold,
|
||||
textAlign = TextAlign.Center
|
||||
text = title,
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
fontWeight = FontWeight.Bold,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Text(
|
||||
text = message,
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Center
|
||||
text = message,
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
|
||||
if (actionText.isNotEmpty()) {
|
||||
@@ -307,64 +320,64 @@ fun EmptyStateMessage(
|
||||
|
||||
@Composable
|
||||
fun CalendarView(
|
||||
sessions: List<ClimbSession>,
|
||||
gyms: List<com.atridad.ascently.data.model.Gym>,
|
||||
selectedMonth: YearMonth,
|
||||
onMonthChange: (YearMonth) -> Unit,
|
||||
selectedDate: LocalDate?,
|
||||
onDateSelected: (LocalDate?) -> Unit,
|
||||
onNavigateToSessionDetail: (String) -> Unit
|
||||
sessions: List<ClimbSession>,
|
||||
gyms: List<com.atridad.ascently.data.model.Gym>,
|
||||
selectedMonth: YearMonth,
|
||||
onMonthChange: (YearMonth) -> Unit,
|
||||
selectedDate: LocalDate?,
|
||||
onDateSelected: (LocalDate?) -> Unit,
|
||||
onNavigateToSessionDetail: (String) -> Unit,
|
||||
) {
|
||||
val sessionsByDate =
|
||||
remember(sessions) {
|
||||
sessions.groupBy {
|
||||
try {
|
||||
java.time.Instant.parse(it.date)
|
||||
.atZone(java.time.ZoneId.systemDefault())
|
||||
.toLocalDate()
|
||||
} catch (_: Exception) {
|
||||
LocalDate.parse(it.date, DateTimeFormatter.ISO_LOCAL_DATE)
|
||||
}
|
||||
remember(sessions) {
|
||||
sessions.groupBy {
|
||||
try {
|
||||
java.time.Instant.parse(it.date)
|
||||
.atZone(java.time.ZoneId.systemDefault())
|
||||
.toLocalDate()
|
||||
} catch (_: Exception) {
|
||||
LocalDate.parse(it.date, DateTimeFormatter.ISO_LOCAL_DATE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val firstDayOfMonth = selectedMonth.atDay(1)
|
||||
val daysInMonth = selectedMonth.lengthOfMonth()
|
||||
val firstDayOfWeek = firstDayOfMonth.dayOfWeek.value % 7
|
||||
val totalCells =
|
||||
((firstDayOfWeek + daysInMonth) / 7.0).let {
|
||||
if (it == it.toInt().toDouble()) it.toInt() * 7 else (it.toInt() + 1) * 7
|
||||
}
|
||||
((firstDayOfWeek + daysInMonth) / 7.0).let {
|
||||
if (it == it.toInt().toDouble()) it.toInt() * 7 else (it.toInt() + 1) * 7
|
||||
}
|
||||
val numRows = totalCells / 7
|
||||
|
||||
LazyColumn(modifier = Modifier.fillMaxSize()) {
|
||||
item {
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors =
|
||||
CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceVariant
|
||||
)
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors =
|
||||
CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceVariant,
|
||||
),
|
||||
) {
|
||||
Column(
|
||||
modifier =
|
||||
Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
modifier =
|
||||
Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
IconButton(onClick = { onMonthChange(selectedMonth.minusMonths(1)) }) {
|
||||
Text("‹", style = MaterialTheme.typography.headlineMedium)
|
||||
}
|
||||
|
||||
Text(
|
||||
text =
|
||||
"${selectedMonth.month.getDisplayName(TextStyle.FULL, Locale.getDefault())} ${selectedMonth.year}",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold
|
||||
text =
|
||||
"${selectedMonth.month.getDisplayName(TextStyle.FULL, Locale.getDefault())} ${selectedMonth.year}",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
|
||||
IconButton(onClick = { onMonthChange(selectedMonth.plusMonths(1)) }) {
|
||||
@@ -375,22 +388,22 @@ fun CalendarView(
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Button(
|
||||
onClick = {
|
||||
val today = LocalDate.now()
|
||||
onMonthChange(YearMonth.from(today))
|
||||
onDateSelected(today)
|
||||
},
|
||||
shape = RoundedCornerShape(50),
|
||||
colors =
|
||||
ButtonDefaults.buttonColors(
|
||||
containerColor = MaterialTheme.colorScheme.primary
|
||||
),
|
||||
contentPadding = PaddingValues(horizontal = 20.dp, vertical = 8.dp)
|
||||
onClick = {
|
||||
val today = LocalDate.now()
|
||||
onMonthChange(YearMonth.from(today))
|
||||
onDateSelected(today)
|
||||
},
|
||||
shape = RoundedCornerShape(50),
|
||||
colors =
|
||||
ButtonDefaults.buttonColors(
|
||||
containerColor = MaterialTheme.colorScheme.primary,
|
||||
),
|
||||
contentPadding = PaddingValues(horizontal = 20.dp, vertical = 8.dp),
|
||||
) {
|
||||
Text(
|
||||
text = "Today",
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
fontWeight = FontWeight.SemiBold
|
||||
text = "Today",
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -401,12 +414,12 @@ fun CalendarView(
|
||||
Row(modifier = Modifier.fillMaxWidth()) {
|
||||
listOf("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat").forEach { day ->
|
||||
Text(
|
||||
text = day,
|
||||
modifier = Modifier.weight(1f),
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
fontWeight = FontWeight.Bold
|
||||
text = day,
|
||||
modifier = Modifier.weight(1f),
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -428,15 +441,15 @@ fun CalendarView(
|
||||
val isToday = date == LocalDate.now()
|
||||
|
||||
CalendarDay(
|
||||
day = dayNumber,
|
||||
hasSession = sessionsOnDate.isNotEmpty(),
|
||||
isSelected = isSelected,
|
||||
isToday = isToday,
|
||||
onClick = {
|
||||
if (sessionsOnDate.isNotEmpty()) {
|
||||
onDateSelected(if (isSelected) null else date)
|
||||
}
|
||||
day = dayNumber,
|
||||
hasSession = sessionsOnDate.isNotEmpty(),
|
||||
isSelected = isSelected,
|
||||
isToday = isToday,
|
||||
onClick = {
|
||||
if (sessionsOnDate.isNotEmpty()) {
|
||||
onDateSelected(if (isSelected) null else date)
|
||||
}
|
||||
},
|
||||
)
|
||||
} else {
|
||||
Spacer(modifier = Modifier.aspectRatio(1f))
|
||||
@@ -453,19 +466,19 @@ fun CalendarView(
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
Text(
|
||||
text =
|
||||
"Sessions on ${selectedDate.format(DateTimeFormatter.ofPattern("MMMM d, yyyy"))}",
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.padding(vertical = 8.dp)
|
||||
text =
|
||||
"Sessions on ${selectedDate.format(DateTimeFormatter.ofPattern("MMMM d, yyyy"))}",
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.padding(vertical = 8.dp),
|
||||
)
|
||||
}
|
||||
|
||||
items(sessionsOnSelectedDate) { session ->
|
||||
SessionCard(
|
||||
session = session,
|
||||
gymName = gyms.find { it.id == session.gymId }?.name ?: "Unknown Gym",
|
||||
onClick = { onNavigateToSessionDetail(session.id) }
|
||||
session = session,
|
||||
gymName = gyms.find { it.id == session.gymId }?.name ?: "Unknown Gym",
|
||||
onClick = { onNavigateToSessionDetail(session.id) },
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
}
|
||||
@@ -477,62 +490,60 @@ fun CalendarView(
|
||||
|
||||
@Composable
|
||||
fun CalendarDay(
|
||||
day: Int,
|
||||
hasSession: Boolean,
|
||||
isSelected: Boolean,
|
||||
isToday: Boolean,
|
||||
onClick: () -> Unit
|
||||
day: Int,
|
||||
hasSession: Boolean,
|
||||
isSelected: Boolean,
|
||||
isToday: Boolean,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
Box(
|
||||
modifier =
|
||||
Modifier.aspectRatio(1f)
|
||||
.padding(2.dp)
|
||||
.clip(CircleShape)
|
||||
.background(
|
||||
when {
|
||||
isSelected -> MaterialTheme.colorScheme.primaryContainer
|
||||
isToday -> MaterialTheme.colorScheme.secondaryContainer
|
||||
else -> Color.Transparent
|
||||
}
|
||||
)
|
||||
.clickable(enabled = hasSession, onClick = onClick),
|
||||
contentAlignment = Alignment.Center
|
||||
modifier =
|
||||
Modifier.aspectRatio(1f)
|
||||
.padding(2.dp)
|
||||
.clip(CircleShape)
|
||||
.background(
|
||||
when {
|
||||
isSelected -> MaterialTheme.colorScheme.primaryContainer
|
||||
isToday -> MaterialTheme.colorScheme.secondaryContainer
|
||||
else -> Color.Transparent
|
||||
},
|
||||
)
|
||||
.clickable(enabled = hasSession, onClick = onClick),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Text(
|
||||
text = day.toString(),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color =
|
||||
when {
|
||||
isSelected -> MaterialTheme.colorScheme.onPrimaryContainer
|
||||
isToday -> MaterialTheme.colorScheme.onSecondaryContainer
|
||||
!hasSession -> MaterialTheme.colorScheme.onSurfaceVariant
|
||||
else -> MaterialTheme.colorScheme.onSurface
|
||||
},
|
||||
fontWeight = if (hasSession || isToday) FontWeight.Bold else FontWeight.Normal
|
||||
text = day.toString(),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color =
|
||||
when {
|
||||
isSelected -> MaterialTheme.colorScheme.onPrimaryContainer
|
||||
isToday -> MaterialTheme.colorScheme.onSecondaryContainer
|
||||
!hasSession -> MaterialTheme.colorScheme.onSurfaceVariant
|
||||
else -> MaterialTheme.colorScheme.onSurface
|
||||
},
|
||||
fontWeight = if (hasSession || isToday) FontWeight.Bold else FontWeight.Normal,
|
||||
)
|
||||
|
||||
if (hasSession) {
|
||||
Box(
|
||||
modifier =
|
||||
Modifier.size(6.dp)
|
||||
.clip(CircleShape)
|
||||
.background(
|
||||
if (isSelected) MaterialTheme.colorScheme.primary
|
||||
else
|
||||
MaterialTheme.colorScheme.primary.copy(
|
||||
alpha = 0.7f
|
||||
)
|
||||
)
|
||||
modifier =
|
||||
Modifier.size(6.dp)
|
||||
.clip(CircleShape)
|
||||
.background(
|
||||
if (isSelected) {
|
||||
MaterialTheme.colorScheme.primary
|
||||
} else {
|
||||
MaterialTheme.colorScheme.primary.copy(
|
||||
alpha = 0.7f,
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun formatDate(dateString: String): String {
|
||||
return DateFormatUtils.formatDateForDisplay(dateString)
|
||||
}
|
||||
|
||||
@@ -63,4 +63,4 @@ val ClimbNeutralVariant30 = Color(0xFF484848)
|
||||
val ClimbNeutralVariant50 = Color(0xFF797979)
|
||||
val ClimbNeutralVariant60 = Color(0xFF939393)
|
||||
val ClimbNeutralVariant80 = Color(0xFFC7C7C7)
|
||||
val ClimbNeutralVariant90 = Color(0xFFE3E3E3)
|
||||
val ClimbNeutralVariant90 = Color(0xFFE3E3E3)
|
||||
|
||||
@@ -12,9 +12,9 @@ object CustomIcons {
|
||||
defaultWidth = 24.dp,
|
||||
defaultHeight = 24.dp,
|
||||
viewportWidth = 24f,
|
||||
viewportHeight = 24f
|
||||
viewportHeight = 24f,
|
||||
).path(
|
||||
fill = SolidColor(color)
|
||||
fill = SolidColor(color),
|
||||
) {
|
||||
moveTo(6f, 6f)
|
||||
horizontalLineTo(18f)
|
||||
|
||||
@@ -47,7 +47,7 @@ private val DarkColorScheme = darkColorScheme(
|
||||
surfaceContainerLow = ClimbNeutral10,
|
||||
surfaceContainer = ClimbNeutral12,
|
||||
surfaceContainerHigh = ClimbNeutral17,
|
||||
surfaceContainerHighest = ClimbNeutral22
|
||||
surfaceContainerHighest = ClimbNeutral22,
|
||||
)
|
||||
|
||||
// Climbing-themed light color scheme with full Material You compatibility
|
||||
@@ -84,7 +84,7 @@ private val LightColorScheme = lightColorScheme(
|
||||
surfaceContainerLow = ClimbNeutral96,
|
||||
surfaceContainer = ClimbNeutral94,
|
||||
surfaceContainerHigh = ClimbNeutral92,
|
||||
surfaceContainerHighest = ClimbNeutral90
|
||||
surfaceContainerHighest = ClimbNeutral90,
|
||||
)
|
||||
|
||||
@Composable
|
||||
@@ -93,7 +93,7 @@ fun AscentlyTheme(
|
||||
// Dynamic color is available on Android 12+ and provides full Material You theming
|
||||
// When enabled, it adapts to the user's system wallpaper colors
|
||||
dynamicColor: Boolean = true,
|
||||
content: @Composable () -> Unit
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
val colorScheme = when {
|
||||
dynamicColor && true -> {
|
||||
@@ -103,7 +103,7 @@ fun AscentlyTheme(
|
||||
darkTheme -> DarkColorScheme
|
||||
else -> LightColorScheme
|
||||
}
|
||||
|
||||
|
||||
val view = LocalView.current
|
||||
if (!view.isInEditMode) {
|
||||
SideEffect {
|
||||
@@ -116,6 +116,6 @@ fun AscentlyTheme(
|
||||
MaterialTheme(
|
||||
colorScheme = colorScheme,
|
||||
typography = Typography,
|
||||
content = content
|
||||
content = content,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,6 @@ val Typography = Typography(
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 16.sp,
|
||||
lineHeight = 24.sp,
|
||||
letterSpacing = 0.5.sp
|
||||
)
|
||||
)
|
||||
letterSpacing = 0.5.sp,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -11,14 +11,14 @@ import com.atridad.ascently.service.SessionTrackingService
|
||||
import com.atridad.ascently.utils.AppLogger
|
||||
import com.atridad.ascently.utils.ImageUtils
|
||||
import com.atridad.ascently.widget.ClimbStatsWidgetProvider
|
||||
import java.io.File
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
|
||||
class ClimbViewModel(
|
||||
private val repository: ClimbRepository,
|
||||
val syncService: SyncService,
|
||||
private val context: Context
|
||||
private val context: Context,
|
||||
) : ViewModel() {
|
||||
|
||||
// Health Connect manager
|
||||
@@ -35,7 +35,7 @@ class ClimbViewModel(
|
||||
.stateIn(
|
||||
scope = viewModelScope,
|
||||
started = SharingStarted.WhileSubscribed(),
|
||||
initialValue = emptyList()
|
||||
initialValue = emptyList(),
|
||||
)
|
||||
|
||||
val problems =
|
||||
@@ -44,7 +44,7 @@ class ClimbViewModel(
|
||||
.stateIn(
|
||||
scope = viewModelScope,
|
||||
started = SharingStarted.WhileSubscribed(),
|
||||
initialValue = emptyList()
|
||||
initialValue = emptyList(),
|
||||
)
|
||||
|
||||
val sessions =
|
||||
@@ -53,7 +53,7 @@ class ClimbViewModel(
|
||||
.stateIn(
|
||||
scope = viewModelScope,
|
||||
started = SharingStarted.WhileSubscribed(),
|
||||
initialValue = emptyList()
|
||||
initialValue = emptyList(),
|
||||
)
|
||||
|
||||
val activeSession =
|
||||
@@ -62,7 +62,7 @@ class ClimbViewModel(
|
||||
.stateIn(
|
||||
scope = viewModelScope,
|
||||
started = SharingStarted.WhileSubscribed(),
|
||||
initialValue = null
|
||||
initialValue = null,
|
||||
)
|
||||
|
||||
val attempts =
|
||||
@@ -71,7 +71,7 @@ class ClimbViewModel(
|
||||
.stateIn(
|
||||
scope = viewModelScope,
|
||||
started = SharingStarted.WhileSubscribed(),
|
||||
initialValue = emptyList()
|
||||
initialValue = emptyList(),
|
||||
)
|
||||
|
||||
// Gym operations
|
||||
@@ -243,7 +243,7 @@ class ClimbViewModel(
|
||||
_uiState.value =
|
||||
_uiState.value.copy(
|
||||
error =
|
||||
"Notification permission is required to track your climbing session. Please enable notifications in settings."
|
||||
"Notification permission is required to track your climbing session. Please enable notifications in settings.",
|
||||
)
|
||||
return@launch
|
||||
}
|
||||
@@ -253,7 +253,7 @@ class ClimbViewModel(
|
||||
AppLogger.d("ClimbViewModel") { "Active session already exists: ${existingActive.id}" }
|
||||
_uiState.value =
|
||||
_uiState.value.copy(
|
||||
error = "There's already an active session. Please end it first."
|
||||
error = "There's already an active session. Please end it first.",
|
||||
)
|
||||
return@launch
|
||||
}
|
||||
@@ -281,7 +281,7 @@ class ClimbViewModel(
|
||||
_uiState.value =
|
||||
_uiState.value.copy(
|
||||
error =
|
||||
"Notification permission is required to manage your climbing session. Please enable notifications in settings."
|
||||
"Notification permission is required to manage your climbing session. Please enable notifications in settings.",
|
||||
)
|
||||
return@launch
|
||||
}
|
||||
@@ -354,20 +354,20 @@ class ClimbViewModel(
|
||||
_uiState.value =
|
||||
_uiState.value.copy(
|
||||
isLoading = true,
|
||||
message = "Creating ZIP file with images..."
|
||||
message = "Creating ZIP file with images...",
|
||||
)
|
||||
repository.exportAllDataToZipUri(context, uri)
|
||||
_uiState.value =
|
||||
_uiState.value.copy(
|
||||
isLoading = false,
|
||||
message =
|
||||
"Export complete! Your climbing data and images have been saved."
|
||||
"Export complete! Your climbing data and images have been saved.",
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
_uiState.value =
|
||||
_uiState.value.copy(
|
||||
isLoading = false,
|
||||
error = "Export failed: ${e.message}"
|
||||
error = "Export failed: ${e.message}",
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -380,7 +380,7 @@ class ClimbViewModel(
|
||||
|
||||
if (!file.name.lowercase().endsWith(".zip")) {
|
||||
throw Exception(
|
||||
"Only ZIP files are supported for import. Please use a ZIP file exported from Ascently."
|
||||
"Only ZIP files are supported for import. Please use a ZIP file exported from Ascently.",
|
||||
)
|
||||
}
|
||||
|
||||
@@ -389,13 +389,13 @@ class ClimbViewModel(
|
||||
_uiState.value =
|
||||
_uiState.value.copy(
|
||||
isLoading = false,
|
||||
message = "Data imported successfully from ${file.name}"
|
||||
message = "Data imported successfully from ${file.name}",
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
_uiState.value =
|
||||
_uiState.value.copy(
|
||||
isLoading = false,
|
||||
error = "Import failed: ${e.message}"
|
||||
error = "Import failed: ${e.message}",
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -447,7 +447,7 @@ class ClimbViewModel(
|
||||
_uiState.value =
|
||||
_uiState.value.copy(
|
||||
isLoading = false,
|
||||
message = "All data has been reset successfully"
|
||||
message = "All data has been reset successfully",
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
_uiState.value =
|
||||
@@ -469,7 +469,7 @@ class ClimbViewModel(
|
||||
healthConnectManager.autoSyncCompletedSession(
|
||||
session,
|
||||
gymName,
|
||||
attemptCount
|
||||
attemptCount,
|
||||
)
|
||||
|
||||
result.onFailure { error ->
|
||||
@@ -489,5 +489,5 @@ class ClimbViewModel(
|
||||
data class ClimbUiState(
|
||||
val isLoading: Boolean = false,
|
||||
val message: String? = null,
|
||||
val error: String? = null
|
||||
val error: String? = null,
|
||||
)
|
||||
|
||||
@@ -7,9 +7,9 @@ import com.atridad.ascently.data.repository.ClimbRepository
|
||||
import com.atridad.ascently.data.sync.SyncService
|
||||
|
||||
class ClimbViewModelFactory(
|
||||
private val repository: ClimbRepository,
|
||||
private val syncService: SyncService,
|
||||
private val context: Context
|
||||
private val repository: ClimbRepository,
|
||||
private val syncService: SyncService,
|
||||
private val context: Context,
|
||||
) : ViewModelProvider.Factory {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
||||
@@ -11,7 +11,7 @@ object AppLogger {
|
||||
DEBUG(Log.DEBUG),
|
||||
INFO(Log.INFO),
|
||||
WARN(Log.WARN),
|
||||
ERROR(Log.ERROR)
|
||||
ERROR(Log.ERROR),
|
||||
}
|
||||
|
||||
fun d(tag: String = DEFAULT_TAG, messageProvider: () -> String) {
|
||||
@@ -34,7 +34,7 @@ object AppLogger {
|
||||
level: Level,
|
||||
tag: String,
|
||||
messageProvider: () -> String,
|
||||
throwable: Throwable? = null
|
||||
throwable: Throwable? = null,
|
||||
) {
|
||||
if (!BuildConfig.DEBUG) return
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ object DateFormatUtils {
|
||||
|
||||
// ISO 8601 formatter matching iOS date format exactly
|
||||
private val ISO_FORMATTER =
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX").withZone(ZoneOffset.UTC)
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX").withZone(ZoneOffset.UTC)
|
||||
|
||||
/** Get current timestamp in iOS-compatible ISO 8601 format */
|
||||
fun nowISO8601(): String {
|
||||
@@ -22,7 +22,6 @@ object DateFormatUtils {
|
||||
return try {
|
||||
Instant.from(ISO_FORMATTER.parse(dateString))
|
||||
} catch (_: Exception) {
|
||||
|
||||
try {
|
||||
Instant.parse(dateString)
|
||||
} catch (_: Exception) {
|
||||
|
||||
@@ -13,7 +13,7 @@ object ImageNamingUtils {
|
||||
|
||||
/** Generates a deterministic filename for a problem image */
|
||||
fun generateImageFilename(problemId: String, imageIndex: Int): String {
|
||||
val input = "${problemId}_${imageIndex}"
|
||||
val input = "${problemId}_$imageIndex"
|
||||
val hash = createHash(input)
|
||||
|
||||
return "problem_${hash}_${imageIndex}${IMAGE_EXTENSION}"
|
||||
|
||||
@@ -32,7 +32,7 @@ object ImageUtils {
|
||||
context: Context,
|
||||
imageUri: Uri,
|
||||
originalBitmap: Bitmap,
|
||||
outputFile: File
|
||||
outputFile: File,
|
||||
): Boolean {
|
||||
return try {
|
||||
// Get EXIF data from original image
|
||||
@@ -147,12 +147,16 @@ object ImageUtils {
|
||||
val imagesDir = getImagesDirectory(context)
|
||||
imagesDir.listFiles()?.mapNotNull { file ->
|
||||
if (file.isFile &&
|
||||
(file.extension == "jpg" ||
|
||||
(
|
||||
file.extension == "jpg" ||
|
||||
file.extension == "jpeg" ||
|
||||
file.extension == "png")
|
||||
file.extension == "png"
|
||||
)
|
||||
) {
|
||||
"$IMAGES_DIR/${file.name}"
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
?: emptyList()
|
||||
} catch (e: Exception) {
|
||||
@@ -187,7 +191,7 @@ object ImageUtils {
|
||||
context: Context,
|
||||
tempFilename: String,
|
||||
problemId: String,
|
||||
imageIndex: Int
|
||||
imageIndex: Int,
|
||||
): String? {
|
||||
return try {
|
||||
val tempFile = File(getImagesDirectory(context), tempFilename)
|
||||
@@ -217,7 +221,7 @@ object ImageUtils {
|
||||
fun saveImageFromBytesWithFilename(
|
||||
context: Context,
|
||||
imageData: ByteArray,
|
||||
filename: String
|
||||
filename: String,
|
||||
): String? {
|
||||
return try {
|
||||
val imageFile = File(getImagesDirectory(context), filename)
|
||||
|
||||
@@ -51,7 +51,7 @@ class MigrationManager(private val context: Context) {
|
||||
"openclimb_data_state" to "ascently_data_state",
|
||||
"health_connect_prefs" to "health_connect_prefs", // Keep same name
|
||||
"deleted_items" to "deleted_items", // Keep same name
|
||||
"sync_preferences" to "sync_preferences" // Keep same name
|
||||
"sync_preferences" to "sync_preferences", // Keep same name
|
||||
)
|
||||
|
||||
for ((oldFileName, newFileName) in preferenceFileMigrations) {
|
||||
@@ -82,7 +82,8 @@ class MigrationManager(private val context: Context) {
|
||||
is Float -> putFloat(key, value)
|
||||
is Boolean -> putBoolean(key, value)
|
||||
is Set<*> -> {
|
||||
@Suppress("UNCHECKED_CAST") putStringSet(key, value as Set<String>)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
putStringSet(key, value as Set<String>)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,7 +109,7 @@ class MigrationManager(private val context: Context) {
|
||||
"ascently_data_state",
|
||||
"health_connect_prefs",
|
||||
"deleted_items",
|
||||
"sync_preferences"
|
||||
"sync_preferences",
|
||||
)
|
||||
|
||||
for (prefFileName in preferencesToCheck) {
|
||||
|
||||
@@ -6,24 +6,24 @@ import android.content.pm.PackageManager
|
||||
import androidx.core.content.ContextCompat
|
||||
|
||||
object NotificationPermissionUtils {
|
||||
|
||||
|
||||
/**
|
||||
* Check if notification permission is granted
|
||||
*/
|
||||
fun isNotificationPermissionGranted(context: Context): Boolean {
|
||||
return ContextCompat.checkSelfPermission(
|
||||
context,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
Manifest.permission.POST_NOTIFICATIONS,
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if notification permission should be requested
|
||||
*/
|
||||
fun shouldRequestNotificationPermission(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the notification permission string
|
||||
*/
|
||||
|
||||
@@ -20,10 +20,10 @@ object AppShortcutManager {
|
||||
|
||||
/** Updates the app shortcuts based on current session state */
|
||||
fun updateShortcuts(
|
||||
context: Context,
|
||||
hasActiveSession: Boolean,
|
||||
hasGyms: Boolean,
|
||||
lastUsedGym: com.atridad.ascently.data.model.Gym? = null
|
||||
context: Context,
|
||||
hasActiveSession: Boolean,
|
||||
hasGyms: Boolean,
|
||||
lastUsedGym: com.atridad.ascently.data.model.Gym? = null,
|
||||
) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||
val shortcutManager = context.getSystemService(ShortcutManager::class.java)
|
||||
@@ -44,52 +44,52 @@ object AppShortcutManager {
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N_MR1)
|
||||
private fun createStartSessionShortcut(
|
||||
context: Context,
|
||||
lastUsedGym: com.atridad.ascently.data.model.Gym? = null
|
||||
context: Context,
|
||||
lastUsedGym: com.atridad.ascently.data.model.Gym? = null,
|
||||
): ShortcutInfo {
|
||||
val startIntent =
|
||||
Intent(context, MainActivity::class.java).apply {
|
||||
action = ACTION_START_SESSION
|
||||
flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
lastUsedGym?.let { gym -> putExtra("LAST_USED_GYM_ID", gym.id) }
|
||||
}
|
||||
Intent(context, MainActivity::class.java).apply {
|
||||
action = ACTION_START_SESSION
|
||||
flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
lastUsedGym?.let { gym -> putExtra("LAST_USED_GYM_ID", gym.id) }
|
||||
}
|
||||
|
||||
val shortLabel =
|
||||
if (lastUsedGym != null) {
|
||||
"Start at ${lastUsedGym.name}"
|
||||
} else {
|
||||
context.getString(R.string.shortcut_start_session_short)
|
||||
}
|
||||
if (lastUsedGym != null) {
|
||||
"Start at ${lastUsedGym.name}"
|
||||
} else {
|
||||
context.getString(R.string.shortcut_start_session_short)
|
||||
}
|
||||
|
||||
val longLabel =
|
||||
if (lastUsedGym != null) {
|
||||
"Start a new climbing session at ${lastUsedGym.name}"
|
||||
} else {
|
||||
context.getString(R.string.shortcut_start_session_long)
|
||||
}
|
||||
if (lastUsedGym != null) {
|
||||
"Start a new climbing session at ${lastUsedGym.name}"
|
||||
} else {
|
||||
context.getString(R.string.shortcut_start_session_long)
|
||||
}
|
||||
|
||||
return ShortcutInfo.Builder(context, SHORTCUT_START_SESSION)
|
||||
.setShortLabel(shortLabel)
|
||||
.setLongLabel(longLabel)
|
||||
.setIcon(Icon.createWithResource(context, R.drawable.ic_play_arrow_24))
|
||||
.setIntent(startIntent)
|
||||
.build()
|
||||
.setShortLabel(shortLabel)
|
||||
.setLongLabel(longLabel)
|
||||
.setIcon(Icon.createWithResource(context, R.drawable.ic_play_arrow_24))
|
||||
.setIntent(startIntent)
|
||||
.build()
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N_MR1)
|
||||
private fun createEndSessionShortcut(context: Context): ShortcutInfo {
|
||||
val endIntent =
|
||||
Intent(context, MainActivity::class.java).apply {
|
||||
action = ACTION_END_SESSION
|
||||
flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
}
|
||||
Intent(context, MainActivity::class.java).apply {
|
||||
action = ACTION_END_SESSION
|
||||
flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
}
|
||||
|
||||
return ShortcutInfo.Builder(context, SHORTCUT_END_SESSION)
|
||||
.setShortLabel(context.getString(R.string.shortcut_end_session_short))
|
||||
.setLongLabel(context.getString(R.string.shortcut_end_session_long))
|
||||
.setIcon(Icon.createWithResource(context, R.drawable.ic_stop_24))
|
||||
.setIntent(endIntent)
|
||||
.build()
|
||||
.setShortLabel(context.getString(R.string.shortcut_end_session_short))
|
||||
.setLongLabel(context.getString(R.string.shortcut_end_session_long))
|
||||
.setIcon(Icon.createWithResource(context, R.drawable.ic_stop_24))
|
||||
.setIntent(endIntent)
|
||||
.build()
|
||||
}
|
||||
|
||||
/** Removes all dynamic shortcuts */
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.atridad.ascently.utils
|
||||
import android.content.Context
|
||||
import com.atridad.ascently.data.format.BackupProblem
|
||||
import com.atridad.ascently.data.format.ClimbDataBackup
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileOutputStream
|
||||
@@ -11,8 +13,6 @@ import java.time.LocalDateTime
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipInputStream
|
||||
import java.util.zip.ZipOutputStream
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
object ZipExportImportUtils {
|
||||
|
||||
@@ -25,15 +25,15 @@ object ZipExportImportUtils {
|
||||
context: Context,
|
||||
exportData: ClimbDataBackup,
|
||||
referencedImagePaths: Set<String>,
|
||||
directory: File? = null
|
||||
directory: File? = null,
|
||||
): File {
|
||||
val exportDir =
|
||||
directory
|
||||
?: File(
|
||||
context.getExternalFilesDir(
|
||||
android.os.Environment.DIRECTORY_DOCUMENTS
|
||||
android.os.Environment.DIRECTORY_DOCUMENTS,
|
||||
),
|
||||
"Ascently"
|
||||
"Ascently",
|
||||
)
|
||||
if (!exportDir.exists()) {
|
||||
exportDir.mkdirs()
|
||||
@@ -92,7 +92,7 @@ object ZipExportImportUtils {
|
||||
|
||||
// Log export summary
|
||||
AppLogger.i("ZipExportImportUtils") {
|
||||
"Export completed: ${successfulImages}/${referencedImagePaths.size} images included"
|
||||
"Export completed: $successfulImages/${referencedImagePaths.size} images included"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ object ZipExportImportUtils {
|
||||
context: Context,
|
||||
uri: android.net.Uri,
|
||||
exportData: ClimbDataBackup,
|
||||
referencedImagePaths: Set<String>
|
||||
referencedImagePaths: Set<String>,
|
||||
) {
|
||||
try {
|
||||
context.contentResolver.openOutputStream(uri)?.use { outputStream ->
|
||||
@@ -164,7 +164,7 @@ object ZipExportImportUtils {
|
||||
}
|
||||
|
||||
AppLogger.i("ZipExportImportUtils") {
|
||||
"Export to URI completed: ${successfulImages}/${referencedImagePaths.size} images included"
|
||||
"Export to URI completed: $successfulImages/${referencedImagePaths.size} images included"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,7 +176,7 @@ object ZipExportImportUtils {
|
||||
|
||||
private fun createMetadata(
|
||||
exportData: ClimbDataBackup,
|
||||
referencedImagePaths: Set<String>
|
||||
referencedImagePaths: Set<String>,
|
||||
): String {
|
||||
return buildString {
|
||||
appendLine("Ascently Export Metadata")
|
||||
@@ -195,7 +195,7 @@ object ZipExportImportUtils {
|
||||
/** Data class to hold extraction results */
|
||||
data class ImportResult(
|
||||
val jsonContent: String,
|
||||
val importedImagePaths: Map<String, String> // original filename -> new relative path
|
||||
val importedImagePaths: Map<String, String>, // original filename -> new relative path
|
||||
)
|
||||
|
||||
/** Extracts a ZIP file and returns the JSON content and imported image paths */
|
||||
@@ -235,7 +235,7 @@ object ZipExportImportUtils {
|
||||
File.createTempFile(
|
||||
"import_image_",
|
||||
"_$originalFilename",
|
||||
context.cacheDir
|
||||
context.cacheDir,
|
||||
)
|
||||
|
||||
FileOutputStream(tempFile).use { output -> zipIn.copyTo(output) }
|
||||
@@ -306,7 +306,7 @@ object ZipExportImportUtils {
|
||||
*/
|
||||
fun updateProblemImagePaths(
|
||||
problems: List<BackupProblem>,
|
||||
imagePathMapping: Map<String, String>
|
||||
imagePathMapping: Map<String, String>,
|
||||
): List<BackupProblem> {
|
||||
return problems.map { problem ->
|
||||
val updatedImagePaths =
|
||||
|
||||
@@ -11,12 +11,12 @@ import com.atridad.ascently.MainActivity
|
||||
import com.atridad.ascently.R
|
||||
import com.atridad.ascently.data.database.AscentlyDatabase
|
||||
import com.atridad.ascently.data.repository.ClimbRepository
|
||||
import java.time.LocalDate
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.launch
|
||||
import java.time.LocalDate
|
||||
|
||||
class ClimbStatsWidgetProvider : AppWidgetProvider() {
|
||||
|
||||
@@ -24,9 +24,9 @@ class ClimbStatsWidgetProvider : AppWidgetProvider() {
|
||||
private val coroutineScope = CoroutineScope(Dispatchers.IO + job)
|
||||
|
||||
override fun onUpdate(
|
||||
context: Context,
|
||||
appWidgetManager: AppWidgetManager,
|
||||
appWidgetIds: IntArray
|
||||
context: Context,
|
||||
appWidgetManager: AppWidgetManager,
|
||||
appWidgetIds: IntArray,
|
||||
) {
|
||||
for (appWidgetId in appWidgetIds) {
|
||||
updateAppWidget(context, appWidgetManager, appWidgetId)
|
||||
@@ -40,9 +40,9 @@ class ClimbStatsWidgetProvider : AppWidgetProvider() {
|
||||
}
|
||||
|
||||
private fun updateAppWidget(
|
||||
context: Context,
|
||||
appWidgetManager: AppWidgetManager,
|
||||
appWidgetId: Int
|
||||
context: Context,
|
||||
appWidgetManager: AppWidgetManager,
|
||||
appWidgetId: Int,
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
try {
|
||||
@@ -59,20 +59,20 @@ class ClimbStatsWidgetProvider : AppWidgetProvider() {
|
||||
|
||||
// Filter for last 7 days across all gyms
|
||||
val weekSessions =
|
||||
sessions.filter { session ->
|
||||
try {
|
||||
val sessionDate = LocalDate.parse(session.date.substring(0, 10))
|
||||
!sessionDate.isBefore(sevenDaysAgo) && !sessionDate.isAfter(today)
|
||||
} catch (_: Exception) {
|
||||
false
|
||||
}
|
||||
sessions.filter { session ->
|
||||
try {
|
||||
val sessionDate = LocalDate.parse(session.date.substring(0, 10))
|
||||
!sessionDate.isBefore(sevenDaysAgo) && !sessionDate.isAfter(today)
|
||||
} catch (_: Exception) {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
val weekSessionIds = weekSessions.map { it.id }.toSet()
|
||||
|
||||
// Count total attempts this week
|
||||
val totalAttempts =
|
||||
attempts.count { attempt -> weekSessionIds.contains(attempt.sessionId) }
|
||||
attempts.count { attempt -> weekSessionIds.contains(attempt.sessionId) }
|
||||
|
||||
// Count sessions this week
|
||||
val totalSessions = weekSessions.size
|
||||
@@ -85,19 +85,19 @@ class ClimbStatsWidgetProvider : AppWidgetProvider() {
|
||||
views.setTextViewText(R.id.widget_sessions_value, totalSessions.toString())
|
||||
|
||||
val intent =
|
||||
Intent(context, MainActivity::class.java).apply {
|
||||
flags =
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK or
|
||||
Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
}
|
||||
Intent(context, MainActivity::class.java).apply {
|
||||
flags =
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK or
|
||||
Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
}
|
||||
val pendingIntent =
|
||||
PendingIntent.getActivity(
|
||||
context,
|
||||
0,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or
|
||||
PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
PendingIntent.getActivity(
|
||||
context,
|
||||
0,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or
|
||||
PendingIntent.FLAG_IMMUTABLE,
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.widget_container, pendingIntent)
|
||||
|
||||
appWidgetManager.updateAppWidget(appWidgetId, views)
|
||||
@@ -110,13 +110,13 @@ class ClimbStatsWidgetProvider : AppWidgetProvider() {
|
||||
|
||||
val intent = Intent(context, MainActivity::class.java)
|
||||
val pendingIntent =
|
||||
PendingIntent.getActivity(
|
||||
context,
|
||||
0,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or
|
||||
PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
PendingIntent.getActivity(
|
||||
context,
|
||||
0,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or
|
||||
PendingIntent.FLAG_IMMUTABLE,
|
||||
)
|
||||
views.setOnClickPendingIntent(R.id.widget_container, pendingIntent)
|
||||
|
||||
appWidgetManager.updateAppWidget(appWidgetId, views)
|
||||
@@ -132,10 +132,10 @@ class ClimbStatsWidgetProvider : AppWidgetProvider() {
|
||||
val appWidgetIds = appWidgetManager.getAppWidgetIds(componentName)
|
||||
|
||||
val intent =
|
||||
Intent(context, ClimbStatsWidgetProvider::class.java).apply {
|
||||
action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
|
||||
putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds)
|
||||
}
|
||||
Intent(context, ClimbStatsWidgetProvider::class.java).apply {
|
||||
action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
|
||||
putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds)
|
||||
}
|
||||
context.sendBroadcast(intent)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.atridad.ascently
|
||||
|
||||
import com.atridad.ascently.data.format.*
|
||||
import com.atridad.ascently.data.model.*
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
class BusinessLogicTests {
|
||||
|
||||
@@ -21,11 +21,11 @@ class BusinessLogicTests {
|
||||
assertNull(session.duration)
|
||||
|
||||
val completedSession =
|
||||
session.copy(
|
||||
status = SessionStatus.COMPLETED,
|
||||
endTime = getCurrentTimestamp(),
|
||||
duration = 7200L
|
||||
)
|
||||
session.copy(
|
||||
status = SessionStatus.COMPLETED,
|
||||
endTime = getCurrentTimestamp(),
|
||||
duration = 7200L,
|
||||
)
|
||||
assertEquals(SessionStatus.COMPLETED, completedSession.status)
|
||||
assertNotNull(completedSession.endTime)
|
||||
assertNotNull(completedSession.duration)
|
||||
@@ -38,12 +38,12 @@ class BusinessLogicTests {
|
||||
val session = ClimbSession.create(gym.id)
|
||||
|
||||
val attempt =
|
||||
Attempt.create(
|
||||
sessionId = session.id,
|
||||
problemId = problem.id,
|
||||
result = AttemptResult.SUCCESS,
|
||||
notes = "Clean send!"
|
||||
)
|
||||
Attempt.create(
|
||||
sessionId = session.id,
|
||||
problemId = problem.id,
|
||||
result = AttemptResult.SUCCESS,
|
||||
notes = "Clean send!",
|
||||
)
|
||||
|
||||
assertEquals(session.id, attempt.sessionId)
|
||||
assertEquals(problem.id, attempt.problemId)
|
||||
@@ -76,12 +76,12 @@ class BusinessLogicTests {
|
||||
val problem2 = createTestProblem(gym.id)
|
||||
|
||||
val attempts =
|
||||
listOf(
|
||||
Attempt.create(session.id, problem1.id, AttemptResult.SUCCESS),
|
||||
Attempt.create(session.id, problem1.id, AttemptResult.FALL),
|
||||
Attempt.create(session.id, problem2.id, AttemptResult.FLASH),
|
||||
Attempt.create(session.id, problem2.id, AttemptResult.SUCCESS)
|
||||
)
|
||||
listOf(
|
||||
Attempt.create(session.id, problem1.id, AttemptResult.SUCCESS),
|
||||
Attempt.create(session.id, problem1.id, AttemptResult.FALL),
|
||||
Attempt.create(session.id, problem2.id, AttemptResult.FLASH),
|
||||
Attempt.create(session.id, problem2.id, AttemptResult.SUCCESS),
|
||||
)
|
||||
|
||||
val sessionStats = calculateSessionStatistics(session, attempts)
|
||||
|
||||
@@ -97,17 +97,17 @@ class BusinessLogicTests {
|
||||
val session = ClimbSession.create(gym.id)
|
||||
|
||||
val problems =
|
||||
listOf(
|
||||
createTestProblemWithGrade(gym.id, "V3"),
|
||||
createTestProblemWithGrade(gym.id, "V4"),
|
||||
createTestProblemWithGrade(gym.id, "V5"),
|
||||
createTestProblemWithGrade(gym.id, "V6")
|
||||
)
|
||||
listOf(
|
||||
createTestProblemWithGrade(gym.id, "V3"),
|
||||
createTestProblemWithGrade(gym.id, "V4"),
|
||||
createTestProblemWithGrade(gym.id, "V5"),
|
||||
createTestProblemWithGrade(gym.id, "V6"),
|
||||
)
|
||||
|
||||
val attempts =
|
||||
problems.map { problem ->
|
||||
Attempt.create(session.id, problem.id, AttemptResult.SUCCESS)
|
||||
}
|
||||
problems.map { problem ->
|
||||
Attempt.create(session.id, problem.id, AttemptResult.SUCCESS)
|
||||
}
|
||||
|
||||
val progression = calculateDifficultyProgression(attempts, problems)
|
||||
|
||||
@@ -123,17 +123,17 @@ class BusinessLogicTests {
|
||||
val problems = listOf(createTestProblem(gym.id), createTestProblem(gym.id))
|
||||
val session = ClimbSession.create(gym.id)
|
||||
val attempts =
|
||||
problems.map { problem ->
|
||||
Attempt.create(session.id, problem.id, AttemptResult.SUCCESS)
|
||||
}
|
||||
problems.map { problem ->
|
||||
Attempt.create(session.id, problem.id, AttemptResult.SUCCESS)
|
||||
}
|
||||
|
||||
val backup =
|
||||
createBackupData(
|
||||
gyms = listOf(gym),
|
||||
problems = problems,
|
||||
sessions = listOf(session),
|
||||
attempts = attempts
|
||||
)
|
||||
createBackupData(
|
||||
gyms = listOf(gym),
|
||||
problems = problems,
|
||||
sessions = listOf(session),
|
||||
attempts = attempts,
|
||||
)
|
||||
|
||||
validateBackupIntegrity(backup)
|
||||
|
||||
@@ -146,30 +146,30 @@ class BusinessLogicTests {
|
||||
@Test
|
||||
fun testClimbTypeCompatibilityRules() {
|
||||
val boulderGym =
|
||||
Gym(
|
||||
id = "boulder_gym",
|
||||
name = "Boulder Gym",
|
||||
location = "Boulder City",
|
||||
supportedClimbTypes = listOf(ClimbType.BOULDER),
|
||||
difficultySystems = listOf(DifficultySystem.V_SCALE, DifficultySystem.FONT),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = null,
|
||||
createdAt = getCurrentTimestamp(),
|
||||
updatedAt = getCurrentTimestamp()
|
||||
)
|
||||
Gym(
|
||||
id = "boulder_gym",
|
||||
name = "Boulder Gym",
|
||||
location = "Boulder City",
|
||||
supportedClimbTypes = listOf(ClimbType.BOULDER),
|
||||
difficultySystems = listOf(DifficultySystem.V_SCALE, DifficultySystem.FONT),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = null,
|
||||
createdAt = getCurrentTimestamp(),
|
||||
updatedAt = getCurrentTimestamp(),
|
||||
)
|
||||
|
||||
val ropeGym =
|
||||
Gym(
|
||||
id = "rope_gym",
|
||||
name = "Rope Gym",
|
||||
location = "Rope City",
|
||||
supportedClimbTypes = listOf(ClimbType.ROPE),
|
||||
difficultySystems = listOf(DifficultySystem.YDS),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = null,
|
||||
createdAt = getCurrentTimestamp(),
|
||||
updatedAt = getCurrentTimestamp()
|
||||
)
|
||||
Gym(
|
||||
id = "rope_gym",
|
||||
name = "Rope Gym",
|
||||
location = "Rope City",
|
||||
supportedClimbTypes = listOf(ClimbType.ROPE),
|
||||
difficultySystems = listOf(DifficultySystem.YDS),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = null,
|
||||
createdAt = getCurrentTimestamp(),
|
||||
updatedAt = getCurrentTimestamp(),
|
||||
)
|
||||
|
||||
// Boulder gym should support boulder problems with V-Scale
|
||||
assertTrue(isCompatibleClimbType(boulderGym, ClimbType.BOULDER, DifficultySystem.V_SCALE))
|
||||
@@ -197,26 +197,26 @@ class BusinessLogicTests {
|
||||
val session = ClimbSession.create(gym.id)
|
||||
|
||||
val attempts =
|
||||
listOf(
|
||||
createAttemptWithTimestamp(
|
||||
session.id,
|
||||
problem.id,
|
||||
"2024-01-01T10:00:00Z",
|
||||
AttemptResult.FALL
|
||||
),
|
||||
createAttemptWithTimestamp(
|
||||
session.id,
|
||||
problem.id,
|
||||
"2024-01-01T10:05:00Z",
|
||||
AttemptResult.FALL
|
||||
),
|
||||
createAttemptWithTimestamp(
|
||||
session.id,
|
||||
problem.id,
|
||||
"2024-01-01T10:10:00Z",
|
||||
AttemptResult.SUCCESS
|
||||
)
|
||||
)
|
||||
listOf(
|
||||
createAttemptWithTimestamp(
|
||||
session.id,
|
||||
problem.id,
|
||||
"2024-01-01T10:00:00Z",
|
||||
AttemptResult.FALL,
|
||||
),
|
||||
createAttemptWithTimestamp(
|
||||
session.id,
|
||||
problem.id,
|
||||
"2024-01-01T10:05:00Z",
|
||||
AttemptResult.FALL,
|
||||
),
|
||||
createAttemptWithTimestamp(
|
||||
session.id,
|
||||
problem.id,
|
||||
"2024-01-01T10:10:00Z",
|
||||
AttemptResult.SUCCESS,
|
||||
),
|
||||
)
|
||||
|
||||
val sequence = AttemptSequence(attempts)
|
||||
|
||||
@@ -230,32 +230,32 @@ class BusinessLogicTests {
|
||||
@Test
|
||||
fun testGradeConsistencyValidation() {
|
||||
val validCombinations =
|
||||
listOf(
|
||||
Pair(ClimbType.BOULDER, DifficultySystem.V_SCALE),
|
||||
Pair(ClimbType.BOULDER, DifficultySystem.FONT),
|
||||
Pair(ClimbType.ROPE, DifficultySystem.YDS),
|
||||
Pair(ClimbType.BOULDER, DifficultySystem.CUSTOM),
|
||||
Pair(ClimbType.ROPE, DifficultySystem.CUSTOM)
|
||||
)
|
||||
listOf(
|
||||
Pair(ClimbType.BOULDER, DifficultySystem.V_SCALE),
|
||||
Pair(ClimbType.BOULDER, DifficultySystem.FONT),
|
||||
Pair(ClimbType.ROPE, DifficultySystem.YDS),
|
||||
Pair(ClimbType.BOULDER, DifficultySystem.CUSTOM),
|
||||
Pair(ClimbType.ROPE, DifficultySystem.CUSTOM),
|
||||
)
|
||||
|
||||
val invalidCombinations =
|
||||
listOf(
|
||||
Pair(ClimbType.BOULDER, DifficultySystem.YDS),
|
||||
Pair(ClimbType.ROPE, DifficultySystem.V_SCALE),
|
||||
Pair(ClimbType.ROPE, DifficultySystem.FONT)
|
||||
)
|
||||
listOf(
|
||||
Pair(ClimbType.BOULDER, DifficultySystem.YDS),
|
||||
Pair(ClimbType.ROPE, DifficultySystem.V_SCALE),
|
||||
Pair(ClimbType.ROPE, DifficultySystem.FONT),
|
||||
)
|
||||
|
||||
validCombinations.forEach { (climbType, difficultySystem) ->
|
||||
assertTrue(
|
||||
"$climbType should be compatible with $difficultySystem",
|
||||
isValidGradeCombination(climbType, difficultySystem)
|
||||
"$climbType should be compatible with $difficultySystem",
|
||||
isValidGradeCombination(climbType, difficultySystem),
|
||||
)
|
||||
}
|
||||
|
||||
invalidCombinations.forEach { (climbType, difficultySystem) ->
|
||||
assertFalse(
|
||||
"$climbType should not be compatible with $difficultySystem",
|
||||
isValidGradeCombination(climbType, difficultySystem)
|
||||
"$climbType should not be compatible with $difficultySystem",
|
||||
isValidGradeCombination(climbType, difficultySystem),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -276,11 +276,11 @@ class BusinessLogicTests {
|
||||
@Test
|
||||
fun testImagePathHandling() {
|
||||
val originalPaths =
|
||||
listOf(
|
||||
"/storage/images/problem1.jpg",
|
||||
"/data/cache/problem2.png",
|
||||
"relative/path/problem3.jpeg"
|
||||
)
|
||||
listOf(
|
||||
"/storage/images/problem1.jpg",
|
||||
"/data/cache/problem2.png",
|
||||
"relative/path/problem3.jpeg",
|
||||
)
|
||||
|
||||
val relativePaths = convertToRelativePaths(originalPaths)
|
||||
|
||||
@@ -295,76 +295,76 @@ class BusinessLogicTests {
|
||||
|
||||
private fun createTestGym(): Gym {
|
||||
return Gym(
|
||||
id = "test_gym_1",
|
||||
name = "Test Climbing Gym",
|
||||
location = "Test City",
|
||||
supportedClimbTypes = listOf(ClimbType.BOULDER, ClimbType.ROPE),
|
||||
difficultySystems = listOf(DifficultySystem.V_SCALE, DifficultySystem.YDS),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = "Test gym for unit testing",
|
||||
createdAt = getCurrentTimestamp(),
|
||||
updatedAt = getCurrentTimestamp()
|
||||
id = "test_gym_1",
|
||||
name = "Test Climbing Gym",
|
||||
location = "Test City",
|
||||
supportedClimbTypes = listOf(ClimbType.BOULDER, ClimbType.ROPE),
|
||||
difficultySystems = listOf(DifficultySystem.V_SCALE, DifficultySystem.YDS),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = "Test gym for unit testing",
|
||||
createdAt = getCurrentTimestamp(),
|
||||
updatedAt = getCurrentTimestamp(),
|
||||
)
|
||||
}
|
||||
|
||||
private fun createTestProblem(
|
||||
gymId: String,
|
||||
climbType: ClimbType = ClimbType.BOULDER
|
||||
gymId: String,
|
||||
climbType: ClimbType = ClimbType.BOULDER,
|
||||
): Problem {
|
||||
val difficulty =
|
||||
when (climbType) {
|
||||
ClimbType.BOULDER -> DifficultyGrade(DifficultySystem.V_SCALE, "V5")
|
||||
ClimbType.ROPE -> DifficultyGrade(DifficultySystem.YDS, "5.10a")
|
||||
}
|
||||
when (climbType) {
|
||||
ClimbType.BOULDER -> DifficultyGrade(DifficultySystem.V_SCALE, "V5")
|
||||
ClimbType.ROPE -> DifficultyGrade(DifficultySystem.YDS, "5.10a")
|
||||
}
|
||||
|
||||
return Problem(
|
||||
id = "test_problem_${java.util.UUID.randomUUID()}",
|
||||
gymId = gymId,
|
||||
name = "Test Problem",
|
||||
description = "A test climbing problem",
|
||||
climbType = climbType,
|
||||
difficulty = difficulty,
|
||||
tags = listOf("test", "overhang"),
|
||||
location = "Wall A",
|
||||
imagePaths = emptyList(),
|
||||
isActive = true,
|
||||
dateSet = "2024-01-01",
|
||||
notes = null,
|
||||
createdAt = getCurrentTimestamp(),
|
||||
updatedAt = getCurrentTimestamp()
|
||||
id = "test_problem_${java.util.UUID.randomUUID()}",
|
||||
gymId = gymId,
|
||||
name = "Test Problem",
|
||||
description = "A test climbing problem",
|
||||
climbType = climbType,
|
||||
difficulty = difficulty,
|
||||
tags = listOf("test", "overhang"),
|
||||
location = "Wall A",
|
||||
imagePaths = emptyList(),
|
||||
isActive = true,
|
||||
dateSet = "2024-01-01",
|
||||
notes = null,
|
||||
createdAt = getCurrentTimestamp(),
|
||||
updatedAt = getCurrentTimestamp(),
|
||||
)
|
||||
}
|
||||
|
||||
private fun createTestProblemWithGrade(gymId: String, grade: String): Problem {
|
||||
return Problem(
|
||||
id = "test_problem_${java.util.UUID.randomUUID()}",
|
||||
gymId = gymId,
|
||||
name = "Test Problem $grade",
|
||||
description = null,
|
||||
climbType = ClimbType.BOULDER,
|
||||
difficulty = DifficultyGrade(DifficultySystem.V_SCALE, grade),
|
||||
tags = emptyList(),
|
||||
location = null,
|
||||
imagePaths = emptyList(),
|
||||
isActive = true,
|
||||
dateSet = null,
|
||||
notes = null,
|
||||
createdAt = getCurrentTimestamp(),
|
||||
updatedAt = getCurrentTimestamp()
|
||||
id = "test_problem_${java.util.UUID.randomUUID()}",
|
||||
gymId = gymId,
|
||||
name = "Test Problem $grade",
|
||||
description = null,
|
||||
climbType = ClimbType.BOULDER,
|
||||
difficulty = DifficultyGrade(DifficultySystem.V_SCALE, grade),
|
||||
tags = emptyList(),
|
||||
location = null,
|
||||
imagePaths = emptyList(),
|
||||
isActive = true,
|
||||
dateSet = null,
|
||||
notes = null,
|
||||
createdAt = getCurrentTimestamp(),
|
||||
updatedAt = getCurrentTimestamp(),
|
||||
)
|
||||
}
|
||||
|
||||
private fun createAttemptWithTimestamp(
|
||||
sessionId: String,
|
||||
problemId: String,
|
||||
timestamp: String,
|
||||
result: AttemptResult
|
||||
sessionId: String,
|
||||
problemId: String,
|
||||
timestamp: String,
|
||||
result: AttemptResult,
|
||||
): Attempt {
|
||||
return Attempt.create(
|
||||
sessionId = sessionId,
|
||||
problemId = problemId,
|
||||
result = result,
|
||||
timestamp = timestamp
|
||||
sessionId = sessionId,
|
||||
problemId = problemId,
|
||||
result = result,
|
||||
timestamp = timestamp,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -373,126 +373,126 @@ class BusinessLogicTests {
|
||||
}
|
||||
|
||||
private fun calculateSessionStatistics(
|
||||
session: ClimbSession,
|
||||
attempts: List<Attempt>
|
||||
session: ClimbSession,
|
||||
attempts: List<Attempt>,
|
||||
): SessionStatistics {
|
||||
val successful =
|
||||
attempts.count {
|
||||
it.result == AttemptResult.SUCCESS || it.result == AttemptResult.FLASH
|
||||
}
|
||||
attempts.count {
|
||||
it.result == AttemptResult.SUCCESS || it.result == AttemptResult.FLASH
|
||||
}
|
||||
val uniqueProblems = attempts.map { it.problemId }.toSet().size
|
||||
val successRate = (successful.toDouble() / attempts.size) * 100
|
||||
|
||||
return SessionStatistics(
|
||||
totalAttempts = attempts.size,
|
||||
successfulAttempts = successful,
|
||||
uniqueProblems = uniqueProblems,
|
||||
successRate = successRate
|
||||
totalAttempts = attempts.size,
|
||||
successfulAttempts = successful,
|
||||
uniqueProblems = uniqueProblems,
|
||||
successRate = successRate,
|
||||
)
|
||||
}
|
||||
|
||||
private fun calculateDifficultyProgression(
|
||||
attempts: List<Attempt>,
|
||||
problems: List<Problem>
|
||||
attempts: List<Attempt>,
|
||||
problems: List<Problem>,
|
||||
): DifficultyProgression {
|
||||
val problemMap = problems.associateBy { it.id }
|
||||
val grades =
|
||||
attempts
|
||||
.mapNotNull { attempt -> problemMap[attempt.problemId]?.difficulty?.grade }
|
||||
.filter { it.startsWith("V") }
|
||||
attempts
|
||||
.mapNotNull { attempt -> problemMap[attempt.problemId]?.difficulty?.grade }
|
||||
.filter { it.startsWith("V") }
|
||||
|
||||
val numericGrades =
|
||||
grades.mapNotNull { grade ->
|
||||
when (grade) {
|
||||
"VB" -> 0
|
||||
else -> grade.removePrefix("V").toIntOrNull()
|
||||
}
|
||||
grades.mapNotNull { grade ->
|
||||
when (grade) {
|
||||
"VB" -> 0
|
||||
else -> grade.removePrefix("V").toIntOrNull()
|
||||
}
|
||||
}
|
||||
|
||||
val minGrade = "V${numericGrades.minOrNull() ?: 0}".replace("V0", "VB")
|
||||
val maxGrade = "V${numericGrades.maxOrNull() ?: 0}".replace("V0", "VB")
|
||||
val avgGrade = numericGrades.average()
|
||||
val showsProgression =
|
||||
numericGrades.size > 1 &&
|
||||
(numericGrades.maxOrNull() ?: 0) > (numericGrades.minOrNull() ?: 0)
|
||||
numericGrades.size > 1 &&
|
||||
(numericGrades.maxOrNull() ?: 0) > (numericGrades.minOrNull() ?: 0)
|
||||
|
||||
return DifficultyProgression(minGrade, maxGrade, avgGrade, showsProgression)
|
||||
}
|
||||
|
||||
private fun createBackupData(
|
||||
gyms: List<Gym>,
|
||||
problems: List<Problem>,
|
||||
sessions: List<ClimbSession>,
|
||||
attempts: List<Attempt>
|
||||
gyms: List<Gym>,
|
||||
problems: List<Problem>,
|
||||
sessions: List<ClimbSession>,
|
||||
attempts: List<Attempt>,
|
||||
): ClimbDataBackup {
|
||||
return ClimbDataBackup(
|
||||
exportedAt = getCurrentTimestamp(),
|
||||
version = "2.0",
|
||||
formatVersion = "2.0",
|
||||
gyms =
|
||||
gyms.map { gym ->
|
||||
BackupGym(
|
||||
id = gym.id,
|
||||
name = gym.name,
|
||||
location = gym.location,
|
||||
supportedClimbTypes = gym.supportedClimbTypes,
|
||||
difficultySystems = gym.difficultySystems,
|
||||
customDifficultyGrades = gym.customDifficultyGrades,
|
||||
notes = gym.notes,
|
||||
createdAt = gym.createdAt,
|
||||
updatedAt = gym.updatedAt
|
||||
)
|
||||
},
|
||||
problems =
|
||||
problems.map { problem ->
|
||||
BackupProblem(
|
||||
id = problem.id,
|
||||
gymId = problem.gymId,
|
||||
name = problem.name,
|
||||
description = problem.description,
|
||||
climbType = problem.climbType,
|
||||
difficulty = problem.difficulty,
|
||||
tags = problem.tags,
|
||||
location = problem.location,
|
||||
imagePaths = problem.imagePaths,
|
||||
isActive = problem.isActive,
|
||||
dateSet = problem.dateSet,
|
||||
notes = problem.notes,
|
||||
createdAt = problem.createdAt,
|
||||
updatedAt = problem.updatedAt
|
||||
)
|
||||
},
|
||||
sessions =
|
||||
sessions.map { session ->
|
||||
BackupClimbSession(
|
||||
id = session.id,
|
||||
gymId = session.gymId,
|
||||
date = session.date,
|
||||
startTime = session.startTime,
|
||||
endTime = session.endTime,
|
||||
duration = session.duration,
|
||||
status = session.status,
|
||||
notes = session.notes,
|
||||
createdAt = session.createdAt,
|
||||
updatedAt = session.updatedAt
|
||||
)
|
||||
},
|
||||
attempts =
|
||||
attempts.map { attempt ->
|
||||
BackupAttempt(
|
||||
id = attempt.id,
|
||||
sessionId = attempt.sessionId,
|
||||
problemId = attempt.problemId,
|
||||
result = attempt.result,
|
||||
highestHold = attempt.highestHold,
|
||||
notes = attempt.notes,
|
||||
duration = attempt.duration,
|
||||
restTime = attempt.restTime,
|
||||
timestamp = attempt.timestamp,
|
||||
createdAt = attempt.createdAt,
|
||||
updatedAt = attempt.updatedAt,
|
||||
)
|
||||
}
|
||||
exportedAt = getCurrentTimestamp(),
|
||||
version = "2.0",
|
||||
formatVersion = "2.0",
|
||||
gyms =
|
||||
gyms.map { gym ->
|
||||
BackupGym(
|
||||
id = gym.id,
|
||||
name = gym.name,
|
||||
location = gym.location,
|
||||
supportedClimbTypes = gym.supportedClimbTypes,
|
||||
difficultySystems = gym.difficultySystems,
|
||||
customDifficultyGrades = gym.customDifficultyGrades,
|
||||
notes = gym.notes,
|
||||
createdAt = gym.createdAt,
|
||||
updatedAt = gym.updatedAt,
|
||||
)
|
||||
},
|
||||
problems =
|
||||
problems.map { problem ->
|
||||
BackupProblem(
|
||||
id = problem.id,
|
||||
gymId = problem.gymId,
|
||||
name = problem.name,
|
||||
description = problem.description,
|
||||
climbType = problem.climbType,
|
||||
difficulty = problem.difficulty,
|
||||
tags = problem.tags,
|
||||
location = problem.location,
|
||||
imagePaths = problem.imagePaths,
|
||||
isActive = problem.isActive,
|
||||
dateSet = problem.dateSet,
|
||||
notes = problem.notes,
|
||||
createdAt = problem.createdAt,
|
||||
updatedAt = problem.updatedAt,
|
||||
)
|
||||
},
|
||||
sessions =
|
||||
sessions.map { session ->
|
||||
BackupClimbSession(
|
||||
id = session.id,
|
||||
gymId = session.gymId,
|
||||
date = session.date,
|
||||
startTime = session.startTime,
|
||||
endTime = session.endTime,
|
||||
duration = session.duration,
|
||||
status = session.status,
|
||||
notes = session.notes,
|
||||
createdAt = session.createdAt,
|
||||
updatedAt = session.updatedAt,
|
||||
)
|
||||
},
|
||||
attempts =
|
||||
attempts.map { attempt ->
|
||||
BackupAttempt(
|
||||
id = attempt.id,
|
||||
sessionId = attempt.sessionId,
|
||||
problemId = attempt.problemId,
|
||||
result = attempt.result,
|
||||
highestHold = attempt.highestHold,
|
||||
notes = attempt.notes,
|
||||
duration = attempt.duration,
|
||||
restTime = attempt.restTime,
|
||||
timestamp = attempt.timestamp,
|
||||
createdAt = attempt.createdAt,
|
||||
updatedAt = attempt.updatedAt,
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -501,8 +501,8 @@ class BusinessLogicTests {
|
||||
val gymIds = backup.gyms.map { it.id }.toSet()
|
||||
backup.problems.forEach { problem ->
|
||||
assertTrue(
|
||||
"Problem ${problem.id} references non-existent gym ${problem.gymId}",
|
||||
gymIds.contains(problem.gymId)
|
||||
"Problem ${problem.id} references non-existent gym ${problem.gymId}",
|
||||
gymIds.contains(problem.gymId),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -510,8 +510,8 @@ class BusinessLogicTests {
|
||||
val sessionIds = backup.sessions.map { it.id }.toSet()
|
||||
backup.attempts.forEach { attempt ->
|
||||
assertTrue(
|
||||
"Attempt ${attempt.id} references non-existent session ${attempt.sessionId}",
|
||||
sessionIds.contains(attempt.sessionId)
|
||||
"Attempt ${attempt.id} references non-existent session ${attempt.sessionId}",
|
||||
sessionIds.contains(attempt.sessionId),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -519,19 +519,19 @@ class BusinessLogicTests {
|
||||
val problemIds = backup.problems.map { it.id }.toSet()
|
||||
backup.attempts.forEach { attempt ->
|
||||
assertTrue(
|
||||
"Attempt ${attempt.id} references non-existent problem ${attempt.problemId}",
|
||||
problemIds.contains(attempt.problemId)
|
||||
"Attempt ${attempt.id} references non-existent problem ${attempt.problemId}",
|
||||
problemIds.contains(attempt.problemId),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun isCompatibleClimbType(
|
||||
gym: Gym,
|
||||
climbType: ClimbType,
|
||||
difficultySystem: DifficultySystem
|
||||
gym: Gym,
|
||||
climbType: ClimbType,
|
||||
difficultySystem: DifficultySystem,
|
||||
): Boolean {
|
||||
return gym.supportedClimbTypes.contains(climbType) &&
|
||||
gym.difficultySystems.contains(difficultySystem)
|
||||
gym.difficultySystems.contains(difficultySystem)
|
||||
}
|
||||
|
||||
private fun calculateSessionDuration(startTime: String, endTime: String): Long {
|
||||
@@ -541,19 +541,19 @@ class BusinessLogicTests {
|
||||
}
|
||||
|
||||
private fun isValidGradeCombination(
|
||||
climbType: ClimbType,
|
||||
difficultySystem: DifficultySystem
|
||||
climbType: ClimbType,
|
||||
difficultySystem: DifficultySystem,
|
||||
): Boolean {
|
||||
return when (climbType) {
|
||||
ClimbType.BOULDER ->
|
||||
difficultySystem in
|
||||
listOf(
|
||||
DifficultySystem.V_SCALE,
|
||||
DifficultySystem.FONT,
|
||||
DifficultySystem.CUSTOM
|
||||
)
|
||||
difficultySystem in
|
||||
listOf(
|
||||
DifficultySystem.V_SCALE,
|
||||
DifficultySystem.FONT,
|
||||
DifficultySystem.CUSTOM,
|
||||
)
|
||||
ClimbType.ROPE ->
|
||||
difficultySystem in listOf(DifficultySystem.YDS, DifficultySystem.CUSTOM)
|
||||
difficultySystem in listOf(DifficultySystem.YDS, DifficultySystem.CUSTOM)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -568,29 +568,29 @@ class BusinessLogicTests {
|
||||
// Data classes for testing
|
||||
|
||||
data class SessionStatistics(
|
||||
val totalAttempts: Int,
|
||||
val successfulAttempts: Int,
|
||||
val uniqueProblems: Int,
|
||||
val successRate: Double
|
||||
val totalAttempts: Int,
|
||||
val successfulAttempts: Int,
|
||||
val uniqueProblems: Int,
|
||||
val successRate: Double,
|
||||
)
|
||||
|
||||
data class DifficultyProgression(
|
||||
val minGrade: String,
|
||||
val maxGrade: String,
|
||||
val averageGrade: Double,
|
||||
val showsProgression: Boolean
|
||||
val minGrade: String,
|
||||
val maxGrade: String,
|
||||
val averageGrade: Double,
|
||||
val showsProgression: Boolean,
|
||||
)
|
||||
|
||||
data class AttemptSequence(val attempts: List<Attempt>) {
|
||||
val totalAttempts = attempts.size
|
||||
val failedAttempts =
|
||||
attempts.count {
|
||||
it.result == AttemptResult.FALL || it.result == AttemptResult.NO_PROGRESS
|
||||
}
|
||||
attempts.count {
|
||||
it.result == AttemptResult.FALL || it.result == AttemptResult.NO_PROGRESS
|
||||
}
|
||||
val successfulAttempts =
|
||||
attempts.count {
|
||||
it.result == AttemptResult.SUCCESS || it.result == AttemptResult.FLASH
|
||||
}
|
||||
attempts.count {
|
||||
it.result == AttemptResult.SUCCESS || it.result == AttemptResult.FLASH
|
||||
}
|
||||
val finalResult = attempts.lastOrNull()?.result
|
||||
|
||||
fun isValidSequence(): Boolean {
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.atridad.ascently
|
||||
|
||||
import com.atridad.ascently.data.format.*
|
||||
import com.atridad.ascently.data.model.*
|
||||
import java.time.Instant
|
||||
import java.time.format.DateTimeFormatter
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import java.time.Instant
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
class DataModelTests {
|
||||
|
||||
@@ -141,17 +141,17 @@ class DataModelTests {
|
||||
@Test
|
||||
fun testBackupGymCreationAndValidation() {
|
||||
val gym =
|
||||
BackupGym(
|
||||
id = "gym123",
|
||||
name = "Test Climbing Gym",
|
||||
location = "Test City",
|
||||
supportedClimbTypes = listOf(ClimbType.BOULDER, ClimbType.ROPE),
|
||||
difficultySystems = listOf(DifficultySystem.V_SCALE, DifficultySystem.YDS),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = "Great gym for beginners",
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T10:00:00Z"
|
||||
)
|
||||
BackupGym(
|
||||
id = "gym123",
|
||||
name = "Test Climbing Gym",
|
||||
location = "Test City",
|
||||
supportedClimbTypes = listOf(ClimbType.BOULDER, ClimbType.ROPE),
|
||||
difficultySystems = listOf(DifficultySystem.V_SCALE, DifficultySystem.YDS),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = "Great gym for beginners",
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T10:00:00Z",
|
||||
)
|
||||
|
||||
assertEquals("gym123", gym.id)
|
||||
assertEquals("Test Climbing Gym", gym.name)
|
||||
@@ -167,22 +167,22 @@ class DataModelTests {
|
||||
@Test
|
||||
fun testBackupProblemCreationAndValidation() {
|
||||
val problem =
|
||||
BackupProblem(
|
||||
id = "problem123",
|
||||
gymId = "gym123",
|
||||
name = "Test Problem",
|
||||
description = "A challenging boulder problem",
|
||||
climbType = ClimbType.BOULDER,
|
||||
difficulty = DifficultyGrade(DifficultySystem.V_SCALE, "V5"),
|
||||
tags = listOf("overhang", "crimpy"),
|
||||
location = "Wall A",
|
||||
imagePaths = listOf("image1.jpg", "image2.jpg"),
|
||||
isActive = true,
|
||||
dateSet = "2024-01-01",
|
||||
notes = "Watch the start holds",
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T10:00:00Z"
|
||||
)
|
||||
BackupProblem(
|
||||
id = "problem123",
|
||||
gymId = "gym123",
|
||||
name = "Test Problem",
|
||||
description = "A challenging boulder problem",
|
||||
climbType = ClimbType.BOULDER,
|
||||
difficulty = DifficultyGrade(DifficultySystem.V_SCALE, "V5"),
|
||||
tags = listOf("overhang", "crimpy"),
|
||||
location = "Wall A",
|
||||
imagePaths = listOf("image1.jpg", "image2.jpg"),
|
||||
isActive = true,
|
||||
dateSet = "2024-01-01",
|
||||
notes = "Watch the start holds",
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T10:00:00Z",
|
||||
)
|
||||
|
||||
assertEquals("problem123", problem.id)
|
||||
assertEquals("gym123", problem.gymId)
|
||||
@@ -190,25 +190,25 @@ class DataModelTests {
|
||||
assertEquals(ClimbType.BOULDER, problem.climbType)
|
||||
assertEquals("V5", problem.difficulty.grade)
|
||||
assertTrue(problem.isActive)
|
||||
assertEquals(2, problem.tags.size)
|
||||
assertEquals(2, problem.tags?.size ?: 0)
|
||||
assertEquals(2, problem.imagePaths?.size ?: 0)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testBackupClimbSessionCreationAndValidation() {
|
||||
val session =
|
||||
BackupClimbSession(
|
||||
id = "session123",
|
||||
gymId = "gym123",
|
||||
date = "2024-01-01",
|
||||
startTime = "2024-01-01T10:00:00Z",
|
||||
endTime = "2024-01-01T12:00:00Z",
|
||||
duration = 7200,
|
||||
status = SessionStatus.COMPLETED,
|
||||
notes = "Great session today",
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T12:00:00Z"
|
||||
)
|
||||
BackupClimbSession(
|
||||
id = "session123",
|
||||
gymId = "gym123",
|
||||
date = "2024-01-01",
|
||||
startTime = "2024-01-01T10:00:00Z",
|
||||
endTime = "2024-01-01T12:00:00Z",
|
||||
duration = 7200,
|
||||
status = SessionStatus.COMPLETED,
|
||||
notes = "Great session today",
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T12:00:00Z",
|
||||
)
|
||||
|
||||
assertEquals("session123", session.id)
|
||||
assertEquals("gym123", session.gymId)
|
||||
@@ -220,19 +220,19 @@ class DataModelTests {
|
||||
@Test
|
||||
fun testBackupAttemptCreationAndValidation() {
|
||||
val attempt =
|
||||
BackupAttempt(
|
||||
id = "attempt123",
|
||||
sessionId = "session123",
|
||||
problemId = "problem123",
|
||||
result = AttemptResult.SUCCESS,
|
||||
highestHold = "Top",
|
||||
notes = "Stuck it on second try",
|
||||
duration = 300,
|
||||
restTime = 120,
|
||||
timestamp = "2024-01-01T10:30:00Z",
|
||||
createdAt = "2024-01-01T10:30:00Z",
|
||||
updatedAt = "2024-01-01T10:30:00Z"
|
||||
)
|
||||
BackupAttempt(
|
||||
id = "attempt123",
|
||||
sessionId = "session123",
|
||||
problemId = "problem123",
|
||||
result = AttemptResult.SUCCESS,
|
||||
highestHold = "Top",
|
||||
notes = "Stuck it on second try",
|
||||
duration = 300,
|
||||
restTime = 120,
|
||||
timestamp = "2024-01-01T10:30:00Z",
|
||||
createdAt = "2024-01-01T10:30:00Z",
|
||||
updatedAt = "2024-01-01T10:30:00Z",
|
||||
)
|
||||
|
||||
assertEquals("attempt123", attempt.id)
|
||||
assertEquals("session123", attempt.sessionId)
|
||||
@@ -246,15 +246,15 @@ class DataModelTests {
|
||||
@Test
|
||||
fun testClimbDataBackupCreationAndValidation() {
|
||||
val backup =
|
||||
ClimbDataBackup(
|
||||
exportedAt = "2024-01-01T10:00:00Z",
|
||||
version = "2.0",
|
||||
formatVersion = "2.0",
|
||||
gyms = emptyList(),
|
||||
problems = emptyList(),
|
||||
sessions = emptyList(),
|
||||
attempts = emptyList()
|
||||
)
|
||||
ClimbDataBackup(
|
||||
exportedAt = "2024-01-01T10:00:00Z",
|
||||
version = "2.0",
|
||||
formatVersion = "2.0",
|
||||
gyms = emptyList(),
|
||||
problems = emptyList(),
|
||||
sessions = emptyList(),
|
||||
attempts = emptyList(),
|
||||
)
|
||||
|
||||
assertEquals("2.0", backup.version)
|
||||
assertEquals("2.0", backup.formatVersion)
|
||||
@@ -280,18 +280,18 @@ class DataModelTests {
|
||||
@Test
|
||||
fun testSessionDurationCalculation() {
|
||||
val session =
|
||||
BackupClimbSession(
|
||||
id = "test",
|
||||
gymId = "gym1",
|
||||
date = "2024-01-01",
|
||||
startTime = "2024-01-01T10:00:00Z",
|
||||
endTime = "2024-01-01T12:00:00Z",
|
||||
duration = 7200,
|
||||
status = SessionStatus.COMPLETED,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T12:00:00Z"
|
||||
)
|
||||
BackupClimbSession(
|
||||
id = "test",
|
||||
gymId = "gym1",
|
||||
date = "2024-01-01",
|
||||
startTime = "2024-01-01T10:00:00Z",
|
||||
endTime = "2024-01-01T12:00:00Z",
|
||||
duration = 7200,
|
||||
status = SessionStatus.COMPLETED,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T12:00:00Z",
|
||||
)
|
||||
|
||||
assertEquals(7200L, session.duration)
|
||||
val hours = session.duration!! / 3600
|
||||
@@ -301,21 +301,21 @@ class DataModelTests {
|
||||
@Test
|
||||
fun testEmptyCollectionsHandling() {
|
||||
val gym =
|
||||
BackupGym(
|
||||
id = "gym1",
|
||||
name = "Test Gym",
|
||||
location = null,
|
||||
supportedClimbTypes = emptyList(),
|
||||
difficultySystems = emptyList(),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T10:00:00Z"
|
||||
)
|
||||
BackupGym(
|
||||
id = "gym1",
|
||||
name = "Test Gym",
|
||||
location = null,
|
||||
supportedClimbTypes = emptyList(),
|
||||
difficultySystems = emptyList(),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T10:00:00Z",
|
||||
)
|
||||
|
||||
assertTrue(gym.supportedClimbTypes.isEmpty())
|
||||
assertTrue(gym.difficultySystems.isEmpty())
|
||||
assertTrue(gym.customDifficultyGrades.isEmpty())
|
||||
assertTrue(gym.supportedClimbTypes?.isEmpty() ?: true)
|
||||
assertTrue(gym.difficultySystems?.isEmpty() ?: true)
|
||||
assertTrue(gym.customDifficultyGrades?.isEmpty() ?: true)
|
||||
assertNull(gym.location)
|
||||
assertNull(gym.notes)
|
||||
}
|
||||
@@ -323,29 +323,29 @@ class DataModelTests {
|
||||
@Test
|
||||
fun testNullableFieldsHandling() {
|
||||
val problem =
|
||||
BackupProblem(
|
||||
id = "problem1",
|
||||
gymId = "gym1",
|
||||
name = null,
|
||||
description = null,
|
||||
climbType = ClimbType.BOULDER,
|
||||
difficulty = DifficultyGrade(DifficultySystem.V_SCALE, "V1"),
|
||||
tags = emptyList(),
|
||||
location = null,
|
||||
imagePaths = null,
|
||||
isActive = true,
|
||||
dateSet = null,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T10:00:00Z"
|
||||
)
|
||||
BackupProblem(
|
||||
id = "problem1",
|
||||
gymId = "gym1",
|
||||
name = null,
|
||||
description = null,
|
||||
climbType = ClimbType.BOULDER,
|
||||
difficulty = DifficultyGrade(DifficultySystem.V_SCALE, "V1"),
|
||||
tags = emptyList(),
|
||||
location = null,
|
||||
imagePaths = null,
|
||||
isActive = true,
|
||||
dateSet = null,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T10:00:00Z",
|
||||
)
|
||||
|
||||
assertNull(problem.name)
|
||||
assertNull(problem.description)
|
||||
assertNull(problem.location)
|
||||
assertNull(problem.dateSet)
|
||||
assertNull(problem.notes)
|
||||
assertTrue(problem.tags.isEmpty())
|
||||
assertTrue(problem.tags?.isEmpty() ?: true)
|
||||
assertNull(problem.imagePaths)
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ class DataModelTests {
|
||||
@Test
|
||||
fun testBackupDataFormatValidation() {
|
||||
val testJson =
|
||||
"""
|
||||
"""
|
||||
{
|
||||
"exportedAt": "2024-01-01T10:00:00Z",
|
||||
"version": "2.0",
|
||||
@@ -372,7 +372,7 @@ class DataModelTests {
|
||||
"sessions": [],
|
||||
"attempts": []
|
||||
}
|
||||
""".trimIndent()
|
||||
""".trimIndent()
|
||||
|
||||
assertTrue(testJson.contains("exportedAt"))
|
||||
assertTrue(testJson.contains("version"))
|
||||
@@ -397,44 +397,44 @@ class DataModelTests {
|
||||
fun testClimbTypeAndDifficultySystemCompatibility() {
|
||||
// Test that V_SCALE works with BOULDER
|
||||
val boulderProblem =
|
||||
BackupProblem(
|
||||
id = "boulder1",
|
||||
gymId = "gym1",
|
||||
name = "Boulder Problem",
|
||||
description = null,
|
||||
climbType = ClimbType.BOULDER,
|
||||
difficulty = DifficultyGrade(DifficultySystem.V_SCALE, "V3"),
|
||||
tags = emptyList(),
|
||||
location = null,
|
||||
imagePaths = null,
|
||||
isActive = true,
|
||||
dateSet = null,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T10:00:00Z"
|
||||
)
|
||||
BackupProblem(
|
||||
id = "boulder1",
|
||||
gymId = "gym1",
|
||||
name = "Boulder Problem",
|
||||
description = null,
|
||||
climbType = ClimbType.BOULDER,
|
||||
difficulty = DifficultyGrade(DifficultySystem.V_SCALE, "V3"),
|
||||
tags = emptyList(),
|
||||
location = null,
|
||||
imagePaths = null,
|
||||
isActive = true,
|
||||
dateSet = null,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T10:00:00Z",
|
||||
)
|
||||
|
||||
assertEquals(ClimbType.BOULDER, boulderProblem.climbType)
|
||||
assertEquals(DifficultySystem.V_SCALE, boulderProblem.difficulty.system)
|
||||
|
||||
// Test that YDS works with ROPE
|
||||
val ropeProblem =
|
||||
BackupProblem(
|
||||
id = "rope1",
|
||||
gymId = "gym1",
|
||||
name = "Rope Problem",
|
||||
description = null,
|
||||
climbType = ClimbType.ROPE,
|
||||
difficulty = DifficultyGrade(DifficultySystem.YDS, "5.10a"),
|
||||
tags = emptyList(),
|
||||
location = null,
|
||||
imagePaths = null,
|
||||
isActive = true,
|
||||
dateSet = null,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T10:00:00Z"
|
||||
)
|
||||
BackupProblem(
|
||||
id = "rope1",
|
||||
gymId = "gym1",
|
||||
name = "Rope Problem",
|
||||
description = null,
|
||||
climbType = ClimbType.ROPE,
|
||||
difficulty = DifficultyGrade(DifficultySystem.YDS, "5.10a"),
|
||||
tags = emptyList(),
|
||||
location = null,
|
||||
imagePaths = null,
|
||||
isActive = true,
|
||||
dateSet = null,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T10:00:00Z",
|
||||
)
|
||||
|
||||
assertEquals(ClimbType.ROPE, ropeProblem.climbType)
|
||||
assertEquals(DifficultySystem.YDS, ropeProblem.difficulty.system)
|
||||
@@ -473,12 +473,12 @@ class DataModelTests {
|
||||
@Test
|
||||
fun testAttemptResultValidation() {
|
||||
val validResults =
|
||||
listOf(
|
||||
AttemptResult.SUCCESS,
|
||||
AttemptResult.FALL,
|
||||
AttemptResult.NO_PROGRESS,
|
||||
AttemptResult.FLASH
|
||||
)
|
||||
listOf(
|
||||
AttemptResult.SUCCESS,
|
||||
AttemptResult.FALL,
|
||||
AttemptResult.NO_PROGRESS,
|
||||
AttemptResult.FLASH,
|
||||
)
|
||||
|
||||
assertEquals(4, validResults.size)
|
||||
assertTrue(validResults.contains(AttemptResult.SUCCESS))
|
||||
@@ -490,7 +490,7 @@ class DataModelTests {
|
||||
@Test
|
||||
fun testSessionStatusValidation() {
|
||||
val validStatuses =
|
||||
listOf(SessionStatus.ACTIVE, SessionStatus.COMPLETED, SessionStatus.PAUSED)
|
||||
listOf(SessionStatus.ACTIVE, SessionStatus.COMPLETED, SessionStatus.PAUSED)
|
||||
|
||||
assertEquals(3, validStatuses.size)
|
||||
assertTrue(validStatuses.contains(SessionStatus.ACTIVE))
|
||||
@@ -501,64 +501,64 @@ class DataModelTests {
|
||||
@Test
|
||||
fun testClimbDataIntegrity() {
|
||||
val gym =
|
||||
BackupGym(
|
||||
id = "gym1",
|
||||
name = "Test Gym",
|
||||
location = "Test City",
|
||||
supportedClimbTypes = listOf(ClimbType.BOULDER),
|
||||
difficultySystems = listOf(DifficultySystem.V_SCALE),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T10:00:00Z"
|
||||
)
|
||||
BackupGym(
|
||||
id = "gym1",
|
||||
name = "Test Gym",
|
||||
location = "Test City",
|
||||
supportedClimbTypes = listOf(ClimbType.BOULDER),
|
||||
difficultySystems = listOf(DifficultySystem.V_SCALE),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T10:00:00Z",
|
||||
)
|
||||
|
||||
val problem =
|
||||
BackupProblem(
|
||||
id = "problem1",
|
||||
gymId = gym.id,
|
||||
name = "Test Problem",
|
||||
description = null,
|
||||
climbType = ClimbType.BOULDER,
|
||||
difficulty = DifficultyGrade(DifficultySystem.V_SCALE, "V3"),
|
||||
tags = emptyList(),
|
||||
location = null,
|
||||
imagePaths = null,
|
||||
isActive = true,
|
||||
dateSet = null,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T10:00:00Z"
|
||||
)
|
||||
BackupProblem(
|
||||
id = "problem1",
|
||||
gymId = gym.id,
|
||||
name = "Test Problem",
|
||||
description = null,
|
||||
climbType = ClimbType.BOULDER,
|
||||
difficulty = DifficultyGrade(DifficultySystem.V_SCALE, "V3"),
|
||||
tags = emptyList(),
|
||||
location = null,
|
||||
imagePaths = null,
|
||||
isActive = true,
|
||||
dateSet = null,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T10:00:00Z",
|
||||
)
|
||||
|
||||
val session =
|
||||
BackupClimbSession(
|
||||
id = "session1",
|
||||
gymId = gym.id,
|
||||
date = "2024-01-01",
|
||||
startTime = "2024-01-01T10:00:00Z",
|
||||
endTime = "2024-01-01T11:00:00Z",
|
||||
duration = 3600,
|
||||
status = SessionStatus.COMPLETED,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T11:00:00Z"
|
||||
)
|
||||
BackupClimbSession(
|
||||
id = "session1",
|
||||
gymId = gym.id,
|
||||
date = "2024-01-01",
|
||||
startTime = "2024-01-01T10:00:00Z",
|
||||
endTime = "2024-01-01T11:00:00Z",
|
||||
duration = 3600,
|
||||
status = SessionStatus.COMPLETED,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00Z",
|
||||
updatedAt = "2024-01-01T11:00:00Z",
|
||||
)
|
||||
|
||||
val attempt =
|
||||
BackupAttempt(
|
||||
id = "attempt1",
|
||||
sessionId = session.id,
|
||||
problemId = problem.id,
|
||||
result = AttemptResult.SUCCESS,
|
||||
highestHold = null,
|
||||
notes = null,
|
||||
duration = 120,
|
||||
restTime = null,
|
||||
timestamp = "2024-01-01T10:30:00Z",
|
||||
createdAt = "2024-01-01T10:30:00Z",
|
||||
updatedAt = "2024-01-01T10:30:00Z"
|
||||
)
|
||||
BackupAttempt(
|
||||
id = "attempt1",
|
||||
sessionId = session.id,
|
||||
problemId = problem.id,
|
||||
result = AttemptResult.SUCCESS,
|
||||
highestHold = null,
|
||||
notes = null,
|
||||
duration = 120,
|
||||
restTime = null,
|
||||
timestamp = "2024-01-01T10:30:00Z",
|
||||
createdAt = "2024-01-01T10:30:00Z",
|
||||
updatedAt = "2024-01-01T10:30:00Z",
|
||||
)
|
||||
|
||||
// Verify referential integrity
|
||||
assertEquals(gym.id, problem.gymId)
|
||||
|
||||
@@ -11,197 +11,197 @@ class SyncMergeLogicTest {
|
||||
fun `test intelligent merge preserves all data`() {
|
||||
// Create local data
|
||||
val localGyms =
|
||||
listOf(
|
||||
BackupGym(
|
||||
id = "gym1",
|
||||
name = "Local Gym 1",
|
||||
location = "Local Location",
|
||||
supportedClimbTypes = listOf(ClimbType.BOULDER),
|
||||
difficultySystems = listOf(DifficultySystem.V_SCALE),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00",
|
||||
updatedAt = "2024-01-01T10:00:00"
|
||||
)
|
||||
)
|
||||
listOf(
|
||||
BackupGym(
|
||||
id = "gym1",
|
||||
name = "Local Gym 1",
|
||||
location = "Local Location",
|
||||
supportedClimbTypes = listOf(ClimbType.BOULDER),
|
||||
difficultySystems = listOf(DifficultySystem.V_SCALE),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00",
|
||||
updatedAt = "2024-01-01T10:00:00",
|
||||
),
|
||||
)
|
||||
|
||||
val localProblems =
|
||||
listOf(
|
||||
BackupProblem(
|
||||
id = "problem1",
|
||||
gymId = "gym1",
|
||||
name = "Local Problem",
|
||||
description = "Local description",
|
||||
climbType = ClimbType.BOULDER,
|
||||
difficulty = DifficultyGrade(DifficultySystem.V_SCALE, "V5"),
|
||||
tags = listOf("local"),
|
||||
location = null,
|
||||
imagePaths = listOf("local_image.jpg"),
|
||||
isActive = true,
|
||||
dateSet = null,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00",
|
||||
updatedAt = "2024-01-01T10:00:00"
|
||||
)
|
||||
)
|
||||
listOf(
|
||||
BackupProblem(
|
||||
id = "problem1",
|
||||
gymId = "gym1",
|
||||
name = "Local Problem",
|
||||
description = "Local description",
|
||||
climbType = ClimbType.BOULDER,
|
||||
difficulty = DifficultyGrade(DifficultySystem.V_SCALE, "V5"),
|
||||
tags = listOf("local"),
|
||||
location = null,
|
||||
imagePaths = listOf("local_image.jpg"),
|
||||
isActive = true,
|
||||
dateSet = null,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00",
|
||||
updatedAt = "2024-01-01T10:00:00",
|
||||
),
|
||||
)
|
||||
|
||||
val localSessions =
|
||||
listOf(
|
||||
BackupClimbSession(
|
||||
id = "session1",
|
||||
gymId = "gym1",
|
||||
date = "2024-01-01",
|
||||
startTime = "2024-01-01T10:00:00",
|
||||
endTime = "2024-01-01T12:00:00",
|
||||
duration = 7200,
|
||||
status = SessionStatus.COMPLETED,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00",
|
||||
updatedAt = "2024-01-01T10:00:00"
|
||||
)
|
||||
)
|
||||
listOf(
|
||||
BackupClimbSession(
|
||||
id = "session1",
|
||||
gymId = "gym1",
|
||||
date = "2024-01-01",
|
||||
startTime = "2024-01-01T10:00:00",
|
||||
endTime = "2024-01-01T12:00:00",
|
||||
duration = 7200,
|
||||
status = SessionStatus.COMPLETED,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00",
|
||||
updatedAt = "2024-01-01T10:00:00",
|
||||
),
|
||||
)
|
||||
|
||||
val localAttempts =
|
||||
listOf(
|
||||
BackupAttempt(
|
||||
id = "attempt1",
|
||||
sessionId = "session1",
|
||||
problemId = "problem1",
|
||||
result = AttemptResult.SUCCESS,
|
||||
highestHold = null,
|
||||
notes = null,
|
||||
duration = 300,
|
||||
restTime = null,
|
||||
timestamp = "2024-01-01T10:30:00",
|
||||
createdAt = "2024-01-01T10:30:00",
|
||||
updatedAt = "2024-01-01T10:30:00"
|
||||
)
|
||||
)
|
||||
listOf(
|
||||
BackupAttempt(
|
||||
id = "attempt1",
|
||||
sessionId = "session1",
|
||||
problemId = "problem1",
|
||||
result = AttemptResult.SUCCESS,
|
||||
highestHold = null,
|
||||
notes = null,
|
||||
duration = 300,
|
||||
restTime = null,
|
||||
timestamp = "2024-01-01T10:30:00",
|
||||
createdAt = "2024-01-01T10:30:00",
|
||||
updatedAt = "2024-01-01T10:30:00",
|
||||
),
|
||||
)
|
||||
|
||||
val localBackup =
|
||||
ClimbDataBackup(
|
||||
exportedAt = "2024-01-01T10:00:00",
|
||||
version = "2.0",
|
||||
formatVersion = "2.0",
|
||||
gyms = localGyms,
|
||||
problems = localProblems,
|
||||
sessions = localSessions,
|
||||
attempts = localAttempts
|
||||
)
|
||||
ClimbDataBackup(
|
||||
exportedAt = "2024-01-01T10:00:00",
|
||||
version = "2.0",
|
||||
formatVersion = "2.0",
|
||||
gyms = localGyms,
|
||||
problems = localProblems,
|
||||
sessions = localSessions,
|
||||
attempts = localAttempts,
|
||||
)
|
||||
|
||||
// Create server data with some overlapping and some unique data
|
||||
val serverGyms =
|
||||
listOf(
|
||||
// Same gym but with newer update
|
||||
BackupGym(
|
||||
id = "gym1",
|
||||
name = "Updated Gym 1",
|
||||
location = "Updated Location",
|
||||
supportedClimbTypes = listOf(ClimbType.BOULDER, ClimbType.ROPE),
|
||||
difficultySystems =
|
||||
listOf(DifficultySystem.V_SCALE, DifficultySystem.YDS),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = "Updated notes",
|
||||
createdAt = "2024-01-01T10:00:00",
|
||||
updatedAt = "2024-01-01T12:00:00" // Newer update
|
||||
),
|
||||
// Unique server gym
|
||||
BackupGym(
|
||||
id = "gym2",
|
||||
name = "Server Gym 2",
|
||||
location = "Server Location",
|
||||
supportedClimbTypes = listOf(ClimbType.ROPE),
|
||||
difficultySystems = listOf(DifficultySystem.YDS),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T11:00:00",
|
||||
updatedAt = "2024-01-01T11:00:00"
|
||||
)
|
||||
)
|
||||
listOf(
|
||||
// Same gym but with newer update
|
||||
BackupGym(
|
||||
id = "gym1",
|
||||
name = "Updated Gym 1",
|
||||
location = "Updated Location",
|
||||
supportedClimbTypes = listOf(ClimbType.BOULDER, ClimbType.ROPE),
|
||||
difficultySystems =
|
||||
listOf(DifficultySystem.V_SCALE, DifficultySystem.YDS),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = "Updated notes",
|
||||
createdAt = "2024-01-01T10:00:00",
|
||||
updatedAt = "2024-01-01T12:00:00", // Newer update
|
||||
),
|
||||
// Unique server gym
|
||||
BackupGym(
|
||||
id = "gym2",
|
||||
name = "Server Gym 2",
|
||||
location = "Server Location",
|
||||
supportedClimbTypes = listOf(ClimbType.ROPE),
|
||||
difficultySystems = listOf(DifficultySystem.YDS),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T11:00:00",
|
||||
updatedAt = "2024-01-01T11:00:00",
|
||||
),
|
||||
)
|
||||
|
||||
val serverProblems =
|
||||
listOf(
|
||||
// Same problem but with newer update and different images
|
||||
BackupProblem(
|
||||
id = "problem1",
|
||||
gymId = "gym1",
|
||||
name = "Updated Problem",
|
||||
description = "Updated description",
|
||||
climbType = ClimbType.BOULDER,
|
||||
difficulty = DifficultyGrade(DifficultySystem.V_SCALE, "V5"),
|
||||
tags = listOf("updated", "server"),
|
||||
location = "Updated location",
|
||||
imagePaths = listOf("server_image.jpg"),
|
||||
isActive = true,
|
||||
dateSet = "2024-01-01",
|
||||
notes = "Updated notes",
|
||||
createdAt = "2024-01-01T10:00:00",
|
||||
updatedAt = "2024-01-01T11:00:00" // Newer update
|
||||
),
|
||||
// Unique server problem
|
||||
BackupProblem(
|
||||
id = "problem2",
|
||||
gymId = "gym2",
|
||||
name = "Server Problem",
|
||||
description = "Server description",
|
||||
climbType = ClimbType.ROPE,
|
||||
difficulty = DifficultyGrade(DifficultySystem.YDS, "5.10a"),
|
||||
tags = listOf("server"),
|
||||
location = null,
|
||||
imagePaths = null,
|
||||
isActive = true,
|
||||
dateSet = null,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T11:00:00",
|
||||
updatedAt = "2024-01-01T11:00:00"
|
||||
)
|
||||
)
|
||||
listOf(
|
||||
// Same problem but with newer update and different images
|
||||
BackupProblem(
|
||||
id = "problem1",
|
||||
gymId = "gym1",
|
||||
name = "Updated Problem",
|
||||
description = "Updated description",
|
||||
climbType = ClimbType.BOULDER,
|
||||
difficulty = DifficultyGrade(DifficultySystem.V_SCALE, "V5"),
|
||||
tags = listOf("updated", "server"),
|
||||
location = "Updated location",
|
||||
imagePaths = listOf("server_image.jpg"),
|
||||
isActive = true,
|
||||
dateSet = "2024-01-01",
|
||||
notes = "Updated notes",
|
||||
createdAt = "2024-01-01T10:00:00",
|
||||
updatedAt = "2024-01-01T11:00:00", // Newer update
|
||||
),
|
||||
// Unique server problem
|
||||
BackupProblem(
|
||||
id = "problem2",
|
||||
gymId = "gym2",
|
||||
name = "Server Problem",
|
||||
description = "Server description",
|
||||
climbType = ClimbType.ROPE,
|
||||
difficulty = DifficultyGrade(DifficultySystem.YDS, "5.10a"),
|
||||
tags = listOf("server"),
|
||||
location = null,
|
||||
imagePaths = null,
|
||||
isActive = true,
|
||||
dateSet = null,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T11:00:00",
|
||||
updatedAt = "2024-01-01T11:00:00",
|
||||
),
|
||||
)
|
||||
|
||||
val serverSessions =
|
||||
listOf(
|
||||
// Unique server session
|
||||
BackupClimbSession(
|
||||
id = "session2",
|
||||
gymId = "gym2",
|
||||
date = "2024-01-02",
|
||||
startTime = "2024-01-02T14:00:00",
|
||||
endTime = "2024-01-02T16:00:00",
|
||||
duration = 7200,
|
||||
status = SessionStatus.COMPLETED,
|
||||
notes = "Server session",
|
||||
createdAt = "2024-01-02T14:00:00",
|
||||
updatedAt = "2024-01-02T14:00:00"
|
||||
)
|
||||
)
|
||||
listOf(
|
||||
// Unique server session
|
||||
BackupClimbSession(
|
||||
id = "session2",
|
||||
gymId = "gym2",
|
||||
date = "2024-01-02",
|
||||
startTime = "2024-01-02T14:00:00",
|
||||
endTime = "2024-01-02T16:00:00",
|
||||
duration = 7200,
|
||||
status = SessionStatus.COMPLETED,
|
||||
notes = "Server session",
|
||||
createdAt = "2024-01-02T14:00:00",
|
||||
updatedAt = "2024-01-02T14:00:00",
|
||||
),
|
||||
)
|
||||
|
||||
val serverAttempts =
|
||||
listOf(
|
||||
// Unique server attempt
|
||||
BackupAttempt(
|
||||
id = "attempt2",
|
||||
sessionId = "session2",
|
||||
problemId = "problem2",
|
||||
result = AttemptResult.FALL,
|
||||
highestHold = "Last move",
|
||||
notes = "Almost had it",
|
||||
duration = 180,
|
||||
restTime = 60,
|
||||
timestamp = "2024-01-02T14:30:00",
|
||||
createdAt = "2024-01-02T14:30:00",
|
||||
updatedAt = "2024-01-02T14:30:00"
|
||||
)
|
||||
)
|
||||
listOf(
|
||||
// Unique server attempt
|
||||
BackupAttempt(
|
||||
id = "attempt2",
|
||||
sessionId = "session2",
|
||||
problemId = "problem2",
|
||||
result = AttemptResult.FALL,
|
||||
highestHold = "Last move",
|
||||
notes = "Almost had it",
|
||||
duration = 180,
|
||||
restTime = 60,
|
||||
timestamp = "2024-01-02T14:30:00",
|
||||
createdAt = "2024-01-02T14:30:00",
|
||||
updatedAt = "2024-01-02T14:30:00",
|
||||
),
|
||||
)
|
||||
|
||||
val serverBackup =
|
||||
ClimbDataBackup(
|
||||
exportedAt = "2024-01-01T12:00:00",
|
||||
version = "2.0",
|
||||
formatVersion = "2.0",
|
||||
gyms = serverGyms,
|
||||
problems = serverProblems,
|
||||
sessions = serverSessions,
|
||||
attempts = serverAttempts
|
||||
)
|
||||
ClimbDataBackup(
|
||||
exportedAt = "2024-01-01T12:00:00",
|
||||
version = "2.0",
|
||||
formatVersion = "2.0",
|
||||
gyms = serverGyms,
|
||||
problems = serverProblems,
|
||||
sessions = serverSessions,
|
||||
attempts = serverAttempts,
|
||||
)
|
||||
|
||||
// Simulate merge logic
|
||||
val mergedBackup = performIntelligentMerge(localBackup, serverBackup)
|
||||
@@ -231,12 +231,12 @@ class SyncMergeLogicTest {
|
||||
|
||||
// Images should be merged (both local and server images preserved)
|
||||
assertTrue(
|
||||
"Should contain local image",
|
||||
mergedProblem1.imagePaths!!.contains("local_image.jpg")
|
||||
"Should contain local image",
|
||||
mergedProblem1.imagePaths!!.contains("local_image.jpg"),
|
||||
)
|
||||
assertTrue(
|
||||
"Should contain server image",
|
||||
mergedProblem1.imagePaths!!.contains("server_image.jpg")
|
||||
"Should contain server image",
|
||||
mergedProblem1.imagePaths!!.contains("server_image.jpg"),
|
||||
)
|
||||
assertEquals("Should have 2 images total", 2, mergedProblem1.imagePaths!!.size)
|
||||
|
||||
@@ -246,78 +246,78 @@ class SyncMergeLogicTest {
|
||||
|
||||
// Verify all sessions are preserved
|
||||
assertTrue(
|
||||
"Should contain local session",
|
||||
mergedBackup.sessions.any { it.id == "session1" }
|
||||
"Should contain local session",
|
||||
mergedBackup.sessions.any { it.id == "session1" },
|
||||
)
|
||||
assertTrue(
|
||||
"Should contain server session",
|
||||
mergedBackup.sessions.any { it.id == "session2" }
|
||||
"Should contain server session",
|
||||
mergedBackup.sessions.any { it.id == "session2" },
|
||||
)
|
||||
|
||||
// Verify all attempts are preserved
|
||||
assertTrue(
|
||||
"Should contain local attempt",
|
||||
mergedBackup.attempts.any { it.id == "attempt1" }
|
||||
"Should contain local attempt",
|
||||
mergedBackup.attempts.any { it.id == "attempt1" },
|
||||
)
|
||||
assertTrue(
|
||||
"Should contain server attempt",
|
||||
mergedBackup.attempts.any { it.id == "attempt2" }
|
||||
"Should contain server attempt",
|
||||
mergedBackup.attempts.any { it.id == "attempt2" },
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test date comparison logic`() {
|
||||
assertTrue(
|
||||
"ISO instant should be newer",
|
||||
isNewerThan("2024-01-01T12:00:00Z", "2024-01-01T10:00:00Z")
|
||||
"ISO instant should be newer",
|
||||
isNewerThan("2024-01-01T12:00:00Z", "2024-01-01T10:00:00Z"),
|
||||
)
|
||||
assertFalse(
|
||||
"ISO instant should be older",
|
||||
isNewerThan("2024-01-01T10:00:00Z", "2024-01-01T12:00:00Z")
|
||||
"ISO instant should be older",
|
||||
isNewerThan("2024-01-01T10:00:00Z", "2024-01-01T12:00:00Z"),
|
||||
)
|
||||
assertTrue(
|
||||
"String comparison should work as fallback",
|
||||
isNewerThan("2024-01-02T10:00:00", "2024-01-01T10:00:00")
|
||||
"String comparison should work as fallback",
|
||||
isNewerThan("2024-01-02T10:00:00", "2024-01-01T10:00:00"),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test empty data scenarios`() {
|
||||
val emptyBackup =
|
||||
ClimbDataBackup(
|
||||
exportedAt = "2024-01-01T10:00:00",
|
||||
version = "2.0",
|
||||
formatVersion = "2.0",
|
||||
gyms = emptyList(),
|
||||
problems = emptyList(),
|
||||
sessions = emptyList(),
|
||||
attempts = emptyList()
|
||||
)
|
||||
ClimbDataBackup(
|
||||
exportedAt = "2024-01-01T10:00:00",
|
||||
version = "2.0",
|
||||
formatVersion = "2.0",
|
||||
gyms = emptyList(),
|
||||
problems = emptyList(),
|
||||
sessions = emptyList(),
|
||||
attempts = emptyList(),
|
||||
)
|
||||
|
||||
val dataBackup =
|
||||
ClimbDataBackup(
|
||||
exportedAt = "2024-01-01T10:00:00",
|
||||
version = "2.0",
|
||||
formatVersion = "2.0",
|
||||
gyms =
|
||||
listOf(
|
||||
BackupGym(
|
||||
id = "gym1",
|
||||
name = "Test Gym",
|
||||
location = null,
|
||||
supportedClimbTypes = listOf(ClimbType.BOULDER),
|
||||
difficultySystems =
|
||||
listOf(DifficultySystem.V_SCALE),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00",
|
||||
updatedAt = "2024-01-01T10:00:00"
|
||||
)
|
||||
),
|
||||
problems = emptyList(),
|
||||
sessions = emptyList(),
|
||||
attempts = emptyList()
|
||||
)
|
||||
ClimbDataBackup(
|
||||
exportedAt = "2024-01-01T10:00:00",
|
||||
version = "2.0",
|
||||
formatVersion = "2.0",
|
||||
gyms =
|
||||
listOf(
|
||||
BackupGym(
|
||||
id = "gym1",
|
||||
name = "Test Gym",
|
||||
location = null,
|
||||
supportedClimbTypes = listOf(ClimbType.BOULDER),
|
||||
difficultySystems =
|
||||
listOf(DifficultySystem.V_SCALE),
|
||||
customDifficultyGrades = emptyList(),
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00",
|
||||
updatedAt = "2024-01-01T10:00:00",
|
||||
),
|
||||
),
|
||||
problems = emptyList(),
|
||||
sessions = emptyList(),
|
||||
attempts = emptyList(),
|
||||
)
|
||||
|
||||
// Test merging empty with data
|
||||
val merged1 = performIntelligentMerge(emptyBackup, dataBackup)
|
||||
@@ -334,8 +334,8 @@ class SyncMergeLogicTest {
|
||||
|
||||
// Helper methods that simulate the merge logic from SyncService
|
||||
private fun performIntelligentMerge(
|
||||
local: ClimbDataBackup,
|
||||
server: ClimbDataBackup
|
||||
local: ClimbDataBackup,
|
||||
server: ClimbDataBackup,
|
||||
): ClimbDataBackup {
|
||||
val mergedGyms = mergeGyms(local.gyms, server.gyms)
|
||||
val mergedProblems = mergeProblems(local.problems, server.problems)
|
||||
@@ -343,13 +343,13 @@ class SyncMergeLogicTest {
|
||||
val mergedAttempts = mergeAttempts(local.attempts, server.attempts)
|
||||
|
||||
return ClimbDataBackup(
|
||||
exportedAt = "2024-01-01T12:00:00",
|
||||
version = "2.0",
|
||||
formatVersion = "2.0",
|
||||
gyms = mergedGyms,
|
||||
problems = mergedProblems,
|
||||
sessions = mergedSessions,
|
||||
attempts = mergedAttempts
|
||||
exportedAt = "2024-01-01T12:00:00",
|
||||
version = "2.0",
|
||||
formatVersion = "2.0",
|
||||
gyms = mergedGyms,
|
||||
problems = mergedProblems,
|
||||
sessions = mergedSessions,
|
||||
attempts = mergedAttempts,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -371,8 +371,8 @@ class SyncMergeLogicTest {
|
||||
}
|
||||
|
||||
private fun mergeProblems(
|
||||
local: List<BackupProblem>,
|
||||
server: List<BackupProblem>
|
||||
local: List<BackupProblem>,
|
||||
server: List<BackupProblem>,
|
||||
): List<BackupProblem> {
|
||||
val merged = mutableMapOf<String, BackupProblem>()
|
||||
|
||||
@@ -390,7 +390,7 @@ class SyncMergeLogicTest {
|
||||
serverProblem.imagePaths?.let { allImagePaths.addAll(it) }
|
||||
|
||||
merged[serverProblem.id] =
|
||||
serverProblem.withUpdatedImagePaths(allImagePaths.toList())
|
||||
serverProblem.withUpdatedImagePaths(allImagePaths.toList())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,8 +398,8 @@ class SyncMergeLogicTest {
|
||||
}
|
||||
|
||||
private fun mergeSessions(
|
||||
local: List<BackupClimbSession>,
|
||||
server: List<BackupClimbSession>
|
||||
local: List<BackupClimbSession>,
|
||||
server: List<BackupClimbSession>,
|
||||
): List<BackupClimbSession> {
|
||||
val merged = mutableMapOf<String, BackupClimbSession>()
|
||||
|
||||
@@ -419,8 +419,8 @@ class SyncMergeLogicTest {
|
||||
}
|
||||
|
||||
private fun mergeAttempts(
|
||||
local: List<BackupAttempt>,
|
||||
server: List<BackupAttempt>
|
||||
local: List<BackupAttempt>,
|
||||
server: List<BackupAttempt>,
|
||||
): List<BackupAttempt> {
|
||||
val merged = mutableMapOf<String, BackupAttempt>()
|
||||
|
||||
@@ -431,10 +431,10 @@ class SyncMergeLogicTest {
|
||||
server.forEach { serverAttempt ->
|
||||
val localAttempt = merged[serverAttempt.id]
|
||||
if (localAttempt == null ||
|
||||
isNewerThan(
|
||||
serverAttempt.updatedAt ?: serverAttempt.createdAt,
|
||||
localAttempt.updatedAt ?: localAttempt.createdAt
|
||||
)
|
||||
isNewerThan(
|
||||
serverAttempt.updatedAt ?: serverAttempt.createdAt,
|
||||
localAttempt.updatedAt ?: localAttempt.createdAt,
|
||||
)
|
||||
) {
|
||||
merged[serverAttempt.id] = serverAttempt
|
||||
}
|
||||
@@ -458,32 +458,32 @@ class SyncMergeLogicTest {
|
||||
@Test
|
||||
fun `test active sessions excluded from sync`() {
|
||||
val allLocalSessions =
|
||||
listOf(
|
||||
BackupClimbSession(
|
||||
id = "active_session_1",
|
||||
gymId = "gym1",
|
||||
date = "2024-01-01",
|
||||
startTime = "2024-01-01T10:00:00",
|
||||
endTime = null,
|
||||
duration = null,
|
||||
status = SessionStatus.ACTIVE,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00",
|
||||
updatedAt = "2024-01-01T10:00:00"
|
||||
),
|
||||
BackupClimbSession(
|
||||
id = "completed_session_1",
|
||||
gymId = "gym1",
|
||||
date = "2023-12-31",
|
||||
startTime = "2023-12-31T15:00:00",
|
||||
endTime = "2023-12-31T17:00:00",
|
||||
duration = 7200000,
|
||||
status = SessionStatus.COMPLETED,
|
||||
notes = "Previous session",
|
||||
createdAt = "2023-12-31T15:00:00",
|
||||
updatedAt = "2023-12-31T17:00:00"
|
||||
)
|
||||
)
|
||||
listOf(
|
||||
BackupClimbSession(
|
||||
id = "active_session_1",
|
||||
gymId = "gym1",
|
||||
date = "2024-01-01",
|
||||
startTime = "2024-01-01T10:00:00",
|
||||
endTime = null,
|
||||
duration = null,
|
||||
status = SessionStatus.ACTIVE,
|
||||
notes = null,
|
||||
createdAt = "2024-01-01T10:00:00",
|
||||
updatedAt = "2024-01-01T10:00:00",
|
||||
),
|
||||
BackupClimbSession(
|
||||
id = "completed_session_1",
|
||||
gymId = "gym1",
|
||||
date = "2023-12-31",
|
||||
startTime = "2023-12-31T15:00:00",
|
||||
endTime = "2023-12-31T17:00:00",
|
||||
duration = 7200000,
|
||||
status = SessionStatus.COMPLETED,
|
||||
notes = "Previous session",
|
||||
createdAt = "2023-12-31T15:00:00",
|
||||
updatedAt = "2023-12-31T17:00:00",
|
||||
),
|
||||
)
|
||||
|
||||
// Simulate filtering that would happen in createBackupFromRepository
|
||||
val sessionsForSync = allLocalSessions.filter { it.status != SessionStatus.ACTIVE }
|
||||
@@ -493,18 +493,18 @@ class SyncMergeLogicTest {
|
||||
|
||||
// Active session should be excluded
|
||||
assertFalse(
|
||||
"Should not contain active session in sync",
|
||||
sessionsForSync.any {
|
||||
it.id == "active_session_1" && it.status == SessionStatus.ACTIVE
|
||||
}
|
||||
"Should not contain active session in sync",
|
||||
sessionsForSync.any {
|
||||
it.id == "active_session_1" && it.status == SessionStatus.ACTIVE
|
||||
},
|
||||
)
|
||||
|
||||
// Completed session should be included
|
||||
assertTrue(
|
||||
"Should contain completed session in sync",
|
||||
sessionsForSync.any {
|
||||
it.id == "completed_session_1" && it.status == SessionStatus.COMPLETED
|
||||
}
|
||||
"Should contain completed session in sync",
|
||||
sessionsForSync.any {
|
||||
it.id == "completed_session_1" && it.status == SessionStatus.COMPLETED
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.atridad.ascently
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.concurrent.TimeUnit
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
class UtilityTests {
|
||||
|
||||
@@ -75,13 +75,13 @@ class UtilityTests {
|
||||
@Test
|
||||
fun testClimbingStatistics() {
|
||||
val attempts =
|
||||
listOf(
|
||||
AttemptData("SUCCESS", 120),
|
||||
AttemptData("FALL", 90),
|
||||
AttemptData("SUCCESS", 150),
|
||||
AttemptData("FLASH", 60),
|
||||
AttemptData("FALL", 110)
|
||||
)
|
||||
listOf(
|
||||
AttemptData("SUCCESS", 120),
|
||||
AttemptData("FALL", 90),
|
||||
AttemptData("SUCCESS", 150),
|
||||
AttemptData("FLASH", 60),
|
||||
AttemptData("FALL", 110),
|
||||
)
|
||||
|
||||
val stats = calculateAttemptStatistics(attempts)
|
||||
|
||||
@@ -163,23 +163,23 @@ class UtilityTests {
|
||||
@Test
|
||||
fun testSearchFiltering() {
|
||||
val problems =
|
||||
listOf(
|
||||
ProblemData(
|
||||
"id1",
|
||||
"Crimpy Problem",
|
||||
"BOULDER",
|
||||
"V5",
|
||||
listOf("crimpy", "overhang")
|
||||
),
|
||||
ProblemData("id2", "Easy Route", "ROPE", "5.6", listOf("beginner", "slab")),
|
||||
ProblemData(
|
||||
"id3",
|
||||
"Hard Boulder",
|
||||
"BOULDER",
|
||||
"V10",
|
||||
listOf("powerful", "roof")
|
||||
)
|
||||
)
|
||||
listOf(
|
||||
ProblemData(
|
||||
"id1",
|
||||
"Crimpy Problem",
|
||||
"BOULDER",
|
||||
"V5",
|
||||
listOf("crimpy", "overhang"),
|
||||
),
|
||||
ProblemData("id2", "Easy Route", "ROPE", "5.6", listOf("beginner", "slab")),
|
||||
ProblemData(
|
||||
"id3",
|
||||
"Hard Boulder",
|
||||
"BOULDER",
|
||||
"V10",
|
||||
listOf("powerful", "roof"),
|
||||
),
|
||||
)
|
||||
|
||||
val boulderProblems = filterByClimbType(problems, "BOULDER")
|
||||
assertEquals(2, boulderProblems.size)
|
||||
@@ -207,20 +207,20 @@ class UtilityTests {
|
||||
@Test
|
||||
fun testBackupValidation() {
|
||||
val validBackup =
|
||||
BackupData(
|
||||
version = "2.0",
|
||||
formatVersion = "2.0",
|
||||
exportedAt = "2024-01-01T10:00:00Z",
|
||||
dataCount = 5
|
||||
)
|
||||
BackupData(
|
||||
version = "2.0",
|
||||
formatVersion = "2.0",
|
||||
exportedAt = "2024-01-01T10:00:00Z",
|
||||
dataCount = 5,
|
||||
)
|
||||
|
||||
val invalidBackup =
|
||||
BackupData(
|
||||
version = "1.0",
|
||||
formatVersion = "2.0",
|
||||
exportedAt = "invalid-date",
|
||||
dataCount = -1
|
||||
)
|
||||
BackupData(
|
||||
version = "1.0",
|
||||
formatVersion = "2.0",
|
||||
exportedAt = "invalid-date",
|
||||
dataCount = -1,
|
||||
)
|
||||
|
||||
assertTrue(isValidBackup(validBackup))
|
||||
assertFalse(isValidBackup(invalidBackup))
|
||||
@@ -258,10 +258,10 @@ class UtilityTests {
|
||||
val successRate = (successful.toDouble() / attempts.size) * 100
|
||||
|
||||
return AttemptStatistics(
|
||||
totalAttempts = attempts.size,
|
||||
successfulAttempts = successful,
|
||||
successRate = successRate,
|
||||
averageDuration = avgDuration
|
||||
totalAttempts = attempts.size,
|
||||
successfulAttempts = successful,
|
||||
successRate = successRate,
|
||||
averageDuration = avgDuration,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -301,8 +301,8 @@ class UtilityTests {
|
||||
}
|
||||
|
||||
private fun filterByClimbType(
|
||||
problems: List<ProblemData>,
|
||||
climbType: String
|
||||
problems: List<ProblemData>,
|
||||
climbType: String,
|
||||
): List<ProblemData> {
|
||||
return problems.filter { it.climbType == climbType }
|
||||
}
|
||||
@@ -312,9 +312,9 @@ class UtilityTests {
|
||||
}
|
||||
|
||||
private fun filterByDifficultyRange(
|
||||
problems: List<ProblemData>,
|
||||
minGrade: String,
|
||||
maxGrade: String
|
||||
problems: List<ProblemData>,
|
||||
minGrade: String,
|
||||
maxGrade: String,
|
||||
): List<ProblemData> {
|
||||
return problems.filter { problem ->
|
||||
if (problem.climbType == "BOULDER" && problem.difficulty.startsWith("V")) {
|
||||
@@ -329,17 +329,17 @@ class UtilityTests {
|
||||
}
|
||||
|
||||
private fun mergeData(
|
||||
local: Map<String, String>,
|
||||
server: Map<String, String>
|
||||
local: Map<String, String>,
|
||||
server: Map<String, String>,
|
||||
): Map<String, String> {
|
||||
return (local.keys + server.keys).associateWith { key -> server[key] ?: local[key]!! }
|
||||
}
|
||||
|
||||
private fun isValidBackup(backup: BackupData): Boolean {
|
||||
return backup.version == "2.0" &&
|
||||
backup.formatVersion == "2.0" &&
|
||||
backup.exportedAt.matches(Regex("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z")) &&
|
||||
backup.dataCount >= 0
|
||||
backup.formatVersion == "2.0" &&
|
||||
backup.exportedAt.matches(Regex("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z")) &&
|
||||
backup.dataCount >= 0
|
||||
}
|
||||
|
||||
// Data classes for testing
|
||||
@@ -347,24 +347,24 @@ class UtilityTests {
|
||||
data class AttemptData(val result: String, val duration: Int)
|
||||
|
||||
data class AttemptStatistics(
|
||||
val totalAttempts: Int,
|
||||
val successfulAttempts: Int,
|
||||
val successRate: Double,
|
||||
val averageDuration: Double
|
||||
val totalAttempts: Int,
|
||||
val successfulAttempts: Int,
|
||||
val successRate: Double,
|
||||
val averageDuration: Double,
|
||||
)
|
||||
|
||||
data class ProblemData(
|
||||
val id: String,
|
||||
val name: String,
|
||||
val climbType: String,
|
||||
val difficulty: String,
|
||||
val tags: List<String>
|
||||
val id: String,
|
||||
val name: String,
|
||||
val climbType: String,
|
||||
val difficulty: String,
|
||||
val tags: List<String>,
|
||||
)
|
||||
|
||||
data class BackupData(
|
||||
val version: String,
|
||||
val formatVersion: String,
|
||||
val exportedAt: String,
|
||||
val dataCount: Int
|
||||
val version: String,
|
||||
val formatVersion: String,
|
||||
val exportedAt: String,
|
||||
val dataCount: Int,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,4 +3,6 @@ plugins {
|
||||
alias(libs.plugins.android.application) apply false
|
||||
alias(libs.plugins.kotlin.android) apply false
|
||||
alias(libs.plugins.kotlin.compose) apply false
|
||||
alias(libs.plugins.detekt) apply false
|
||||
alias(libs.plugins.spotless) apply false
|
||||
}
|
||||
584
android/detekt.yml
Normal file
@@ -0,0 +1,584 @@
|
||||
build:
|
||||
maxIssues: -1
|
||||
excludeCorrectable: false
|
||||
|
||||
config:
|
||||
validation: true
|
||||
warningsAsErrors: false
|
||||
|
||||
processors:
|
||||
active: true
|
||||
exclude:
|
||||
- 'DetektProgressListener'
|
||||
|
||||
console-reports:
|
||||
active: true
|
||||
|
||||
output-reports:
|
||||
active: true
|
||||
exclude:
|
||||
- 'TxtOutputReport'
|
||||
|
||||
complexity:
|
||||
active: true
|
||||
ComplexCondition:
|
||||
active: true
|
||||
threshold: 5
|
||||
CyclomaticComplexMethod:
|
||||
active: true
|
||||
threshold: 50
|
||||
ignoreSingleWhenExpression: true
|
||||
ignoreSimpleWhenEntries: true
|
||||
ignoreNestingFunctions: false
|
||||
nestingFunctions:
|
||||
- 'also'
|
||||
- 'apply'
|
||||
- 'let'
|
||||
- 'run'
|
||||
- 'with'
|
||||
LabeledExpression:
|
||||
active: false
|
||||
LargeClass:
|
||||
active: true
|
||||
threshold: 800
|
||||
LongMethod:
|
||||
active: true
|
||||
threshold: 120
|
||||
ignoreAnnotated:
|
||||
- 'Composable'
|
||||
- 'Test'
|
||||
LongParameterList:
|
||||
active: true
|
||||
functionThreshold: 15
|
||||
constructorThreshold: 15
|
||||
ignoreDefaultParameters: true
|
||||
ignoreDataClasses: true
|
||||
ignoreAnnotatedParameter:
|
||||
- 'Composable'
|
||||
MethodOverloading:
|
||||
active: false
|
||||
NamedArguments:
|
||||
active: false
|
||||
NestedBlockDepth:
|
||||
active: true
|
||||
threshold: 8
|
||||
NestedScopeFunctions:
|
||||
active: true
|
||||
threshold: 2
|
||||
functions:
|
||||
- 'also'
|
||||
- 'apply'
|
||||
- 'let'
|
||||
- 'run'
|
||||
- 'with'
|
||||
ReplaceSafeCallChainWithRun:
|
||||
active: false
|
||||
StringLiteralDuplication:
|
||||
active: false
|
||||
threshold: 4
|
||||
ignoreAnnotation: true
|
||||
excludeStringsWithLessThan5Characters: true
|
||||
ignoreStringsRegex: '$^'
|
||||
TooManyFunctions:
|
||||
active: true
|
||||
thresholdInFiles: 40
|
||||
thresholdInClasses: 40
|
||||
thresholdInInterfaces: 25
|
||||
thresholdInObjects: 25
|
||||
thresholdInEnums: 15
|
||||
ignoreDeprecated: true
|
||||
ignorePrivate: true
|
||||
ignoreOverridden: true
|
||||
|
||||
coroutines:
|
||||
active: true
|
||||
GlobalCoroutineUsage:
|
||||
active: true
|
||||
InjectDispatcher:
|
||||
active: true
|
||||
dispatcherNames:
|
||||
- 'IO'
|
||||
- 'Default'
|
||||
- 'Unconfined'
|
||||
RedundantSuspendModifier:
|
||||
active: true
|
||||
SleepInsteadOfDelay:
|
||||
active: true
|
||||
SuspendFunSwallowedCancellation:
|
||||
active: true
|
||||
SuspendFunWithCoroutineScopeReceiver:
|
||||
active: true
|
||||
SuspendFunWithFlowReturnType:
|
||||
active: true
|
||||
|
||||
empty-blocks:
|
||||
active: true
|
||||
EmptyCatchBlock:
|
||||
active: true
|
||||
allowedExceptionNameRegex: '_|(ignore|expected).*'
|
||||
EmptyClassBlock:
|
||||
active: true
|
||||
EmptyDefaultConstructor:
|
||||
active: true
|
||||
EmptyDoWhileBlock:
|
||||
active: true
|
||||
EmptyElseBlock:
|
||||
active: true
|
||||
EmptyFinallyBlock:
|
||||
active: true
|
||||
EmptyForBlock:
|
||||
active: true
|
||||
EmptyFunctionBlock:
|
||||
active: true
|
||||
ignoreOverridden: true
|
||||
EmptyIfBlock:
|
||||
active: true
|
||||
EmptyInitBlock:
|
||||
active: true
|
||||
EmptyKtFile:
|
||||
active: true
|
||||
EmptySecondaryConstructor:
|
||||
active: true
|
||||
EmptyTryBlock:
|
||||
active: true
|
||||
EmptyWhenBlock:
|
||||
active: true
|
||||
EmptyWhileBlock:
|
||||
active: true
|
||||
|
||||
exceptions:
|
||||
active: true
|
||||
ExceptionRaisedInUnexpectedLocation:
|
||||
active: true
|
||||
methodNames:
|
||||
- 'equals'
|
||||
- 'finalize'
|
||||
- 'hashCode'
|
||||
- 'toString'
|
||||
InstanceOfCheckForException:
|
||||
active: true
|
||||
NotImplementedDeclaration:
|
||||
active: false
|
||||
ObjectExtendsThrowable:
|
||||
active: false
|
||||
PrintStackTrace:
|
||||
active: true
|
||||
RethrowCaughtException:
|
||||
active: true
|
||||
ReturnFromFinally:
|
||||
active: true
|
||||
SwallowedException:
|
||||
active: false
|
||||
ignoredExceptionTypes:
|
||||
- 'InterruptedException'
|
||||
- 'MalformedURLException'
|
||||
- 'NumberFormatException'
|
||||
- 'ParseException'
|
||||
allowedExceptionNameRegex: '_|(ignore|expected).*'
|
||||
ThrowingExceptionFromFinally:
|
||||
active: true
|
||||
ThrowingExceptionInMain:
|
||||
active: false
|
||||
ThrowingExceptionsWithoutMessageOrCause:
|
||||
active: true
|
||||
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt']
|
||||
exceptions:
|
||||
- 'ArrayIndexOutOfBoundsException'
|
||||
- 'Exception'
|
||||
- 'IllegalArgumentException'
|
||||
- 'IllegalMonitorStateException'
|
||||
- 'IllegalStateException'
|
||||
- 'IndexOutOfBoundsException'
|
||||
- 'NullPointerException'
|
||||
- 'RuntimeException'
|
||||
- 'Throwable'
|
||||
ThrowingNewInstanceOfSameException:
|
||||
active: true
|
||||
TooGenericExceptionCaught:
|
||||
active: false
|
||||
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt']
|
||||
exceptionNames:
|
||||
- 'ArrayIndexOutOfBoundsException'
|
||||
- 'Error'
|
||||
- 'Exception'
|
||||
- 'IllegalMonitorStateException'
|
||||
- 'IndexOutOfBoundsException'
|
||||
- 'NullPointerException'
|
||||
- 'RuntimeException'
|
||||
- 'Throwable'
|
||||
allowedExceptionNameRegex: '_|(ignore|expected).*'
|
||||
TooGenericExceptionThrown:
|
||||
active: false
|
||||
exceptionNames:
|
||||
- 'Error'
|
||||
- 'Exception'
|
||||
- 'RuntimeException'
|
||||
- 'Throwable'
|
||||
|
||||
naming:
|
||||
active: true
|
||||
BooleanPropertyNaming:
|
||||
active: true
|
||||
allowedPattern: '^(is|has|are|should|can|will|does|did)'
|
||||
ClassNaming:
|
||||
active: true
|
||||
classPattern: '[A-Z][a-zA-Z0-9]*'
|
||||
ConstructorParameterNaming:
|
||||
active: true
|
||||
parameterPattern: '[a-z][A-Za-z0-9]*'
|
||||
privateParameterPattern: '[a-z][A-Za-z0-9]*'
|
||||
excludeClassPattern: '$^'
|
||||
EnumNaming:
|
||||
active: true
|
||||
enumEntryPattern: '[A-Z][_a-zA-Z0-9]*'
|
||||
ForbiddenClassName:
|
||||
active: false
|
||||
FunctionMaxLength:
|
||||
active: false
|
||||
FunctionMinLength:
|
||||
active: false
|
||||
FunctionNaming:
|
||||
active: true
|
||||
functionPattern: '[a-zA-Z][a-zA-Z0-9]*'
|
||||
excludeClassPattern: '$^'
|
||||
ignoreAnnotated:
|
||||
- 'Composable'
|
||||
FunctionParameterNaming:
|
||||
active: true
|
||||
parameterPattern: '[a-z][A-Za-z0-9]*'
|
||||
excludeClassPattern: '$^'
|
||||
InvalidPackageDeclaration:
|
||||
active: true
|
||||
rootPackage: 'com.atridad.ascently'
|
||||
LambdaParameterNaming:
|
||||
active: true
|
||||
parameterPattern: '[a-z][A-Za-z0-9]*|_'
|
||||
MatchingDeclarationName:
|
||||
active: false
|
||||
mustBeFirst: true
|
||||
MemberNameEqualsClassName:
|
||||
active: true
|
||||
ignoreOverridden: true
|
||||
NoNameShadowing:
|
||||
active: true
|
||||
NonBooleanPropertyPrefixedWithIs:
|
||||
active: true
|
||||
ObjectPropertyNaming:
|
||||
active: false
|
||||
PackageNaming:
|
||||
active: true
|
||||
packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*'
|
||||
TopLevelPropertyNaming:
|
||||
active: true
|
||||
constantPattern: '[A-Z][_A-Z0-9]*'
|
||||
propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
|
||||
privatePropertyPattern: '_?[A-Za-z][A-Za-z0-9]*'
|
||||
VariableMaxLength:
|
||||
active: false
|
||||
VariableMinLength:
|
||||
active: false
|
||||
VariableNaming:
|
||||
active: true
|
||||
variablePattern: '[a-z][A-Za-z0-9]*'
|
||||
privateVariablePattern: '[_a-z][A-Za-z0-9]*'
|
||||
excludeClassPattern: '$^'
|
||||
|
||||
performance:
|
||||
active: true
|
||||
ArrayPrimitive:
|
||||
active: true
|
||||
CouldBeSequence:
|
||||
active: false
|
||||
ForEachOnRange:
|
||||
active: true
|
||||
SpreadOperator:
|
||||
active: false
|
||||
UnnecessaryPartOfBinaryExpression:
|
||||
active: true
|
||||
UnnecessaryTemporaryInstantiation:
|
||||
active: true
|
||||
|
||||
potential-bugs:
|
||||
active: true
|
||||
AvoidReferentialEquality:
|
||||
active: true
|
||||
CastNullableToNonNullableType:
|
||||
active: true
|
||||
CastToNullableType:
|
||||
active: false
|
||||
Deprecation:
|
||||
active: false
|
||||
DontDowncastCollectionTypes:
|
||||
active: true
|
||||
DoubleMutabilityForCollection:
|
||||
active: true
|
||||
ElseCaseInsteadOfExhaustiveWhen:
|
||||
active: false
|
||||
EqualsAlwaysReturnsTrueOrFalse:
|
||||
active: true
|
||||
EqualsWithHashCodeExist:
|
||||
active: true
|
||||
ExitOutsideMain:
|
||||
active: false
|
||||
ExplicitGarbageCollectionCall:
|
||||
active: true
|
||||
HasPlatformType:
|
||||
active: true
|
||||
IgnoredReturnValue:
|
||||
active: true
|
||||
ImplicitDefaultLocale:
|
||||
active: true
|
||||
ImplicitUnitReturnType:
|
||||
active: true
|
||||
allowExplicitReturnType: true
|
||||
InvalidRange:
|
||||
active: true
|
||||
IteratorHasNextCallsNextMethod:
|
||||
active: true
|
||||
IteratorNotThrowingNoSuchElementException:
|
||||
active: true
|
||||
LateinitUsage:
|
||||
active: false
|
||||
MapGetWithNotNullAssertionOperator:
|
||||
active: true
|
||||
MissingPackageDeclaration:
|
||||
active: true
|
||||
NullCheckOnMutableProperty:
|
||||
active: true
|
||||
NullableToStringCall:
|
||||
active: true
|
||||
PropertyUsedBeforeDeclaration:
|
||||
active: false
|
||||
UnconditionalJumpStatementInLoop:
|
||||
active: true
|
||||
UnnecessaryNotNullCheck:
|
||||
active: true
|
||||
UnnecessaryNotNullOperator:
|
||||
active: true
|
||||
UnnecessarySafeCall:
|
||||
active: true
|
||||
UnreachableCatchBlock:
|
||||
active: true
|
||||
UnreachableCode:
|
||||
active: true
|
||||
UnsafeCallOnNullableType:
|
||||
active: true
|
||||
UnsafeCast:
|
||||
active: true
|
||||
UnusedUnaryOperator:
|
||||
active: true
|
||||
UselessPostfixExpression:
|
||||
active: true
|
||||
WrongEqualsTypeParameter:
|
||||
active: true
|
||||
|
||||
style:
|
||||
active: true
|
||||
AlsoCouldBeApply:
|
||||
active: false
|
||||
BracesOnIfStatements:
|
||||
active: false
|
||||
singleLine: 'never'
|
||||
multiLine: 'always'
|
||||
BracesOnWhenStatements:
|
||||
active: false
|
||||
singleLine: 'necessary'
|
||||
multiLine: 'necessary'
|
||||
CanBeNonNullable:
|
||||
active: true
|
||||
CascadingCallWrapping:
|
||||
active: false
|
||||
ClassOrdering:
|
||||
active: false
|
||||
CollapsibleIfStatements:
|
||||
active: false
|
||||
DataClassContainsFunctions:
|
||||
active: false
|
||||
DataClassShouldBeImmutable:
|
||||
active: true
|
||||
DestructuringDeclarationWithTooManyEntries:
|
||||
active: true
|
||||
maxDestructuringEntries: 5
|
||||
EqualsNullCall:
|
||||
active: true
|
||||
EqualsOnSignatureLine:
|
||||
active: true
|
||||
ExplicitCollectionElementAccessMethod:
|
||||
active: true
|
||||
ExplicitItLambdaParameter:
|
||||
active: false
|
||||
ExpressionBodySyntax:
|
||||
active: false
|
||||
includeLineWrapping: false
|
||||
ForbiddenAnnotation:
|
||||
active: false
|
||||
ForbiddenComment:
|
||||
active: false
|
||||
ForbiddenImport:
|
||||
active: false
|
||||
ForbiddenMethodCall:
|
||||
active: false
|
||||
ForbiddenSuppress:
|
||||
active: false
|
||||
ForbiddenVoid:
|
||||
active: true
|
||||
ignoreOverridden: true
|
||||
ignoreUsageInGenerics: true
|
||||
FunctionOnlyReturningConstant:
|
||||
active: false
|
||||
ignoreOverridableFunction: true
|
||||
ignoreActualFunction: true
|
||||
excludedFunctions: []
|
||||
LoopWithTooManyJumpStatements:
|
||||
active: true
|
||||
maxJumpCount: 2
|
||||
MagicNumber:
|
||||
active: false
|
||||
MandatoryBracesLoops:
|
||||
active: true
|
||||
MaxChainedCallsOnSameLine:
|
||||
active: true
|
||||
maxChainedCalls: 5
|
||||
MaxLineLength:
|
||||
active: true
|
||||
maxLineLength: 220
|
||||
excludePackageStatements: true
|
||||
excludeImportStatements: true
|
||||
excludeCommentStatements: true
|
||||
excludeRawStrings: true
|
||||
MayBeConst:
|
||||
active: true
|
||||
ModifierOrder:
|
||||
active: true
|
||||
MultilineRawStringIndentation:
|
||||
active: false
|
||||
indentSize: 4
|
||||
MultilineLambdaItParameter:
|
||||
active: true
|
||||
NestedClassesVisibility:
|
||||
active: true
|
||||
NewLineAtEndOfFile:
|
||||
active: false
|
||||
NoTabs:
|
||||
active: true
|
||||
NullableBooleanCheck:
|
||||
active: true
|
||||
ObjectLiteralToLambda:
|
||||
active: true
|
||||
OptionalAbstractKeyword:
|
||||
active: true
|
||||
OptionalUnit:
|
||||
active: true
|
||||
PreferToOverPairSyntax:
|
||||
active: true
|
||||
ProtectedMemberInFinalClass:
|
||||
active: true
|
||||
RedundantExplicitType:
|
||||
active: true
|
||||
RedundantHigherOrderMapUsage:
|
||||
active: true
|
||||
RedundantVisibilityModifierRule:
|
||||
active: false
|
||||
ReturnCount:
|
||||
active: true
|
||||
max: 6
|
||||
excludedFunctions:
|
||||
- 'equals'
|
||||
excludeLabeled: true
|
||||
excludeReturnFromLambda: true
|
||||
excludeGuardClauses: true
|
||||
SafeCast:
|
||||
active: true
|
||||
SerialVersionUIDInSerializableClass:
|
||||
active: false
|
||||
SpacingBetweenPackageAndImports:
|
||||
active: true
|
||||
StringShouldBeRawString:
|
||||
active: false
|
||||
ThrowsCount:
|
||||
active: true
|
||||
max: 10
|
||||
excludeGuardClauses: true
|
||||
TrailingWhitespace:
|
||||
active: false
|
||||
TrimMultilineRawString:
|
||||
active: true
|
||||
UnderscoresInNumericLiterals:
|
||||
active: false
|
||||
acceptableLength: 4
|
||||
allowNonStandardGrouping: false
|
||||
UnnecessaryAbstractClass:
|
||||
active: true
|
||||
UnnecessaryAnnotationUseSiteTarget:
|
||||
active: true
|
||||
UnnecessaryApply:
|
||||
active: true
|
||||
UnnecessaryBackticks:
|
||||
active: true
|
||||
UnnecessaryBracesAroundTrailingLambda:
|
||||
active: true
|
||||
UnnecessaryFilter:
|
||||
active: true
|
||||
UnnecessaryInheritance:
|
||||
active: true
|
||||
UnnecessaryInnerClass:
|
||||
active: true
|
||||
UnnecessaryLet:
|
||||
active: true
|
||||
UnnecessaryParentheses:
|
||||
active: false
|
||||
allowForUnclearPrecedence: true
|
||||
UntilInsteadOfRangeTo:
|
||||
active: true
|
||||
UnusedImports:
|
||||
active: true
|
||||
UnusedParameter:
|
||||
active: true
|
||||
allowedNames: 'ignored|expected|_|session|startTime|endTime|xAxisFormatter'
|
||||
UnusedPrivateClass:
|
||||
active: true
|
||||
UnusedPrivateMember:
|
||||
active: true
|
||||
allowedNames: '(_|ignored|expected|serialVersionUID)'
|
||||
UnusedPrivateProperty:
|
||||
active: true
|
||||
allowedNames: '_|ignored|expected|serialVersionUID'
|
||||
UseAnyOrNoneInsteadOfFind:
|
||||
active: true
|
||||
UseArrayLiteralsInAnnotations:
|
||||
active: true
|
||||
UseCheckNotNull:
|
||||
active: true
|
||||
UseCheckOrError:
|
||||
active: true
|
||||
UseDataClass:
|
||||
active: false
|
||||
UseEmptyCounterpart:
|
||||
active: true
|
||||
UseIfEmptyOrIfBlank:
|
||||
active: true
|
||||
UseIfInsteadOfWhen:
|
||||
active: false
|
||||
UseIsNullOrEmpty:
|
||||
active: true
|
||||
UseLet:
|
||||
active: false
|
||||
UseOrEmpty:
|
||||
active: true
|
||||
UseRequire:
|
||||
active: true
|
||||
UseRequireNotNull:
|
||||
active: true
|
||||
UseSumOfInsteadOfFlatMapSize:
|
||||
active: true
|
||||
UselessCallOnNotNull:
|
||||
active: true
|
||||
UtilityClassWithPublicConstructor:
|
||||
active: true
|
||||
VarCouldBeVal:
|
||||
active: true
|
||||
WildcardImport:
|
||||
active: false
|
||||
excludeImports:
|
||||
- 'java.util.*'
|
||||
- 'kotlinx.android.synthetic.*'
|
||||
@@ -10,7 +10,11 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. For more details, visit
|
||||
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
|
||||
# org.gradle.parallel=true
|
||||
org.gradle.parallel=true
|
||||
# Enable Gradle build caching for faster incremental builds
|
||||
org.gradle.caching=true
|
||||
# Enable configuration caching for faster configuration phase
|
||||
org.gradle.configuration-cache=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[versions]
|
||||
agp = "8.12.3"
|
||||
kotlin = "2.2.21"
|
||||
kotlin = "2.3.0"
|
||||
coreKtx = "1.17.0"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.3.0"
|
||||
@@ -10,8 +10,8 @@ androidxTestExt = "1.3.0"
|
||||
androidxTestRunner = "1.7.0"
|
||||
androidxTestRules = "1.7.0"
|
||||
lifecycleRuntimeKtx = "2.10.0"
|
||||
activityCompose = "1.12.0"
|
||||
composeBom = "2025.11.01"
|
||||
activityCompose = "1.12.2"
|
||||
composeBom = "2025.12.01"
|
||||
room = "2.8.4"
|
||||
navigation = "2.9.6"
|
||||
viewmodel = "2.10.0"
|
||||
@@ -19,7 +19,10 @@ kotlinxSerialization = "1.9.0"
|
||||
kotlinxCoroutines = "1.10.2"
|
||||
coil = "2.7.0"
|
||||
ksp = "2.2.20-2.0.3"
|
||||
exifinterface = "1.4.1"
|
||||
exifinterface = "1.4.2"
|
||||
healthConnect = "1.1.0"
|
||||
detekt = "1.23.8"
|
||||
spotless = "8.1.0"
|
||||
|
||||
[libraries]
|
||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||
@@ -69,9 +72,14 @@ mockk = { group = "io.mockk", name = "mockk", version = "1.14.6" }
|
||||
coil-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coil" }
|
||||
androidx-exifinterface = { group = "androidx.exifinterface", name = "exifinterface", version.ref = "exifinterface" }
|
||||
|
||||
# Health Connect
|
||||
health-connect = { group = "androidx.health.connect", name = "connect-client", version.ref = "healthConnect" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
||||
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
|
||||
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
|
||||
|
||||
3
branding/.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
*.tmp
|
||||
.DS_Store
|
||||
*.log
|
||||
@@ -1,394 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import xml.etree.ElementTree as ET
|
||||
from pathlib import Path
|
||||
from typing import Callable, TypedDict
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
|
||||
class Polygon(TypedDict):
|
||||
coords: list[tuple[float, float]]
|
||||
fill: str
|
||||
|
||||
|
||||
SCRIPT_DIR = Path(__file__).parent
|
||||
PROJECT_ROOT = SCRIPT_DIR.parent
|
||||
SOURCE_DIR = SCRIPT_DIR / "source"
|
||||
LOGOS_DIR = SCRIPT_DIR / "logos"
|
||||
|
||||
|
||||
def parse_svg_polygons(svg_path: Path) -> list[Polygon]:
|
||||
tree = ET.parse(svg_path)
|
||||
root = tree.getroot()
|
||||
|
||||
ns = {"svg": "http://www.w3.org/2000/svg"}
|
||||
polygons = root.findall(".//svg:polygon", ns)
|
||||
if not polygons:
|
||||
polygons = root.findall(".//polygon")
|
||||
|
||||
result: list[Polygon] = []
|
||||
for poly in polygons:
|
||||
points_str = poly.get("points", "").strip()
|
||||
fill = poly.get("fill", "#000000")
|
||||
|
||||
coords: list[tuple[float, float]] = []
|
||||
for pair in points_str.split():
|
||||
x, y = pair.split(",")
|
||||
coords.append((float(x), float(y)))
|
||||
|
||||
result.append({"coords": coords, "fill": fill})
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def get_bbox(polygons: list[Polygon]) -> dict[str, float]:
|
||||
all_coords: list[tuple[float, float]] = []
|
||||
for poly in polygons:
|
||||
all_coords.extend(poly["coords"])
|
||||
|
||||
xs = [c[0] for c in all_coords]
|
||||
ys = [c[1] for c in all_coords]
|
||||
|
||||
return {
|
||||
"min_x": min(xs),
|
||||
"max_x": max(xs),
|
||||
"min_y": min(ys),
|
||||
"max_y": max(ys),
|
||||
"width": max(xs) - min(xs),
|
||||
"height": max(ys) - min(ys),
|
||||
}
|
||||
|
||||
|
||||
def scale_and_center(
|
||||
polygons: list[Polygon], viewbox_size: float, target_width: float
|
||||
) -> list[Polygon]:
|
||||
bbox = get_bbox(polygons)
|
||||
|
||||
scale = target_width / bbox["width"]
|
||||
center = viewbox_size / 2
|
||||
|
||||
scaled_polys: list[Polygon] = []
|
||||
for poly in polygons:
|
||||
scaled_coords = [(x * scale, y * scale) for x, y in poly["coords"]]
|
||||
scaled_polys.append({"coords": scaled_coords, "fill": poly["fill"]})
|
||||
|
||||
scaled_bbox = get_bbox(scaled_polys)
|
||||
current_center_x = (scaled_bbox["min_x"] + scaled_bbox["max_x"]) / 2
|
||||
current_center_y = (scaled_bbox["min_y"] + scaled_bbox["max_y"]) / 2
|
||||
|
||||
offset_x = center - current_center_x
|
||||
offset_y = center - current_center_y
|
||||
|
||||
final_polys: list[Polygon] = []
|
||||
for poly in scaled_polys:
|
||||
final_coords = [(x + offset_x, y + offset_y) for x, y in poly["coords"]]
|
||||
final_polys.append({"coords": final_coords, "fill": poly["fill"]})
|
||||
|
||||
return final_polys
|
||||
|
||||
|
||||
def format_svg_points(coords: list[tuple[float, float]]) -> str:
|
||||
return " ".join(f"{x:.3f},{y:.3f}" for x, y in coords)
|
||||
|
||||
|
||||
def format_android_path(coords: list[tuple[float, float]]) -> str:
|
||||
points = " ".join(f"{x:.3f},{y:.3f}" for x, y in coords)
|
||||
pairs = points.split()
|
||||
return f"M{pairs[0]} L{pairs[1]} L{pairs[2]} Z"
|
||||
|
||||
|
||||
def generate_svg(polygons: list[Polygon], width: int, height: int) -> str:
|
||||
lines = [
|
||||
f'<svg width="{width}" height="{height}" viewBox="0 0 {width} {height}" xmlns="http://www.w3.org/2000/svg">'
|
||||
]
|
||||
for poly in polygons:
|
||||
points = format_svg_points(poly["coords"])
|
||||
lines.append(f' <polygon points="{points}" fill="{poly["fill"]}"/>')
|
||||
lines.append("</svg>")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def generate_android_vector(
|
||||
polygons: list[Polygon], width: int, height: int, viewbox: int
|
||||
) -> str:
|
||||
lines = [
|
||||
'<?xml version="1.0" encoding="utf-8"?>',
|
||||
'<vector xmlns:android="http://schemas.android.com/apk/res/android"',
|
||||
f' android:width="{width}dp"',
|
||||
f' android:height="{height}dp"',
|
||||
f' android:viewportWidth="{viewbox}"',
|
||||
f' android:viewportHeight="{viewbox}">',
|
||||
]
|
||||
for poly in polygons:
|
||||
path = format_android_path(poly["coords"])
|
||||
lines.append(
|
||||
f' <path android:fillColor="{poly["fill"]}" android:pathData="{path}" />'
|
||||
)
|
||||
lines.append("</vector>")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def rasterize_svg(
|
||||
svg_path: Path,
|
||||
output_path: Path,
|
||||
size: int,
|
||||
bg_color: tuple[int, int, int, int] | None = None,
|
||||
circular: bool = False,
|
||||
) -> None:
|
||||
from xml.dom import minidom
|
||||
|
||||
doc = minidom.parse(str(svg_path))
|
||||
|
||||
img = Image.new(
|
||||
"RGBA", (size, size), (255, 255, 255, 0) if bg_color is None else bg_color
|
||||
)
|
||||
draw = ImageDraw.Draw(img)
|
||||
|
||||
svg_elem = doc.getElementsByTagName("svg")[0]
|
||||
viewbox = svg_elem.getAttribute("viewBox").split()
|
||||
if viewbox:
|
||||
vb_width = float(viewbox[2])
|
||||
vb_height = float(viewbox[3])
|
||||
scale_x = size / vb_width
|
||||
scale_y = size / vb_height
|
||||
else:
|
||||
scale_x = scale_y = 1
|
||||
|
||||
def parse_transform(
|
||||
transform_str: str,
|
||||
) -> Callable[[float, float], tuple[float, float]]:
|
||||
import re
|
||||
|
||||
if not transform_str:
|
||||
return lambda x, y: (x, y)
|
||||
|
||||
transforms: list[tuple[str, list[float]]] = []
|
||||
for match in re.finditer(r"(\w+)\(([^)]+)\)", transform_str):
|
||||
func, args_str = match.groups()
|
||||
args = [float(x) for x in args_str.replace(",", " ").split()]
|
||||
transforms.append((func, args))
|
||||
|
||||
def apply_transforms(x: float, y: float) -> tuple[float, float]:
|
||||
for func, args in transforms:
|
||||
if func == "translate":
|
||||
x += args[0]
|
||||
y += args[1] if len(args) > 1 else args[0]
|
||||
elif func == "scale":
|
||||
x *= args[0]
|
||||
y *= args[1] if len(args) > 1 else args[0]
|
||||
return x, y
|
||||
|
||||
return apply_transforms
|
||||
|
||||
for g in doc.getElementsByTagName("g"):
|
||||
transform = parse_transform(g.getAttribute("transform"))
|
||||
|
||||
for poly in g.getElementsByTagName("polygon"):
|
||||
points_str = poly.getAttribute("points").strip()
|
||||
fill = poly.getAttribute("fill")
|
||||
if not fill:
|
||||
fill = "#000000"
|
||||
|
||||
coords: list[tuple[float, float]] = []
|
||||
for pair in points_str.split():
|
||||
x, y = pair.split(",")
|
||||
x, y = float(x), float(y)
|
||||
x, y = transform(x, y)
|
||||
coords.append((x * scale_x, y * scale_y))
|
||||
|
||||
draw.polygon(coords, fill=fill)
|
||||
|
||||
for poly in doc.getElementsByTagName("polygon"):
|
||||
if poly.parentNode and getattr(poly.parentNode, "tagName", None) == "g":
|
||||
continue
|
||||
|
||||
points_str = poly.getAttribute("points").strip()
|
||||
fill = poly.getAttribute("fill")
|
||||
if not fill:
|
||||
fill = "#000000"
|
||||
|
||||
coords = []
|
||||
for pair in points_str.split():
|
||||
x, y = pair.split(",")
|
||||
coords.append((float(x) * scale_x, float(y) * scale_y))
|
||||
|
||||
draw.polygon(coords, fill=fill)
|
||||
|
||||
if circular:
|
||||
mask = Image.new("L", (size, size), 0)
|
||||
mask_draw = ImageDraw.Draw(mask)
|
||||
mask_draw.ellipse((0, 0, size, size), fill=255)
|
||||
img.putalpha(mask)
|
||||
|
||||
img.save(output_path)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
print("Generating branding assets...")
|
||||
|
||||
logo_svg = SOURCE_DIR / "logo.svg"
|
||||
icon_light = SOURCE_DIR / "icon-light.svg"
|
||||
icon_dark = SOURCE_DIR / "icon-dark.svg"
|
||||
icon_tinted = SOURCE_DIR / "icon-tinted.svg"
|
||||
|
||||
polygons = parse_svg_polygons(logo_svg)
|
||||
|
||||
print(" iOS...")
|
||||
ios_assets = PROJECT_ROOT / "ios/Ascently/Assets.xcassets/AppIcon.appiconset"
|
||||
|
||||
for src, dst in [
|
||||
(icon_light, ios_assets / "app_icon_light_template.svg"),
|
||||
(icon_dark, ios_assets / "app_icon_dark_template.svg"),
|
||||
(icon_tinted, ios_assets / "app_icon_tinted_template.svg"),
|
||||
]:
|
||||
with open(src) as f:
|
||||
content = f.read()
|
||||
with open(dst, "w") as f:
|
||||
f.write(content)
|
||||
|
||||
img_light = Image.new("RGB", (1024, 1024), (255, 255, 255))
|
||||
draw_light = ImageDraw.Draw(img_light)
|
||||
scaled = scale_and_center(polygons, 1024, int(1024 * 0.7))
|
||||
for poly in scaled:
|
||||
coords = [(x, y) for x, y in poly["coords"]]
|
||||
draw_light.polygon(coords, fill=poly["fill"])
|
||||
img_light.save(ios_assets / "app_icon_1024.png")
|
||||
|
||||
img_dark = Image.new("RGB", (1024, 1024), (26, 26, 26))
|
||||
draw_dark = ImageDraw.Draw(img_dark)
|
||||
for poly in scaled:
|
||||
coords = [(x, y) for x, y in poly["coords"]]
|
||||
draw_dark.polygon(coords, fill=poly["fill"])
|
||||
img_dark.save(ios_assets / "app_icon_1024_dark.png")
|
||||
|
||||
img_tinted = Image.new("RGB", (1024, 1024), (0, 0, 0))
|
||||
draw_tinted = ImageDraw.Draw(img_tinted)
|
||||
for i, poly in enumerate(scaled):
|
||||
coords = [(x, y) for x, y in poly["coords"]]
|
||||
draw_tinted.polygon(coords, fill=(0, 0, 0))
|
||||
img_tinted.save(ios_assets / "app_icon_1024_tinted.png")
|
||||
|
||||
print(" Android...")
|
||||
|
||||
polys_108 = scale_and_center(polygons, 108, 60)
|
||||
android_xml = generate_android_vector(polys_108, 108, 108, 108)
|
||||
(
|
||||
PROJECT_ROOT / "android/app/src/main/res/drawable/ic_launcher_foreground.xml"
|
||||
).write_text(android_xml)
|
||||
|
||||
polys_24 = scale_and_center(polygons, 24, 20)
|
||||
mountains_xml = generate_android_vector(polys_24, 24, 24, 24)
|
||||
(PROJECT_ROOT / "android/app/src/main/res/drawable/ic_mountains.xml").write_text(
|
||||
mountains_xml
|
||||
)
|
||||
|
||||
for density, size in [
|
||||
("mdpi", 48),
|
||||
("hdpi", 72),
|
||||
("xhdpi", 96),
|
||||
("xxhdpi", 144),
|
||||
("xxxhdpi", 192),
|
||||
]:
|
||||
mipmap_dir = PROJECT_ROOT / f"android/app/src/main/res/mipmap-{density}"
|
||||
|
||||
img = Image.new("RGBA", (size, size), (255, 255, 255, 255))
|
||||
draw = ImageDraw.Draw(img)
|
||||
|
||||
scaled = scale_and_center(polygons, size, int(size * 0.6))
|
||||
for poly in scaled:
|
||||
coords = [(x, y) for x, y in poly["coords"]]
|
||||
draw.polygon(coords, fill=poly["fill"])
|
||||
|
||||
img.save(mipmap_dir / "ic_launcher.webp")
|
||||
|
||||
img_round = Image.new("RGBA", (size, size), (255, 255, 255, 255))
|
||||
draw_round = ImageDraw.Draw(img_round)
|
||||
|
||||
for poly in scaled:
|
||||
coords = [(x, y) for x, y in poly["coords"]]
|
||||
draw_round.polygon(coords, fill=poly["fill"])
|
||||
|
||||
mask = Image.new("L", (size, size), 0)
|
||||
mask_draw = ImageDraw.Draw(mask)
|
||||
mask_draw.ellipse((0, 0, size, size), fill=255)
|
||||
img_round.putalpha(mask)
|
||||
|
||||
img_round.save(mipmap_dir / "ic_launcher_round.webp")
|
||||
|
||||
print(" Docs...")
|
||||
|
||||
polys_32 = scale_and_center(polygons, 32, 26)
|
||||
logo_svg_32 = generate_svg(polys_32, 32, 32)
|
||||
(PROJECT_ROOT / "docs/src/assets/logo.svg").write_text(logo_svg_32)
|
||||
(PROJECT_ROOT / "docs/src/assets/logo-dark.svg").write_text(logo_svg_32)
|
||||
|
||||
polys_256 = scale_and_center(polygons, 256, 208)
|
||||
logo_svg_256 = generate_svg(polys_256, 256, 256)
|
||||
(PROJECT_ROOT / "docs/src/assets/logo-highres.svg").write_text(logo_svg_256)
|
||||
|
||||
logo_32_path = PROJECT_ROOT / "docs/src/assets/logo.svg"
|
||||
rasterize_svg(logo_32_path, PROJECT_ROOT / "docs/public/favicon.png", 32)
|
||||
|
||||
sizes = [16, 32, 48]
|
||||
imgs = []
|
||||
for size in sizes:
|
||||
img = Image.new("RGBA", (size, size), (255, 255, 255, 0))
|
||||
draw = ImageDraw.Draw(img)
|
||||
|
||||
scaled = scale_and_center(polygons, size, int(size * 0.8))
|
||||
for poly in scaled:
|
||||
coords = [(x, y) for x, y in poly["coords"]]
|
||||
draw.polygon(coords, fill=poly["fill"])
|
||||
|
||||
imgs.append(img)
|
||||
|
||||
imgs[0].save(
|
||||
PROJECT_ROOT / "docs/public/favicon.ico",
|
||||
format="ICO",
|
||||
sizes=[(s, s) for s in sizes],
|
||||
append_images=imgs[1:],
|
||||
)
|
||||
|
||||
print(" Logos...")
|
||||
|
||||
LOGOS_DIR.mkdir(exist_ok=True)
|
||||
|
||||
sizes = [64, 128, 256, 512, 1024, 2048]
|
||||
for size in sizes:
|
||||
img = Image.new("RGBA", (size, size), (255, 255, 255, 0))
|
||||
draw = ImageDraw.Draw(img)
|
||||
|
||||
scaled = scale_and_center(polygons, size, int(size * 0.8))
|
||||
for poly in scaled:
|
||||
coords = [(x, y) for x, y in poly["coords"]]
|
||||
draw.polygon(coords, fill=poly["fill"])
|
||||
|
||||
img.save(LOGOS_DIR / f"logo-{size}.png")
|
||||
|
||||
for size in sizes:
|
||||
img = Image.new("RGBA", (size, size), (255, 255, 255, 255))
|
||||
draw = ImageDraw.Draw(img)
|
||||
|
||||
scaled = scale_and_center(polygons, size, int(size * 0.8))
|
||||
for poly in scaled:
|
||||
coords = [(x, y) for x, y in poly["coords"]]
|
||||
draw.polygon(coords, fill=poly["fill"])
|
||||
|
||||
img.save(LOGOS_DIR / f"logo-{size}-white.png")
|
||||
|
||||
for size in sizes:
|
||||
img = Image.new("RGBA", (size, size), (26, 26, 26, 255))
|
||||
draw = ImageDraw.Draw(img)
|
||||
|
||||
scaled = scale_and_center(polygons, size, int(size * 0.8))
|
||||
for poly in scaled:
|
||||
coords = [(x, y) for x, y in poly["coords"]]
|
||||
draw.polygon(coords, fill=poly["fill"])
|
||||
|
||||
img.save(LOGOS_DIR / f"logo-{size}-dark.png")
|
||||
|
||||
print("Done.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
if ! command -v python3 &> /dev/null; then
|
||||
echo "Error: Python 3 required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
python3 "$SCRIPT_DIR/generate.py"
|
||||
BIN
branding/source/AscentlyBlueBall.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
branding/source/AscentlyGreenBall.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
branding/source/AscentlyRedBall.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
branding/source/AscentlyYellowBall.png
Normal file
|
After Width: | Height: | Size: 74 KiB |
BIN
branding/source/AscetlyTriangle1.png
Normal file
|
After Width: | Height: | Size: 64 KiB |
BIN
branding/source/AscetlyTriangle2.png
Normal file
|
After Width: | Height: | Size: 66 KiB |
BIN
branding/source/Balls.icon/Assets/AscentlyBlueBall.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
branding/source/Balls.icon/Assets/AscentlyGreenBall.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
branding/source/Balls.icon/Assets/AscentlyRedBall.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
branding/source/Balls.icon/Assets/AscentlyYellowBall.png
Normal file
|
After Width: | Height: | Size: 74 KiB |
67
branding/source/Balls.icon/icon.json
Normal file
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"fill" : "automatic",
|
||||
"groups" : [
|
||||
{
|
||||
"layers" : [
|
||||
{
|
||||
"image-name" : "AscentlyRedBall.png",
|
||||
"name" : "AscentlyRedBall",
|
||||
"position" : {
|
||||
"scale" : 0.4,
|
||||
"translation-in-points" : [
|
||||
90.60312499999992,
|
||||
127.86484375000009
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"image-name" : "AscentlyYellowBall.png",
|
||||
"name" : "AscentlyYellowBall",
|
||||
"position" : {
|
||||
"scale" : 0.3,
|
||||
"translation-in-points" : [
|
||||
90.50312500000001,
|
||||
-177.66484375
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"image-name" : "AscentlyBlueBall.png",
|
||||
"name" : "AscentlyBlueBall",
|
||||
"position" : {
|
||||
"scale" : 0.3,
|
||||
"translation-in-points" : [
|
||||
-138.20312500000006,
|
||||
177.3648437500001
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"image-name" : "AscentlyGreenBall.png",
|
||||
"name" : "AscentlyGreenBall",
|
||||
"position" : {
|
||||
"scale" : 0.2,
|
||||
"translation-in-points" : [
|
||||
-138.30312499999997,
|
||||
-43.08515625000001
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"shadow" : {
|
||||
"kind" : "neutral",
|
||||
"opacity" : 0.5
|
||||
},
|
||||
"translucency" : {
|
||||
"enabled" : true,
|
||||
"value" : 0.5
|
||||
}
|
||||
}
|
||||
],
|
||||
"supported-platforms" : {
|
||||
"circles" : [
|
||||
"watchOS"
|
||||
],
|
||||
"squares" : "shared"
|
||||
}
|
||||
}
|
||||
BIN
branding/source/Icon.icon/Assets/AscetlyTriangle1.png
Normal file
|
After Width: | Height: | Size: 64 KiB |
BIN
branding/source/Icon.icon/Assets/AscetlyTriangle2.png
Normal file
|
After Width: | Height: | Size: 66 KiB |
45
branding/source/Icon.icon/icon.json
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"fill" : "automatic",
|
||||
"groups" : [
|
||||
{
|
||||
"layers" : [
|
||||
{
|
||||
"image-name" : "AscetlyTriangle2.png",
|
||||
"name" : "AscetlyTriangle2",
|
||||
"position" : {
|
||||
"scale" : 0.75,
|
||||
"translation-in-points" : [
|
||||
108,
|
||||
-53.8125
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"image-name" : "AscetlyTriangle1.png",
|
||||
"name" : "AscetlyTriangle1",
|
||||
"position" : {
|
||||
"scale" : 0.5,
|
||||
"translation-in-points" : [
|
||||
-215,
|
||||
39.9375
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"shadow" : {
|
||||
"kind" : "neutral",
|
||||
"opacity" : 0.5
|
||||
},
|
||||
"translucency" : {
|
||||
"enabled" : true,
|
||||
"value" : 0.5
|
||||
}
|
||||
}
|
||||
],
|
||||
"supported-platforms" : {
|
||||
"circles" : [
|
||||
"watchOS"
|
||||
],
|
||||
"squares" : "shared"
|
||||
}
|
||||
}
|
||||
@@ -26,8 +26,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/node": "^9.5.1",
|
||||
"@astrojs/starlight": "^0.37.0",
|
||||
"astro": "^5.16.3",
|
||||
"@astrojs/starlight": "^0.37.1",
|
||||
"astro": "^5.16.5",
|
||||
"qrcode": "^1.5.4",
|
||||
"sharp": "^0.34.5"
|
||||
},
|
||||
|
||||
245
docs/pnpm-lock.yaml
generated
@@ -10,13 +10,13 @@ importers:
|
||||
dependencies:
|
||||
'@astrojs/node':
|
||||
specifier: ^9.5.1
|
||||
version: 9.5.1(astro@5.16.3(@types/node@24.10.1)(rollup@4.53.3)(typescript@5.9.3))
|
||||
version: 9.5.1(astro@5.16.5(@types/node@25.0.1)(rollup@4.53.3)(typescript@5.9.3))
|
||||
'@astrojs/starlight':
|
||||
specifier: ^0.37.0
|
||||
version: 0.37.0(astro@5.16.3(@types/node@24.10.1)(rollup@4.53.3)(typescript@5.9.3))
|
||||
specifier: ^0.37.1
|
||||
version: 0.37.1(astro@5.16.5(@types/node@25.0.1)(rollup@4.53.3)(typescript@5.9.3))
|
||||
astro:
|
||||
specifier: ^5.16.3
|
||||
version: 5.16.3(@types/node@24.10.1)(rollup@4.53.3)(typescript@5.9.3)
|
||||
specifier: ^5.16.5
|
||||
version: 5.16.5(@types/node@25.0.1)(rollup@4.53.3)(typescript@5.9.3)
|
||||
qrcode:
|
||||
specifier: ^1.5.4
|
||||
version: 1.5.4
|
||||
@@ -36,11 +36,11 @@ packages:
|
||||
'@astrojs/internal-helpers@0.7.5':
|
||||
resolution: {integrity: sha512-vreGnYSSKhAjFJCWAwe/CNhONvoc5lokxtRoZims+0wa3KbHBdPHSSthJsKxPd8d/aic6lWKpRTYGY/hsgK6EA==}
|
||||
|
||||
'@astrojs/markdown-remark@6.3.9':
|
||||
resolution: {integrity: sha512-hX2cLC/KW74Io1zIbn92kI482j9J7LleBLGCVU9EP3BeH5MVrnFawOnqD0t/q6D1Z+ZNeQG2gNKMslCcO36wng==}
|
||||
'@astrojs/markdown-remark@6.3.10':
|
||||
resolution: {integrity: sha512-kk4HeYR6AcnzC4QV8iSlOfh+N8TZ3MEStxPyenyCtemqn8IpEATBFMTJcfrNW32dgpt6MY3oCkMM/Tv3/I4G3A==}
|
||||
|
||||
'@astrojs/mdx@4.3.12':
|
||||
resolution: {integrity: sha512-pL3CVPtuQrPnDhWjy7zqbOibNyPaxP4VpQS8T8spwKqKzauJ4yoKyNkVTD8jrP7EAJHmBhZ7PTmUGZqOpKKp8g==}
|
||||
'@astrojs/mdx@4.3.13':
|
||||
resolution: {integrity: sha512-IHDHVKz0JfKBy3//52JSiyWv089b7GVSChIXLrlUOoTLWowG3wr2/8hkaEgEyd/vysvNQvGk+QhysXpJW5ve6Q==}
|
||||
engines: {node: 18.20.8 || ^20.3.0 || >=22.0.0}
|
||||
peerDependencies:
|
||||
astro: ^5.0.0
|
||||
@@ -57,8 +57,8 @@ packages:
|
||||
'@astrojs/sitemap@3.6.0':
|
||||
resolution: {integrity: sha512-4aHkvcOZBWJigRmMIAJwRQXBS+ayoP5z40OklTXYXhUDhwusz+DyDl+nSshY6y9DvkVEavwNcFO8FD81iGhXjg==}
|
||||
|
||||
'@astrojs/starlight@0.37.0':
|
||||
resolution: {integrity: sha512-1AlaEjYYRO+5o6P5maPUBQZr6Q3wtuhMQTmsDQExI07wJVwe7EC2wGhXnFo+jpCjwHv/Bdg33PQheY4UhMj01g==}
|
||||
'@astrojs/starlight@0.37.1':
|
||||
resolution: {integrity: sha512-STNsR5PaDoiW4IgcX17Fp42FfyqwuweWPts/EWEMcFPAeg9Nvpu3UvVCorasYrgfJgaJTeydsOV++0ACA1KYDA==}
|
||||
peerDependencies:
|
||||
astro: ^5.5.0
|
||||
|
||||
@@ -254,17 +254,17 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@expressive-code/core@0.41.3':
|
||||
resolution: {integrity: sha512-9qzohqU7O0+JwMEEgQhnBPOw5DtsQRBXhW++5fvEywsuX44vCGGof1SL5OvPElvNgaWZ4pFZAFSlkNOkGyLwSQ==}
|
||||
'@expressive-code/core@0.41.4':
|
||||
resolution: {integrity: sha512-4eDiyq3hI3vJ0KnwIqonh9evy9p8aNixsf5wwnvDWcoPfYU3LGB6Nkb6WDdYS4z52tODCvN5gMRy1DtRopcxXg==}
|
||||
|
||||
'@expressive-code/plugin-frames@0.41.3':
|
||||
resolution: {integrity: sha512-rFQtmf/3N2CK3Cq/uERweMTYZnBu+CwxBdHuOftEmfA9iBE7gTVvwpbh82P9ZxkPLvc40UMhYt7uNuAZexycRQ==}
|
||||
'@expressive-code/plugin-frames@0.41.4':
|
||||
resolution: {integrity: sha512-W9jZW8LsPS8fW5T5CQyXUyyCrMxb7qfl6oxlLZB1rW74qM572Id4CWEXOM/7fFDcd1pW2fUxMoGzJMh0T2Awhg==}
|
||||
|
||||
'@expressive-code/plugin-shiki@0.41.3':
|
||||
resolution: {integrity: sha512-RlTARoopzhFJIOVHLGvuXJ8DCEme/hjV+ZnRJBIxzxsKVpGPW4Oshqg9xGhWTYdHstTsxO663s0cdBLzZj9TQA==}
|
||||
'@expressive-code/plugin-shiki@0.41.4':
|
||||
resolution: {integrity: sha512-zOc0tfWISODHnnpfRJyssTvSWVVe+gj08GcFYiR2a6M8fKF1w5CJkpgf7tTvnoUTuVmL1DHRmiQFUnpGjtRGog==}
|
||||
|
||||
'@expressive-code/plugin-text-markers@0.41.3':
|
||||
resolution: {integrity: sha512-SN8tkIzDpA0HLAscEYD2IVrfLiid6qEdE9QLlGVSxO1KEw7qYvjpbNBQjUjMr5/jvTJ7ys6zysU2vLPHE0sb2g==}
|
||||
'@expressive-code/plugin-text-markers@0.41.4':
|
||||
resolution: {integrity: sha512-lGqbjtIuiY+UZ+z61kKIJAZtF7H5xoT8lkxANmeoVaat+H47O5A+rr5WLmD45ezprO/NTogxHsaMfqRCuQ4vlw==}
|
||||
|
||||
'@img/colour@1.0.0':
|
||||
resolution: {integrity: sha512-A5P/LfWGFSl6nsckYtjw9da+19jB8hkJ6ACTGcDfEJ0aE+l2n2El7dsVM7UVHZQ9s2lmYMWlrS21YLy2IR1LUw==}
|
||||
@@ -564,23 +564,23 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@shikijs/core@3.17.1':
|
||||
resolution: {integrity: sha512-VWsduykcibGU0WMi66PflThDWyqEeTOiWdCRa3wmsZuishh+1PDSOh5gGxHdSrOtS+v1pmYaxodk/JNzwusElA==}
|
||||
'@shikijs/core@3.20.0':
|
||||
resolution: {integrity: sha512-f2ED7HYV4JEk827mtMDwe/yQ25pRiXZmtHjWF8uzZKuKiEsJR7Ce1nuQ+HhV9FzDcbIo4ObBCD9GPTzNuy9S1g==}
|
||||
|
||||
'@shikijs/engine-javascript@3.17.1':
|
||||
resolution: {integrity: sha512-Ars0DVJITQrkOl5Swwy+94NL/BlOi/w1NSFbPGkcsln7Dv+M2qHaVpNHwdtWCC4/arzvjuHbyWBUsWExDHPDLw==}
|
||||
'@shikijs/engine-javascript@3.20.0':
|
||||
resolution: {integrity: sha512-OFx8fHAZuk7I42Z9YAdZ95To6jDePQ9Rnfbw9uSRTSbBhYBp1kEOKv/3jOimcj3VRUKusDYM6DswLauwfhboLg==}
|
||||
|
||||
'@shikijs/engine-oniguruma@3.17.1':
|
||||
resolution: {integrity: sha512-fsXPy4va/4iblEGS+22nP5V08IwwBcM+8xHUzSON0QmHm29/AJRghA95w9VDnxuwp9wOdJxEhfPkKp6vqcsN+w==}
|
||||
'@shikijs/engine-oniguruma@3.20.0':
|
||||
resolution: {integrity: sha512-Yx3gy7xLzM0ZOjqoxciHjA7dAt5tyzJE3L4uQoM83agahy+PlW244XJSrmJRSBvGYELDhYXPacD4R/cauV5bzQ==}
|
||||
|
||||
'@shikijs/langs@3.17.1':
|
||||
resolution: {integrity: sha512-YTBVN+L2j7zBuOVjNZ2XiSNQEkm/7wZ1TSc5UO77GJPcg7Rk25WSscWA7y8pW7Bo25JIU0EWchUkq/UQjOJlJA==}
|
||||
'@shikijs/langs@3.20.0':
|
||||
resolution: {integrity: sha512-le+bssCxcSHrygCWuOrYJHvjus6zhQ2K7q/0mgjiffRbkhM4o1EWu2m+29l0yEsHDbWaWPNnDUTRVVBvBBeKaA==}
|
||||
|
||||
'@shikijs/themes@3.17.1':
|
||||
resolution: {integrity: sha512-aohwwqNUB5h2ATfgrqYRPl8vyazqCiQ2wIV4xq+UzaBRHpqLMGSemkasK+vIEpl0YaendoaKUsDfpwhCqyHIaQ==}
|
||||
'@shikijs/themes@3.20.0':
|
||||
resolution: {integrity: sha512-U1NSU7Sl26Q7ErRvJUouArxfM2euWqq1xaSrbqMu2iqa+tSp0D1Yah8216sDYbdDHw4C8b75UpE65eWorm2erQ==}
|
||||
|
||||
'@shikijs/types@3.17.1':
|
||||
resolution: {integrity: sha512-yUFLiCnZHHJ16KbVbt3B1EzBUadU3OVpq0PEyb301m5BbuFKApQYBzJGhrK48hH/tYWSjzwcj7BSmYbBc0zntQ==}
|
||||
'@shikijs/types@3.20.0':
|
||||
resolution: {integrity: sha512-lhYAATn10nkZcBQ0BlzSbJA3wcmL5MXUUF8d2Zzon6saZDlToKaiRX60n2+ZaHJCmXEcZRWNzn+k9vplr8Jhsw==}
|
||||
|
||||
'@shikijs/vscode-textmate@10.0.2':
|
||||
resolution: {integrity: sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==}
|
||||
@@ -621,8 +621,8 @@ packages:
|
||||
'@types/node@17.0.45':
|
||||
resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==}
|
||||
|
||||
'@types/node@24.10.1':
|
||||
resolution: {integrity: sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==}
|
||||
'@types/node@25.0.1':
|
||||
resolution: {integrity: sha512-czWPzKIAXucn9PtsttxmumiQ9N0ok9FrBwgRWrwmVLlp86BrMExzvXRLFYRJ+Ex3g6yqj+KuaxfX1JTgV2lpfg==}
|
||||
|
||||
'@types/qrcode@1.5.6':
|
||||
resolution: {integrity: sha512-te7NQcV2BOvdj2b1hCAHzAoMNuj65kNBMz0KBaxM6c3VGBOhU0dURQKOtH8CFNI/dsKkwlv32p26qYQTWoB5bw==}
|
||||
@@ -689,13 +689,13 @@ packages:
|
||||
resolution: {integrity: sha512-LElXdjswlqjWrPpJFg1Fx4wpkOCxj1TDHlSV4PlaRxHGWko024xICaa97ZkMfs6DRKlCguiAI+rbXv5GWwXIkg==}
|
||||
hasBin: true
|
||||
|
||||
astro-expressive-code@0.41.3:
|
||||
resolution: {integrity: sha512-u+zHMqo/QNLE2eqYRCrK3+XMlKakv33Bzuz+56V1gs8H0y6TZ0hIi3VNbIxeTn51NLn+mJfUV/A0kMNfE4rANw==}
|
||||
astro-expressive-code@0.41.4:
|
||||
resolution: {integrity: sha512-LK6EcK/hIHfOSo9zqapzu4CbTC0YBtMOVdvWjInpB2SgYtxiF22aZDqdpejN8J28mWPqPLQwSqdl2lWuirNXmw==}
|
||||
peerDependencies:
|
||||
astro: ^4.0.0-beta || ^5.0.0-beta || ^3.3.0
|
||||
|
||||
astro@5.16.3:
|
||||
resolution: {integrity: sha512-KzDk41F9Dspf5fM/Ls4XZhV4/csjJcWBrlenbnp5V3NGwU1zEaJz/HIyrdKdf5yw+FgwCeD2+Yos1Xkx9gnI0A==}
|
||||
astro@5.16.5:
|
||||
resolution: {integrity: sha512-QeuM4xzTR0QuXFDNlGVW0BW7rcquKFIkylaPeM4ufii0/RRiPTYtwxDYVZ3KfiMRuuc+nbLD0214kMKTvz/yvQ==}
|
||||
engines: {node: 18.20.8 || ^20.3.0 || >=22.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0'}
|
||||
hasBin: true
|
||||
|
||||
@@ -873,8 +873,8 @@ packages:
|
||||
resolution: {integrity: sha512-KxektNH63SrbfUyDiwXqRb1rLwKt33AmMv+5Nhsw1kqZ13SJBRTgZHtGbE+hH3a1mVW1cz+4pqSWVPAtLVXTzQ==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
devalue@5.5.0:
|
||||
resolution: {integrity: sha512-69sM5yrHfFLJt0AZ9QqZXGCPfJ7fQjvpln3Rq5+PS03LD32Ost1Q9N+eEnaQwGRIriKkMImXD56ocjQmfjbV3w==}
|
||||
devalue@5.6.1:
|
||||
resolution: {integrity: sha512-jDwizj+IlEZBunHcOuuFVBnIMPAEHvTsJj0BcIp94xYguLRVBcXO853px/MyIJvbVzWdsGvrRweIUWJw8hBP7A==}
|
||||
|
||||
devlop@1.1.0:
|
||||
resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==}
|
||||
@@ -986,8 +986,8 @@ packages:
|
||||
eventemitter3@5.0.1:
|
||||
resolution: {integrity: sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==}
|
||||
|
||||
expressive-code@0.41.3:
|
||||
resolution: {integrity: sha512-YLnD62jfgBZYrXIPQcJ0a51Afv9h8VlWqEGK9uU2T5nL/5rb8SnA86+7+mgCZe5D34Tff5RNEA5hjNVJYHzrFg==}
|
||||
expressive-code@0.41.4:
|
||||
resolution: {integrity: sha512-A9aFLhgqLkL6VSfqYkPqkJVMtA90/bhCLmUO7L3/a1xWISNMcHoCS6d6i8ePwi8HvHr3xRLswHTNt6NheTjdXA==}
|
||||
|
||||
extend@3.0.2:
|
||||
resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==}
|
||||
@@ -1086,8 +1086,8 @@ packages:
|
||||
hast-util-to-jsx-runtime@2.3.6:
|
||||
resolution: {integrity: sha512-zl6s8LwNyo1P9uw+XJGvZtdFF1GdAkOg8ujOw+4Pyb76874fLps4ueHXDhXWdk6YHQ6OgUtinliG7RsYvCbbBg==}
|
||||
|
||||
hast-util-to-parse5@8.0.0:
|
||||
resolution: {integrity: sha512-3KKrV5ZVI8if87DVSi1vDeByYrkGzg4mEfeu4alwgmmIeARiBLKCZS2uw5Gb6nU9x9Yufyj3iudm6i7nl52PFw==}
|
||||
hast-util-to-parse5@8.0.1:
|
||||
resolution: {integrity: sha512-MlWT6Pjt4CG9lFCjiz4BH7l9wmrMkfkJYCxFwKQic8+RTZgWPuWxwAfjJElsXkex7DJjfSJsQIt931ilUgmwdA==}
|
||||
|
||||
hast-util-to-string@3.0.1:
|
||||
resolution: {integrity: sha512-XelQVTDWvqcl3axRfI0xSeoVKzyIFPwsAGSLIsKdJKQMXDYJS4WYrBNF/8J7RdhIcFI2BOHgAifggsvsxp/3+A==}
|
||||
@@ -1399,8 +1399,8 @@ packages:
|
||||
node-fetch-native@1.6.7:
|
||||
resolution: {integrity: sha512-g9yhqoedzIUm0nTnTqAQvueMPVOuIY16bqgAJJC8XOOubYFNwz6IER9qs0Gq2Xd0+CecCKFjtdDTMA4u4xG06Q==}
|
||||
|
||||
node-mock-http@1.0.3:
|
||||
resolution: {integrity: sha512-jN8dK25fsfnMrVsEhluUTPkBFY+6ybu7jSB1n+ri/vOGjJxU8J9CZhpSGkHXSkFjtUhbmoncG/YG9ta5Ludqog==}
|
||||
node-mock-http@1.0.4:
|
||||
resolution: {integrity: sha512-8DY+kFsDkNXy1sJglUfuODx1/opAGJGyrTuFqEoN90oRc2Vk0ZbD4K2qmKXBBEhZQzdKHIVfEJpDU8Ak2NJEvQ==}
|
||||
|
||||
normalize-path@3.0.0:
|
||||
resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}
|
||||
@@ -1512,9 +1512,6 @@ packages:
|
||||
resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==}
|
||||
engines: {node: '>= 6'}
|
||||
|
||||
property-information@6.5.0:
|
||||
resolution: {integrity: sha512-PgTgs/BlvHxOu8QuEN7wi5A0OmXaBcHpmCSTehcs6Uuu9IkDIEo13Hy7n898RHfrQ49vKCoGeWZSaAK01nwVig==}
|
||||
|
||||
property-information@7.1.0:
|
||||
resolution: {integrity: sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ==}
|
||||
|
||||
@@ -1554,11 +1551,11 @@ packages:
|
||||
regex-utilities@2.3.0:
|
||||
resolution: {integrity: sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==}
|
||||
|
||||
regex@6.0.1:
|
||||
resolution: {integrity: sha512-uorlqlzAKjKQZ5P+kTJr3eeJGSVroLKoHmquUj4zHWuR+hEyNqlXsSKlYYF5F4NI6nl7tWCs0apKJ0lmfsXAPA==}
|
||||
regex@6.1.0:
|
||||
resolution: {integrity: sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==}
|
||||
|
||||
rehype-expressive-code@0.41.3:
|
||||
resolution: {integrity: sha512-8d9Py4c/V6I/Od2VIXFAdpiO2kc0SV2qTJsRAaqSIcM9aruW4ASLNe2kOEo1inXAAkIhpFzAHTc358HKbvpNUg==}
|
||||
rehype-expressive-code@0.41.4:
|
||||
resolution: {integrity: sha512-qEUKfh/Aw9VZSUCXnJef41o7lpfnhXmQdXTkP2ZWGibSk4SoJVJ4ra1xN1t+hL1rp0d0GPKZ1CpM3q6bjV0xbg==}
|
||||
|
||||
rehype-format@5.0.1:
|
||||
resolution: {integrity: sha512-zvmVru9uB0josBVpr946OR8ui7nJEdzZobwLOOqHb/OOD88W0Vk2SqLwoVOj0fM6IPCCO6TaV9CvQvJMWwukFQ==}
|
||||
@@ -1652,8 +1649,8 @@ packages:
|
||||
resolution: {integrity: sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==}
|
||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||
|
||||
shiki@3.17.1:
|
||||
resolution: {integrity: sha512-KbAPJo6pQpfjupOg5HW0fk/OSmeBfzza2IjZ5XbNKbqhZaCoxro/EyOgesaLvTdyDfrsAUDA6L4q14sc+k9i7g==}
|
||||
shiki@3.20.0:
|
||||
resolution: {integrity: sha512-kgCOlsnyWb+p0WU+01RjkCH+eBVsjL1jOwUYWv0YDWkM2/A46+LDKVs5yZCUXjJG6bj4ndFoAg5iLIIue6dulg==}
|
||||
|
||||
sisteransi@1.0.5:
|
||||
resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==}
|
||||
@@ -2009,7 +2006,7 @@ snapshots:
|
||||
|
||||
'@astrojs/internal-helpers@0.7.5': {}
|
||||
|
||||
'@astrojs/markdown-remark@6.3.9':
|
||||
'@astrojs/markdown-remark@6.3.10':
|
||||
dependencies:
|
||||
'@astrojs/internal-helpers': 0.7.5
|
||||
'@astrojs/prism': 3.3.0
|
||||
@@ -2025,7 +2022,7 @@ snapshots:
|
||||
remark-parse: 11.0.0
|
||||
remark-rehype: 11.1.2
|
||||
remark-smartypants: 3.0.2
|
||||
shiki: 3.17.1
|
||||
shiki: 3.20.0
|
||||
smol-toml: 1.5.2
|
||||
unified: 11.0.5
|
||||
unist-util-remove-position: 5.0.0
|
||||
@@ -2035,12 +2032,12 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@astrojs/mdx@4.3.12(astro@5.16.3(@types/node@24.10.1)(rollup@4.53.3)(typescript@5.9.3))':
|
||||
'@astrojs/mdx@4.3.13(astro@5.16.5(@types/node@25.0.1)(rollup@4.53.3)(typescript@5.9.3))':
|
||||
dependencies:
|
||||
'@astrojs/markdown-remark': 6.3.9
|
||||
'@astrojs/markdown-remark': 6.3.10
|
||||
'@mdx-js/mdx': 3.1.1
|
||||
acorn: 8.15.0
|
||||
astro: 5.16.3(@types/node@24.10.1)(rollup@4.53.3)(typescript@5.9.3)
|
||||
astro: 5.16.5(@types/node@25.0.1)(rollup@4.53.3)(typescript@5.9.3)
|
||||
es-module-lexer: 1.7.0
|
||||
estree-util-visit: 2.0.0
|
||||
hast-util-to-html: 9.0.5
|
||||
@@ -2054,10 +2051,10 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@astrojs/node@9.5.1(astro@5.16.3(@types/node@24.10.1)(rollup@4.53.3)(typescript@5.9.3))':
|
||||
'@astrojs/node@9.5.1(astro@5.16.5(@types/node@25.0.1)(rollup@4.53.3)(typescript@5.9.3))':
|
||||
dependencies:
|
||||
'@astrojs/internal-helpers': 0.7.5
|
||||
astro: 5.16.3(@types/node@24.10.1)(rollup@4.53.3)(typescript@5.9.3)
|
||||
astro: 5.16.5(@types/node@25.0.1)(rollup@4.53.3)(typescript@5.9.3)
|
||||
send: 1.2.0
|
||||
server-destroy: 1.0.1
|
||||
transitivePeerDependencies:
|
||||
@@ -2073,17 +2070,17 @@ snapshots:
|
||||
stream-replace-string: 2.0.0
|
||||
zod: 3.25.76
|
||||
|
||||
'@astrojs/starlight@0.37.0(astro@5.16.3(@types/node@24.10.1)(rollup@4.53.3)(typescript@5.9.3))':
|
||||
'@astrojs/starlight@0.37.1(astro@5.16.5(@types/node@25.0.1)(rollup@4.53.3)(typescript@5.9.3))':
|
||||
dependencies:
|
||||
'@astrojs/markdown-remark': 6.3.9
|
||||
'@astrojs/mdx': 4.3.12(astro@5.16.3(@types/node@24.10.1)(rollup@4.53.3)(typescript@5.9.3))
|
||||
'@astrojs/markdown-remark': 6.3.10
|
||||
'@astrojs/mdx': 4.3.13(astro@5.16.5(@types/node@25.0.1)(rollup@4.53.3)(typescript@5.9.3))
|
||||
'@astrojs/sitemap': 3.6.0
|
||||
'@pagefind/default-ui': 1.4.0
|
||||
'@types/hast': 3.0.4
|
||||
'@types/js-yaml': 4.0.9
|
||||
'@types/mdast': 4.0.4
|
||||
astro: 5.16.3(@types/node@24.10.1)(rollup@4.53.3)(typescript@5.9.3)
|
||||
astro-expressive-code: 0.41.3(astro@5.16.3(@types/node@24.10.1)(rollup@4.53.3)(typescript@5.9.3))
|
||||
astro: 5.16.5(@types/node@25.0.1)(rollup@4.53.3)(typescript@5.9.3)
|
||||
astro-expressive-code: 0.41.4(astro@5.16.5(@types/node@25.0.1)(rollup@4.53.3)(typescript@5.9.3))
|
||||
bcp-47: 2.1.0
|
||||
hast-util-from-html: 2.0.3
|
||||
hast-util-select: 6.0.4
|
||||
@@ -2223,7 +2220,7 @@ snapshots:
|
||||
'@esbuild/win32-x64@0.25.12':
|
||||
optional: true
|
||||
|
||||
'@expressive-code/core@0.41.3':
|
||||
'@expressive-code/core@0.41.4':
|
||||
dependencies:
|
||||
'@ctrl/tinycolor': 4.2.0
|
||||
hast-util-select: 6.0.4
|
||||
@@ -2235,18 +2232,18 @@ snapshots:
|
||||
unist-util-visit: 5.0.0
|
||||
unist-util-visit-parents: 6.0.2
|
||||
|
||||
'@expressive-code/plugin-frames@0.41.3':
|
||||
'@expressive-code/plugin-frames@0.41.4':
|
||||
dependencies:
|
||||
'@expressive-code/core': 0.41.3
|
||||
'@expressive-code/core': 0.41.4
|
||||
|
||||
'@expressive-code/plugin-shiki@0.41.3':
|
||||
'@expressive-code/plugin-shiki@0.41.4':
|
||||
dependencies:
|
||||
'@expressive-code/core': 0.41.3
|
||||
shiki: 3.17.1
|
||||
'@expressive-code/core': 0.41.4
|
||||
shiki: 3.20.0
|
||||
|
||||
'@expressive-code/plugin-text-markers@0.41.3':
|
||||
'@expressive-code/plugin-text-markers@0.41.4':
|
||||
dependencies:
|
||||
'@expressive-code/core': 0.41.3
|
||||
'@expressive-code/core': 0.41.4
|
||||
|
||||
'@img/colour@1.0.0': {}
|
||||
|
||||
@@ -2472,33 +2469,33 @@ snapshots:
|
||||
'@rollup/rollup-win32-x64-msvc@4.53.3':
|
||||
optional: true
|
||||
|
||||
'@shikijs/core@3.17.1':
|
||||
'@shikijs/core@3.20.0':
|
||||
dependencies:
|
||||
'@shikijs/types': 3.17.1
|
||||
'@shikijs/types': 3.20.0
|
||||
'@shikijs/vscode-textmate': 10.0.2
|
||||
'@types/hast': 3.0.4
|
||||
hast-util-to-html: 9.0.5
|
||||
|
||||
'@shikijs/engine-javascript@3.17.1':
|
||||
'@shikijs/engine-javascript@3.20.0':
|
||||
dependencies:
|
||||
'@shikijs/types': 3.17.1
|
||||
'@shikijs/types': 3.20.0
|
||||
'@shikijs/vscode-textmate': 10.0.2
|
||||
oniguruma-to-es: 4.3.4
|
||||
|
||||
'@shikijs/engine-oniguruma@3.17.1':
|
||||
'@shikijs/engine-oniguruma@3.20.0':
|
||||
dependencies:
|
||||
'@shikijs/types': 3.17.1
|
||||
'@shikijs/types': 3.20.0
|
||||
'@shikijs/vscode-textmate': 10.0.2
|
||||
|
||||
'@shikijs/langs@3.17.1':
|
||||
'@shikijs/langs@3.20.0':
|
||||
dependencies:
|
||||
'@shikijs/types': 3.17.1
|
||||
'@shikijs/types': 3.20.0
|
||||
|
||||
'@shikijs/themes@3.17.1':
|
||||
'@shikijs/themes@3.20.0':
|
||||
dependencies:
|
||||
'@shikijs/types': 3.17.1
|
||||
'@shikijs/types': 3.20.0
|
||||
|
||||
'@shikijs/types@3.17.1':
|
||||
'@shikijs/types@3.20.0':
|
||||
dependencies:
|
||||
'@shikijs/vscode-textmate': 10.0.2
|
||||
'@types/hast': 3.0.4
|
||||
@@ -2521,7 +2518,7 @@ snapshots:
|
||||
|
||||
'@types/fontkit@2.0.8':
|
||||
dependencies:
|
||||
'@types/node': 24.10.1
|
||||
'@types/node': 25.0.1
|
||||
|
||||
'@types/hast@3.0.4':
|
||||
dependencies:
|
||||
@@ -2543,13 +2540,13 @@ snapshots:
|
||||
|
||||
'@types/node@17.0.45': {}
|
||||
|
||||
'@types/node@24.10.1':
|
||||
'@types/node@25.0.1':
|
||||
dependencies:
|
||||
undici-types: 7.16.0
|
||||
|
||||
'@types/qrcode@1.5.6':
|
||||
dependencies:
|
||||
'@types/node': 24.10.1
|
||||
'@types/node': 25.0.1
|
||||
|
||||
'@types/sax@1.2.7':
|
||||
dependencies:
|
||||
@@ -2596,16 +2593,16 @@ snapshots:
|
||||
|
||||
astring@1.9.0: {}
|
||||
|
||||
astro-expressive-code@0.41.3(astro@5.16.3(@types/node@24.10.1)(rollup@4.53.3)(typescript@5.9.3)):
|
||||
astro-expressive-code@0.41.4(astro@5.16.5(@types/node@25.0.1)(rollup@4.53.3)(typescript@5.9.3)):
|
||||
dependencies:
|
||||
astro: 5.16.3(@types/node@24.10.1)(rollup@4.53.3)(typescript@5.9.3)
|
||||
rehype-expressive-code: 0.41.3
|
||||
astro: 5.16.5(@types/node@25.0.1)(rollup@4.53.3)(typescript@5.9.3)
|
||||
rehype-expressive-code: 0.41.4
|
||||
|
||||
astro@5.16.3(@types/node@24.10.1)(rollup@4.53.3)(typescript@5.9.3):
|
||||
astro@5.16.5(@types/node@25.0.1)(rollup@4.53.3)(typescript@5.9.3):
|
||||
dependencies:
|
||||
'@astrojs/compiler': 2.13.0
|
||||
'@astrojs/internal-helpers': 0.7.5
|
||||
'@astrojs/markdown-remark': 6.3.9
|
||||
'@astrojs/markdown-remark': 6.3.10
|
||||
'@astrojs/telemetry': 3.3.0
|
||||
'@capsizecss/unpack': 3.0.1
|
||||
'@oslojs/encoding': 1.1.0
|
||||
@@ -2621,7 +2618,7 @@ snapshots:
|
||||
cssesc: 3.0.0
|
||||
debug: 4.4.3
|
||||
deterministic-object-hash: 2.0.2
|
||||
devalue: 5.5.0
|
||||
devalue: 5.6.1
|
||||
diff: 5.2.0
|
||||
dlv: 1.1.3
|
||||
dset: 3.1.4
|
||||
@@ -2647,7 +2644,7 @@ snapshots:
|
||||
prompts: 2.4.2
|
||||
rehype: 13.0.2
|
||||
semver: 7.7.3
|
||||
shiki: 3.17.1
|
||||
shiki: 3.20.0
|
||||
smol-toml: 1.5.2
|
||||
svgo: 4.0.0
|
||||
tinyexec: 1.0.2
|
||||
@@ -2658,8 +2655,8 @@ snapshots:
|
||||
unist-util-visit: 5.0.0
|
||||
unstorage: 1.17.3
|
||||
vfile: 6.0.3
|
||||
vite: 6.4.1(@types/node@24.10.1)
|
||||
vitefu: 1.1.1(vite@6.4.1(@types/node@24.10.1))
|
||||
vite: 6.4.1(@types/node@25.0.1)
|
||||
vitefu: 1.1.1(vite@6.4.1(@types/node@25.0.1))
|
||||
xxhash-wasm: 1.1.0
|
||||
yargs-parser: 21.1.1
|
||||
yocto-spinner: 0.2.3
|
||||
@@ -2844,7 +2841,7 @@ snapshots:
|
||||
dependencies:
|
||||
base-64: 1.0.0
|
||||
|
||||
devalue@5.5.0: {}
|
||||
devalue@5.6.1: {}
|
||||
|
||||
devlop@1.1.0:
|
||||
dependencies:
|
||||
@@ -2980,12 +2977,12 @@ snapshots:
|
||||
|
||||
eventemitter3@5.0.1: {}
|
||||
|
||||
expressive-code@0.41.3:
|
||||
expressive-code@0.41.4:
|
||||
dependencies:
|
||||
'@expressive-code/core': 0.41.3
|
||||
'@expressive-code/plugin-frames': 0.41.3
|
||||
'@expressive-code/plugin-shiki': 0.41.3
|
||||
'@expressive-code/plugin-text-markers': 0.41.3
|
||||
'@expressive-code/core': 0.41.4
|
||||
'@expressive-code/plugin-frames': 0.41.4
|
||||
'@expressive-code/plugin-shiki': 0.41.4
|
||||
'@expressive-code/plugin-text-markers': 0.41.4
|
||||
|
||||
extend@3.0.2: {}
|
||||
|
||||
@@ -3037,7 +3034,7 @@ snapshots:
|
||||
defu: 6.1.4
|
||||
destr: 2.0.5
|
||||
iron-webcrypto: 1.2.1
|
||||
node-mock-http: 1.0.3
|
||||
node-mock-http: 1.0.4
|
||||
radix3: 1.1.2
|
||||
ufo: 1.6.1
|
||||
uncrypto: 0.1.3
|
||||
@@ -3115,7 +3112,7 @@ snapshots:
|
||||
'@types/unist': 3.0.3
|
||||
'@ungap/structured-clone': 1.3.0
|
||||
hast-util-from-parse5: 8.0.3
|
||||
hast-util-to-parse5: 8.0.0
|
||||
hast-util-to-parse5: 8.0.1
|
||||
html-void-elements: 3.0.0
|
||||
mdast-util-to-hast: 13.2.1
|
||||
parse5: 7.3.0
|
||||
@@ -3198,12 +3195,12 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
hast-util-to-parse5@8.0.0:
|
||||
hast-util-to-parse5@8.0.1:
|
||||
dependencies:
|
||||
'@types/hast': 3.0.4
|
||||
comma-separated-tokens: 2.0.3
|
||||
devlop: 1.1.0
|
||||
property-information: 6.5.0
|
||||
property-information: 7.1.0
|
||||
space-separated-tokens: 2.0.2
|
||||
web-namespaces: 2.0.1
|
||||
zwitch: 2.0.4
|
||||
@@ -3795,7 +3792,7 @@ snapshots:
|
||||
|
||||
node-fetch-native@1.6.7: {}
|
||||
|
||||
node-mock-http@1.0.3: {}
|
||||
node-mock-http@1.0.4: {}
|
||||
|
||||
normalize-path@3.0.0: {}
|
||||
|
||||
@@ -3820,7 +3817,7 @@ snapshots:
|
||||
oniguruma-to-es@4.3.4:
|
||||
dependencies:
|
||||
oniguruma-parser: 0.12.1
|
||||
regex: 6.0.1
|
||||
regex: 6.1.0
|
||||
regex-recursion: 6.0.2
|
||||
|
||||
p-limit@2.3.0:
|
||||
@@ -3915,8 +3912,6 @@ snapshots:
|
||||
kleur: 3.0.3
|
||||
sisteransi: 1.0.5
|
||||
|
||||
property-information@6.5.0: {}
|
||||
|
||||
property-information@7.1.0: {}
|
||||
|
||||
qrcode@1.5.4:
|
||||
@@ -3966,13 +3961,13 @@ snapshots:
|
||||
|
||||
regex-utilities@2.3.0: {}
|
||||
|
||||
regex@6.0.1:
|
||||
regex@6.1.0:
|
||||
dependencies:
|
||||
regex-utilities: 2.3.0
|
||||
|
||||
rehype-expressive-code@0.41.3:
|
||||
rehype-expressive-code@0.41.4:
|
||||
dependencies:
|
||||
expressive-code: 0.41.3
|
||||
expressive-code: 0.41.4
|
||||
|
||||
rehype-format@5.0.1:
|
||||
dependencies:
|
||||
@@ -4185,14 +4180,14 @@ snapshots:
|
||||
'@img/sharp-win32-ia32': 0.34.5
|
||||
'@img/sharp-win32-x64': 0.34.5
|
||||
|
||||
shiki@3.17.1:
|
||||
shiki@3.20.0:
|
||||
dependencies:
|
||||
'@shikijs/core': 3.17.1
|
||||
'@shikijs/engine-javascript': 3.17.1
|
||||
'@shikijs/engine-oniguruma': 3.17.1
|
||||
'@shikijs/langs': 3.17.1
|
||||
'@shikijs/themes': 3.17.1
|
||||
'@shikijs/types': 3.17.1
|
||||
'@shikijs/core': 3.20.0
|
||||
'@shikijs/engine-javascript': 3.20.0
|
||||
'@shikijs/engine-oniguruma': 3.20.0
|
||||
'@shikijs/langs': 3.20.0
|
||||
'@shikijs/themes': 3.20.0
|
||||
'@shikijs/types': 3.20.0
|
||||
'@shikijs/vscode-textmate': 10.0.2
|
||||
'@types/hast': 3.0.4
|
||||
|
||||
@@ -4393,7 +4388,7 @@ snapshots:
|
||||
'@types/unist': 3.0.3
|
||||
vfile-message: 4.0.3
|
||||
|
||||
vite@6.4.1(@types/node@24.10.1):
|
||||
vite@6.4.1(@types/node@25.0.1):
|
||||
dependencies:
|
||||
esbuild: 0.25.12
|
||||
fdir: 6.5.0(picomatch@4.0.3)
|
||||
@@ -4402,12 +4397,12 @@ snapshots:
|
||||
rollup: 4.53.3
|
||||
tinyglobby: 0.2.15
|
||||
optionalDependencies:
|
||||
'@types/node': 24.10.1
|
||||
'@types/node': 25.0.1
|
||||
fsevents: 2.3.3
|
||||
|
||||
vitefu@1.1.1(vite@6.4.1(@types/node@24.10.1)):
|
||||
vitefu@1.1.1(vite@6.4.1(@types/node@25.0.1)):
|
||||
optionalDependencies:
|
||||
vite: 6.4.1(@types/node@24.10.1)
|
||||
vite: 6.4.1(@types/node@25.0.1)
|
||||
|
||||
web-namespaces@2.0.1: {}
|
||||
|
||||
|
||||
@@ -16,6 +16,62 @@ const hasLink = (link: string | undefined) => link && link.trim() !== "";
|
||||
---
|
||||
|
||||
<Tabs syncKey="platform">
|
||||
<TabItem label="iOS" icon="apple">
|
||||
<CardGrid>
|
||||
{
|
||||
hasLink(downloadLinks.ios.appStore) && (
|
||||
<Card title="App Store" icon="rocket">
|
||||
<p style="text-align: center;">
|
||||
<LinkButton
|
||||
href={downloadLinks.ios.appStore}
|
||||
variant="primary"
|
||||
icon="external"
|
||||
>
|
||||
Download on App Store
|
||||
</LinkButton>
|
||||
</p>
|
||||
{showQR && (
|
||||
<p style="text-align: center;">
|
||||
<QRCode
|
||||
data={downloadLinks.ios.appStore}
|
||||
size={200}
|
||||
alt="QR code for App Store"
|
||||
/>
|
||||
</p>
|
||||
)}
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
||||
{
|
||||
hasLink(downloadLinks.ios.testFlight) && (
|
||||
<Card title="TestFlight Beta" icon="warning">
|
||||
<p style="text-align: center;">
|
||||
<LinkButton
|
||||
href={downloadLinks.ios.testFlight}
|
||||
variant="secondary"
|
||||
icon="external"
|
||||
>
|
||||
Join TestFlight
|
||||
</LinkButton>
|
||||
</p>
|
||||
{showQR && (
|
||||
<p style="text-align: center;">
|
||||
<QRCode
|
||||
data={downloadLinks.ios.testFlight}
|
||||
size={200}
|
||||
alt="QR code for TestFlight"
|
||||
/>
|
||||
</p>
|
||||
)}
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
</CardGrid>
|
||||
|
||||
<p><strong>Requirements:</strong> {requirements.ios}</p>
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="Android" icon="star">
|
||||
<CardGrid>
|
||||
{
|
||||
@@ -96,60 +152,4 @@ const hasLink = (link: string | undefined) => link && link.trim() !== "";
|
||||
|
||||
<p><strong>Requirements:</strong> {requirements.android}</p>
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="iOS" icon="apple">
|
||||
<CardGrid>
|
||||
{
|
||||
hasLink(downloadLinks.ios.appStore) && (
|
||||
<Card title="App Store" icon="rocket">
|
||||
<p style="text-align: center;">
|
||||
<LinkButton
|
||||
href={downloadLinks.ios.appStore}
|
||||
variant="primary"
|
||||
icon="external"
|
||||
>
|
||||
Download on App Store
|
||||
</LinkButton>
|
||||
</p>
|
||||
{showQR && (
|
||||
<p style="text-align: center;">
|
||||
<QRCode
|
||||
data={downloadLinks.ios.appStore}
|
||||
size={200}
|
||||
alt="QR code for App Store"
|
||||
/>
|
||||
</p>
|
||||
)}
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
||||
{
|
||||
hasLink(downloadLinks.ios.testFlight) && (
|
||||
<Card title="TestFlight Beta" icon="warning">
|
||||
<p style="text-align: center;">
|
||||
<LinkButton
|
||||
href={downloadLinks.ios.testFlight}
|
||||
variant="secondary"
|
||||
icon="external"
|
||||
>
|
||||
Join TestFlight
|
||||
</LinkButton>
|
||||
</p>
|
||||
{showQR && (
|
||||
<p style="text-align: center;">
|
||||
<QRCode
|
||||
data={downloadLinks.ios.testFlight}
|
||||
size={200}
|
||||
alt="QR code for TestFlight"
|
||||
/>
|
||||
</p>
|
||||
)}
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
</CardGrid>
|
||||
|
||||
<p><strong>Requirements:</strong> {requirements.ios}</p>
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -42,6 +42,6 @@ Ascently is an **offline-first FOSS** app designed to help climbers track their
|
||||
|
||||
---
|
||||
|
||||
*Built with ❤️ by Atridad Lahiji*
|
||||
*Built with ❤️ by [Atridad Lahiji](https://atri.dad)*
|
||||
|
||||
*Contact: me@atri.dad*
|
||||
|
||||
22
ios/.editorconfig
Normal file
@@ -0,0 +1,22 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.swift]
|
||||
indent_size = 4
|
||||
max_line_length = 140
|
||||
|
||||
[*.{plist,storyboard,xib,xcscheme,xcworkspacedata}]
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
68
ios/.swiftformat
Normal file
@@ -0,0 +1,68 @@
|
||||
# SwiftFormat Configuration for Ascently iOS
|
||||
# Maintains consistent formatting across the project
|
||||
|
||||
# File options
|
||||
--exclude build,Pods,DerivedData,.build
|
||||
|
||||
# Format options
|
||||
--swiftversion 6.0
|
||||
--indent 4
|
||||
--tabwidth 4
|
||||
--maxwidth 140
|
||||
--wraparguments before-first
|
||||
--wrapparameters before-first
|
||||
--wrapcollections before-first
|
||||
--wrapconditions after-first
|
||||
--wrapreturntype preserve
|
||||
--wrapeffects preserve
|
||||
--closingparen balanced
|
||||
--funcattributes prev-line
|
||||
--typeattributes prev-line
|
||||
--varattributes preserve
|
||||
--storedvarattrs same-line
|
||||
--computedvarattrs preserve
|
||||
--complexattributes prev-line
|
||||
--typeblanklines preserve
|
||||
--structthreshold 20
|
||||
--enumthreshold 20
|
||||
--extensionacl on-declarations
|
||||
--organizetypes class,struct,enum,extension,protocol
|
||||
--modifierorder acl,setteracl,override,static,final,required,convenience,lazy,dynamic
|
||||
--self remove
|
||||
--importgrouping alpha
|
||||
--semicolons inline
|
||||
--operatorfunc spaced
|
||||
--nospaceoperators ..<,...
|
||||
--ranges no-space
|
||||
--emptybraces no-space
|
||||
--trimwhitespace always
|
||||
--stripunusedargs closure-only
|
||||
--header ignore
|
||||
--guardelse auto
|
||||
--elseposition same-line
|
||||
--shortoptionals always
|
||||
--linebreaks lf
|
||||
--xcodeindentation disabled
|
||||
--fragment false
|
||||
--conflictmarkers reject
|
||||
--ifdef no-indent
|
||||
--extensionlength 0
|
||||
|
||||
# Enable rules
|
||||
--enable isEmpty,sortedSwitchCases,redundantInit,redundantGet,redundantObjc
|
||||
--enable blankLineAfterSwitchCase,consecutiveSpaces,duplicateImports
|
||||
--enable elseOnSameLine,emptyBraces,hoistAwait,hoistPatternLet,hoistTry
|
||||
--enable leadingDelimiters,redundantBackticks,redundantBreak,redundantClosure
|
||||
--enable redundantExtensionACL,redundantFileprivate,redundantLetError
|
||||
--enable redundantNilInit,redundantParens,redundantPattern,redundantRawValues
|
||||
--enable redundantReturn,redundantSelf,redundantType,redundantVoidReturnType
|
||||
--enable semicolons,sortImports,spaceAroundBraces,spaceAroundBrackets
|
||||
--enable spaceAroundComments,spaceAroundGenerics,spaceAroundOperators
|
||||
--enable spaceAroundParens,spaceInsideBraces,spaceInsideBrackets
|
||||
--enable spaceInsideComments,spaceInsideGenerics,spaceInsideParens
|
||||
--enable strongOutlets,strongifiedSelf,todos,trailingClosures,trailingCommas
|
||||
--enable typeSugar,unusedArguments,void,wrapArguments,wrapAttributes
|
||||
--enable yodaConditions,blankLinesBetweenScopes,blankLinesAtEndOfScope
|
||||
|
||||
# Disable rules
|
||||
--disable wrapMultilineStatementBraces
|
||||
139
ios/.swiftlint.yml
Normal file
@@ -0,0 +1,139 @@
|
||||
excluded:
|
||||
- build
|
||||
- Pods
|
||||
- DerivedData
|
||||
- .build
|
||||
- AscentlyTests
|
||||
|
||||
disabled_rules:
|
||||
- trailing_whitespace
|
||||
- todo
|
||||
- nesting
|
||||
- opening_brace
|
||||
- multiple_closures_with_trailing_closure
|
||||
- trailing_comma
|
||||
- attributes
|
||||
- function_parameter_count
|
||||
- large_tuple
|
||||
|
||||
opt_in_rules:
|
||||
- empty_count
|
||||
- explicit_init
|
||||
- closure_spacing
|
||||
- overridden_super_call
|
||||
- redundant_nil_coalescing
|
||||
- first_where
|
||||
- sorted_first_last
|
||||
- contains_over_filter_count
|
||||
- contains_over_filter_is_empty
|
||||
- empty_string
|
||||
- prefer_zero_over_explicit_init
|
||||
- flatmap_over_map_reduce
|
||||
- last_where
|
||||
- sorted_imports
|
||||
- toggle_bool
|
||||
- unavailable_function
|
||||
- unneeded_parentheses_in_closure_argument
|
||||
- vertical_whitespace_closing_braces
|
||||
- yoda_condition
|
||||
- collection_alignment
|
||||
- literal_expression_end_indentation
|
||||
|
||||
line_length:
|
||||
warning: 140
|
||||
error: 250
|
||||
ignores_comments: true
|
||||
ignores_urls: true
|
||||
ignores_function_declarations: true
|
||||
ignores_interpolated_strings: true
|
||||
|
||||
type_body_length:
|
||||
warning: 600
|
||||
error: 1000
|
||||
|
||||
file_length:
|
||||
warning: 1000
|
||||
error: 1500
|
||||
ignore_comment_only_lines: true
|
||||
|
||||
function_body_length:
|
||||
warning: 100
|
||||
error: 200
|
||||
|
||||
cyclomatic_complexity:
|
||||
warning: 20
|
||||
error: 30
|
||||
ignores_case_statements: true
|
||||
|
||||
identifier_name:
|
||||
min_length:
|
||||
warning: 2
|
||||
error: 1
|
||||
max_length:
|
||||
warning: 50
|
||||
error: 60
|
||||
validates_start_with_lowercase: error
|
||||
allowed_symbols:
|
||||
- _
|
||||
excluded:
|
||||
- id
|
||||
- i
|
||||
- j
|
||||
- x
|
||||
- y
|
||||
- z
|
||||
- to
|
||||
- at
|
||||
- or
|
||||
- is
|
||||
- no
|
||||
- go
|
||||
- db
|
||||
- DATA_JSON_FILENAME
|
||||
- IMAGES_DIR_NAME
|
||||
- METADATA_FILENAME
|
||||
# ViewBuilder section functions (SwiftUI convention)
|
||||
- StatusSection
|
||||
- IconDisplaySection
|
||||
- DebugSection
|
||||
- TestingSection
|
||||
- ResultsSection
|
||||
- GymSelectionSection
|
||||
- SessionDetailsSection
|
||||
- ProblemSelectionSection
|
||||
- CreateProblemSection
|
||||
- AttemptDetailsSection
|
||||
- BasicInfoSection
|
||||
- ClimbTypesSection
|
||||
- DifficultySystemsSection
|
||||
- NotesSection
|
||||
- ClimbTypeSection
|
||||
- DifficultySection
|
||||
- LocationSection
|
||||
- TagsSection
|
||||
- PhotosSection
|
||||
- AdditionalInfoSection
|
||||
|
||||
type_name:
|
||||
min_length:
|
||||
warning: 3
|
||||
error: 2
|
||||
max_length:
|
||||
warning: 50
|
||||
error: 60
|
||||
|
||||
force_cast: warning
|
||||
|
||||
force_try: warning
|
||||
|
||||
large_tuple:
|
||||
warning: 4
|
||||
error: 6
|
||||
|
||||
nesting:
|
||||
type_level:
|
||||
warning: 3
|
||||
function_level:
|
||||
warning: 5
|
||||
|
||||
reporter: "xcode"
|
||||
@@ -7,6 +7,52 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
D28C33372F0F87D60040FE49 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D28C33312F0F87D60040FE49 /* Assets.xcassets */; };
|
||||
D28C33382F0F87D60040FE49 /* Balls.icon in Resources */ = {isa = PBXBuildFile; fileRef = D28C33322F0F87D60040FE49 /* Balls.icon */; };
|
||||
D28C33392F0F87D60040FE49 /* Icon.icon in Resources */ = {isa = PBXBuildFile; fileRef = D28C33342F0F87D60040FE49 /* Icon.icon */; };
|
||||
D28C333B2F0F87D60040FE49 /* AscentlyShortcuts.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C32F92F0F87D60040FE49 /* AscentlyShortcuts.swift */; };
|
||||
D28C333C2F0F87D60040FE49 /* SessionIntentSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C32FA2F0F87D60040FE49 /* SessionIntentSupport.swift */; };
|
||||
D28C333D2F0F87D60040FE49 /* ToggleSessionIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C32FB2F0F87D60040FE49 /* ToggleSessionIntent.swift */; };
|
||||
D28C333E2F0F87D60040FE49 /* AsyncImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C32FD2F0F87D60040FE49 /* AsyncImageView.swift */; };
|
||||
D28C333F2F0F87D60040FE49 /* CameraImagePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C32FE2F0F87D60040FE49 /* CameraImagePicker.swift */; };
|
||||
D28C33402F0F87D60040FE49 /* PhotoOptionSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C32FF2F0F87D60040FE49 /* PhotoOptionSheet.swift */; };
|
||||
D28C33412F0F87D60040FE49 /* ActivityAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33022F0F87D60040FE49 /* ActivityAttributes.swift */; };
|
||||
D28C33422F0F87D60040FE49 /* BackupFormat.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33032F0F87D60040FE49 /* BackupFormat.swift */; };
|
||||
D28C33432F0F87D60040FE49 /* DataModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33042F0F87D60040FE49 /* DataModels.swift */; };
|
||||
D28C33442F0F87D60040FE49 /* DeltaSyncFormat.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33052F0F87D60040FE49 /* DeltaSyncFormat.swift */; };
|
||||
D28C33452F0F87D60040FE49 /* ServerSyncProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33072F0F87D60040FE49 /* ServerSyncProvider.swift */; };
|
||||
D28C33462F0F87D60040FE49 /* SyncMerger.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33082F0F87D60040FE49 /* SyncMerger.swift */; };
|
||||
D28C33472F0F87D60040FE49 /* SyncProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33092F0F87D60040FE49 /* SyncProvider.swift */; };
|
||||
D28C33482F0F87D60040FE49 /* HealthKitService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C330B2F0F87D60040FE49 /* HealthKitService.swift */; };
|
||||
D28C33492F0F87D60040FE49 /* MusicService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C330C2F0F87D60040FE49 /* MusicService.swift */; };
|
||||
D28C334A2F0F87D60040FE49 /* SyncService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C330D2F0F87D60040FE49 /* SyncService.swift */; };
|
||||
D28C334B2F0F87D60040FE49 /* AppIconHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33102F0F87D60040FE49 /* AppIconHelper.swift */; };
|
||||
D28C334C2F0F87D60040FE49 /* AppLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33112F0F87D60040FE49 /* AppLogger.swift */; };
|
||||
D28C334D2F0F87D60040FE49 /* DataStateManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33122F0F87D60040FE49 /* DataStateManager.swift */; };
|
||||
D28C334E2F0F87D60040FE49 /* IconTestView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33132F0F87D60040FE49 /* IconTestView.swift */; };
|
||||
D28C334F2F0F87D60040FE49 /* ImageManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33142F0F87D60040FE49 /* ImageManager.swift */; };
|
||||
D28C33502F0F87D60040FE49 /* ImageNamingUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33152F0F87D60040FE49 /* ImageNamingUtils.swift */; };
|
||||
D28C33512F0F87D60040FE49 /* OrientationAwareImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33162F0F87D60040FE49 /* OrientationAwareImage.swift */; };
|
||||
D28C33522F0F87D60040FE49 /* ThemeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33172F0F87D60040FE49 /* ThemeManager.swift */; };
|
||||
D28C33532F0F87D60040FE49 /* ZipUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33182F0F87D60040FE49 /* ZipUtils.swift */; };
|
||||
D28C33542F0F87D60040FE49 /* ClimbingDataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C331A2F0F87D60040FE49 /* ClimbingDataManager.swift */; };
|
||||
D28C33552F0F87D60040FE49 /* LiveActivityManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C331B2F0F87D60040FE49 /* LiveActivityManager.swift */; };
|
||||
D28C33562F0F87D60040FE49 /* AddAttemptView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C331D2F0F87D60040FE49 /* AddAttemptView.swift */; };
|
||||
D28C33572F0F87D60040FE49 /* AddEditGymView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C331E2F0F87D60040FE49 /* AddEditGymView.swift */; };
|
||||
D28C33582F0F87D60040FE49 /* AddEditProblemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C331F2F0F87D60040FE49 /* AddEditProblemView.swift */; };
|
||||
D28C33592F0F87D60040FE49 /* AddEditSessionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33202F0F87D60040FE49 /* AddEditSessionView.swift */; };
|
||||
D28C335A2F0F87D60040FE49 /* GymDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33232F0F87D60040FE49 /* GymDetailView.swift */; };
|
||||
D28C335B2F0F87D60040FE49 /* ProblemDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33242F0F87D60040FE49 /* ProblemDetailView.swift */; };
|
||||
D28C335C2F0F87D60040FE49 /* SessionDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33252F0F87D60040FE49 /* SessionDetailView.swift */; };
|
||||
D28C335D2F0F87D60040FE49 /* AnalyticsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33272F0F87D60040FE49 /* AnalyticsView.swift */; };
|
||||
D28C335E2F0F87D60040FE49 /* CalendarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33282F0F87D60040FE49 /* CalendarView.swift */; };
|
||||
D28C335F2F0F87D60040FE49 /* GymsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33292F0F87D60040FE49 /* GymsView.swift */; };
|
||||
D28C33602F0F87D60040FE49 /* LiveActivityDebugView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C332A2F0F87D60040FE49 /* LiveActivityDebugView.swift */; };
|
||||
D28C33612F0F87D60040FE49 /* ProblemsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C332B2F0F87D60040FE49 /* ProblemsView.swift */; };
|
||||
D28C33622F0F87D60040FE49 /* SessionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C332C2F0F87D60040FE49 /* SessionsView.swift */; };
|
||||
D28C33632F0F87D60040FE49 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C332D2F0F87D60040FE49 /* SettingsView.swift */; };
|
||||
D28C33642F0F87D60040FE49 /* AscentlyApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33302F0F87D60040FE49 /* AscentlyApp.swift */; };
|
||||
D28C33652F0F87D60040FE49 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28C33332F0F87D60040FE49 /* ContentView.swift */; };
|
||||
D2FE94822E78E95C008CDB25 /* ActivityKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2FE94802E78E958008CDB25 /* ActivityKit.framework */; };
|
||||
D2FE948D2E78FEE0008CDB25 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2FE948C2E78FEE0008CDB25 /* WidgetKit.framework */; };
|
||||
D2FE948F2E78FEE0008CDB25 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2FE948E2E78FEE0008CDB25 /* SwiftUI.framework */; };
|
||||
@@ -48,6 +94,54 @@
|
||||
/* Begin PBXFileReference section */
|
||||
D24C19682E75002A0045894C /* Ascently.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Ascently.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D268B79E2E83894A003AA641 /* SessionStatusLiveExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SessionStatusLiveExtension.entitlements; sourceTree = "<group>"; };
|
||||
D28C32F92F0F87D60040FE49 /* AscentlyShortcuts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AscentlyShortcuts.swift; sourceTree = "<group>"; };
|
||||
D28C32FA2F0F87D60040FE49 /* SessionIntentSupport.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionIntentSupport.swift; sourceTree = "<group>"; };
|
||||
D28C32FB2F0F87D60040FE49 /* ToggleSessionIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleSessionIntent.swift; sourceTree = "<group>"; };
|
||||
D28C32FD2F0F87D60040FE49 /* AsyncImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AsyncImageView.swift; sourceTree = "<group>"; };
|
||||
D28C32FE2F0F87D60040FE49 /* CameraImagePicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraImagePicker.swift; sourceTree = "<group>"; };
|
||||
D28C32FF2F0F87D60040FE49 /* PhotoOptionSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoOptionSheet.swift; sourceTree = "<group>"; };
|
||||
D28C33022F0F87D60040FE49 /* ActivityAttributes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityAttributes.swift; sourceTree = "<group>"; };
|
||||
D28C33032F0F87D60040FE49 /* BackupFormat.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackupFormat.swift; sourceTree = "<group>"; };
|
||||
D28C33042F0F87D60040FE49 /* DataModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataModels.swift; sourceTree = "<group>"; };
|
||||
D28C33052F0F87D60040FE49 /* DeltaSyncFormat.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeltaSyncFormat.swift; sourceTree = "<group>"; };
|
||||
D28C33072F0F87D60040FE49 /* ServerSyncProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerSyncProvider.swift; sourceTree = "<group>"; };
|
||||
D28C33082F0F87D60040FE49 /* SyncMerger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SyncMerger.swift; sourceTree = "<group>"; };
|
||||
D28C33092F0F87D60040FE49 /* SyncProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SyncProvider.swift; sourceTree = "<group>"; };
|
||||
D28C330B2F0F87D60040FE49 /* HealthKitService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HealthKitService.swift; sourceTree = "<group>"; };
|
||||
D28C330C2F0F87D60040FE49 /* MusicService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicService.swift; sourceTree = "<group>"; };
|
||||
D28C330D2F0F87D60040FE49 /* SyncService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SyncService.swift; sourceTree = "<group>"; };
|
||||
D28C33102F0F87D60040FE49 /* AppIconHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIconHelper.swift; sourceTree = "<group>"; };
|
||||
D28C33112F0F87D60040FE49 /* AppLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLogger.swift; sourceTree = "<group>"; };
|
||||
D28C33122F0F87D60040FE49 /* DataStateManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataStateManager.swift; sourceTree = "<group>"; };
|
||||
D28C33132F0F87D60040FE49 /* IconTestView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconTestView.swift; sourceTree = "<group>"; };
|
||||
D28C33142F0F87D60040FE49 /* ImageManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageManager.swift; sourceTree = "<group>"; };
|
||||
D28C33152F0F87D60040FE49 /* ImageNamingUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageNamingUtils.swift; sourceTree = "<group>"; };
|
||||
D28C33162F0F87D60040FE49 /* OrientationAwareImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrientationAwareImage.swift; sourceTree = "<group>"; };
|
||||
D28C33172F0F87D60040FE49 /* ThemeManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeManager.swift; sourceTree = "<group>"; };
|
||||
D28C33182F0F87D60040FE49 /* ZipUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZipUtils.swift; sourceTree = "<group>"; };
|
||||
D28C331A2F0F87D60040FE49 /* ClimbingDataManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClimbingDataManager.swift; sourceTree = "<group>"; };
|
||||
D28C331B2F0F87D60040FE49 /* LiveActivityManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LiveActivityManager.swift; sourceTree = "<group>"; };
|
||||
D28C331D2F0F87D60040FE49 /* AddAttemptView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAttemptView.swift; sourceTree = "<group>"; };
|
||||
D28C331E2F0F87D60040FE49 /* AddEditGymView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddEditGymView.swift; sourceTree = "<group>"; };
|
||||
D28C331F2F0F87D60040FE49 /* AddEditProblemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddEditProblemView.swift; sourceTree = "<group>"; };
|
||||
D28C33202F0F87D60040FE49 /* AddEditSessionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddEditSessionView.swift; sourceTree = "<group>"; };
|
||||
D28C33232F0F87D60040FE49 /* GymDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GymDetailView.swift; sourceTree = "<group>"; };
|
||||
D28C33242F0F87D60040FE49 /* ProblemDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProblemDetailView.swift; sourceTree = "<group>"; };
|
||||
D28C33252F0F87D60040FE49 /* SessionDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionDetailView.swift; sourceTree = "<group>"; };
|
||||
D28C33272F0F87D60040FE49 /* AnalyticsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsView.swift; sourceTree = "<group>"; };
|
||||
D28C33282F0F87D60040FE49 /* CalendarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarView.swift; sourceTree = "<group>"; };
|
||||
D28C33292F0F87D60040FE49 /* GymsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GymsView.swift; sourceTree = "<group>"; };
|
||||
D28C332A2F0F87D60040FE49 /* LiveActivityDebugView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LiveActivityDebugView.swift; sourceTree = "<group>"; };
|
||||
D28C332B2F0F87D60040FE49 /* ProblemsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProblemsView.swift; sourceTree = "<group>"; };
|
||||
D28C332C2F0F87D60040FE49 /* SessionsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionsView.swift; sourceTree = "<group>"; };
|
||||
D28C332D2F0F87D60040FE49 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
|
||||
D28C332F2F0F87D60040FE49 /* Ascently.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Ascently.entitlements; sourceTree = "<group>"; };
|
||||
D28C33302F0F87D60040FE49 /* AscentlyApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AscentlyApp.swift; sourceTree = "<group>"; };
|
||||
D28C33312F0F87D60040FE49 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
D28C33322F0F87D60040FE49 /* Balls.icon */ = {isa = PBXFileReference; lastKnownFileType = folder.iconcomposer.icon; path = Balls.icon; sourceTree = "<group>"; };
|
||||
D28C33332F0F87D60040FE49 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||
D28C33342F0F87D60040FE49 /* Icon.icon */ = {isa = PBXFileReference; lastKnownFileType = folder.iconcomposer.icon; path = Icon.icon; sourceTree = "<group>"; };
|
||||
D28C33352F0F87D60040FE49 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
D2F32FAD2E90B26500B1BC56 /* AscentlyTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AscentlyTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D2FE94802E78E958008CDB25 /* ActivityKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ActivityKit.framework; path = System/Library/Frameworks/ActivityKit.framework; sourceTree = SDKROOT; };
|
||||
D2FE948B2E78FEE0008CDB25 /* SessionStatusLiveExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = SessionStatusLiveExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@@ -56,13 +150,6 @@
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||
D28C3C8B2E75111D00F7AEE9 /* Exceptions for "Ascently" folder in "Ascently" target */ = {
|
||||
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||
membershipExceptions = (
|
||||
Info.plist,
|
||||
);
|
||||
target = D24C19672E75002A0045894C /* Ascently */;
|
||||
};
|
||||
D2FE94A42E78FEE1008CDB25 /* Exceptions for "SessionStatusLive" folder in "SessionStatusLiveExtension" target */ = {
|
||||
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||
membershipExceptions = (
|
||||
@@ -73,14 +160,6 @@
|
||||
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||
|
||||
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
||||
D24C196A2E75002A0045894C /* Ascently */ = {
|
||||
isa = PBXFileSystemSynchronizedRootGroup;
|
||||
exceptions = (
|
||||
D28C3C8B2E75111D00F7AEE9 /* Exceptions for "Ascently" folder in "Ascently" target */,
|
||||
);
|
||||
path = Ascently;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D2F32FAE2E90B26500B1BC56 /* AscentlyTests */ = {
|
||||
isa = PBXFileSystemSynchronizedRootGroup;
|
||||
path = AscentlyTests;
|
||||
@@ -129,7 +208,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D268B79E2E83894A003AA641 /* SessionStatusLiveExtension.entitlements */,
|
||||
D24C196A2E75002A0045894C /* Ascently */,
|
||||
D28C33362F0F87D60040FE49 /* Ascently */,
|
||||
D2FE94902E78FEE0008CDB25 /* SessionStatusLive */,
|
||||
D2F32FAE2E90B26500B1BC56 /* AscentlyTests */,
|
||||
D2FE947F2E78E958008CDB25 /* Frameworks */,
|
||||
@@ -147,6 +226,165 @@
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D28C32FC2F0F87D60040FE49 /* AppIntents */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D28C32F92F0F87D60040FE49 /* AscentlyShortcuts.swift */,
|
||||
D28C32FA2F0F87D60040FE49 /* SessionIntentSupport.swift */,
|
||||
D28C32FB2F0F87D60040FE49 /* ToggleSessionIntent.swift */,
|
||||
);
|
||||
path = AppIntents;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D28C33002F0F87D60040FE49 /* Components */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D28C32FD2F0F87D60040FE49 /* AsyncImageView.swift */,
|
||||
D28C32FE2F0F87D60040FE49 /* CameraImagePicker.swift */,
|
||||
D28C32FF2F0F87D60040FE49 /* PhotoOptionSheet.swift */,
|
||||
);
|
||||
path = Components;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D28C33012F0F87D60040FE49 /* FocusFilter */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
path = FocusFilter;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D28C33062F0F87D60040FE49 /* Models */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D28C33022F0F87D60040FE49 /* ActivityAttributes.swift */,
|
||||
D28C33032F0F87D60040FE49 /* BackupFormat.swift */,
|
||||
D28C33042F0F87D60040FE49 /* DataModels.swift */,
|
||||
D28C33052F0F87D60040FE49 /* DeltaSyncFormat.swift */,
|
||||
);
|
||||
path = Models;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D28C330A2F0F87D60040FE49 /* Sync */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D28C33072F0F87D60040FE49 /* ServerSyncProvider.swift */,
|
||||
D28C33082F0F87D60040FE49 /* SyncMerger.swift */,
|
||||
D28C33092F0F87D60040FE49 /* SyncProvider.swift */,
|
||||
);
|
||||
path = Sync;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D28C330E2F0F87D60040FE49 /* Services */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D28C330A2F0F87D60040FE49 /* Sync */,
|
||||
D28C330B2F0F87D60040FE49 /* HealthKitService.swift */,
|
||||
D28C330C2F0F87D60040FE49 /* MusicService.swift */,
|
||||
D28C330D2F0F87D60040FE49 /* SyncService.swift */,
|
||||
);
|
||||
path = Services;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D28C330F2F0F87D60040FE49 /* Spotlight */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
path = Spotlight;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D28C33192F0F87D60040FE49 /* Utils */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D28C33102F0F87D60040FE49 /* AppIconHelper.swift */,
|
||||
D28C33112F0F87D60040FE49 /* AppLogger.swift */,
|
||||
D28C33122F0F87D60040FE49 /* DataStateManager.swift */,
|
||||
D28C33132F0F87D60040FE49 /* IconTestView.swift */,
|
||||
D28C33142F0F87D60040FE49 /* ImageManager.swift */,
|
||||
D28C33152F0F87D60040FE49 /* ImageNamingUtils.swift */,
|
||||
D28C33162F0F87D60040FE49 /* OrientationAwareImage.swift */,
|
||||
D28C33172F0F87D60040FE49 /* ThemeManager.swift */,
|
||||
D28C33182F0F87D60040FE49 /* ZipUtils.swift */,
|
||||
);
|
||||
path = Utils;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D28C331C2F0F87D60040FE49 /* ViewModels */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D28C331A2F0F87D60040FE49 /* ClimbingDataManager.swift */,
|
||||
D28C331B2F0F87D60040FE49 /* LiveActivityManager.swift */,
|
||||
);
|
||||
path = ViewModels;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D28C33212F0F87D60040FE49 /* AddEdit */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D28C331D2F0F87D60040FE49 /* AddAttemptView.swift */,
|
||||
D28C331E2F0F87D60040FE49 /* AddEditGymView.swift */,
|
||||
D28C331F2F0F87D60040FE49 /* AddEditProblemView.swift */,
|
||||
D28C33202F0F87D60040FE49 /* AddEditSessionView.swift */,
|
||||
);
|
||||
path = AddEdit;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D28C33222F0F87D60040FE49 /* Debug */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
path = Debug;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D28C33262F0F87D60040FE49 /* Detail */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D28C33232F0F87D60040FE49 /* GymDetailView.swift */,
|
||||
D28C33242F0F87D60040FE49 /* ProblemDetailView.swift */,
|
||||
D28C33252F0F87D60040FE49 /* SessionDetailView.swift */,
|
||||
);
|
||||
path = Detail;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D28C332E2F0F87D60040FE49 /* Views */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D28C33212F0F87D60040FE49 /* AddEdit */,
|
||||
D28C33222F0F87D60040FE49 /* Debug */,
|
||||
D28C33262F0F87D60040FE49 /* Detail */,
|
||||
D28C33272F0F87D60040FE49 /* AnalyticsView.swift */,
|
||||
D28C33282F0F87D60040FE49 /* CalendarView.swift */,
|
||||
D28C33292F0F87D60040FE49 /* GymsView.swift */,
|
||||
D28C332A2F0F87D60040FE49 /* LiveActivityDebugView.swift */,
|
||||
D28C332B2F0F87D60040FE49 /* ProblemsView.swift */,
|
||||
D28C332C2F0F87D60040FE49 /* SessionsView.swift */,
|
||||
D28C332D2F0F87D60040FE49 /* SettingsView.swift */,
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D28C33362F0F87D60040FE49 /* Ascently */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D28C32FC2F0F87D60040FE49 /* AppIntents */,
|
||||
D28C33002F0F87D60040FE49 /* Components */,
|
||||
D28C33012F0F87D60040FE49 /* FocusFilter */,
|
||||
D28C33062F0F87D60040FE49 /* Models */,
|
||||
D28C330E2F0F87D60040FE49 /* Services */,
|
||||
D28C330F2F0F87D60040FE49 /* Spotlight */,
|
||||
D28C33192F0F87D60040FE49 /* Utils */,
|
||||
D28C331C2F0F87D60040FE49 /* ViewModels */,
|
||||
D28C332E2F0F87D60040FE49 /* Views */,
|
||||
D28C332F2F0F87D60040FE49 /* Ascently.entitlements */,
|
||||
D28C33302F0F87D60040FE49 /* AscentlyApp.swift */,
|
||||
D28C33312F0F87D60040FE49 /* Assets.xcassets */,
|
||||
D28C33322F0F87D60040FE49 /* Balls.icon */,
|
||||
D28C33332F0F87D60040FE49 /* ContentView.swift */,
|
||||
D28C33342F0F87D60040FE49 /* Icon.icon */,
|
||||
D28C33352F0F87D60040FE49 /* Info.plist */,
|
||||
);
|
||||
path = Ascently;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D2FE947F2E78E958008CDB25 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -174,9 +412,6 @@
|
||||
dependencies = (
|
||||
D2FE949F2E78FEE1008CDB25 /* PBXTargetDependency */,
|
||||
);
|
||||
fileSystemSynchronizedGroups = (
|
||||
D24C196A2E75002A0045894C /* Ascently */,
|
||||
);
|
||||
name = Ascently;
|
||||
packageProductDependencies = (
|
||||
);
|
||||
@@ -277,6 +512,9 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D28C33372F0F87D60040FE49 /* Assets.xcassets in Resources */,
|
||||
D28C33382F0F87D60040FE49 /* Balls.icon in Resources */,
|
||||
D28C33392F0F87D60040FE49 /* Icon.icon in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -301,6 +539,49 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D28C333B2F0F87D60040FE49 /* AscentlyShortcuts.swift in Sources */,
|
||||
D28C333C2F0F87D60040FE49 /* SessionIntentSupport.swift in Sources */,
|
||||
D28C333D2F0F87D60040FE49 /* ToggleSessionIntent.swift in Sources */,
|
||||
D28C333E2F0F87D60040FE49 /* AsyncImageView.swift in Sources */,
|
||||
D28C333F2F0F87D60040FE49 /* CameraImagePicker.swift in Sources */,
|
||||
D28C33402F0F87D60040FE49 /* PhotoOptionSheet.swift in Sources */,
|
||||
D28C33412F0F87D60040FE49 /* ActivityAttributes.swift in Sources */,
|
||||
D28C33422F0F87D60040FE49 /* BackupFormat.swift in Sources */,
|
||||
D28C33432F0F87D60040FE49 /* DataModels.swift in Sources */,
|
||||
D28C33442F0F87D60040FE49 /* DeltaSyncFormat.swift in Sources */,
|
||||
D28C33452F0F87D60040FE49 /* ServerSyncProvider.swift in Sources */,
|
||||
D28C33462F0F87D60040FE49 /* SyncMerger.swift in Sources */,
|
||||
D28C33472F0F87D60040FE49 /* SyncProvider.swift in Sources */,
|
||||
D28C33482F0F87D60040FE49 /* HealthKitService.swift in Sources */,
|
||||
D28C33492F0F87D60040FE49 /* MusicService.swift in Sources */,
|
||||
D28C334A2F0F87D60040FE49 /* SyncService.swift in Sources */,
|
||||
D28C334B2F0F87D60040FE49 /* AppIconHelper.swift in Sources */,
|
||||
D28C334C2F0F87D60040FE49 /* AppLogger.swift in Sources */,
|
||||
D28C334D2F0F87D60040FE49 /* DataStateManager.swift in Sources */,
|
||||
D28C334E2F0F87D60040FE49 /* IconTestView.swift in Sources */,
|
||||
D28C334F2F0F87D60040FE49 /* ImageManager.swift in Sources */,
|
||||
D28C33502F0F87D60040FE49 /* ImageNamingUtils.swift in Sources */,
|
||||
D28C33512F0F87D60040FE49 /* OrientationAwareImage.swift in Sources */,
|
||||
D28C33522F0F87D60040FE49 /* ThemeManager.swift in Sources */,
|
||||
D28C33532F0F87D60040FE49 /* ZipUtils.swift in Sources */,
|
||||
D28C33542F0F87D60040FE49 /* ClimbingDataManager.swift in Sources */,
|
||||
D28C33552F0F87D60040FE49 /* LiveActivityManager.swift in Sources */,
|
||||
D28C33562F0F87D60040FE49 /* AddAttemptView.swift in Sources */,
|
||||
D28C33572F0F87D60040FE49 /* AddEditGymView.swift in Sources */,
|
||||
D28C33582F0F87D60040FE49 /* AddEditProblemView.swift in Sources */,
|
||||
D28C33592F0F87D60040FE49 /* AddEditSessionView.swift in Sources */,
|
||||
D28C335A2F0F87D60040FE49 /* GymDetailView.swift in Sources */,
|
||||
D28C335B2F0F87D60040FE49 /* ProblemDetailView.swift in Sources */,
|
||||
D28C335C2F0F87D60040FE49 /* SessionDetailView.swift in Sources */,
|
||||
D28C335D2F0F87D60040FE49 /* AnalyticsView.swift in Sources */,
|
||||
D28C335E2F0F87D60040FE49 /* CalendarView.swift in Sources */,
|
||||
D28C335F2F0F87D60040FE49 /* GymsView.swift in Sources */,
|
||||
D28C33602F0F87D60040FE49 /* LiveActivityDebugView.swift in Sources */,
|
||||
D28C33612F0F87D60040FE49 /* ProblemsView.swift in Sources */,
|
||||
D28C33622F0F87D60040FE49 /* SessionsView.swift in Sources */,
|
||||
D28C33632F0F87D60040FE49 /* SettingsView.swift in Sources */,
|
||||
D28C33642F0F87D60040FE49 /* AscentlyApp.swift in Sources */,
|
||||
D28C33652F0F87D60040FE49 /* ContentView.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -460,12 +741,13 @@
|
||||
D24C19742E75002A0045894C /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_ALTERNATE_APPICON_NAMES = Balls;
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = Icon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = Ascently/Ascently.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 38;
|
||||
CURRENT_PROJECT_VERSION = 40;
|
||||
DEVELOPMENT_TEAM = 4BC9Y2LL4B;
|
||||
DRIVERKIT_DEPLOYMENT_TARGET = 24.6;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
@@ -487,7 +769,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 15.6;
|
||||
MARKETING_VERSION = 2.5.1;
|
||||
MARKETING_VERSION = 2.6.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.atridad.Ascently;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
@@ -508,12 +790,13 @@
|
||||
D24C19752E75002A0045894C /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_ALTERNATE_APPICON_NAMES = Balls;
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = Icon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = Ascently/Ascently.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 38;
|
||||
CURRENT_PROJECT_VERSION = 40;
|
||||
DEVELOPMENT_TEAM = 4BC9Y2LL4B;
|
||||
DRIVERKIT_DEPLOYMENT_TARGET = 24.6;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
@@ -535,7 +818,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 15.6;
|
||||
MARKETING_VERSION = 2.5.1;
|
||||
MARKETING_VERSION = 2.6.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.atridad.Ascently;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
@@ -602,7 +885,7 @@
|
||||
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
|
||||
CODE_SIGN_ENTITLEMENTS = SessionStatusLiveExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 38;
|
||||
CURRENT_PROJECT_VERSION = 40;
|
||||
DEVELOPMENT_TEAM = 4BC9Y2LL4B;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = SessionStatusLive/Info.plist;
|
||||
@@ -613,7 +896,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 2.5.1;
|
||||
MARKETING_VERSION = 2.6.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.atridad.Ascently.SessionStatusLive;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
@@ -632,7 +915,7 @@
|
||||
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
|
||||
CODE_SIGN_ENTITLEMENTS = SessionStatusLiveExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 38;
|
||||
CURRENT_PROJECT_VERSION = 40;
|
||||
DEVELOPMENT_TEAM = 4BC9Y2LL4B;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = SessionStatusLive/Info.plist;
|
||||
@@ -643,7 +926,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 2.5.1;
|
||||
MARKETING_VERSION = 2.6.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.atridad.Ascently.SessionStatusLive;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
{
|
||||
"images": [
|
||||
{
|
||||
"filename": "app_icon_1024.png",
|
||||
"idiom": "universal",
|
||||
"platform": "ios",
|
||||
"size": "1024x1024"
|
||||
},
|
||||
{
|
||||
"appearances": [
|
||||
{
|
||||
"appearance": "luminosity",
|
||||
"value": "dark"
|
||||
}
|
||||
],
|
||||
"filename": "app_icon_1024_dark.png",
|
||||
"idiom": "universal",
|
||||
"platform": "ios",
|
||||
"size": "1024x1024"
|
||||
},
|
||||
{
|
||||
"appearances": [
|
||||
{
|
||||
"appearance": "luminosity",
|
||||
"value": "tinted"
|
||||
}
|
||||
],
|
||||
"filename": "app_icon_1024_tinted.png",
|
||||
"idiom": "universal",
|
||||
"platform": "ios",
|
||||
"size": "1024x1024"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
"author": "xcode",
|
||||
"version": 1
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 3.1 KiB |