openuispec 0.2.9 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/cli/index.ts +80 -2
- package/cli/init.ts +23 -8
- package/docs/cli.md +42 -7
- package/drift/index.ts +41 -15
- package/mcp-server/index.ts +247 -117
- package/mcp-server/screenshot-android.ts +185 -44
- package/mcp-server/screenshot-ios.ts +242 -30
- package/mcp-server/screenshot.ts +96 -1
- package/package.json +5 -2
- package/prepare/index.ts +16 -0
- package/scripts/take-all-screenshots.ts +507 -0
- package/status/index.ts +2 -2
- package/examples/social-app/.mcp.json +0 -10
- package/examples/social-app/AGENTS.md +0 -124
- package/examples/social-app/CLAUDE.md +0 -124
- package/examples/social-app/backend/.gitkeep +0 -1
- package/examples/social-app/generated/android/social-app/app/.paparazzi-hashes.json +0 -3
- package/examples/social-app/generated/android/social-app/app/build.gradle.kts +0 -94
- package/examples/social-app/generated/android/social-app/app/src/main/AndroidManifest.xml +0 -26
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/AppContainer.kt +0 -20
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/MainActivity.kt +0 -35
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/SocialAppApplication.kt +0 -13
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/data/MockData.kt +0 -98
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/data/preferences/AppPreferences.kt +0 -19
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/data/preferences/DataStorePreferencesRepository.kt +0 -68
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/data/preferences/PreferencesRepository.kt +0 -15
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/model/Models.kt +0 -34
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/MainShell.kt +0 -390
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/components/Components.kt +0 -234
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/components/ContractPrimitives.kt +0 -641
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/navigation/RootComponent.kt +0 -113
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/screens/ChatDetailScreen.kt +0 -212
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/screens/CreatePostScreen.kt +0 -113
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/screens/DiscoverScreen.kt +0 -137
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/screens/EditProfileScreen.kt +0 -180
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/screens/HomeFeedScreen.kt +0 -169
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/screens/MessagesInboxScreen.kt +0 -85
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/screens/NotificationsScreen.kt +0 -74
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/screens/PostDetailScreen.kt +0 -293
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/screens/ProfileSelfScreen.kt +0 -116
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/screens/SearchResultsScreen.kt +0 -161
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/screens/SettingsScreen.kt +0 -164
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/screens/SettingsStore.kt +0 -95
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/screens/UserProfileScreen.kt +0 -123
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/theme/Color.kt +0 -33
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/theme/Shape.kt +0 -41
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/theme/Spacing.kt +0 -20
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/theme/Theme.kt +0 -82
- package/examples/social-app/generated/android/social-app/app/src/main/java/com/social/app/ui/theme/Type.kt +0 -60
- package/examples/social-app/generated/android/social-app/app/src/main/res/drawable/ic_launcher_foreground.xml +0 -9
- package/examples/social-app/generated/android/social-app/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +0 -5
- package/examples/social-app/generated/android/social-app/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +0 -5
- package/examples/social-app/generated/android/social-app/app/src/main/res/values/strings.xml +0 -91
- package/examples/social-app/generated/android/social-app/app/src/main/res/values/themes.xml +0 -10
- package/examples/social-app/generated/android/social-app/app/src/main/res/values-ru/strings.xml +0 -79
- package/examples/social-app/generated/android/social-app/app/src/main/res/values-uz/strings.xml +0 -79
- package/examples/social-app/generated/android/social-app/app/src/main/xml/AndroidManifest.xml +0 -23
- package/examples/social-app/generated/android/social-app/app/src/test/kotlin/com/social/app/screenshots/HomeFeedScreenshotTest.kt +0 -34
- package/examples/social-app/generated/android/social-app/build.gradle.kts +0 -7
- package/examples/social-app/generated/android/social-app/gradle/libs.versions.toml +0 -50
- package/examples/social-app/generated/android/social-app/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/examples/social-app/generated/android/social-app/gradle/wrapper/gradle-wrapper.properties +0 -8
- package/examples/social-app/generated/android/social-app/gradle.properties +0 -11
- package/examples/social-app/generated/android/social-app/gradlew +0 -248
- package/examples/social-app/generated/android/social-app/settings.gradle.kts +0 -27
- package/examples/social-app/generated/web/social-app/index.html +0 -12
- package/examples/social-app/generated/web/social-app/package-lock.json +0 -2517
- package/examples/social-app/generated/web/social-app/package.json +0 -27
- package/examples/social-app/generated/web/social-app/src/app/App.tsx +0 -58
- package/examples/social-app/generated/web/social-app/src/components/Shell.tsx +0 -259
- package/examples/social-app/generated/web/social-app/src/components/cards.tsx +0 -317
- package/examples/social-app/generated/web/social-app/src/components/ui.tsx +0 -340
- package/examples/social-app/generated/web/social-app/src/flows/CreatePostFlow.tsx +0 -86
- package/examples/social-app/generated/web/social-app/src/i18n.tsx +0 -59
- package/examples/social-app/generated/web/social-app/src/lib/icons.tsx +0 -85
- package/examples/social-app/generated/web/social-app/src/lib/tokens.ts +0 -70
- package/examples/social-app/generated/web/social-app/src/lib/utils.ts +0 -97
- package/examples/social-app/generated/web/social-app/src/locales/en.json +0 -67
- package/examples/social-app/generated/web/social-app/src/locales/ru.json +0 -67
- package/examples/social-app/generated/web/social-app/src/locales/uz.json +0 -67
- package/examples/social-app/generated/web/social-app/src/main.tsx +0 -16
- package/examples/social-app/generated/web/social-app/src/screens/ChatDetailScreen.tsx +0 -90
- package/examples/social-app/generated/web/social-app/src/screens/DiscoverScreen.tsx +0 -86
- package/examples/social-app/generated/web/social-app/src/screens/EditProfileScreen.tsx +0 -57
- package/examples/social-app/generated/web/social-app/src/screens/HomeFeedScreen.tsx +0 -103
- package/examples/social-app/generated/web/social-app/src/screens/MessagesInboxScreen.tsx +0 -52
- package/examples/social-app/generated/web/social-app/src/screens/NotificationsScreen.tsx +0 -41
- package/examples/social-app/generated/web/social-app/src/screens/PostDetailScreen.tsx +0 -115
- package/examples/social-app/generated/web/social-app/src/screens/ProfileSelfScreen.tsx +0 -57
- package/examples/social-app/generated/web/social-app/src/screens/ProfileUserScreen.tsx +0 -76
- package/examples/social-app/generated/web/social-app/src/screens/SearchResultsScreen.tsx +0 -96
- package/examples/social-app/generated/web/social-app/src/screens/SettingsScreen.tsx +0 -79
- package/examples/social-app/generated/web/social-app/src/state/store.ts +0 -592
- package/examples/social-app/generated/web/social-app/src/styles.css +0 -125
- package/examples/social-app/generated/web/social-app/src/vite-env.d.ts +0 -1
- package/examples/social-app/generated/web/social-app/tsconfig.json +0 -22
- package/examples/social-app/generated/web/social-app/tsconfig.node.json +0 -13
- package/examples/social-app/generated/web/social-app/tsconfig.node.tsbuildinfo +0 -1
- package/examples/social-app/generated/web/social-app/tsconfig.tsbuildinfo +0 -1
- package/examples/social-app/generated/web/social-app/vite.config.d.ts +0 -2
- package/examples/social-app/generated/web/social-app/vite.config.js +0 -6
- package/examples/social-app/generated/web/social-app/vite.config.ts +0 -7
- package/examples/social-app/package.json +0 -13
- package/examples/social-app/take-web-screenshots.ts +0 -97
- package/examples/taskflow/.codex/config.toml +0 -4
- package/examples/taskflow/.mcp.json +0 -10
- package/examples/taskflow/AGENTS.md +0 -124
- package/examples/taskflow/CLAUDE.md +0 -124
- package/examples/taskflow/backend/.gitkeep +0 -1
- package/examples/taskflow/generated/android/TaskFlow/README.md +0 -43
- package/examples/taskflow/generated/android/TaskFlow/app/build.gradle.kts +0 -76
- package/examples/taskflow/generated/android/TaskFlow/app/proguard-rules.pro +0 -1
- package/examples/taskflow/generated/android/TaskFlow/app/src/main/AndroidManifest.xml +0 -21
- package/examples/taskflow/generated/android/TaskFlow/app/src/main/java/uz/rsteam/taskflow/MainActivity.kt +0 -19
- package/examples/taskflow/generated/android/TaskFlow/app/src/main/java/uz/rsteam/taskflow/TaskFlowApp.kt +0 -283
- package/examples/taskflow/generated/android/TaskFlow/app/src/main/java/uz/rsteam/taskflow/model/DomainModels.kt +0 -106
- package/examples/taskflow/generated/android/TaskFlow/app/src/main/java/uz/rsteam/taskflow/model/SampleData.kt +0 -57
- package/examples/taskflow/generated/android/TaskFlow/app/src/main/java/uz/rsteam/taskflow/ui/components/Common.kt +0 -109
- package/examples/taskflow/generated/android/TaskFlow/app/src/main/java/uz/rsteam/taskflow/ui/screens/HomeScreen.kt +0 -112
- package/examples/taskflow/generated/android/TaskFlow/app/src/main/java/uz/rsteam/taskflow/ui/screens/ProjectsScreen.kt +0 -61
- package/examples/taskflow/generated/android/TaskFlow/app/src/main/java/uz/rsteam/taskflow/ui/screens/SettingsScreen.kt +0 -82
- package/examples/taskflow/generated/android/TaskFlow/app/src/main/java/uz/rsteam/taskflow/ui/screens/TaskDetailScreen.kt +0 -111
- package/examples/taskflow/generated/android/TaskFlow/app/src/main/java/uz/rsteam/taskflow/ui/sheets/Sheets.kt +0 -77
- package/examples/taskflow/generated/android/TaskFlow/app/src/main/java/uz/rsteam/taskflow/ui/theme/Color.kt +0 -30
- package/examples/taskflow/generated/android/TaskFlow/app/src/main/java/uz/rsteam/taskflow/ui/theme/Theme.kt +0 -86
- package/examples/taskflow/generated/android/TaskFlow/app/src/main/java/uz/rsteam/taskflow/ui/theme/Type.kt +0 -57
- package/examples/taskflow/generated/android/TaskFlow/app/src/main/res/values/strings.xml +0 -155
- package/examples/taskflow/generated/android/TaskFlow/app/src/main/res/values/themes.xml +0 -4
- package/examples/taskflow/generated/android/TaskFlow/build.gradle.kts +0 -5
- package/examples/taskflow/generated/android/TaskFlow/gradle/gradle-daemon-jvm.properties +0 -12
- package/examples/taskflow/generated/android/TaskFlow/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/examples/taskflow/generated/android/TaskFlow/gradle/wrapper/gradle-wrapper.properties +0 -7
- package/examples/taskflow/generated/android/TaskFlow/gradle.properties +0 -4
- package/examples/taskflow/generated/android/TaskFlow/gradlew +0 -18
- package/examples/taskflow/generated/android/TaskFlow/gradlew.bat +0 -12
- package/examples/taskflow/generated/android/TaskFlow/settings.gradle.kts +0 -18
- package/examples/taskflow/generated/ios/TaskFlow/README.md +0 -21
- package/examples/taskflow/generated/ios/TaskFlow/Resources/en.lproj/Localizable.strings +0 -115
- package/examples/taskflow/generated/ios/TaskFlow/Sources/TaskFlow/App/TaskFlowApp.swift +0 -24
- package/examples/taskflow/generated/ios/TaskFlow/Sources/TaskFlow/Components/AppChrome.swift +0 -150
- package/examples/taskflow/generated/ios/TaskFlow/Sources/TaskFlow/Flows/TaskEditorSheet.swift +0 -220
- package/examples/taskflow/generated/ios/TaskFlow/Sources/TaskFlow/Models/DomainModels.swift +0 -122
- package/examples/taskflow/generated/ios/TaskFlow/Sources/TaskFlow/Screens/CalendarView.swift +0 -21
- package/examples/taskflow/generated/ios/TaskFlow/Sources/TaskFlow/Screens/HomeView.swift +0 -201
- package/examples/taskflow/generated/ios/TaskFlow/Sources/TaskFlow/Screens/ProfileEditView.swift +0 -48
- package/examples/taskflow/generated/ios/TaskFlow/Sources/TaskFlow/Screens/ProjectDetailView.swift +0 -59
- package/examples/taskflow/generated/ios/TaskFlow/Sources/TaskFlow/Screens/ProjectsView.swift +0 -63
- package/examples/taskflow/generated/ios/TaskFlow/Sources/TaskFlow/Screens/SettingsView.swift +0 -85
- package/examples/taskflow/generated/ios/TaskFlow/Sources/TaskFlow/Screens/TaskDetailView.swift +0 -219
- package/examples/taskflow/generated/ios/TaskFlow/Sources/TaskFlow/Support/AppModel.swift +0 -320
- package/examples/taskflow/generated/ios/TaskFlow/Sources/TaskFlow/Support/AppSupport.swift +0 -41
- package/examples/taskflow/generated/ios/TaskFlow/project.yml +0 -26
- package/examples/taskflow/generated/web/TaskFlow/README.md +0 -19
- package/examples/taskflow/generated/web/TaskFlow/index.html +0 -12
- package/examples/taskflow/generated/web/TaskFlow/package-lock.json +0 -1908
- package/examples/taskflow/generated/web/TaskFlow/package.json +0 -24
- package/examples/taskflow/generated/web/TaskFlow/src/App.tsx +0 -58
- package/examples/taskflow/generated/web/TaskFlow/src/AppShell.tsx +0 -55
- package/examples/taskflow/generated/web/TaskFlow/src/components/Common.tsx +0 -82
- package/examples/taskflow/generated/web/TaskFlow/src/components/Modals.tsx +0 -191
- package/examples/taskflow/generated/web/TaskFlow/src/components/Nav.tsx +0 -41
- package/examples/taskflow/generated/web/TaskFlow/src/generated/messages.ts +0 -131
- package/examples/taskflow/generated/web/TaskFlow/src/hooks.ts +0 -25
- package/examples/taskflow/generated/web/TaskFlow/src/i18n.ts +0 -39
- package/examples/taskflow/generated/web/TaskFlow/src/locales.en.json +0 -111
- package/examples/taskflow/generated/web/TaskFlow/src/main.tsx +0 -13
- package/examples/taskflow/generated/web/TaskFlow/src/screens/HomeScreen.tsx +0 -111
- package/examples/taskflow/generated/web/TaskFlow/src/screens/ProjectsScreen.tsx +0 -82
- package/examples/taskflow/generated/web/TaskFlow/src/screens/SettingsScreens.tsx +0 -132
- package/examples/taskflow/generated/web/TaskFlow/src/screens/TaskDetail.tsx +0 -105
- package/examples/taskflow/generated/web/TaskFlow/src/store.ts +0 -216
- package/examples/taskflow/generated/web/TaskFlow/src/styles.css +0 -617
- package/examples/taskflow/generated/web/TaskFlow/src/types.ts +0 -64
- package/examples/taskflow/generated/web/TaskFlow/src/utils.ts +0 -78
- package/examples/taskflow/generated/web/TaskFlow/tsconfig.json +0 -21
- package/examples/taskflow/generated/web/TaskFlow/vite.config.ts +0 -6
- package/examples/todo-orbit/.codex/config.toml +0 -4
- package/examples/todo-orbit/.mcp.json +0 -10
- package/examples/todo-orbit/AGENTS.md +0 -124
- package/examples/todo-orbit/CLAUDE.md +0 -124
- package/examples/todo-orbit/backend/.gitkeep +0 -1
- package/examples/todo-orbit/generated/android/Todo Orbit/README.md +0 -14
- package/examples/todo-orbit/generated/android/Todo Orbit/app/build.gradle.kts +0 -58
- package/examples/todo-orbit/generated/android/Todo Orbit/app/proguard-rules.pro +0 -1
- package/examples/todo-orbit/generated/android/Todo Orbit/app/src/main/AndroidManifest.xml +0 -20
- package/examples/todo-orbit/generated/android/Todo Orbit/app/src/main/java/uz/rsteam/todoorbit/MainActivity.kt +0 -14
- package/examples/todo-orbit/generated/android/Todo Orbit/app/src/main/java/uz/rsteam/todoorbit/TodoOrbitApp.kt +0 -345
- package/examples/todo-orbit/generated/android/Todo Orbit/app/src/main/java/uz/rsteam/todoorbit/support/AppLogic.kt +0 -231
- package/examples/todo-orbit/generated/android/Todo Orbit/app/src/main/java/uz/rsteam/todoorbit/support/Models.kt +0 -169
- package/examples/todo-orbit/generated/android/Todo Orbit/app/src/main/java/uz/rsteam/todoorbit/support/Strings.kt +0 -8
- package/examples/todo-orbit/generated/android/Todo Orbit/app/src/main/java/uz/rsteam/todoorbit/ui/components/CommonComponents.kt +0 -236
- package/examples/todo-orbit/generated/android/Todo Orbit/app/src/main/java/uz/rsteam/todoorbit/ui/screens/AnalyticsScreen.kt +0 -193
- package/examples/todo-orbit/generated/android/Todo Orbit/app/src/main/java/uz/rsteam/todoorbit/ui/screens/SettingsScreen.kt +0 -102
- package/examples/todo-orbit/generated/android/Todo Orbit/app/src/main/java/uz/rsteam/todoorbit/ui/screens/TasksScreen.kt +0 -347
- package/examples/todo-orbit/generated/android/Todo Orbit/app/src/main/java/uz/rsteam/todoorbit/ui/sheets/EditorSheets.kt +0 -347
- package/examples/todo-orbit/generated/android/Todo Orbit/app/src/main/java/uz/rsteam/todoorbit/ui/theme/TodoOrbitTheme.kt +0 -59
- package/examples/todo-orbit/generated/android/Todo Orbit/app/src/main/res/values/strings.xml +0 -149
- package/examples/todo-orbit/generated/android/Todo Orbit/app/src/main/res/values-ru/strings.xml +0 -155
- package/examples/todo-orbit/generated/android/Todo Orbit/build.gradle.kts +0 -4
- package/examples/todo-orbit/generated/android/Todo Orbit/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/examples/todo-orbit/generated/android/Todo Orbit/gradle/wrapper/gradle-wrapper.properties +0 -7
- package/examples/todo-orbit/generated/android/Todo Orbit/gradle.properties +0 -4
- package/examples/todo-orbit/generated/android/Todo Orbit/gradlew +0 -248
- package/examples/todo-orbit/generated/android/Todo Orbit/gradlew.bat +0 -93
- package/examples/todo-orbit/generated/android/Todo Orbit/settings.gradle.kts +0 -18
- package/examples/todo-orbit/generated/ios/Todo Orbit/.screenshot-uitest/Sources/ScreenshotUITest.swift +0 -36
- package/examples/todo-orbit/generated/ios/Todo Orbit/README.md +0 -29
- package/examples/todo-orbit/generated/ios/Todo Orbit/Resources/en.lproj/Localizable.strings +0 -119
- package/examples/todo-orbit/generated/ios/Todo Orbit/Resources/ru.lproj/Localizable.strings +0 -119
- package/examples/todo-orbit/generated/ios/Todo Orbit/Sources/TodoOrbit/App/TodoOrbitApp.swift +0 -50
- package/examples/todo-orbit/generated/ios/Todo Orbit/Sources/TodoOrbit/Components/OrbitChrome.swift +0 -204
- package/examples/todo-orbit/generated/ios/Todo Orbit/Sources/TodoOrbit/Components/SchedulePreviewView.swift +0 -126
- package/examples/todo-orbit/generated/ios/Todo Orbit/Sources/TodoOrbit/Components/TrendChartView.swift +0 -70
- package/examples/todo-orbit/generated/ios/Todo Orbit/Sources/TodoOrbit/Flows/RecurringRuleSheet.swift +0 -126
- package/examples/todo-orbit/generated/ios/Todo Orbit/Sources/TodoOrbit/Flows/TaskEditorSheet.swift +0 -61
- package/examples/todo-orbit/generated/ios/Todo Orbit/Sources/TodoOrbit/Models/DomainModels.swift +0 -238
- package/examples/todo-orbit/generated/ios/Todo Orbit/Sources/TodoOrbit/Screens/AnalyticsView.swift +0 -94
- package/examples/todo-orbit/generated/ios/Todo Orbit/Sources/TodoOrbit/Screens/SettingsView.swift +0 -76
- package/examples/todo-orbit/generated/ios/Todo Orbit/Sources/TodoOrbit/Screens/TasksHomeView.swift +0 -364
- package/examples/todo-orbit/generated/ios/Todo Orbit/Sources/TodoOrbit/Support/AppModel.swift +0 -324
- package/examples/todo-orbit/generated/ios/Todo Orbit/TodoOrbit.xcodeproj/project.pbxproj +0 -400
- package/examples/todo-orbit/generated/ios/Todo Orbit/TodoOrbit.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/examples/todo-orbit/generated/ios/Todo Orbit/project.yml +0 -25
- package/examples/todo-orbit/generated/web/Todo Orbit/index.html +0 -16
- package/examples/todo-orbit/generated/web/Todo Orbit/package-lock.json +0 -1087
- package/examples/todo-orbit/generated/web/Todo Orbit/package.json +0 -24
- package/examples/todo-orbit/generated/web/Todo Orbit/src/App.tsx +0 -2167
- package/examples/todo-orbit/generated/web/Todo Orbit/src/main.tsx +0 -13
- package/examples/todo-orbit/generated/web/Todo Orbit/src/styles.css +0 -926
- package/examples/todo-orbit/generated/web/Todo Orbit/tsconfig.json +0 -19
- package/examples/todo-orbit/generated/web/Todo Orbit/vite.config.ts +0 -6
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
package uz.rsteam.todoorbit
|
|
2
|
-
|
|
3
|
-
import androidx.appcompat.app.AppCompatDelegate
|
|
4
|
-
import androidx.compose.animation.Crossfade
|
|
5
|
-
import androidx.compose.foundation.ExperimentalFoundationApi
|
|
6
|
-
import androidx.compose.foundation.layout.Arrangement
|
|
7
|
-
import androidx.compose.foundation.layout.BoxWithConstraints
|
|
8
|
-
import androidx.compose.foundation.layout.Column
|
|
9
|
-
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
|
10
|
-
import androidx.compose.foundation.layout.Row
|
|
11
|
-
import androidx.compose.foundation.layout.Spacer
|
|
12
|
-
import androidx.compose.foundation.layout.fillMaxSize
|
|
13
|
-
import androidx.compose.foundation.layout.height
|
|
14
|
-
import androidx.compose.foundation.layout.padding
|
|
15
|
-
import androidx.compose.material.icons.Icons
|
|
16
|
-
import androidx.compose.material.icons.automirrored.outlined.TrendingUp
|
|
17
|
-
import androidx.compose.material.icons.outlined.Checklist
|
|
18
|
-
import androidx.compose.material.icons.outlined.Settings
|
|
19
|
-
import androidx.compose.material3.AlertDialog
|
|
20
|
-
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
21
|
-
import androidx.compose.material3.Icon
|
|
22
|
-
import androidx.compose.material3.MaterialTheme
|
|
23
|
-
import androidx.compose.material3.NavigationBar
|
|
24
|
-
import androidx.compose.material3.NavigationBarItem
|
|
25
|
-
import androidx.compose.material3.NavigationRail
|
|
26
|
-
import androidx.compose.material3.NavigationRailItem
|
|
27
|
-
import androidx.compose.material3.Scaffold
|
|
28
|
-
import androidx.compose.material3.SnackbarHost
|
|
29
|
-
import androidx.compose.material3.SnackbarHostState
|
|
30
|
-
import androidx.compose.material3.Surface
|
|
31
|
-
import androidx.compose.material3.Text
|
|
32
|
-
import androidx.compose.material3.TextButton
|
|
33
|
-
import androidx.compose.material3.TopAppBar
|
|
34
|
-
import androidx.compose.runtime.Composable
|
|
35
|
-
import androidx.compose.runtime.LaunchedEffect
|
|
36
|
-
import androidx.compose.runtime.getValue
|
|
37
|
-
import androidx.compose.runtime.mutableStateListOf
|
|
38
|
-
import androidx.compose.runtime.mutableStateOf
|
|
39
|
-
import androidx.compose.runtime.remember
|
|
40
|
-
import androidx.compose.runtime.rememberCoroutineScope
|
|
41
|
-
import androidx.compose.runtime.saveable.rememberSaveable
|
|
42
|
-
import androidx.compose.runtime.setValue
|
|
43
|
-
import androidx.compose.ui.Modifier
|
|
44
|
-
import androidx.compose.ui.res.stringResource
|
|
45
|
-
import androidx.compose.ui.text.font.FontWeight
|
|
46
|
-
import androidx.compose.ui.unit.dp
|
|
47
|
-
import androidx.core.os.LocaleListCompat
|
|
48
|
-
import kotlinx.coroutines.launch
|
|
49
|
-
import uz.rsteam.todoorbit.ui.theme.TodoOrbitTheme
|
|
50
|
-
import java.time.LocalDate
|
|
51
|
-
import java.time.LocalDateTime
|
|
52
|
-
|
|
53
|
-
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class, ExperimentalLayoutApi::class)
|
|
54
|
-
@Composable
|
|
55
|
-
fun TodoOrbitGeneratedApp() {
|
|
56
|
-
var tab by rememberSaveable { mutableStateOf(ScreenTab.Tasks) }
|
|
57
|
-
var filter by rememberSaveable { mutableStateOf(TaskFilter.All) }
|
|
58
|
-
var searchQuery by rememberSaveable { mutableStateOf("") }
|
|
59
|
-
var analyticsPeriod by rememberSaveable { mutableStateOf(AnalyticsPeriod.Week) }
|
|
60
|
-
var preferences by rememberSaveable(stateSaver = PreferencesStateSaver) { mutableStateOf(PreferencesState()) }
|
|
61
|
-
var selectedTaskId by rememberSaveable { mutableStateOf(sampleTasks().first().id) }
|
|
62
|
-
var overlay by remember { mutableStateOf<OverlayState?>(null) }
|
|
63
|
-
val snackbarHostState = remember { SnackbarHostState() }
|
|
64
|
-
val scope = rememberCoroutineScope()
|
|
65
|
-
val tasks = remember { mutableStateListOf(*sampleTasks().toTypedArray()) }
|
|
66
|
-
val recurringRules = remember { mutableStateListOf<RecurringRuleModel>() }
|
|
67
|
-
val createTaskSuccessMessage = stringResource(R.string.create_task_success)
|
|
68
|
-
val editTaskSuccessMessage = stringResource(R.string.edit_task_success)
|
|
69
|
-
val recurringRuleSuccessMessage = stringResource(R.string.recurring_rule_success)
|
|
70
|
-
|
|
71
|
-
LaunchedEffect(preferences.locale) {
|
|
72
|
-
AppCompatDelegate.setApplicationLocales(
|
|
73
|
-
LocaleListCompat.forLanguageTags(preferences.locale.toLanguageTag())
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
TodoOrbitTheme(darkTheme = preferences.themeMode == ThemeMode.Dark) {
|
|
78
|
-
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
|
|
79
|
-
BoxWithConstraints {
|
|
80
|
-
val useRail = maxWidth >= 900.dp
|
|
81
|
-
val useSplitView = useRail && this@BoxWithConstraints.maxWidth >= 1200.dp
|
|
82
|
-
val visibleTasks = remember(tasks.toList(), filter, searchQuery) {
|
|
83
|
-
tasks.filter { task ->
|
|
84
|
-
val matchesFilter = when (filter) {
|
|
85
|
-
TaskFilter.All -> true
|
|
86
|
-
TaskFilter.Open -> task.status == TaskStatus.Open
|
|
87
|
-
TaskFilter.Done -> task.status == TaskStatus.Done
|
|
88
|
-
}
|
|
89
|
-
val matchesSearch = listOf(task.title, task.notes).joinToString(" ").contains(searchQuery, ignoreCase = true)
|
|
90
|
-
matchesFilter && matchesSearch
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
val selectedTask = tasks.firstOrNull { it.id == selectedTaskId } ?: tasks.firstOrNull()
|
|
94
|
-
val overview = analyticsOverview(tasks)
|
|
95
|
-
val trendSeries = trendPoints(tasks, analyticsPeriod, preferences.locale)
|
|
96
|
-
val overdueTasks = tasks.filter { it.status == TaskStatus.Open && it.dueDate?.isBefore(LocalDate.now()) == true }
|
|
97
|
-
|
|
98
|
-
Scaffold(
|
|
99
|
-
topBar = {
|
|
100
|
-
TopAppBar(
|
|
101
|
-
title = {
|
|
102
|
-
Column {
|
|
103
|
-
Text(stringResource(R.string.app_name), fontWeight = FontWeight.Bold)
|
|
104
|
-
Text(
|
|
105
|
-
text = when (tab) {
|
|
106
|
-
ScreenTab.Tasks -> stringResource(R.string.app_path_home)
|
|
107
|
-
ScreenTab.Analytics -> stringResource(R.string.app_path_analytics)
|
|
108
|
-
ScreenTab.Settings -> stringResource(R.string.app_path_settings)
|
|
109
|
-
},
|
|
110
|
-
style = MaterialTheme.typography.labelSmall,
|
|
111
|
-
color = MaterialTheme.colorScheme.onSurfaceVariant
|
|
112
|
-
)
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
)
|
|
116
|
-
},
|
|
117
|
-
bottomBar = {
|
|
118
|
-
if (!useRail) {
|
|
119
|
-
NavigationBar {
|
|
120
|
-
NavigationBarItem(
|
|
121
|
-
selected = tab == ScreenTab.Tasks,
|
|
122
|
-
onClick = { tab = ScreenTab.Tasks },
|
|
123
|
-
icon = { Icon(Icons.Outlined.Checklist, contentDescription = null) },
|
|
124
|
-
label = { Text(stringResource(R.string.nav_tasks)) }
|
|
125
|
-
)
|
|
126
|
-
NavigationBarItem(
|
|
127
|
-
selected = tab == ScreenTab.Analytics,
|
|
128
|
-
onClick = { tab = ScreenTab.Analytics },
|
|
129
|
-
icon = { Icon(Icons.AutoMirrored.Outlined.TrendingUp, contentDescription = null) },
|
|
130
|
-
label = { Text(stringResource(R.string.nav_analytics)) }
|
|
131
|
-
)
|
|
132
|
-
NavigationBarItem(
|
|
133
|
-
selected = tab == ScreenTab.Settings,
|
|
134
|
-
onClick = { tab = ScreenTab.Settings },
|
|
135
|
-
icon = { Icon(Icons.Outlined.Settings, contentDescription = null) },
|
|
136
|
-
label = { Text(stringResource(R.string.nav_settings)) }
|
|
137
|
-
)
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
snackbarHost = { SnackbarHost(snackbarHostState) }
|
|
142
|
-
) { innerPadding ->
|
|
143
|
-
Row(modifier = Modifier.fillMaxSize().padding(innerPadding)) {
|
|
144
|
-
if (useRail) {
|
|
145
|
-
NavigationRail(containerColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.45f)) {
|
|
146
|
-
Spacer(Modifier.height(12.dp))
|
|
147
|
-
NavigationRailItem(
|
|
148
|
-
selected = tab == ScreenTab.Tasks,
|
|
149
|
-
onClick = { tab = ScreenTab.Tasks },
|
|
150
|
-
icon = { Icon(Icons.Outlined.Checklist, contentDescription = null) },
|
|
151
|
-
label = { Text(stringResource(R.string.nav_tasks)) }
|
|
152
|
-
)
|
|
153
|
-
NavigationRailItem(
|
|
154
|
-
selected = tab == ScreenTab.Analytics,
|
|
155
|
-
onClick = { tab = ScreenTab.Analytics },
|
|
156
|
-
icon = { Icon(Icons.AutoMirrored.Outlined.TrendingUp, contentDescription = null) },
|
|
157
|
-
label = { Text(stringResource(R.string.nav_analytics)) }
|
|
158
|
-
)
|
|
159
|
-
NavigationRailItem(
|
|
160
|
-
selected = tab == ScreenTab.Settings,
|
|
161
|
-
onClick = { tab = ScreenTab.Settings },
|
|
162
|
-
icon = { Icon(Icons.Outlined.Settings, contentDescription = null) },
|
|
163
|
-
label = { Text(stringResource(R.string.nav_settings)) }
|
|
164
|
-
)
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
Crossfade(targetState = tab, modifier = Modifier.fillMaxSize(), label = "tab-crossfade") { activeTab ->
|
|
169
|
-
when (activeTab) {
|
|
170
|
-
ScreenTab.Tasks -> {
|
|
171
|
-
TasksScreen(
|
|
172
|
-
tasks = visibleTasks,
|
|
173
|
-
allTasks = tasks,
|
|
174
|
-
filter = filter,
|
|
175
|
-
searchQuery = searchQuery,
|
|
176
|
-
selectedTask = selectedTask,
|
|
177
|
-
locale = preferences.locale,
|
|
178
|
-
useSplitView = useSplitView,
|
|
179
|
-
onSearchChange = { searchQuery = it },
|
|
180
|
-
onFilterChange = { filter = it },
|
|
181
|
-
onSelectTask = { selectedTaskId = it.id },
|
|
182
|
-
onToggleTask = { task ->
|
|
183
|
-
val index = tasks.indexOfFirst { it.id == task.id }
|
|
184
|
-
if (index >= 0) {
|
|
185
|
-
tasks[index] = task.copy(
|
|
186
|
-
status = if (task.status == TaskStatus.Done) TaskStatus.Open else TaskStatus.Done,
|
|
187
|
-
updatedAt = LocalDateTime.now()
|
|
188
|
-
)
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
onCreateTask = { overlay = OverlayState.CreateTask },
|
|
192
|
-
onEditTask = { overlay = OverlayState.EditTask(it.id) },
|
|
193
|
-
onDeleteTask = {
|
|
194
|
-
tasks.removeAll { task -> task.id == it.id }
|
|
195
|
-
selectedTaskId = tasks.firstOrNull()?.id.orEmpty()
|
|
196
|
-
},
|
|
197
|
-
onMoreInfo = { overlay = OverlayState.TaskMeta(it.id) }
|
|
198
|
-
)
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
ScreenTab.Analytics -> {
|
|
202
|
-
AnalyticsScreen(
|
|
203
|
-
period = analyticsPeriod,
|
|
204
|
-
overview = overview,
|
|
205
|
-
trendSeries = trendSeries,
|
|
206
|
-
overdueTasks = overdueTasks,
|
|
207
|
-
onPeriodChange = { analyticsPeriod = it },
|
|
208
|
-
locale = preferences.locale
|
|
209
|
-
)
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
ScreenTab.Settings -> {
|
|
213
|
-
SettingsScreen(
|
|
214
|
-
preferences = preferences,
|
|
215
|
-
recurringRules = recurringRules,
|
|
216
|
-
onPreferencesChange = { preferences = it },
|
|
217
|
-
onOpenRecurringRule = { overlay = OverlayState.RecurringRule },
|
|
218
|
-
locale = preferences.locale
|
|
219
|
-
)
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
when (val currentOverlay = overlay) {
|
|
227
|
-
OverlayState.CreateTask -> {
|
|
228
|
-
TaskEditorSheet(
|
|
229
|
-
draft = TaskDraft(),
|
|
230
|
-
title = stringResource(R.string.create_task_title),
|
|
231
|
-
saveLabel = stringResource(R.string.create_task_save),
|
|
232
|
-
onDismiss = { overlay = null },
|
|
233
|
-
onSubmit = { draft ->
|
|
234
|
-
tasks.add(
|
|
235
|
-
0,
|
|
236
|
-
TaskModel(
|
|
237
|
-
id = "task-${System.currentTimeMillis()}",
|
|
238
|
-
title = draft.title.trim(),
|
|
239
|
-
notes = draft.notes.trim(),
|
|
240
|
-
status = TaskStatus.Open,
|
|
241
|
-
priority = draft.priority,
|
|
242
|
-
dueDate = draft.dueDate,
|
|
243
|
-
createdAt = LocalDateTime.now(),
|
|
244
|
-
updatedAt = LocalDateTime.now()
|
|
245
|
-
)
|
|
246
|
-
)
|
|
247
|
-
selectedTaskId = tasks.first().id
|
|
248
|
-
overlay = null
|
|
249
|
-
scope.launch {
|
|
250
|
-
snackbarHostState.showSnackbar(createTaskSuccessMessage)
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
is OverlayState.EditTask -> {
|
|
257
|
-
val task = tasks.firstOrNull { it.id == currentOverlay.taskId }
|
|
258
|
-
if (task != null) {
|
|
259
|
-
TaskEditorSheet(
|
|
260
|
-
draft = TaskDraft(
|
|
261
|
-
title = task.title,
|
|
262
|
-
notes = task.notes,
|
|
263
|
-
priority = task.priority,
|
|
264
|
-
dueDate = task.dueDate
|
|
265
|
-
),
|
|
266
|
-
title = stringResource(R.string.edit_task_title),
|
|
267
|
-
saveLabel = stringResource(R.string.edit_task_save),
|
|
268
|
-
onDismiss = { overlay = null },
|
|
269
|
-
onSubmit = { draft ->
|
|
270
|
-
val index = tasks.indexOfFirst { it.id == task.id }
|
|
271
|
-
if (index >= 0) {
|
|
272
|
-
tasks[index] = task.copy(
|
|
273
|
-
title = draft.title.trim(),
|
|
274
|
-
notes = draft.notes.trim(),
|
|
275
|
-
priority = draft.priority,
|
|
276
|
-
dueDate = draft.dueDate,
|
|
277
|
-
updatedAt = LocalDateTime.now()
|
|
278
|
-
)
|
|
279
|
-
}
|
|
280
|
-
overlay = null
|
|
281
|
-
scope.launch {
|
|
282
|
-
snackbarHostState.showSnackbar(editTaskSuccessMessage)
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
)
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
OverlayState.RecurringRule -> {
|
|
290
|
-
RecurringRuleSheet(
|
|
291
|
-
preferences = preferences,
|
|
292
|
-
rules = recurringRules,
|
|
293
|
-
locale = preferences.locale,
|
|
294
|
-
onDismiss = { overlay = null },
|
|
295
|
-
onSubmit = { rule ->
|
|
296
|
-
recurringRules.add(0, rule)
|
|
297
|
-
overlay = null
|
|
298
|
-
scope.launch {
|
|
299
|
-
snackbarHostState.showSnackbar(recurringRuleSuccessMessage)
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
)
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
is OverlayState.TaskMeta -> {
|
|
306
|
-
val task = tasks.firstOrNull { it.id == currentOverlay.taskId }
|
|
307
|
-
if (task != null) {
|
|
308
|
-
AlertDialog(
|
|
309
|
-
onDismissRequest = { overlay = null },
|
|
310
|
-
title = { Text(stringResource(R.string.task_detail_more_info)) },
|
|
311
|
-
text = {
|
|
312
|
-
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
|
313
|
-
LabelValue(
|
|
314
|
-
stringResource(R.string.task_detail_status),
|
|
315
|
-
stringResource(task.status.labelRes)
|
|
316
|
-
)
|
|
317
|
-
LabelValue(
|
|
318
|
-
stringResource(R.string.task_detail_priority),
|
|
319
|
-
stringResource(task.priority.labelRes)
|
|
320
|
-
)
|
|
321
|
-
LabelValue(
|
|
322
|
-
stringResource(R.string.task_detail_created),
|
|
323
|
-
formatAbsolute(task.createdAt.toLocalDate(), preferences.locale)
|
|
324
|
-
)
|
|
325
|
-
LabelValue(
|
|
326
|
-
stringResource(R.string.task_detail_updated),
|
|
327
|
-
formatAbsolute(task.updatedAt.toLocalDate(), preferences.locale)
|
|
328
|
-
)
|
|
329
|
-
}
|
|
330
|
-
},
|
|
331
|
-
confirmButton = {
|
|
332
|
-
TextButton(onClick = { overlay = null }) {
|
|
333
|
-
Text(stringResource(R.string.common_cancel))
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
)
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
null -> Unit
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
package uz.rsteam.todoorbit
|
|
2
|
-
|
|
3
|
-
import java.time.LocalDate
|
|
4
|
-
import java.time.LocalDateTime
|
|
5
|
-
import java.time.format.DateTimeFormatter
|
|
6
|
-
import java.time.format.FormatStyle
|
|
7
|
-
import java.util.Locale
|
|
8
|
-
import kotlin.math.roundToInt
|
|
9
|
-
|
|
10
|
-
data class AnalyticsOverview(
|
|
11
|
-
val completedToday: Int,
|
|
12
|
-
val openTasks: Int,
|
|
13
|
-
val overdueTasks: Int,
|
|
14
|
-
val completionRate: Int
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
fun analyticsOverview(tasks: List<TaskModel>): AnalyticsOverview {
|
|
18
|
-
val today = LocalDate.now()
|
|
19
|
-
val completedToday = tasks.count { it.status == TaskStatus.Done && it.updatedAt.toLocalDate() == today }
|
|
20
|
-
val openTasks = tasks.count { it.status == TaskStatus.Open }
|
|
21
|
-
val overdueTasks = tasks.count { it.status == TaskStatus.Open && it.dueDate?.isBefore(today) == true }
|
|
22
|
-
val completionRate = if (tasks.isEmpty()) 0 else (((tasks.size - openTasks).toFloat() / tasks.size) * 100f).roundToInt()
|
|
23
|
-
return AnalyticsOverview(completedToday, openTasks, overdueTasks, completionRate)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
fun trendPoints(tasks: List<TaskModel>, period: AnalyticsPeriod, locale: UiLocale): List<TrendPoint> {
|
|
27
|
-
val length = when (period) {
|
|
28
|
-
AnalyticsPeriod.Week -> 7
|
|
29
|
-
AnalyticsPeriod.Month -> 6
|
|
30
|
-
AnalyticsPeriod.Quarter -> 8
|
|
31
|
-
}
|
|
32
|
-
val formatter = when (locale) {
|
|
33
|
-
UiLocale.En -> DateTimeFormatter.ofPattern(if (period == AnalyticsPeriod.Week) "EEE" else "MMM d", Locale.ENGLISH)
|
|
34
|
-
UiLocale.Ru -> DateTimeFormatter.ofPattern(if (period == AnalyticsPeriod.Week) "EEE" else "d MMM", Locale("ru"))
|
|
35
|
-
}
|
|
36
|
-
val today = LocalDate.now()
|
|
37
|
-
return (0 until length).map { index ->
|
|
38
|
-
val cursor = today.minusDays(((length - index - 1) * if (period == AnalyticsPeriod.Week) 1 else 5).toLong())
|
|
39
|
-
TrendPoint(
|
|
40
|
-
label = cursor.format(formatter),
|
|
41
|
-
completed = tasks.count { it.status == TaskStatus.Done && !it.updatedAt.toLocalDate().isAfter(cursor) },
|
|
42
|
-
created = tasks.count { !it.createdAt.toLocalDate().isAfter(cursor) }
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
fun validateRuleDraft(
|
|
48
|
-
draft: RuleDraft,
|
|
49
|
-
preferences: PreferencesState,
|
|
50
|
-
rules: List<RecurringRuleModel>
|
|
51
|
-
): Map<String, UiText> {
|
|
52
|
-
val errors = mutableMapOf<String, UiText>()
|
|
53
|
-
val trimmedName = draft.name.trim()
|
|
54
|
-
if (trimmedName.length < 4) {
|
|
55
|
-
errors["name"] = UiText.Resource(R.string.validation_rule_name_min_length, listOf(4))
|
|
56
|
-
} else if (trimmedName == "Default") {
|
|
57
|
-
errors["name"] = UiText.Resource(R.string.validation_rule_name_reserved)
|
|
58
|
-
} else if (rules.any { it.name.equals(trimmedName, ignoreCase = true) }) {
|
|
59
|
-
errors["name"] = UiText.Resource(R.string.validation_rule_name_taken)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (draft.confirmName.trim() != trimmedName) {
|
|
63
|
-
errors["confirmName"] = UiText.Resource(R.string.validation_match_field)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
val interval = draft.interval.toIntOrNull()
|
|
67
|
-
when {
|
|
68
|
-
interval == null || interval < 1 -> errors["interval"] = UiText.Resource(R.string.validation_min_value, listOf(1))
|
|
69
|
-
interval > 30 -> errors["interval"] = UiText.Resource(R.string.validation_max_value, listOf(30))
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (draft.cadence == null) {
|
|
73
|
-
errors["cadence"] = UiText.Resource(R.string.validation_fix_errors)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (draft.cadence == Cadence.Weekly && draft.weekday == null) {
|
|
77
|
-
errors["weekday"] = UiText.Resource(R.string.validation_fix_errors)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (draft.cadence == Cadence.Monthly) {
|
|
81
|
-
val monthDay = draft.monthDay.toIntOrNull()
|
|
82
|
-
when {
|
|
83
|
-
monthDay == null || monthDay < 1 -> errors["monthDay"] = UiText.Resource(R.string.validation_min_value, listOf(1))
|
|
84
|
-
monthDay > 28 -> errors["monthDay"] = UiText.Resource(R.string.validation_month_day_max)
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (draft.hasEndDate && draft.endDate != null && draft.endDate.isBefore(draft.startDate)) {
|
|
89
|
-
errors["endDate"] = UiText.Resource(R.string.validation_end_date_after_start)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (preferences.remindersEnabled && !Regex("^([01]\\d|2[0-3]):[0-5]\\d$").matches(draft.remindAt)) {
|
|
93
|
-
errors["remindAt"] = UiText.Resource(R.string.validation_time_format)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (draft.enableSummary && draft.summaryChannel == null) {
|
|
97
|
-
errors["summaryChannel"] = UiText.Resource(R.string.validation_fix_errors)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return errors
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
fun schedulePreview(draft: RuleDraft): SchedulePreviewState {
|
|
104
|
-
val interval = draft.interval.toIntOrNull() ?: return SchedulePreviewState(PreviewMode.Invalid)
|
|
105
|
-
val cadence = draft.cadence ?: return SchedulePreviewState(PreviewMode.Invalid)
|
|
106
|
-
if (interval < 1) return SchedulePreviewState(PreviewMode.Invalid)
|
|
107
|
-
if (draft.hasEndDate && draft.endDate != null && draft.endDate.isBefore(draft.startDate)) {
|
|
108
|
-
return SchedulePreviewState(PreviewMode.Invalid)
|
|
109
|
-
}
|
|
110
|
-
if (cadence == Cadence.Weekly && draft.weekday == null) return SchedulePreviewState(PreviewMode.Invalid)
|
|
111
|
-
val monthlyDay = if (cadence == Cadence.Monthly) draft.monthDay.toIntOrNull() ?: return SchedulePreviewState(PreviewMode.Invalid) else null
|
|
112
|
-
|
|
113
|
-
val result = mutableListOf<LocalDate>()
|
|
114
|
-
var cursor = draft.startDate
|
|
115
|
-
repeat(4) {
|
|
116
|
-
val next = when (cadence) {
|
|
117
|
-
Cadence.Daily -> cursor
|
|
118
|
-
Cadence.Weekly -> nextWeekdayFrom(cursor, draft.weekday!!)
|
|
119
|
-
Cadence.Monthly -> nextMonthlyFrom(cursor, monthlyDay!!)
|
|
120
|
-
}
|
|
121
|
-
if (draft.endDate != null && next.isAfter(draft.endDate)) return@repeat
|
|
122
|
-
result += next
|
|
123
|
-
cursor = when (cadence) {
|
|
124
|
-
Cadence.Daily -> next.plusDays(interval.toLong())
|
|
125
|
-
Cadence.Weekly -> next.plusWeeks(interval.toLong())
|
|
126
|
-
Cadence.Monthly -> next.plusMonths(interval.toLong())
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return if (result.isEmpty()) SchedulePreviewState(PreviewMode.Empty) else SchedulePreviewState(PreviewMode.Ready, result)
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
fun formatAbsolute(date: LocalDate, locale: UiLocale): String {
|
|
134
|
-
val formatter = when (locale) {
|
|
135
|
-
UiLocale.En -> DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).withLocale(Locale.ENGLISH)
|
|
136
|
-
UiLocale.Ru -> DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).withLocale(Locale("ru"))
|
|
137
|
-
}
|
|
138
|
-
return formatter.format(date)
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
fun parseLocalDateOrNull(value: String): LocalDate? {
|
|
142
|
-
return runCatching {
|
|
143
|
-
value.takeIf(String::isNotBlank)?.let(LocalDate::parse)
|
|
144
|
-
}.getOrNull()
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
private fun nextWeekdayFrom(date: LocalDate, weekday: Weekday): LocalDate {
|
|
148
|
-
var cursor = date
|
|
149
|
-
while (cursor.dayOfWeek.value != weekdayToDayNumber(weekday)) {
|
|
150
|
-
cursor = cursor.plusDays(1)
|
|
151
|
-
}
|
|
152
|
-
return cursor
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
private fun nextMonthlyFrom(date: LocalDate, day: Int): LocalDate {
|
|
156
|
-
val base = date.withDayOfMonth(1)
|
|
157
|
-
val candidate = base.withDayOfMonth(day.coerceAtMost(base.lengthOfMonth()))
|
|
158
|
-
return if (candidate.isBefore(date)) {
|
|
159
|
-
base.plusMonths(1).withDayOfMonth(day.coerceAtMost(base.plusMonths(1).lengthOfMonth()))
|
|
160
|
-
} else {
|
|
161
|
-
candidate
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
private fun weekdayToDayNumber(weekday: Weekday): Int {
|
|
166
|
-
return when (weekday) {
|
|
167
|
-
Weekday.Mon -> 1
|
|
168
|
-
Weekday.Tue -> 2
|
|
169
|
-
Weekday.Wed -> 3
|
|
170
|
-
Weekday.Thu -> 4
|
|
171
|
-
Weekday.Fri -> 5
|
|
172
|
-
Weekday.Sat -> 6
|
|
173
|
-
Weekday.Sun -> 7
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
fun sampleTasks(): List<TaskModel> {
|
|
178
|
-
val now = LocalDateTime.now()
|
|
179
|
-
return listOf(
|
|
180
|
-
TaskModel(
|
|
181
|
-
id = "task-1",
|
|
182
|
-
title = "Prepare bilingual launch notes",
|
|
183
|
-
notes = "Document the web, iOS, and Android behavior differences before review.",
|
|
184
|
-
status = TaskStatus.Open,
|
|
185
|
-
priority = Priority.High,
|
|
186
|
-
dueDate = LocalDate.now().plusDays(2),
|
|
187
|
-
createdAt = now.minusDays(6),
|
|
188
|
-
updatedAt = now.minusDays(1)
|
|
189
|
-
),
|
|
190
|
-
TaskModel(
|
|
191
|
-
id = "task-2",
|
|
192
|
-
title = "Review recurring-rule validation",
|
|
193
|
-
notes = "Confirm async uniqueness checks and cross-field constraints.",
|
|
194
|
-
status = TaskStatus.Done,
|
|
195
|
-
priority = Priority.Medium,
|
|
196
|
-
dueDate = LocalDate.now().minusDays(1),
|
|
197
|
-
createdAt = now.minusDays(5),
|
|
198
|
-
updatedAt = now
|
|
199
|
-
),
|
|
200
|
-
TaskModel(
|
|
201
|
-
id = "task-3",
|
|
202
|
-
title = "Polish analytics empty states",
|
|
203
|
-
notes = "Ensure chart and overdue list degrade gracefully on zero-data snapshots.",
|
|
204
|
-
status = TaskStatus.Open,
|
|
205
|
-
priority = Priority.Medium,
|
|
206
|
-
dueDate = LocalDate.now().plusDays(5),
|
|
207
|
-
createdAt = now.minusDays(4),
|
|
208
|
-
updatedAt = now.minusDays(2)
|
|
209
|
-
),
|
|
210
|
-
TaskModel(
|
|
211
|
-
id = "task-4",
|
|
212
|
-
title = "Regenerate drift snapshots",
|
|
213
|
-
notes = "Refresh ios, android, and web state after spec edits.",
|
|
214
|
-
status = TaskStatus.Open,
|
|
215
|
-
priority = Priority.Low,
|
|
216
|
-
dueDate = LocalDate.now().minusDays(3),
|
|
217
|
-
createdAt = now.minusDays(3),
|
|
218
|
-
updatedAt = now.minusDays(3)
|
|
219
|
-
),
|
|
220
|
-
TaskModel(
|
|
221
|
-
id = "task-5",
|
|
222
|
-
title = "Prototype schedule preview contract",
|
|
223
|
-
notes = "Use derived occurrences to prove custom-contract generation.",
|
|
224
|
-
status = TaskStatus.Done,
|
|
225
|
-
priority = Priority.High,
|
|
226
|
-
dueDate = LocalDate.now().plusDays(1),
|
|
227
|
-
createdAt = now.minusDays(8),
|
|
228
|
-
updatedAt = now.minusDays(1)
|
|
229
|
-
)
|
|
230
|
-
)
|
|
231
|
-
}
|