diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3820a95 --- /dev/null +++ b/.gitignore @@ -0,0 +1,45 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.build/ +.buildlog/ +.history +.svn/ +.swiftpm/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ +/coverage/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/.metadata b/.metadata new file mode 100644 index 0000000..32b7bfd --- /dev/null +++ b/.metadata @@ -0,0 +1,42 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "f6ff1529fd6d8af5f706051d9251ac9231c83407" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + - platform: android + create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + - platform: ios + create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + - platform: linux + create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + - platform: macos + create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + - platform: web + create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..b7e061c --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,277 @@ +# Add Months + +Local-first Flutter app that identifies the single behavioral change most likely to extend lifespan using hazard-based modeling. + +## Quick Start + +```bash +flutter pub get +flutter test test/risk_engine/ # 23 unit tests +flutter run # Debug mode +flutter run --release -d # Release build +``` + +## Architecture + +``` +lib/ +├── main.dart # App entry, routing logic +├── theme.dart # Muted clinical color palette +├── models/ +│ ├── enums.dart # Sex, SmokingStatus, AlcoholLevel, etc. +│ ├── user_profile.dart # Age, sex, country, height, weight, diagnoses +│ ├── behavioral_inputs.dart # Modifiable behaviors +│ └── result.dart # LifespanDelta, RankedFactor, CalculationResult +├── risk_engine/ +│ ├── hazard_ratios.dart # HR constants from meta-analyses +│ ├── mortality_tables.dart # 50 countries → 4 mortality groups +│ └── calculator.dart # Core ranking algorithm +├── screens/ +│ ├── welcome_screen.dart # Onboarding +│ ├── baseline_screen.dart # Demographics, BMI, conditions +│ ├── behavioral_screen.dart # Modifiable factors input +│ └── results_screen.dart # Dominant challenge display +└── storage/ + └── local_storage.dart # SQLite persistence +``` + +## Core Principles + +1. **Local-first**: All data on device, no cloud, no accounts, no analytics +2. **Evidence-based**: Hazard ratios from peer-reviewed meta-analyses +3. **Privacy**: Delete All Data = full wipe including encryption keys +4. **Neutral tone**: "Exposure", "Factor", "Estimated gain" — no moral language + +## Risk Engine + +### Hazard Ratio Model + +Combined HR = Smoking × Alcohol × Sleep × Activity × BMI × Driving × WorkHours + +Capped at 4.0 to prevent unrealistic compounding. + +### Key Hazard Ratios + +| Factor | Level | HR | +|--------|-------|-----| +| Smoking | Never | 1.0 | +| | Former | 1.3 | +| | Current (<10/day) | 1.8 | +| | Current (10-20/day) | 2.2 | +| | Current (>20/day) | 2.8 | +| Alcohol | None/Light | 1.0 | +| | Moderate (8-14/wk) | 1.1 | +| | Heavy (15-21/wk) | 1.3 | +| | Very Heavy (21+/wk) | 1.6 | +| Sleep | 7-8 hrs | 1.0 | +| | 6-7 hrs | 1.05 | +| | <6 hrs | 1.15 | +| | >8 hrs | 1.10 | +| | + Inconsistent | ×1.05 | +| Activity | High | 1.0 | +| | Moderate | 1.05 | +| | Light | 1.15 | +| | Sedentary | 1.4 | +| BMI | 18.5-25 | 1.0 | +| | 25-30 | 1.1 | +| | 30-35 | 1.2 | +| | 35-40 | 1.4 | +| | 40+ | 1.8 | +| Driving | <50 mi/wk | 1.0 | +| | 50-150 | 1.02 | +| | 150-300 | 1.04 | +| | 300+ | 1.08 | +| Work Hours | <40 | 1.0 | +| | 40-55 | 1.05 | +| | 55-70 | 1.15 | +| | 70+ | 1.3 | + +### Existing Conditions (Non-modifiable) + +| Condition | HR Multiplier | +|-----------|---------------| +| Cardiovascular | 1.5 | +| Diabetes | 1.4 | +| Cancer (active) | 2.0 | +| COPD | 1.6 | +| Hypertension | 1.2 | + +### Delta Calculation + +```dart +// Simplified Gompertz-style approximation +rawDeltaYears = baselineYears × (1 - modifiedHR/currentHR) × 0.3 + +// Convert to months with uncertainty range +lowMonths = rawDeltaYears × 12 × 0.6 +highMonths = rawDeltaYears × 12 × 1.4 +``` + +### Ranking Algorithm + +1. For each modifiable behavior: + - Compute HR with behavior set to optimal + - Calculate delta months gained +2. Sort by midpoint delta descending +3. Filter out behaviors already at optimal +4. Return ranked list with confidence levels + +### Confidence Levels + +| Factor | Confidence | Rationale | +|--------|------------|-----------| +| Smoking | High | Extremely well-documented | +| Alcohol (heavy) | High | Strong epidemiological data | +| Physical Activity | High | Large meta-analyses | +| BMI (extreme) | High | Well-established | +| Sleep | Moderate | Growing evidence, some confounding | +| Work Hours | Moderate | Decent studies, cultural variation | +| Driving | Emerging | Harder to isolate, regional variation | + +## Mortality Tables + +### Country Groups + +| Group | LE at Birth (M) | Countries | +|-------|-----------------|-----------| +| A | 81 | Japan, Switzerland, Singapore, Spain, Italy, Australia, Iceland, Israel, Sweden, France, South Korea, Norway | +| B | 77 | USA, UK, Germany, Canada, Netherlands, Belgium, Austria, Finland, Ireland, New Zealand, Denmark, Portugal, Czech Republic, Poland, Chile, Costa Rica, Cuba, UAE, Qatar, Taiwan | +| C | 72 | China, Brazil, Mexico, Russia, Turkey, Argentina, Colombia, Thailand, Vietnam, Malaysia, Iran, Saudi Arabia, Egypt, Ukraine, Romania, Hungary, Peru, Philippines | +| D | 65 | India, Indonesia, South Africa, Pakistan, Bangladesh, Nigeria, Kenya, Ghana, Ethiopia, Myanmar, Nepal, Cambodia | + +Female LE = Male LE + 4.5 years + +### Remaining Life Expectancy + +```dart +// Survivors have higher LE than birth cohort suggests +survivorBonus = currentAge × 0.15 // capped at 5 +remainingLE = (leAtBirth - currentAge) + survivorBonus +``` + +## Storage + +### SQLite Schema + +```sql +CREATE TABLE user_data ( + key TEXT PRIMARY KEY, + value TEXT NOT NULL, -- JSON + updated_at INTEGER NOT NULL +) +``` + +### Stored Keys + +- `profile`: UserProfile JSON +- `behaviors`: BehavioralInputs JSON +- `lastResult`: CalculationResult JSON + +### Delete All Data + +```dart +await db.delete('user_data'); // Wipes all rows +``` + +## UI Theme + +### Colors (Muted Clinical) + +```dart +primary: #4A90A4 // Muted teal +primaryDark: #2D6073 +primaryLight: #7BB8CC +surface: #F8FAFB +textPrimary: #1A2B33 +textSecondary: #5A6B73 +success: #4A9A7C +warning: #B8934A +error: #A45A5A +``` + +### Typography + +- Headlines: SF Pro Display style, tight letter-spacing +- Body: 16px, 1.5 line height +- Labels: 600 weight + +## Testing + +```bash +# Run all risk engine tests +flutter test test/risk_engine/ + +# 23 tests covering: +# - Hazard ratios for each behavior +# - Mortality table lookups +# - Combined HR calculation +# - Ranking algorithm +# - Confidence assignments +# - Existing conditions impact +``` + +Widget tests require SQLite mocking — integration test on device. + +## App Icon + +Generated programmatically: muted teal tree on white background. + +```bash +dart run tool/generate_icon.dart +dart run flutter_launcher_icons +``` + +## Model Versioning + +```dart +const modelVersion = '1.0'; +``` + +Stored with each calculation result. Future updates can show: +"Results updated under model v1.1" + +## Screen Flow + +``` +Welcome → Baseline → Behavioral → Results + ↑ ↓ + └────── Recalculate ───┘ +``` + +Results screen shows: +- Dominant Challenge (largest gain) +- Estimated Gain range (e.g., "36-60 months") +- Confidence level (High/Moderate/Emerging) +- Secondary factor +- All other factors (if any) +- Delete All Data button + +## Key Design Decisions + +1. **BMI is baseline only** — affects calculation but not shown as a "challenge" +2. **Cigarettes/day** — slider with haptic at 20 (one pack), max 40 +3. **Country** — full dropdown (50 countries), mapped internally to groups +4. **No gamification** — no streaks, badges, or progress tracking +5. **No notifications** — user controls when to recalculate + +## Dependencies + +```yaml +dependencies: + sqflite: ^2.3.0 # Local database + path: ^1.8.3 # Path utilities + flutter_secure_storage: # Encryption key storage (future) + +dev_dependencies: + flutter_launcher_icons: ^0.14.1 +``` + +## Future Enhancements (Out of MVP Scope) + +- Partner mode (compare two profiles) +- Export PDF summary +- Drug use factor +- Diet quality factor +- Stress/mental health factor +- Location-based mortality refinement +- Longitudinal tracking diff --git a/README.md b/README.md new file mode 100644 index 0000000..3c407c7 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# add_months + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..0d29021 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..be3943c --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,14 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java +.cxx/ + +# Remember to never publicly share your keystore. +# See https://flutter.dev/to/reference-keystore +key.properties +**/*.keystore +**/*.jks diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts new file mode 100644 index 0000000..0c43895 --- /dev/null +++ b/android/app/build.gradle.kts @@ -0,0 +1,44 @@ +plugins { + id("com.android.application") + id("kotlin-android") + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id("dev.flutter.flutter-gradle-plugin") +} + +android { + namespace = "com.payfrit.add_months" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17.toString() + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId = "com.payfrit.add_months" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig = signingConfigs.getByName("debug") + } + } +} + +flutter { + source = "../.." +} diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..dbaa3a6 --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/kotlin/com/payfrit/add_months/MainActivity.kt b/android/app/src/main/kotlin/com/payfrit/add_months/MainActivity.kt new file mode 100644 index 0000000..136e229 --- /dev/null +++ b/android/app/src/main/kotlin/com/payfrit/add_months/MainActivity.kt @@ -0,0 +1,5 @@ +package com.payfrit.add_months + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity : FlutterActivity() diff --git a/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..a8b72c0 Binary files /dev/null and b/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..5547e49 Binary files /dev/null and b/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/drawable-v21/launch_background.xml b/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..ea4a32a Binary files /dev/null and b/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..c2a87a2 Binary files /dev/null and b/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..2817529 Binary files /dev/null and b/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/drawable/launch_background.xml b/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..c79c58a --- /dev/null +++ b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..5f838b2 Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..df44a59 Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..1ca9cf1 Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..9ff6097 Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..75c2191 Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/values-night/styles.xml b/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..c5d5899 --- /dev/null +++ b/android/app/src/main/res/values/colors.xml @@ -0,0 +1,4 @@ + + + #FFFFFF + \ No newline at end of file diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..cb1ef88 --- /dev/null +++ b/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/android/build.gradle.kts b/android/build.gradle.kts new file mode 100644 index 0000000..dbee657 --- /dev/null +++ b/android/build.gradle.kts @@ -0,0 +1,24 @@ +allprojects { + repositories { + google() + mavenCentral() + } +} + +val newBuildDir: Directory = + rootProject.layout.buildDirectory + .dir("../../build") + .get() +rootProject.layout.buildDirectory.value(newBuildDir) + +subprojects { + val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) + project.layout.buildDirectory.value(newSubprojectBuildDir) +} +subprojects { + project.evaluationDependsOn(":app") +} + +tasks.register("clean") { + delete(rootProject.layout.buildDirectory) +} diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 0000000..fbee1d8 --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,2 @@ +org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError +android.useAndroidX=true diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e4ef43f --- /dev/null +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts new file mode 100644 index 0000000..ca7fe06 --- /dev/null +++ b/android/settings.gradle.kts @@ -0,0 +1,26 @@ +pluginManagement { + val flutterSdkPath = + run { + val properties = java.util.Properties() + file("local.properties").inputStream().use { properties.load(it) } + val flutterSdkPath = properties.getProperty("flutter.sdk") + require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" } + flutterSdkPath + } + + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id("dev.flutter.flutter-plugin-loader") version "1.0.0" + id("com.android.application") version "8.11.1" apply false + id("org.jetbrains.kotlin.android") version "2.2.20" apply false +} + +include(":app") diff --git a/assets/icon/app_icon.png b/assets/icon/app_icon.png new file mode 100644 index 0000000..a769dea Binary files /dev/null and b/assets/icon/app_icon.png differ diff --git a/assets/icon/app_icon_foreground.png b/assets/icon/app_icon_foreground.png new file mode 100644 index 0000000..a769dea Binary files /dev/null and b/assets/icon/app_icon_foreground.png differ diff --git a/ios/.gitignore b/ios/.gitignore new file mode 100644 index 0000000..7a7f987 --- /dev/null +++ b/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/ios/Flutter/AppFrameworkInfo.plist b/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000..1dc6cf7 --- /dev/null +++ b/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 13.0 + + diff --git a/ios/Flutter/Debug.xcconfig b/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/ios/Flutter/Release.xcconfig b/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..5646fa5 --- /dev/null +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,616 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + 331C8082294A63A400263BE5 /* RunnerTests */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + 331C8081294A63A400263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C8080294A63A400263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C807D294A63A400263BE5 /* Sources */, + 331C807F294A63A400263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C8086294A63A400263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C8080294A63A400263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 97C146ED1CF9000F007C117D; + }; + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + 331C8080294A63A400263BE5 /* RunnerTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C807F294A63A400263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C807D294A63A400263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C8086294A63A400263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.payfrit.addMonths; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 331C8088294A63A400263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.payfrit.addMonths.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Debug; + }; + 331C8089294A63A400263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.payfrit.addMonths.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Release; + }; + 331C808A294A63A400263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.payfrit.addMonths.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.payfrit.addMonths; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.payfrit.addMonths; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C8088294A63A400263BE5 /* Debug */, + 331C8089294A63A400263BE5 /* Release */, + 331C808A294A63A400263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..e3773d4 --- /dev/null +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000..6266644 --- /dev/null +++ b/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import Flutter +import UIKit + +@main +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d0d98aa --- /dev/null +++ b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1 @@ +{"images":[{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@3x.png","scale":"3x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@3x.png","scale":"3x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@3x.png","scale":"3x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@1x.png","scale":"1x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@3x.png","scale":"3x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@1x.png","scale":"1x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@1x.png","scale":"1x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@1x.png","scale":"1x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@2x.png","scale":"2x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@1x.png","scale":"1x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@2x.png","scale":"2x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@1x.png","scale":"1x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@2x.png","scale":"2x"},{"size":"83.5x83.5","idiom":"ipad","filename":"Icon-App-83.5x83.5@2x.png","scale":"2x"},{"size":"1024x1024","idiom":"ios-marketing","filename":"Icon-App-1024x1024@1x.png","scale":"1x"}],"info":{"version":1,"author":"xcode"}} \ No newline at end of file diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000..5b0c147 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000..e051b03 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000..39ce2c8 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000..39eb09c Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000..2d5b2a5 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000..fc2c489 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000..934c856 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000..39ce2c8 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000..9a29ac4 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000..3007c01 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png new file mode 100644 index 0000000..110f7ec Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png new file mode 100644 index 0000000..c52e444 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png new file mode 100644 index 0000000..3b64fb3 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png new file mode 100644 index 0000000..581f6d2 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000..3007c01 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000..f9f623a Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png new file mode 100644 index 0000000..5f838b2 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png new file mode 100644 index 0000000..9ff6097 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000..807e9fc Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000..a991457 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000..fa706b6 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000..0bedcf2 --- /dev/null +++ b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000..89c2725 --- /dev/null +++ b/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/ios/Runner/Base.lproj/LaunchScreen.storyboard b/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..f2e259c --- /dev/null +++ b/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner/Base.lproj/Main.storyboard b/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f3c2851 --- /dev/null +++ b/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist new file mode 100644 index 0000000..3e4f7fa --- /dev/null +++ b/ios/Runner/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Add Months + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + add_months + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + + diff --git a/ios/Runner/Runner-Bridging-Header.h b/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000..308a2a5 --- /dev/null +++ b/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/ios/RunnerTests/RunnerTests.swift b/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..86a7c3b --- /dev/null +++ b/ios/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Flutter +import UIKit +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/lib/main.dart b/lib/main.dart new file mode 100644 index 0000000..a2ab4ec --- /dev/null +++ b/lib/main.dart @@ -0,0 +1,107 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'screens/screens.dart'; +import 'storage/local_storage.dart'; +import 'theme.dart'; + +void main() async { + WidgetsFlutterBinding.ensureInitialized(); + + // Initialize database + await LocalStorage.database; + + // Set preferred orientations + await SystemChrome.setPreferredOrientations([ + DeviceOrientation.portraitUp, + DeviceOrientation.portraitDown, + ]); + + runApp(const AddMonthsApp()); +} + +class AddMonthsApp extends StatelessWidget { + const AddMonthsApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Add Months', + debugShowCheckedModeBanner: false, + theme: buildAppTheme(), + home: const AppRouter(), + ); + } +} + +class AppRouter extends StatefulWidget { + const AppRouter({super.key}); + + @override + State createState() => _AppRouterState(); +} + +class _AppRouterState extends State { + bool _loading = true; + bool _hasData = false; + + @override + void initState() { + super.initState(); + _checkExistingData(); + } + + Future _checkExistingData() async { + final hasData = await LocalStorage.hasCompletedSetup(); + setState(() { + _hasData = hasData; + _loading = false; + }); + } + + @override + Widget build(BuildContext context) { + if (_loading) { + return const Scaffold( + body: Center( + child: CircularProgressIndicator(), + ), + ); + } + + // If user has existing data, go straight to results + if (_hasData) { + return FutureBuilder( + future: _loadExistingData(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Scaffold( + body: Center(child: CircularProgressIndicator()), + ); + } + + if (snapshot.hasData) { + final data = snapshot.data!; + return ResultsScreen( + profile: data.$1, + behaviors: data.$2, + ); + } + + return const OnboardingScreen(); + }, + ); + } + + return const OnboardingScreen(); + } + + Future<(dynamic, dynamic)?> _loadExistingData() async { + final profile = await LocalStorage.getProfile(); + final behaviors = await LocalStorage.getBehaviors(); + + if (profile != null && behaviors != null) { + return (profile, behaviors); + } + return null; + } +} diff --git a/lib/models/behavioral_inputs.dart b/lib/models/behavioral_inputs.dart new file mode 100644 index 0000000..171dd07 --- /dev/null +++ b/lib/models/behavioral_inputs.dart @@ -0,0 +1,145 @@ +import 'enums.dart'; + +class BehavioralInputs { + // Screen 1: Basic behaviors + final SmokingStatus smoking; + final int cigarettesPerDay; + final AlcoholLevel alcohol; + final double sleepHours; + final bool sleepConsistent; + final ActivityLevel activity; + + // Screen 2: Lifestyle factors + final DietQuality diet; + final ProcessedFoodLevel processedFood; + final DrugUse drugUse; + final SocialConnection social; + final StressLevel stress; + final DrivingExposure driving; + final WorkHoursLevel workHours; + + const BehavioralInputs({ + required this.smoking, + this.cigarettesPerDay = 0, + required this.alcohol, + required this.sleepHours, + required this.sleepConsistent, + required this.activity, + required this.diet, + required this.processedFood, + required this.drugUse, + required this.social, + required this.stress, + required this.driving, + required this.workHours, + }); + + static const optimal = BehavioralInputs( + smoking: SmokingStatus.never, + cigarettesPerDay: 0, + alcohol: AlcoholLevel.none, + sleepHours: 7.5, + sleepConsistent: true, + activity: ActivityLevel.high, + diet: DietQuality.excellent, + processedFood: ProcessedFoodLevel.rarely, + drugUse: DrugUse.none, + social: SocialConnection.strong, + stress: StressLevel.low, + driving: DrivingExposure.low, + workHours: WorkHoursLevel.normal, + ); + + /// Create partial inputs from screen 1 (with defaults for screen 2) + factory BehavioralInputs.fromScreen1({ + required SmokingStatus smoking, + int cigarettesPerDay = 0, + required AlcoholLevel alcohol, + required double sleepHours, + required bool sleepConsistent, + required ActivityLevel activity, + }) { + return BehavioralInputs( + smoking: smoking, + cigarettesPerDay: cigarettesPerDay, + alcohol: alcohol, + sleepHours: sleepHours, + sleepConsistent: sleepConsistent, + activity: activity, + diet: DietQuality.fair, + processedFood: ProcessedFoodLevel.frequent, + drugUse: DrugUse.none, + social: SocialConnection.moderate, + stress: StressLevel.moderate, + driving: DrivingExposure.low, + workHours: WorkHoursLevel.normal, + ); + } + + Map toJson() => { + 'smoking': smoking.name, + 'cigarettesPerDay': cigarettesPerDay, + 'alcohol': alcohol.name, + 'sleepHours': sleepHours, + 'sleepConsistent': sleepConsistent, + 'activity': activity.name, + 'diet': diet.name, + 'processedFood': processedFood.name, + 'drugUse': drugUse.name, + 'social': social.name, + 'stress': stress.name, + 'driving': driving.name, + 'workHours': workHours.name, + }; + + factory BehavioralInputs.fromJson(Map json) => + BehavioralInputs( + smoking: SmokingStatus.values.byName(json['smoking'] as String), + cigarettesPerDay: json['cigarettesPerDay'] as int? ?? 0, + alcohol: AlcoholLevel.values.byName(json['alcohol'] as String), + sleepHours: (json['sleepHours'] as num).toDouble(), + sleepConsistent: json['sleepConsistent'] as bool, + activity: ActivityLevel.values.byName(json['activity'] as String), + diet: DietQuality.values.byName(json['diet'] as String? ?? 'fair'), + processedFood: ProcessedFoodLevel.values + .byName(json['processedFood'] as String? ?? 'frequent'), + drugUse: DrugUse.values.byName(json['drugUse'] as String? ?? 'none'), + social: SocialConnection.values + .byName(json['social'] as String? ?? 'moderate'), + stress: + StressLevel.values.byName(json['stress'] as String? ?? 'moderate'), + driving: DrivingExposure.values.byName(json['driving'] as String), + workHours: WorkHoursLevel.values.byName(json['workHours'] as String), + ); + + BehavioralInputs copyWith({ + SmokingStatus? smoking, + int? cigarettesPerDay, + AlcoholLevel? alcohol, + double? sleepHours, + bool? sleepConsistent, + ActivityLevel? activity, + DietQuality? diet, + ProcessedFoodLevel? processedFood, + DrugUse? drugUse, + SocialConnection? social, + StressLevel? stress, + DrivingExposure? driving, + WorkHoursLevel? workHours, + }) => + BehavioralInputs( + smoking: smoking ?? this.smoking, + cigarettesPerDay: cigarettesPerDay ?? this.cigarettesPerDay, + alcohol: alcohol ?? this.alcohol, + sleepHours: sleepHours ?? this.sleepHours, + sleepConsistent: sleepConsistent ?? this.sleepConsistent, + activity: activity ?? this.activity, + diet: diet ?? this.diet, + processedFood: processedFood ?? this.processedFood, + drugUse: drugUse ?? this.drugUse, + social: social ?? this.social, + stress: stress ?? this.stress, + driving: driving ?? this.driving, + workHours: workHours ?? this.workHours, + ); +} diff --git a/lib/models/enums.dart b/lib/models/enums.dart new file mode 100644 index 0000000..c1505ba --- /dev/null +++ b/lib/models/enums.dart @@ -0,0 +1,26 @@ +enum Sex { male, female } + +enum SmokingStatus { never, former, current } + +enum AlcoholLevel { none, light, moderate, heavy, veryHeavy } + +enum ActivityLevel { sedentary, light, moderate, high } + +enum DrivingExposure { low, moderate, high, veryHigh } + +enum WorkHoursLevel { normal, elevated, high, extreme } + +enum Diagnosis { cardiovascular, diabetes, cancer, copd, hypertension } + +enum Confidence { high, moderate, emerging } + +// Lifestyle factors +enum DietQuality { poor, fair, good, excellent } + +enum ProcessedFoodLevel { daily, frequent, occasional, rarely } + +enum DrugUse { none, occasional, regular, daily } + +enum SocialConnection { isolated, limited, moderate, strong } + +enum StressLevel { low, moderate, high, chronic } diff --git a/lib/models/models.dart b/lib/models/models.dart new file mode 100644 index 0000000..28ba9e6 --- /dev/null +++ b/lib/models/models.dart @@ -0,0 +1,5 @@ +export 'enums.dart'; +export 'user_profile.dart'; +export 'behavioral_inputs.dart'; +export 'result.dart'; +export 'saved_run.dart'; diff --git a/lib/models/result.dart b/lib/models/result.dart new file mode 100644 index 0000000..b9f58b3 --- /dev/null +++ b/lib/models/result.dart @@ -0,0 +1,90 @@ +import 'enums.dart'; + +class LifespanDelta { + final int lowMonths; + final int highMonths; + final Confidence confidence; + + const LifespanDelta({ + required this.lowMonths, + required this.highMonths, + required this.confidence, + }); + + int get midpointMonths => ((lowMonths + highMonths) / 2).round(); + + String get rangeDisplay { + if (lowMonths <= 0 && highMonths <= 0) return '0'; + if (lowMonths == highMonths) return '$lowMonths'; + return '$lowMonths–$highMonths'; + } + + Map toJson() => { + 'lowMonths': lowMonths, + 'highMonths': highMonths, + 'confidence': confidence.name, + }; + + factory LifespanDelta.fromJson(Map json) => LifespanDelta( + lowMonths: json['lowMonths'] as int, + highMonths: json['highMonths'] as int, + confidence: Confidence.values.byName(json['confidence'] as String), + ); +} + +class RankedFactor { + final String behaviorKey; + final String displayName; + final LifespanDelta delta; + + const RankedFactor({ + required this.behaviorKey, + required this.displayName, + required this.delta, + }); + + Map toJson() => { + 'behaviorKey': behaviorKey, + 'displayName': displayName, + 'delta': delta.toJson(), + }; + + factory RankedFactor.fromJson(Map json) => RankedFactor( + behaviorKey: json['behaviorKey'] as String, + displayName: json['displayName'] as String, + delta: LifespanDelta.fromJson(json['delta'] as Map), + ); +} + +class CalculationResult { + final List rankedFactors; + final String modelVersion; + final DateTime calculatedAt; + + const CalculationResult({ + required this.rankedFactors, + required this.modelVersion, + required this.calculatedAt, + }); + + RankedFactor? get dominantFactor => + rankedFactors.isNotEmpty ? rankedFactors.first : null; + + RankedFactor? get secondaryFactor => + rankedFactors.length > 1 ? rankedFactors[1] : null; + + Map toJson() => { + 'rankedFactors': rankedFactors.map((f) => f.toJson()).toList(), + 'modelVersion': modelVersion, + 'calculatedAt': calculatedAt.toIso8601String(), + }; + + factory CalculationResult.fromJson(Map json) => + CalculationResult( + rankedFactors: (json['rankedFactors'] as List) + .map((f) => RankedFactor.fromJson(f as Map)) + .toList(), + modelVersion: json['modelVersion'] as String, + calculatedAt: DateTime.parse(json['calculatedAt'] as String), + ); +} diff --git a/lib/models/saved_run.dart b/lib/models/saved_run.dart new file mode 100644 index 0000000..f542f32 --- /dev/null +++ b/lib/models/saved_run.dart @@ -0,0 +1,80 @@ +import 'behavioral_inputs.dart'; +import 'result.dart'; +import 'user_profile.dart'; + +class SavedRun { + final String id; + final String label; + final CalculationResult result; + final UserProfile profile; + final BehavioralInputs behaviors; + final DateTime createdAt; + + const SavedRun({ + required this.id, + required this.label, + required this.result, + required this.profile, + required this.behaviors, + required this.createdAt, + }); + + String get displayDate { + final now = DateTime.now(); + final diff = now.difference(createdAt); + + if (diff.inDays == 0) { + return 'Today'; + } else if (diff.inDays == 1) { + return 'Yesterday'; + } else if (diff.inDays < 7) { + return '${diff.inDays} days ago'; + } else { + return '${createdAt.month}/${createdAt.day}/${createdAt.year}'; + } + } + + String get dominantFactorSummary { + final factor = result.dominantFactor; + if (factor == null) return 'Optimal'; + return '${factor.displayName}: ${factor.delta.rangeDisplay} mo'; + } + + Map toJson() => { + 'id': id, + 'label': label, + 'result': result.toJson(), + 'profile': profile.toJson(), + 'behaviors': behaviors.toJson(), + 'createdAt': createdAt.toIso8601String(), + }; + + factory SavedRun.fromJson(Map json) => SavedRun( + id: json['id'] as String, + label: json['label'] as String, + result: + CalculationResult.fromJson(json['result'] as Map), + profile: + UserProfile.fromJson(json['profile'] as Map), + behaviors: BehavioralInputs.fromJson( + json['behaviors'] as Map), + createdAt: DateTime.parse(json['createdAt'] as String), + ); + + SavedRun copyWith({ + String? id, + String? label, + CalculationResult? result, + UserProfile? profile, + BehavioralInputs? behaviors, + DateTime? createdAt, + }) => + SavedRun( + id: id ?? this.id, + label: label ?? this.label, + result: result ?? this.result, + profile: profile ?? this.profile, + behaviors: behaviors ?? this.behaviors, + createdAt: createdAt ?? this.createdAt, + ); +} diff --git a/lib/models/user_profile.dart b/lib/models/user_profile.dart new file mode 100644 index 0000000..0756955 --- /dev/null +++ b/lib/models/user_profile.dart @@ -0,0 +1,58 @@ +import 'enums.dart'; + +class UserProfile { + final int age; + final Sex sex; + final String country; + final double heightCm; + final double weightKg; + final Set diagnoses; + + const UserProfile({ + required this.age, + required this.sex, + required this.country, + required this.heightCm, + required this.weightKg, + this.diagnoses = const {}, + }); + + double get bmi => weightKg / ((heightCm / 100) * (heightCm / 100)); + + Map toJson() => { + 'age': age, + 'sex': sex.name, + 'country': country, + 'heightCm': heightCm, + 'weightKg': weightKg, + 'diagnoses': diagnoses.map((d) => d.name).toList(), + }; + + factory UserProfile.fromJson(Map json) => UserProfile( + age: json['age'] as int, + sex: Sex.values.byName(json['sex'] as String), + country: json['country'] as String, + heightCm: (json['heightCm'] as num).toDouble(), + weightKg: (json['weightKg'] as num).toDouble(), + diagnoses: (json['diagnoses'] as List) + .map((d) => Diagnosis.values.byName(d as String)) + .toSet(), + ); + + UserProfile copyWith({ + int? age, + Sex? sex, + String? country, + double? heightCm, + double? weightKg, + Set? diagnoses, + }) => + UserProfile( + age: age ?? this.age, + sex: sex ?? this.sex, + country: country ?? this.country, + heightCm: heightCm ?? this.heightCm, + weightKg: weightKg ?? this.weightKg, + diagnoses: diagnoses ?? this.diagnoses, + ); +} diff --git a/lib/risk_engine/calculator.dart b/lib/risk_engine/calculator.dart new file mode 100644 index 0000000..29c00c5 --- /dev/null +++ b/lib/risk_engine/calculator.dart @@ -0,0 +1,199 @@ +import 'dart:math'; +import '../models/models.dart'; +import 'hazard_ratios.dart'; +import 'mortality_tables.dart'; + +const String modelVersion = '1.1'; + +/// Maximum combined hazard ratio (prevents unrealistic compounding). +const double _maxCombinedHR = 4.0; + +/// Damping factor for delta calculation (conservative estimate). +const double _dampingFactor = 0.3; + +/// Uncertainty range multipliers (±20% around midpoint). +const double _lowMultiplier = 0.8; +const double _highMultiplier = 1.2; + +/// Calculate combined hazard ratio from behavioral inputs. +double computeCombinedHazard(BehavioralInputs inputs, double bmi) { + double hr = 1.0; + + // Screen 1 factors + hr *= getSmokingHR(inputs.smoking, inputs.cigarettesPerDay); + hr *= getAlcoholHR(inputs.alcohol); + hr *= getSleepHR(inputs.sleepHours, inputs.sleepConsistent); + hr *= getActivityHR(inputs.activity); + hr *= getBmiHR(bmi); + + // Screen 2 factors + hr *= getDietHR(inputs.diet); + hr *= getProcessedFoodHR(inputs.processedFood); + hr *= getDrugUseHR(inputs.drugUse); + hr *= getSocialHR(inputs.social); + hr *= getStressHR(inputs.stress); + hr *= getDrivingHR(inputs.driving); + hr *= getWorkHoursHR(inputs.workHours); + + return min(hr, _maxCombinedHR); +} + +/// Calculate lifespan delta when modifying a behavior to optimal. +LifespanDelta _computeDelta( + double baselineYears, + double currentHR, + double modifiedHR, + String behaviorKey, +) { + if (currentHR <= modifiedHR) { + return LifespanDelta( + lowMonths: 0, + highMonths: 0, + confidence: getConfidenceForBehavior(behaviorKey), + ); + } + + final rawDeltaYears = + baselineYears * (1 - modifiedHR / currentHR) * _dampingFactor; + + final midpointMonths = rawDeltaYears * 12; + final lowMonths = (midpointMonths * _lowMultiplier).round(); + final highMonths = (midpointMonths * _highMultiplier).round(); + + return LifespanDelta( + lowMonths: max(0, lowMonths), + highMonths: max(0, highMonths), + confidence: getConfidenceForBehavior(behaviorKey), + ); +} + +/// Get modified inputs with a specific behavior set to optimal. +BehavioralInputs _setToOptimal(BehavioralInputs inputs, String behaviorKey) { + switch (behaviorKey) { + case 'smoking': + return inputs.copyWith( + smoking: SmokingStatus.never, + cigarettesPerDay: 0, + ); + case 'alcohol': + return inputs.copyWith(alcohol: AlcoholLevel.none); + case 'sleep': + return inputs.copyWith(sleepHours: 7.5, sleepConsistent: true); + case 'activity': + return inputs.copyWith(activity: ActivityLevel.high); + case 'diet': + return inputs.copyWith(diet: DietQuality.excellent); + case 'processedFood': + return inputs.copyWith(processedFood: ProcessedFoodLevel.rarely); + case 'drugUse': + return inputs.copyWith(drugUse: DrugUse.none); + case 'social': + return inputs.copyWith(social: SocialConnection.strong); + case 'stress': + return inputs.copyWith(stress: StressLevel.low); + case 'driving': + return inputs.copyWith(driving: DrivingExposure.low); + case 'workHours': + return inputs.copyWith(workHours: WorkHoursLevel.normal); + default: + return inputs; + } +} + +/// Check if a behavior is already at optimal level. +bool _isOptimal(BehavioralInputs inputs, String behaviorKey) { + switch (behaviorKey) { + case 'smoking': + return inputs.smoking == SmokingStatus.never; + case 'alcohol': + return inputs.alcohol == AlcoholLevel.none || + inputs.alcohol == AlcoholLevel.light; + case 'sleep': + return inputs.sleepHours >= 7 && + inputs.sleepHours <= 8 && + inputs.sleepConsistent; + case 'activity': + return inputs.activity == ActivityLevel.high; + case 'diet': + return inputs.diet == DietQuality.excellent; + case 'processedFood': + return inputs.processedFood == ProcessedFoodLevel.rarely; + case 'drugUse': + return inputs.drugUse == DrugUse.none; + case 'social': + return inputs.social == SocialConnection.strong; + case 'stress': + return inputs.stress == StressLevel.low; + case 'driving': + return inputs.driving == DrivingExposure.low; + case 'workHours': + return inputs.workHours == WorkHoursLevel.normal; + default: + return true; + } +} + +/// List of modifiable behavior keys. +const _modifiableBehaviors = [ + 'smoking', + 'alcohol', + 'sleep', + 'activity', + 'diet', + 'processedFood', + 'drugUse', + 'social', + 'stress', + 'driving', + 'workHours', +]; + +/// Calculate ranked factors for a user profile and behavioral inputs. +CalculationResult calculateRankedFactors( + UserProfile profile, + BehavioralInputs inputs, +) { + final baselineYears = getRemainingLifeExpectancy( + profile.age, + profile.sex, + profile.country, + ); + + final conditionHR = getDiagnosisHR(profile.diagnoses); + final adjustedBaselineYears = baselineYears / conditionHR; + + final currentHR = computeCombinedHazard(inputs, profile.bmi); + + final factors = []; + + for (final behaviorKey in _modifiableBehaviors) { + if (_isOptimal(inputs, behaviorKey)) continue; + + final modifiedInputs = _setToOptimal(inputs, behaviorKey); + final modifiedHR = computeCombinedHazard(modifiedInputs, profile.bmi); + + final delta = _computeDelta( + adjustedBaselineYears, + currentHR, + modifiedHR, + behaviorKey, + ); + + if (delta.highMonths >= 1) { + factors.add(RankedFactor( + behaviorKey: behaviorKey, + displayName: getDisplayName(behaviorKey), + delta: delta, + )); + } + } + + factors.sort( + (a, b) => b.delta.midpointMonths.compareTo(a.delta.midpointMonths)); + + return CalculationResult( + rankedFactors: factors, + modelVersion: modelVersion, + calculatedAt: DateTime.now(), + ); +} diff --git a/lib/risk_engine/hazard_ratios.dart b/lib/risk_engine/hazard_ratios.dart new file mode 100644 index 0000000..633bd9d --- /dev/null +++ b/lib/risk_engine/hazard_ratios.dart @@ -0,0 +1,248 @@ +import '../models/models.dart'; + +/// Hazard ratios based on conservative estimates from meta-analyses. +/// All HRs are relative to optimal baseline (HR = 1.0). + +double getSmokingHR(SmokingStatus status, int cigarettesPerDay) { + switch (status) { + case SmokingStatus.never: + return 1.0; + case SmokingStatus.former: + return 1.3; + case SmokingStatus.current: + if (cigarettesPerDay < 10) return 1.8; + if (cigarettesPerDay <= 20) return 2.2; + return 2.8; + } +} + +double getAlcoholHR(AlcoholLevel level) { + switch (level) { + case AlcoholLevel.none: + case AlcoholLevel.light: + return 1.0; + case AlcoholLevel.moderate: + return 1.1; + case AlcoholLevel.heavy: + return 1.3; + case AlcoholLevel.veryHeavy: + return 1.6; + } +} + +double getSleepHR(double hours, bool consistent) { + double hr; + if (hours >= 7 && hours <= 8) { + hr = 1.0; + } else if (hours >= 6 && hours < 7) { + hr = 1.05; + } else if (hours < 6) { + hr = 1.15; + } else { + // > 8 hours + hr = 1.10; + } + + if (!consistent) { + hr *= 1.05; + } + + return hr; +} + +double getActivityHR(ActivityLevel level) { + switch (level) { + case ActivityLevel.high: + return 1.0; + case ActivityLevel.moderate: + return 1.05; + case ActivityLevel.light: + return 1.15; + case ActivityLevel.sedentary: + return 1.4; + } +} + +double getBmiHR(double bmi) { + if (bmi >= 18.5 && bmi < 25) return 1.0; + if (bmi >= 25 && bmi < 30) return 1.1; + if (bmi >= 30 && bmi < 35) return 1.2; + if (bmi >= 35 && bmi < 40) return 1.4; + if (bmi >= 40) return 1.8; + return 1.15; // Underweight +} + +double getDrivingHR(DrivingExposure level) { + switch (level) { + case DrivingExposure.low: + return 1.0; + case DrivingExposure.moderate: + return 1.02; + case DrivingExposure.high: + return 1.04; + case DrivingExposure.veryHigh: + return 1.08; + } +} + +double getWorkHoursHR(WorkHoursLevel level) { + switch (level) { + case WorkHoursLevel.normal: + return 1.0; + case WorkHoursLevel.elevated: + return 1.05; + case WorkHoursLevel.high: + return 1.15; + case WorkHoursLevel.extreme: + return 1.3; + } +} + +// --- New lifestyle factors --- + +/// Diet quality - based on Mediterranean diet studies +double getDietHR(DietQuality level) { + switch (level) { + case DietQuality.excellent: + return 1.0; + case DietQuality.good: + return 1.05; + case DietQuality.fair: + return 1.15; + case DietQuality.poor: + return 1.3; + } +} + +/// Processed food consumption - ultra-processed food studies +double getProcessedFoodHR(ProcessedFoodLevel level) { + switch (level) { + case ProcessedFoodLevel.rarely: + return 1.0; + case ProcessedFoodLevel.occasional: + return 1.05; + case ProcessedFoodLevel.frequent: + return 1.12; + case ProcessedFoodLevel.daily: + return 1.2; + } +} + +/// Drug use - excluding alcohol/tobacco (cannabis, recreational drugs) +double getDrugUseHR(DrugUse level) { + switch (level) { + case DrugUse.none: + return 1.0; + case DrugUse.occasional: + return 1.05; + case DrugUse.regular: + return 1.15; + case DrugUse.daily: + return 1.35; + } +} + +/// Social connection - loneliness/isolation meta-analyses +double getSocialHR(SocialConnection level) { + switch (level) { + case SocialConnection.strong: + return 1.0; + case SocialConnection.moderate: + return 1.05; + case SocialConnection.limited: + return 1.2; + case SocialConnection.isolated: + return 1.45; + } +} + +/// Chronic stress - based on allostatic load research +double getStressHR(StressLevel level) { + switch (level) { + case StressLevel.low: + return 1.0; + case StressLevel.moderate: + return 1.05; + case StressLevel.high: + return 1.15; + case StressLevel.chronic: + return 1.35; + } +} + +/// Existing conditions modify baseline mortality but are NOT modifiable. +double getDiagnosisHR(Set diagnoses) { + double hr = 1.0; + for (final diagnosis in diagnoses) { + switch (diagnosis) { + case Diagnosis.cardiovascular: + hr *= 1.5; + break; + case Diagnosis.diabetes: + hr *= 1.4; + break; + case Diagnosis.cancer: + hr *= 2.0; + break; + case Diagnosis.copd: + hr *= 1.6; + break; + case Diagnosis.hypertension: + hr *= 1.2; + break; + } + } + return hr; +} + +/// Confidence levels for each behavior based on evidence quality. +Confidence getConfidenceForBehavior(String behaviorKey) { + switch (behaviorKey) { + case 'smoking': + case 'alcohol': + case 'activity': + case 'social': + return Confidence.high; + case 'sleep': + case 'workHours': + case 'diet': + case 'stress': + return Confidence.moderate; + case 'driving': + case 'processedFood': + case 'drugUse': + return Confidence.emerging; + default: + return Confidence.moderate; + } +} + +/// Display names for behaviors. +String getDisplayName(String behaviorKey) { + switch (behaviorKey) { + case 'smoking': + return 'Smoking'; + case 'alcohol': + return 'Alcohol Consumption'; + case 'sleep': + return 'Sleep'; + case 'activity': + return 'Physical Activity'; + case 'driving': + return 'Driving Exposure'; + case 'workHours': + return 'Work Hours'; + case 'diet': + return 'Diet Quality'; + case 'processedFood': + return 'Processed Food'; + case 'drugUse': + return 'Drug Use'; + case 'social': + return 'Social Connection'; + case 'stress': + return 'Chronic Stress'; + default: + return behaviorKey; + } +} diff --git a/lib/risk_engine/mortality_tables.dart b/lib/risk_engine/mortality_tables.dart new file mode 100644 index 0000000..563db89 --- /dev/null +++ b/lib/risk_engine/mortality_tables.dart @@ -0,0 +1,131 @@ +import '../models/models.dart'; + +/// Simplified mortality groups with approximate life expectancy at birth. +/// Data approximated from WHO 2024 estimates. +enum MortalityGroup { + groupA, // High LE countries (~83-85) + groupB, // Upper-middle LE (~79-81) + groupC, // Middle LE (~72-76) + groupD, // Lower LE (~65-70) +} + +/// Maps countries to their mortality group. +MortalityGroup getCountryGroup(String country) { + return _countryToGroup[country] ?? MortalityGroup.groupB; +} + +/// Get baseline life expectancy at birth for a given country group and sex. +double getLifeExpectancyAtBirth(MortalityGroup group, Sex sex) { + final base = _groupBaseLE[group]!; + // Women live ~4-5 years longer on average + return sex == Sex.female ? base + 4.5 : base; +} + +/// Get remaining life expectancy at current age. +/// Simplified model: as you age, remaining LE decreases but survivors +/// tend to live longer than birth LE suggests. +double getRemainingLifeExpectancy(int currentAge, Sex sex, String country) { + final group = getCountryGroup(country); + final leAtBirth = getLifeExpectancyAtBirth(group, sex); + + if (currentAge >= leAtBirth) { + // Past average LE - use simplified survival model + // Each year survived past LE adds ~0.5-0.8 expected years + return 5.0 + (leAtBirth - currentAge) * 0.1; + } + + // Simplified remaining LE calculation + // People who survive to age X have higher LE than birth cohort suggests + final survivorBonus = currentAge * 0.15; // ~0.15 years bonus per year survived + final rawRemaining = leAtBirth - currentAge; + + return rawRemaining + survivorBonus.clamp(0, 5); +} + +/// Base life expectancy by mortality group (male baseline). +const _groupBaseLE = { + MortalityGroup.groupA: 81.0, + MortalityGroup.groupB: 77.0, + MortalityGroup.groupC: 72.0, + MortalityGroup.groupD: 65.0, +}; + +/// Country to mortality group mapping. +const _countryToGroup = { + // Group A - High LE (83-85) + 'Japan': MortalityGroup.groupA, + 'Switzerland': MortalityGroup.groupA, + 'Singapore': MortalityGroup.groupA, + 'Spain': MortalityGroup.groupA, + 'Italy': MortalityGroup.groupA, + 'Australia': MortalityGroup.groupA, + 'Iceland': MortalityGroup.groupA, + 'Israel': MortalityGroup.groupA, + 'Sweden': MortalityGroup.groupA, + 'France': MortalityGroup.groupA, + 'South Korea': MortalityGroup.groupA, + 'Norway': MortalityGroup.groupA, + + // Group B - Upper-middle LE (79-81) + 'United States': MortalityGroup.groupB, + 'United Kingdom': MortalityGroup.groupB, + 'Germany': MortalityGroup.groupB, + 'Canada': MortalityGroup.groupB, + 'Netherlands': MortalityGroup.groupB, + 'Belgium': MortalityGroup.groupB, + 'Austria': MortalityGroup.groupB, + 'Finland': MortalityGroup.groupB, + 'Ireland': MortalityGroup.groupB, + 'New Zealand': MortalityGroup.groupB, + 'Denmark': MortalityGroup.groupB, + 'Portugal': MortalityGroup.groupB, + 'Czech Republic': MortalityGroup.groupB, + 'Poland': MortalityGroup.groupB, + 'Chile': MortalityGroup.groupB, + 'Costa Rica': MortalityGroup.groupB, + 'Cuba': MortalityGroup.groupB, + 'United Arab Emirates': MortalityGroup.groupB, + 'Qatar': MortalityGroup.groupB, + 'Taiwan': MortalityGroup.groupB, + + // Group C - Middle LE (72-76) + 'China': MortalityGroup.groupC, + 'Brazil': MortalityGroup.groupC, + 'Mexico': MortalityGroup.groupC, + 'Russia': MortalityGroup.groupC, + 'Turkey': MortalityGroup.groupC, + 'Argentina': MortalityGroup.groupC, + 'Colombia': MortalityGroup.groupC, + 'Thailand': MortalityGroup.groupC, + 'Vietnam': MortalityGroup.groupC, + 'Malaysia': MortalityGroup.groupC, + 'Iran': MortalityGroup.groupC, + 'Saudi Arabia': MortalityGroup.groupC, + 'Egypt': MortalityGroup.groupC, + 'Ukraine': MortalityGroup.groupC, + 'Romania': MortalityGroup.groupC, + 'Hungary': MortalityGroup.groupC, + 'Peru': MortalityGroup.groupC, + 'Philippines': MortalityGroup.groupC, + + // Group D - Lower LE (65-70) + 'India': MortalityGroup.groupD, + 'Indonesia': MortalityGroup.groupD, + 'South Africa': MortalityGroup.groupD, + 'Pakistan': MortalityGroup.groupD, + 'Bangladesh': MortalityGroup.groupD, + 'Nigeria': MortalityGroup.groupD, + 'Kenya': MortalityGroup.groupD, + 'Ghana': MortalityGroup.groupD, + 'Ethiopia': MortalityGroup.groupD, + 'Myanmar': MortalityGroup.groupD, + 'Nepal': MortalityGroup.groupD, + 'Cambodia': MortalityGroup.groupD, +}; + +/// Get list of all supported countries, sorted alphabetically. +List getSupportedCountries() { + final countries = _countryToGroup.keys.toList(); + countries.sort(); + return countries; +} diff --git a/lib/risk_engine/risk_engine.dart b/lib/risk_engine/risk_engine.dart new file mode 100644 index 0000000..2762679 --- /dev/null +++ b/lib/risk_engine/risk_engine.dart @@ -0,0 +1,3 @@ +export 'hazard_ratios.dart'; +export 'mortality_tables.dart'; +export 'calculator.dart'; diff --git a/lib/screens/about_screen.dart b/lib/screens/about_screen.dart new file mode 100644 index 0000000..7e5c8ce --- /dev/null +++ b/lib/screens/about_screen.dart @@ -0,0 +1,196 @@ +import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; +import '../theme.dart'; + +class AboutScreen extends StatelessWidget { + const AboutScreen({super.key}); + + static const String _helpUrl = 'https://addmonths.app/help'; + static const String _privacyUrl = 'https://addmonths.app/privacy'; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('About'), + leading: IconButton( + icon: const Icon(Icons.arrow_back), + onPressed: () => Navigator.pop(context), + ), + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // App name and version + Center( + child: Column( + children: [ + Container( + width: 80, + height: 80, + decoration: BoxDecoration( + color: AppColors.surfaceVariant, + borderRadius: BorderRadius.circular(20), + ), + child: const Icon( + Icons.timeline, + size: 40, + color: AppColors.primary, + ), + ), + const SizedBox(height: 16), + Text( + 'Add Months', + style: Theme.of(context).textTheme.headlineMedium, + ), + const SizedBox(height: 4), + Text( + 'Version 1.2', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: AppColors.textSecondary, + ), + ), + ], + ), + ), + const SizedBox(height: 32), + + // Description + Text( + 'What is Add Months?', + style: Theme.of(context).textTheme.titleMedium, + ), + const SizedBox(height: 8), + Text( + 'Add Months uses evidence-based hazard ratios from peer-reviewed ' + 'meta-analyses to identify which single lifestyle change could ' + 'have the biggest impact on your lifespan.', + style: Theme.of(context).textTheme.bodyMedium, + ), + const SizedBox(height: 16), + Text( + 'Answer simple questions about your demographics and habits, ' + 'and the app calculates which modifiable factor offers the ' + 'greatest potential benefit.', + style: Theme.of(context).textTheme.bodyMedium, + ), + const SizedBox(height: 32), + + // Privacy note + Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: AppColors.surfaceVariant, + borderRadius: BorderRadius.circular(12), + ), + child: Row( + children: [ + const Icon( + Icons.lock_outline, + color: AppColors.primary, + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Your data stays on your device', + style: Theme.of(context).textTheme.titleSmall, + ), + const SizedBox(height: 4), + Text( + 'No accounts, no cloud sync, no analytics. ' + 'Everything is stored locally.', + style: Theme.of(context).textTheme.bodySmall, + ), + ], + ), + ), + ], + ), + ), + const SizedBox(height: 32), + + // Links + _buildLinkButton( + context, + icon: Icons.help_outline, + label: 'How it works', + onTap: () => _launchUrl(_helpUrl), + ), + const SizedBox(height: 12), + _buildLinkButton( + context, + icon: Icons.privacy_tip_outlined, + label: 'Privacy Policy', + onTap: () => _launchUrl(_privacyUrl), + ), + const SizedBox(height: 32), + + // Disclaimer + Text( + 'Disclaimer', + style: Theme.of(context).textTheme.titleSmall?.copyWith( + color: AppColors.textSecondary, + ), + ), + const SizedBox(height: 8), + Text( + 'This app provides general information based on population-level ' + 'research and is not medical advice. Individual results vary widely. ' + 'Consult a healthcare provider for personalized guidance.', + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: AppColors.textSecondary, + ), + ), + ], + ), + ), + ); + } + + Widget _buildLinkButton( + BuildContext context, { + required IconData icon, + required String label, + required VoidCallback onTap, + }) { + return InkWell( + onTap: onTap, + borderRadius: BorderRadius.circular(12), + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14), + decoration: BoxDecoration( + border: Border.all(color: AppColors.divider), + borderRadius: BorderRadius.circular(12), + ), + child: Row( + children: [ + Icon(icon, color: AppColors.primary), + const SizedBox(width: 12), + Text( + label, + style: Theme.of(context).textTheme.bodyLarge, + ), + const Spacer(), + const Icon( + Icons.open_in_new, + size: 18, + color: AppColors.textSecondary, + ), + ], + ), + ), + ); + } + + Future _launchUrl(String url) async { + final uri = Uri.parse(url); + if (await canLaunchUrl(uri)) { + await launchUrl(uri, mode: LaunchMode.externalApplication); + } + } +} diff --git a/lib/screens/baseline_screen.dart b/lib/screens/baseline_screen.dart new file mode 100644 index 0000000..319cb0c --- /dev/null +++ b/lib/screens/baseline_screen.dart @@ -0,0 +1,487 @@ +import 'package:flutter/material.dart'; +import '../models/models.dart'; +import '../risk_engine/mortality_tables.dart'; +import '../storage/local_storage.dart'; +import '../theme.dart'; +import 'about_screen.dart'; +import 'behavioral_screen.dart'; + +class BaselineScreen extends StatefulWidget { + final bool readOnly; + final UserProfile? initialProfile; + + const BaselineScreen({ + super.key, + this.readOnly = false, + this.initialProfile, + }); + + @override + State createState() => _BaselineScreenState(); +} + +class _BaselineScreenState extends State { + int _age = 35; + Sex _sex = Sex.male; + String _country = 'United States'; + double _heightCm = 170; + double _weightKg = 70; + final Set _diagnoses = {}; + bool _useMetric = false; + + late List _countries; + + @override + void initState() { + super.initState(); + _countries = getSupportedCountries(); + _loadInitialData(); + } + + Future _loadInitialData() async { + // Load unit preference + final useMetric = await LocalStorage.getUseMetricUnits(); + setState(() => _useMetric = useMetric); + + // If initial profile provided, use that + if (widget.initialProfile != null) { + _applyProfile(widget.initialProfile!); + return; + } + + // Otherwise load from storage + final profile = await LocalStorage.getProfile(); + if (profile != null) { + _applyProfile(profile); + } + } + + void _applyProfile(UserProfile profile) { + setState(() { + _age = profile.age; + _sex = profile.sex; + _country = profile.country; + _heightCm = profile.heightCm; + _weightKg = profile.weightKg; + _diagnoses.clear(); + _diagnoses.addAll(profile.diagnoses); + }); + } + + double get _bmi => _weightKg / ((_heightCm / 100) * (_heightCm / 100)); + + String get _bmiCategory { + if (_bmi < 18.5) return 'Underweight'; + if (_bmi < 25) return 'Normal'; + if (_bmi < 30) return 'Overweight'; + if (_bmi < 35) return 'Obese I'; + if (_bmi < 40) return 'Obese II'; + return 'Obese III'; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(widget.readOnly ? 'Baseline (View Only)' : 'Baseline'), + leading: IconButton( + icon: const Icon(Icons.arrow_back), + onPressed: () => Navigator.pop(context), + ), + actions: [ + IconButton( + icon: Icon(_useMetric ? Icons.straighten : Icons.square_foot), + tooltip: _useMetric ? 'Using Metric' : 'Using Imperial', + onPressed: widget.readOnly ? null : _toggleUnits, + ), + IconButton( + icon: const Icon(Icons.info_outline), + onPressed: () => Navigator.push( + context, + MaterialPageRoute(builder: (_) => const AboutScreen()), + ), + ), + ], + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Demographics', + style: Theme.of(context).textTheme.headlineSmall, + ), + const SizedBox(height: 8), + Text( + 'This information establishes your baseline life expectancy.', + style: Theme.of(context).textTheme.bodyMedium, + ), + const SizedBox(height: 24), + + // Age + _buildSectionLabel('Age'), + const SizedBox(height: 8), + _buildAgeSelector(), + const SizedBox(height: 24), + + // Sex + _buildSectionLabel('Biological Sex'), + const SizedBox(height: 8), + _buildSexSelector(), + const SizedBox(height: 24), + + // Country + _buildSectionLabel('Country'), + const SizedBox(height: 8), + _buildCountryDropdown(), + const SizedBox(height: 24), + + // Height + _buildSectionLabel('Height'), + const SizedBox(height: 8), + _buildHeightSlider(), + const SizedBox(height: 24), + + // Weight + _buildSectionLabel('Weight'), + const SizedBox(height: 8), + _buildWeightSlider(), + const SizedBox(height: 16), + + // BMI display + _buildBmiDisplay(), + const SizedBox(height: 32), + + // Existing conditions + Text( + 'Existing Conditions', + style: Theme.of(context).textTheme.headlineSmall, + ), + const SizedBox(height: 8), + Text( + 'Select any diagnosed conditions. These affect baseline calculations but are not modifiable factors.', + style: Theme.of(context).textTheme.bodyMedium, + ), + const SizedBox(height: 16), + _buildDiagnosisCheckboxes(), + const SizedBox(height: 32), + + // Continue button (hidden in readOnly mode) + if (!widget.readOnly) + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: _continue, + child: const Text('Continue'), + ), + ), + const SizedBox(height: 16), + ], + ), + ), + ); + } + + Widget _buildSectionLabel(String label) { + return Text( + label, + style: Theme.of(context).textTheme.labelLarge, + ); + } + + Widget _buildAgeSelector() { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + decoration: BoxDecoration( + color: AppColors.surfaceVariant, + borderRadius: BorderRadius.circular(12), + ), + child: Row( + children: [ + IconButton( + icon: const Icon(Icons.remove), + onPressed: widget.readOnly || _age <= 18 + ? null + : () => setState(() => _age--), + ), + Expanded( + child: Text( + '$_age years', + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.headlineMedium, + ), + ), + IconButton( + icon: const Icon(Icons.add), + onPressed: widget.readOnly || _age >= 100 + ? null + : () => setState(() => _age++), + ), + ], + ), + ); + } + + Widget _buildSexSelector() { + return Row( + children: [ + Expanded( + child: _buildToggleButton( + 'Male', + _sex == Sex.male, + widget.readOnly ? null : () => setState(() => _sex = Sex.male), + ), + ), + const SizedBox(width: 12), + Expanded( + child: _buildToggleButton( + 'Female', + _sex == Sex.female, + widget.readOnly ? null : () => setState(() => _sex = Sex.female), + ), + ), + ], + ); + } + + Widget _buildToggleButton(String label, bool selected, VoidCallback? onTap) { + return GestureDetector( + onTap: onTap, + child: Container( + padding: const EdgeInsets.symmetric(vertical: 14), + decoration: BoxDecoration( + color: selected ? AppColors.primary : AppColors.surfaceVariant, + borderRadius: BorderRadius.circular(12), + ), + child: Text( + label, + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: selected ? Colors.white : AppColors.textSecondary, + ), + ), + ), + ); + } + + Widget _buildCountryDropdown() { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 16), + decoration: BoxDecoration( + color: AppColors.surfaceVariant, + borderRadius: BorderRadius.circular(12), + ), + child: DropdownButtonHideUnderline( + child: DropdownButton( + value: _country, + isExpanded: true, + icon: const Icon(Icons.keyboard_arrow_down), + items: _countries.map((country) { + return DropdownMenuItem( + value: country, + child: Text(country), + ); + }).toList(), + onChanged: widget.readOnly + ? null + : (value) { + if (value != null) setState(() => _country = value); + }, + ), + ), + ); + } + + Widget _buildHeightSlider() { + final primaryText = _useMetric + ? '${_heightCm.round()} cm' + : _cmToFeetInches(_heightCm); + final secondaryText = _useMetric + ? _cmToFeetInches(_heightCm) + : '${_heightCm.round()} cm'; + + return Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + primaryText, + style: Theme.of(context).textTheme.headlineMedium, + ), + Text( + secondaryText, + style: Theme.of(context).textTheme.bodyMedium, + ), + ], + ), + Slider( + value: _heightCm, + min: 120, + max: 220, + divisions: 100, + onChanged: widget.readOnly + ? null + : (value) => setState(() => _heightCm = value), + ), + ], + ); + } + + Widget _buildWeightSlider() { + final lbs = (_weightKg * 2.205).round(); + final primaryText = _useMetric ? '${_weightKg.round()} kg' : '$lbs lbs'; + final secondaryText = _useMetric ? '$lbs lbs' : '${_weightKg.round()} kg'; + + return Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + primaryText, + style: Theme.of(context).textTheme.headlineMedium, + ), + Text( + secondaryText, + style: Theme.of(context).textTheme.bodyMedium, + ), + ], + ), + Slider( + value: _weightKg, + min: 30, + max: 200, + divisions: 170, + onChanged: widget.readOnly + ? null + : (value) => setState(() => _weightKg = value), + ), + ], + ); + } + + Widget _buildBmiDisplay() { + return Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: AppColors.surfaceVariant, + borderRadius: BorderRadius.circular(12), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'BMI', + style: Theme.of(context).textTheme.bodyMedium, + ), + Text( + _bmi.toStringAsFixed(1), + style: Theme.of(context).textTheme.headlineMedium, + ), + ], + ), + Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), + decoration: BoxDecoration( + color: _getBmiColor(), + borderRadius: BorderRadius.circular(8), + ), + child: Text( + _bmiCategory, + style: const TextStyle( + color: Colors.white, + fontWeight: FontWeight.w600, + ), + ), + ), + ], + ), + ); + } + + Color _getBmiColor() { + if (_bmi < 18.5 || _bmi >= 30) return AppColors.warning; + if (_bmi >= 25) return AppColors.primary; + return AppColors.success; + } + + Widget _buildDiagnosisCheckboxes() { + return Column( + children: Diagnosis.values.map((diagnosis) { + return CheckboxListTile( + value: _diagnoses.contains(diagnosis), + onChanged: widget.readOnly + ? null + : (checked) { + setState(() { + if (checked == true) { + _diagnoses.add(diagnosis); + } else { + _diagnoses.remove(diagnosis); + } + }); + }, + title: Text(_getDiagnosisLabel(diagnosis)), + controlAffinity: ListTileControlAffinity.leading, + contentPadding: EdgeInsets.zero, + ); + }).toList(), + ); + } + + String _getDiagnosisLabel(Diagnosis diagnosis) { + switch (diagnosis) { + case Diagnosis.cardiovascular: + return 'Cardiovascular disease'; + case Diagnosis.diabetes: + return 'Diabetes'; + case Diagnosis.cancer: + return 'Cancer (active)'; + case Diagnosis.copd: + return 'COPD'; + case Diagnosis.hypertension: + return 'Hypertension'; + } + } + + String _cmToFeetInches(double cm) { + final totalInches = cm / 2.54; + final feet = (totalInches / 12).floor(); + final inches = (totalInches % 12).round(); + return "$feet'$inches\""; + } + + Future _toggleUnits() async { + final newValue = !_useMetric; + await LocalStorage.setUseMetricUnits(newValue); + setState(() => _useMetric = newValue); + } + + void _continue() async { + final profile = UserProfile( + age: _age, + sex: _sex, + country: _country, + heightCm: _heightCm, + weightKg: _weightKg, + diagnoses: _diagnoses, + ); + + await LocalStorage.saveProfile(profile); + + if (mounted) { + Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => BehavioralScreen(profile: profile), + ), + ); + } + } +} diff --git a/lib/screens/behavioral_screen.dart b/lib/screens/behavioral_screen.dart new file mode 100644 index 0000000..b177725 --- /dev/null +++ b/lib/screens/behavioral_screen.dart @@ -0,0 +1,339 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import '../models/models.dart'; +import '../storage/local_storage.dart'; +import '../theme.dart'; +import 'about_screen.dart'; +import 'lifestyle_screen.dart'; + +class BehavioralScreen extends StatefulWidget { + final UserProfile profile; + final bool readOnly; + final BehavioralInputs? initialBehaviors; + + const BehavioralScreen({ + super.key, + required this.profile, + this.readOnly = false, + this.initialBehaviors, + }); + + @override + State createState() => _BehavioralScreenState(); +} + +class _BehavioralScreenState extends State { + SmokingStatus _smoking = SmokingStatus.never; + int _cigarettesPerDay = 0; + AlcoholLevel _alcohol = AlcoholLevel.none; + double _sleepHours = 7.5; + bool _sleepConsistent = true; + ActivityLevel _activity = ActivityLevel.moderate; + + @override + void initState() { + super.initState(); + _loadInitialData(); + } + + Future _loadInitialData() async { + // If initial behaviors provided, use those + if (widget.initialBehaviors != null) { + _applyBehaviors(widget.initialBehaviors!); + return; + } + + // Otherwise load from storage + final behaviors = await LocalStorage.getBehaviors(); + if (behaviors != null) { + _applyBehaviors(behaviors); + } + } + + void _applyBehaviors(BehavioralInputs behaviors) { + setState(() { + _smoking = behaviors.smoking; + _cigarettesPerDay = behaviors.cigarettesPerDay; + _alcohol = behaviors.alcohol; + _sleepHours = behaviors.sleepHours; + _sleepConsistent = behaviors.sleepConsistent; + _activity = behaviors.activity; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(widget.readOnly ? 'Habits (View Only)' : 'Habits'), + leading: IconButton( + icon: const Icon(Icons.arrow_back), + onPressed: () => Navigator.pop(context), + ), + actions: [ + IconButton( + icon: const Icon(Icons.info_outline), + onPressed: () => Navigator.push( + context, + MaterialPageRoute(builder: (_) => const AboutScreen()), + ), + ), + ], + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Daily Habits', + style: Theme.of(context).textTheme.headlineSmall, + ), + const SizedBox(height: 8), + Text( + 'Substances, sleep, and activity levels.', + style: Theme.of(context).textTheme.bodyMedium, + ), + const SizedBox(height: 32), + + // Smoking + _buildSectionLabel('Smoking'), + const SizedBox(height: 12), + _buildSmokingSelector(), + if (_smoking == SmokingStatus.current) ...[ + const SizedBox(height: 16), + _buildCigarettesSlider(), + ], + const SizedBox(height: 28), + + // Alcohol + _buildSectionLabel('Alcohol'), + const SizedBox(height: 12), + _buildAlcoholSelector(), + const SizedBox(height: 28), + + // Sleep + _buildSectionLabel('Sleep'), + const SizedBox(height: 12), + _buildSleepSlider(), + const SizedBox(height: 12), + _buildSleepConsistentToggle(), + const SizedBox(height: 28), + + // Physical Activity + _buildSectionLabel('Physical Activity'), + const SizedBox(height: 12), + _buildActivitySelector(), + const SizedBox(height: 40), + + // Continue button (hidden in readOnly mode) + if (!widget.readOnly) + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: _continue, + child: const Text('Continue'), + ), + ), + const SizedBox(height: 16), + ], + ), + ), + ); + } + + Widget _buildSectionLabel(String label) { + return Text( + label, + style: Theme.of(context).textTheme.labelLarge, + ); + } + + Widget _buildSmokingSelector() { + return _buildSegmentedControl( + value: _smoking, + options: [ + (SmokingStatus.never, 'Never'), + (SmokingStatus.former, 'Former'), + (SmokingStatus.current, 'Current'), + ], + onChanged: widget.readOnly ? null : (value) => setState(() => _smoking = value), + ); + } + + Widget _buildCigarettesSlider() { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Cigarettes per day', + style: Theme.of(context).textTheme.bodyMedium, + ), + const SizedBox(height: 8), + Row( + children: [ + Expanded( + child: Slider( + value: _cigarettesPerDay.toDouble(), + min: 1, + max: 40, + divisions: 39, + onChanged: widget.readOnly + ? null + : (value) { + if (value.round() == 20 && _cigarettesPerDay != 20) { + HapticFeedback.mediumImpact(); + } + setState(() => _cigarettesPerDay = value.round()); + }, + ), + ), + SizedBox( + width: 50, + child: Text( + '$_cigarettesPerDay', + style: Theme.of(context).textTheme.headlineMedium, + textAlign: TextAlign.center, + ), + ), + ], + ), + Text( + _cigarettesPerDay <= 20 + ? '${(_cigarettesPerDay / 20).toStringAsFixed(1)} pack/day' + : '${(_cigarettesPerDay / 20).toStringAsFixed(1)} packs/day', + style: Theme.of(context).textTheme.bodySmall, + ), + ], + ); + } + + Widget _buildAlcoholSelector() { + return _buildSegmentedControl( + value: _alcohol, + options: [ + (AlcoholLevel.none, 'None'), + (AlcoholLevel.light, '1-7/wk'), + (AlcoholLevel.moderate, '8-14'), + (AlcoholLevel.heavy, '15-21'), + (AlcoholLevel.veryHeavy, '21+'), + ], + onChanged: widget.readOnly ? null : (value) => setState(() => _alcohol = value), + ); + } + + Widget _buildSleepSlider() { + return Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Average hours per night', + style: Theme.of(context).textTheme.bodyMedium, + ), + Text( + _sleepHours.toStringAsFixed(1), + style: Theme.of(context).textTheme.headlineMedium, + ), + ], + ), + Slider( + value: _sleepHours, + min: 4, + max: 12, + divisions: 16, + onChanged: widget.readOnly + ? null + : (value) => setState(() => _sleepHours = value), + ), + ], + ); + } + + Widget _buildSleepConsistentToggle() { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Consistent schedule', + style: Theme.of(context).textTheme.bodyLarge, + ), + Switch( + value: _sleepConsistent, + onChanged: widget.readOnly + ? null + : (value) => setState(() => _sleepConsistent = value), + ), + ], + ); + } + + Widget _buildActivitySelector() { + return _buildSegmentedControl( + value: _activity, + options: [ + (ActivityLevel.sedentary, 'Sedentary'), + (ActivityLevel.light, 'Light'), + (ActivityLevel.moderate, 'Moderate'), + (ActivityLevel.high, 'High'), + ], + onChanged: widget.readOnly ? null : (value) => setState(() => _activity = value), + ); + } + + Widget _buildSegmentedControl({ + required T value, + required List<(T, String)> options, + required ValueChanged? onChanged, + }) { + return Container( + decoration: BoxDecoration( + color: AppColors.surfaceVariant, + borderRadius: BorderRadius.circular(12), + ), + child: Row( + children: options.map((option) { + final isSelected = value == option.$1; + return Expanded( + child: GestureDetector( + onTap: onChanged == null ? null : () => onChanged(option.$1), + child: Container( + padding: const EdgeInsets.symmetric(vertical: 12), + decoration: BoxDecoration( + color: isSelected ? AppColors.primary : Colors.transparent, + borderRadius: BorderRadius.circular(12), + ), + child: Text( + option.$2, + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 13, + fontWeight: FontWeight.w600, + color: isSelected ? Colors.white : AppColors.textSecondary, + ), + ), + ), + ), + ); + }).toList(), + ), + ); + } + + void _continue() { + Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => LifestyleScreen( + profile: widget.profile, + smoking: _smoking, + cigarettesPerDay: _cigarettesPerDay, + alcohol: _alcohol, + sleepHours: _sleepHours, + sleepConsistent: _sleepConsistent, + activity: _activity, + ), + ), + ); + } +} diff --git a/lib/screens/compare_runs_screen.dart b/lib/screens/compare_runs_screen.dart new file mode 100644 index 0000000..6d0d81e --- /dev/null +++ b/lib/screens/compare_runs_screen.dart @@ -0,0 +1,350 @@ +import 'package:flutter/material.dart'; +import '../models/models.dart'; +import '../storage/local_storage.dart'; +import '../theme.dart'; +import 'about_screen.dart'; + +class CompareRunsScreen extends StatefulWidget { + final SavedRun initialRun; + + const CompareRunsScreen({super.key, required this.initialRun}); + + @override + State createState() => _CompareRunsScreenState(); +} + +class _CompareRunsScreenState extends State { + List _allRuns = []; + SavedRun? _selectedRun; + bool _loading = true; + + @override + void initState() { + super.initState(); + _loadRuns(); + } + + Future _loadRuns() async { + final runs = await LocalStorage.getSavedRuns(); + // Exclude the initial run from selection options + final otherRuns = runs.where((r) => r.id != widget.initialRun.id).toList(); + setState(() { + _allRuns = otherRuns; + _loading = false; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Compare Runs'), + leading: IconButton( + icon: const Icon(Icons.arrow_back), + onPressed: () => Navigator.pop(context), + ), + actions: [ + IconButton( + icon: const Icon(Icons.info_outline), + onPressed: () => Navigator.push( + context, + MaterialPageRoute(builder: (_) => const AboutScreen()), + ), + ), + ], + ), + body: _loading + ? const Center(child: CircularProgressIndicator()) + : _buildContent(), + ); + } + + Widget _buildContent() { + if (_selectedRun == null) { + return _buildRunSelector(); + } + return _buildComparison(); + } + + Widget _buildRunSelector() { + return Padding( + padding: const EdgeInsets.all(24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Select a run to compare with', + style: Theme.of(context).textTheme.headlineSmall, + ), + const SizedBox(height: 8), + Text( + 'Comparing: ${widget.initialRun.label}', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: AppColors.primary, + ), + ), + const SizedBox(height: 24), + Expanded( + child: ListView.builder( + itemCount: _allRuns.length, + itemBuilder: (context, index) { + final run = _allRuns[index]; + return Card( + margin: const EdgeInsets.only(bottom: 12), + child: ListTile( + title: Text(run.label), + subtitle: Text(run.displayDate), + trailing: const Icon(Icons.chevron_right), + onTap: () => setState(() => _selectedRun = run), + ), + ); + }, + ), + ), + ], + ), + ); + } + + Widget _buildComparison() { + final runA = widget.initialRun; + final runB = _selectedRun!; + + return SingleChildScrollView( + padding: const EdgeInsets.all(24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Header with run labels + Row( + children: [ + Expanded( + child: _buildRunHeader(runA, 'Run A'), + ), + const SizedBox(width: 16), + Expanded( + child: _buildRunHeader(runB, 'Run B'), + ), + ], + ), + const SizedBox(height: 24), + + // Dominant factors comparison + Text( + 'Dominant Challenge', + style: Theme.of(context).textTheme.titleMedium, + ), + const SizedBox(height: 12), + _buildDominantComparison(runA, runB), + const SizedBox(height: 24), + + // Profile changes + Text( + 'Profile Changes', + style: Theme.of(context).textTheme.titleMedium, + ), + const SizedBox(height: 12), + _buildProfileComparison(runA.profile, runB.profile), + const SizedBox(height: 32), + + // Change comparison button + Center( + child: TextButton( + onPressed: () => setState(() => _selectedRun = null), + child: const Text('Compare with different run'), + ), + ), + ], + ), + ); + } + + Widget _buildRunHeader(SavedRun run, String tag) { + return Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: AppColors.surfaceVariant, + borderRadius: BorderRadius.circular(12), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + tag, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: AppColors.textSecondary, + ), + ), + const SizedBox(height: 4), + Text( + run.label, + style: Theme.of(context).textTheme.titleSmall, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + Text( + run.displayDate, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: AppColors.textSecondary, + ), + ), + ], + ), + ); + } + + Widget _buildDominantComparison(SavedRun runA, SavedRun runB) { + final dominantA = runA.result.dominantFactor; + final dominantB = runB.result.dominantFactor; + + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: _buildCompactFactorCard(dominantA), + ), + const SizedBox(width: 16), + Expanded( + child: _buildCompactFactorCard(dominantB), + ), + ], + ); + } + + Widget _buildCompactFactorCard(RankedFactor? factor) { + if (factor == null) { + return Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: AppColors.success.withAlpha(26), + borderRadius: BorderRadius.circular(12), + ), + child: Column( + children: [ + const Icon(Icons.check_circle, color: AppColors.success), + const SizedBox(height: 8), + Text( + 'Optimal', + style: Theme.of(context).textTheme.titleSmall?.copyWith( + color: AppColors.success, + ), + ), + ], + ), + ); + } + + return Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: AppColors.primary.withAlpha(26), + borderRadius: BorderRadius.circular(12), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + factor.displayName, + style: Theme.of(context).textTheme.titleSmall, + ), + const SizedBox(height: 4), + Text( + '${factor.delta.rangeDisplay} mo', + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + color: AppColors.primary, + ), + ), + ], + ), + ); + } + + Widget _buildProfileComparison(UserProfile profileA, UserProfile profileB) { + final changes = []; + + if (profileA.age != profileB.age) { + changes.add(_buildChangeRow( + 'Age', + '${profileA.age}', + '${profileB.age}', + )); + } + + if (profileA.weightKg != profileB.weightKg) { + changes.add(_buildChangeRow( + 'Weight', + '${profileA.weightKg.round()} kg', + '${profileB.weightKg.round()} kg', + )); + } + + if (profileA.country != profileB.country) { + changes.add(_buildChangeRow( + 'Country', + profileA.country, + profileB.country, + )); + } + + if (changes.isEmpty) { + return Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: AppColors.surfaceVariant, + borderRadius: BorderRadius.circular(12), + ), + child: Center( + child: Text( + 'No profile changes between runs', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: AppColors.textSecondary, + ), + ), + ), + ); + } + + return Column(children: changes); + } + + Widget _buildChangeRow(String label, String valueA, String valueB) { + return Container( + margin: const EdgeInsets.only(bottom: 8), + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: AppColors.surfaceVariant, + borderRadius: BorderRadius.circular(12), + ), + child: Row( + children: [ + Expanded( + flex: 2, + child: Text( + label, + style: Theme.of(context).textTheme.bodyMedium, + ), + ), + Expanded( + flex: 2, + child: Text( + valueA, + style: Theme.of(context).textTheme.bodyMedium, + textAlign: TextAlign.center, + ), + ), + const Icon(Icons.arrow_forward, size: 16, color: AppColors.textSecondary), + Expanded( + flex: 2, + child: Text( + valueB, + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w600, + ), + textAlign: TextAlign.center, + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/lifestyle_screen.dart b/lib/screens/lifestyle_screen.dart new file mode 100644 index 0000000..9f2ae68 --- /dev/null +++ b/lib/screens/lifestyle_screen.dart @@ -0,0 +1,364 @@ +import 'package:flutter/material.dart'; +import '../models/models.dart'; +import '../storage/local_storage.dart'; +import '../theme.dart'; +import 'about_screen.dart'; +import 'results_screen.dart'; + +class LifestyleScreen extends StatefulWidget { + final UserProfile profile; + final SmokingStatus smoking; + final int cigarettesPerDay; + final AlcoholLevel alcohol; + final double sleepHours; + final bool sleepConsistent; + final ActivityLevel activity; + final bool readOnly; + final BehavioralInputs? initialBehaviors; + + const LifestyleScreen({ + super.key, + required this.profile, + required this.smoking, + required this.cigarettesPerDay, + required this.alcohol, + required this.sleepHours, + required this.sleepConsistent, + required this.activity, + this.readOnly = false, + this.initialBehaviors, + }); + + @override + State createState() => _LifestyleScreenState(); +} + +class _LifestyleScreenState extends State { + DietQuality _diet = DietQuality.fair; + ProcessedFoodLevel _processedFood = ProcessedFoodLevel.frequent; + DrugUse _drugUse = DrugUse.none; + SocialConnection _social = SocialConnection.moderate; + StressLevel _stress = StressLevel.moderate; + DrivingExposure _driving = DrivingExposure.low; + WorkHoursLevel _workHours = WorkHoursLevel.normal; + bool _useMetric = false; + + @override + void initState() { + super.initState(); + _loadInitialData(); + } + + Future _loadInitialData() async { + // Load unit preference + final useMetric = await LocalStorage.getUseMetricUnits(); + setState(() => _useMetric = useMetric); + + // If initial behaviors provided, use those + if (widget.initialBehaviors != null) { + _applyBehaviors(widget.initialBehaviors!); + return; + } + + // Otherwise load from storage + final behaviors = await LocalStorage.getBehaviors(); + if (behaviors != null) { + _applyBehaviors(behaviors); + } + } + + void _applyBehaviors(BehavioralInputs behaviors) { + setState(() { + _diet = behaviors.diet; + _processedFood = behaviors.processedFood; + _drugUse = behaviors.drugUse; + _social = behaviors.social; + _stress = behaviors.stress; + _driving = behaviors.driving; + _workHours = behaviors.workHours; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(widget.readOnly ? 'Lifestyle (View Only)' : 'Lifestyle'), + leading: IconButton( + icon: const Icon(Icons.arrow_back), + onPressed: () => Navigator.pop(context), + ), + actions: [ + IconButton( + icon: const Icon(Icons.info_outline), + onPressed: () => Navigator.push( + context, + MaterialPageRoute(builder: (_) => const AboutScreen()), + ), + ), + ], + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Lifestyle Factors', + style: Theme.of(context).textTheme.headlineSmall, + ), + const SizedBox(height: 8), + Text( + 'Diet, social life, stress, and daily exposures.', + style: Theme.of(context).textTheme.bodyMedium, + ), + const SizedBox(height: 32), + + // Diet Quality + _buildSectionLabel('Diet Quality'), + _buildSectionHint('Vegetables, whole foods, variety'), + const SizedBox(height: 12), + _buildDietSelector(), + const SizedBox(height: 28), + + // Processed Food + _buildSectionLabel('Processed Food'), + _buildSectionHint('Fast food, packaged snacks, sugary drinks'), + const SizedBox(height: 12), + _buildProcessedFoodSelector(), + const SizedBox(height: 28), + + // Drug Use + _buildSectionLabel('Recreational Drugs'), + _buildSectionHint('Cannabis, stimulants, other substances'), + const SizedBox(height: 12), + _buildDrugUseSelector(), + const SizedBox(height: 28), + + // Social Connection + _buildSectionLabel('Social Connection'), + _buildSectionHint('Time with friends, family, community'), + const SizedBox(height: 12), + _buildSocialSelector(), + const SizedBox(height: 28), + + // Stress Level + _buildSectionLabel('Stress Level'), + _buildSectionHint('Work pressure, anxiety, life demands'), + const SizedBox(height: 12), + _buildStressSelector(), + const SizedBox(height: 28), + + // Driving Exposure + _buildSectionLabel(_useMetric ? 'Driving (km/week)' : 'Driving (mi/week)'), + const SizedBox(height: 12), + _buildDrivingSelector(), + const SizedBox(height: 28), + + // Work Hours + _buildSectionLabel('Work Hours'), + const SizedBox(height: 12), + _buildWorkHoursSelector(), + const SizedBox(height: 40), + + // Calculate button (hidden in readOnly mode) + if (!widget.readOnly) + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: _calculate, + child: const Text('Calculate'), + ), + ), + const SizedBox(height: 16), + ], + ), + ), + ); + } + + Widget _buildSectionLabel(String label) { + return Text( + label, + style: Theme.of(context).textTheme.labelLarge, + ); + } + + Widget _buildSectionHint(String hint) { + return Text( + hint, + style: Theme.of(context).textTheme.bodySmall, + ); + } + + Widget _buildDietSelector() { + return _buildSegmentedControl( + value: _diet, + options: [ + (DietQuality.poor, 'Poor'), + (DietQuality.fair, 'Fair'), + (DietQuality.good, 'Good'), + (DietQuality.excellent, 'Excellent'), + ], + onChanged: widget.readOnly ? null : (value) => setState(() => _diet = value), + ); + } + + Widget _buildProcessedFoodSelector() { + return _buildSegmentedControl( + value: _processedFood, + options: [ + (ProcessedFoodLevel.daily, 'Daily'), + (ProcessedFoodLevel.frequent, 'Often'), + (ProcessedFoodLevel.occasional, 'Sometimes'), + (ProcessedFoodLevel.rarely, 'Rarely'), + ], + onChanged: widget.readOnly ? null : (value) => setState(() => _processedFood = value), + ); + } + + Widget _buildDrugUseSelector() { + return _buildSegmentedControl( + value: _drugUse, + options: [ + (DrugUse.none, 'None'), + (DrugUse.occasional, 'Occasional'), + (DrugUse.regular, 'Regular'), + (DrugUse.daily, 'Daily'), + ], + onChanged: widget.readOnly ? null : (value) => setState(() => _drugUse = value), + ); + } + + Widget _buildSocialSelector() { + return _buildSegmentedControl( + value: _social, + options: [ + (SocialConnection.isolated, 'Isolated'), + (SocialConnection.limited, 'Limited'), + (SocialConnection.moderate, 'Moderate'), + (SocialConnection.strong, 'Strong'), + ], + onChanged: widget.readOnly ? null : (value) => setState(() => _social = value), + ); + } + + Widget _buildStressSelector() { + return _buildSegmentedControl( + value: _stress, + options: [ + (StressLevel.low, 'Low'), + (StressLevel.moderate, 'Moderate'), + (StressLevel.high, 'High'), + (StressLevel.chronic, 'Chronic'), + ], + onChanged: widget.readOnly ? null : (value) => setState(() => _stress = value), + ); + } + + Widget _buildDrivingSelector() { + // Show metric (km) or imperial (mi) based on preference + final options = _useMetric + ? [ + (DrivingExposure.low, '<80 km'), + (DrivingExposure.moderate, '80-240'), + (DrivingExposure.high, '240-480'), + (DrivingExposure.veryHigh, '480+'), + ] + : [ + (DrivingExposure.low, '<50 mi'), + (DrivingExposure.moderate, '50-150'), + (DrivingExposure.high, '150-300'), + (DrivingExposure.veryHigh, '300+'), + ]; + + return _buildSegmentedControl( + value: _driving, + options: options, + onChanged: widget.readOnly ? null : (value) => setState(() => _driving = value), + ); + } + + Widget _buildWorkHoursSelector() { + return _buildSegmentedControl( + value: _workHours, + options: [ + (WorkHoursLevel.normal, '<40'), + (WorkHoursLevel.elevated, '40-55'), + (WorkHoursLevel.high, '55-70'), + (WorkHoursLevel.extreme, '70+'), + ], + onChanged: widget.readOnly ? null : (value) => setState(() => _workHours = value), + ); + } + + Widget _buildSegmentedControl({ + required T value, + required List<(T, String)> options, + required ValueChanged? onChanged, + }) { + return Container( + decoration: BoxDecoration( + color: AppColors.surfaceVariant, + borderRadius: BorderRadius.circular(12), + ), + child: Row( + children: options.map((option) { + final isSelected = value == option.$1; + return Expanded( + child: GestureDetector( + onTap: onChanged == null ? null : () => onChanged(option.$1), + child: Container( + padding: const EdgeInsets.symmetric(vertical: 12), + decoration: BoxDecoration( + color: isSelected ? AppColors.primary : Colors.transparent, + borderRadius: BorderRadius.circular(12), + ), + child: Text( + option.$2, + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 13, + fontWeight: FontWeight.w600, + color: isSelected ? Colors.white : AppColors.textSecondary, + ), + ), + ), + ), + ); + }).toList(), + ), + ); + } + + void _calculate() async { + final behaviors = BehavioralInputs( + smoking: widget.smoking, + cigarettesPerDay: widget.cigarettesPerDay, + alcohol: widget.alcohol, + sleepHours: widget.sleepHours, + sleepConsistent: widget.sleepConsistent, + activity: widget.activity, + diet: _diet, + processedFood: _processedFood, + drugUse: _drugUse, + social: _social, + stress: _stress, + driving: _driving, + workHours: _workHours, + ); + + await LocalStorage.saveBehaviors(behaviors); + + if (mounted) { + Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => ResultsScreen( + profile: widget.profile, + behaviors: behaviors, + ), + ), + ); + } + } +} diff --git a/lib/screens/onboarding_screen.dart b/lib/screens/onboarding_screen.dart new file mode 100644 index 0000000..ef422a1 --- /dev/null +++ b/lib/screens/onboarding_screen.dart @@ -0,0 +1,265 @@ +import 'package:flutter/material.dart'; +import '../theme.dart'; +import 'baseline_screen.dart'; + +class OnboardingScreen extends StatefulWidget { + const OnboardingScreen({super.key}); + + @override + State createState() => _OnboardingScreenState(); +} + +class _OnboardingScreenState extends State { + final _controller = PageController(); + int _currentPage = 0; + + final _slides = const [ + _SlideData( + icon: Icons.person_outline, + title: 'Tell us your baseline', + description: 'Age, sex, country, and any existing health conditions.', + ), + _SlideData( + icon: Icons.checklist_outlined, + title: 'Answer a few questions', + description: 'Simple inputs about sleep, activity, and daily habits.', + ), + _SlideData( + icon: Icons.insights_outlined, + title: 'See your biggest lever', + description: 'Discover which single change could add the most months to your life.', + ), + ]; + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SafeArea( + child: Column( + children: [ + // Header + Padding( + padding: const EdgeInsets.fromLTRB(32, 24, 32, 0), + child: Column( + children: [ + Text( + 'Add Months', + style: Theme.of(context).textTheme.headlineMedium?.copyWith( + fontWeight: FontWeight.w700, + ), + ), + const SizedBox(height: 4), + Text( + 'Evidence-based lifespan optimization', + style: Theme.of(context).textTheme.bodyMedium, + ), + ], + ), + ), + const SizedBox(height: 16), + // Progress bar + Padding( + padding: const EdgeInsets.symmetric(horizontal: 32), + child: _buildProgressBar(), + ), + // Slides + Expanded( + child: PageView.builder( + controller: _controller, + itemCount: _slides.length, + onPageChanged: (index) => setState(() => _currentPage = index), + itemBuilder: (context, index) => + _buildSlide(index, _slides[index]), + ), + ), + // Bottom section + Padding( + padding: const EdgeInsets.fromLTRB(32, 0, 32, 32), + child: Column( + children: [ + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: _onButtonPressed, + child: Text(_currentPage == _slides.length - 1 + ? 'Get Started' + : 'Next'), + ), + ), + const SizedBox(height: 12), + if (_currentPage < _slides.length - 1) + TextButton( + onPressed: _skip, + child: Text( + 'Skip', + style: TextStyle(color: AppColors.textTertiary), + ), + ) + else + const SizedBox(height: 40), + ], + ), + ), + ], + ), + ), + ); + } + + Widget _buildProgressBar() { + return Row( + children: List.generate(_slides.length, (index) { + final isCompleted = index < _currentPage; + final isCurrent = index == _currentPage; + return Expanded( + child: Container( + margin: EdgeInsets.only(right: index < _slides.length - 1 ? 8 : 0), + child: Column( + children: [ + // Step number row + Row( + children: [ + Container( + width: 24, + height: 24, + decoration: BoxDecoration( + color: isCompleted || isCurrent + ? AppColors.primary + : AppColors.divider, + shape: BoxShape.circle, + ), + child: Center( + child: isCompleted + ? const Icon(Icons.check, + size: 14, color: Colors.white) + : Text( + '${index + 1}', + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: isCurrent + ? Colors.white + : AppColors.textTertiary, + ), + ), + ), + ), + const SizedBox(width: 8), + Expanded( + child: Container( + height: 3, + decoration: BoxDecoration( + color: isCompleted + ? AppColors.primary + : AppColors.divider, + borderRadius: BorderRadius.circular(2), + ), + ), + ), + ], + ), + ], + ), + ), + ); + }), + ); + } + + Widget _buildSlide(int index, _SlideData slide) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 40), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // Step indicator + Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4), + decoration: BoxDecoration( + color: AppColors.primary.withAlpha(26), + borderRadius: BorderRadius.circular(12), + ), + child: Text( + 'Step ${index + 1} of ${_slides.length}', + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: AppColors.primary, + ), + ), + ), + const SizedBox(height: 32), + // Icon + Container( + width: 100, + height: 100, + decoration: BoxDecoration( + color: AppColors.primary.withAlpha(26), + shape: BoxShape.circle, + ), + child: Icon( + slide.icon, + size: 48, + color: AppColors.primary, + ), + ), + const SizedBox(height: 32), + // Title + Text( + slide.title, + style: Theme.of(context).textTheme.headlineMedium, + textAlign: TextAlign.center, + ), + const SizedBox(height: 12), + // Description + Text( + slide.description, + style: Theme.of(context).textTheme.bodyLarge?.copyWith( + color: AppColors.textSecondary, + ), + textAlign: TextAlign.center, + ), + ], + ), + ); + } + + void _onButtonPressed() { + if (_currentPage < _slides.length - 1) { + _controller.nextPage( + duration: const Duration(milliseconds: 300), + curve: Curves.easeInOut, + ); + } else { + _navigateToBaseline(); + } + } + + void _skip() { + _navigateToBaseline(); + } + + void _navigateToBaseline() { + Navigator.of(context).pushReplacement( + MaterialPageRoute(builder: (_) => const BaselineScreen()), + ); + } +} + +class _SlideData { + final IconData icon; + final String title; + final String description; + + const _SlideData({ + required this.icon, + required this.title, + required this.description, + }); +} diff --git a/lib/screens/results_screen.dart b/lib/screens/results_screen.dart new file mode 100644 index 0000000..d8b0e0d --- /dev/null +++ b/lib/screens/results_screen.dart @@ -0,0 +1,471 @@ +import 'package:flutter/material.dart'; +import '../models/models.dart'; +import '../risk_engine/calculator.dart'; +import '../storage/local_storage.dart'; +import '../theme.dart'; +import 'about_screen.dart'; +import 'baseline_screen.dart'; +import 'onboarding_screen.dart'; +import 'saved_runs_screen.dart'; + +class ResultsScreen extends StatefulWidget { + final UserProfile profile; + final BehavioralInputs behaviors; + + const ResultsScreen({ + super.key, + required this.profile, + required this.behaviors, + }); + + @override + State createState() => _ResultsScreenState(); +} + +class _ResultsScreenState extends State { + late CalculationResult _result; + + @override + void initState() { + super.initState(); + _result = calculateRankedFactors(widget.profile, widget.behaviors); + _saveResult(); + } + + Future _saveResult() async { + await LocalStorage.saveResult(_result); + } + + @override + Widget build(BuildContext context) { + final dominant = _result.dominantFactor; + final secondary = _result.secondaryFactor; + + return Scaffold( + appBar: AppBar( + title: const Text('Results'), + automaticallyImplyLeading: false, + actions: [ + IconButton( + icon: const Icon(Icons.info_outline), + onPressed: () => Navigator.push( + context, + MaterialPageRoute(builder: (_) => const AboutScreen()), + ), + ), + ], + ), + body: SafeArea( + child: SingleChildScrollView( + padding: const EdgeInsets.all(24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (dominant != null) ...[ + // Dominant challenge card + _buildDominantCard(dominant), + const SizedBox(height: 24), + + // Explanation + Text( + 'Addressing this exposure would likely produce the largest increase in expected lifespan among available changes.', + style: Theme.of(context).textTheme.bodyMedium, + ), + const SizedBox(height: 32), + + // Secondary factor + if (secondary != null) ...[ + Text( + 'Secondary Factor', + style: Theme.of(context).textTheme.headlineSmall, + ), + const SizedBox(height: 12), + _buildSecondaryCard(secondary), + const SizedBox(height: 32), + ], + + // All factors + if (_result.rankedFactors.length > 2) ...[ + Text( + 'All Factors', + style: Theme.of(context).textTheme.headlineSmall, + ), + const SizedBox(height: 12), + ..._result.rankedFactors.skip(2).map((factor) { + return Padding( + padding: const EdgeInsets.only(bottom: 8), + child: _buildFactorRow(factor), + ); + }), + const SizedBox(height: 24), + ], + ] else ...[ + // No factors to improve + _buildOptimalCard(), + const SizedBox(height: 24), + ], + + // Model version + Center( + child: Text( + 'Model v${_result.modelVersion}', + style: Theme.of(context).textTheme.bodySmall, + ), + ), + const SizedBox(height: 32), + + // Action buttons + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: _saveRun, + child: const Text('Save Run'), + ), + ), + const SizedBox(height: 12), + SizedBox( + width: double.infinity, + child: OutlinedButton( + onPressed: _recalculate, + child: const Text('Recalculate'), + ), + ), + const SizedBox(height: 12), + Center( + child: TextButton( + onPressed: _viewSavedRuns, + child: const Text('View Saved Runs'), + ), + ), + const SizedBox(height: 24), + SizedBox( + width: double.infinity, + child: OutlinedButton( + onPressed: _showDeleteConfirmation, + style: OutlinedButton.styleFrom( + foregroundColor: AppColors.error, + side: const BorderSide(color: AppColors.error), + ), + child: const Text('Delete All Data'), + ), + ), + const SizedBox(height: 16), + ], + ), + ), + ), + ); + } + + Widget _buildDominantCard(RankedFactor factor) { + return Container( + width: double.infinity, + padding: const EdgeInsets.all(24), + decoration: BoxDecoration( + gradient: const LinearGradient( + colors: [AppColors.primary, AppColors.primaryDark], + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + borderRadius: BorderRadius.circular(20), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'DOMINANT CHALLENGE', + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w700, + color: Colors.white70, + letterSpacing: 1.2, + ), + ), + const SizedBox(height: 12), + Text( + factor.displayName, + style: const TextStyle( + fontSize: 28, + fontWeight: FontWeight.w700, + color: Colors.white, + letterSpacing: -0.5, + ), + ), + const SizedBox(height: 20), + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'ESTIMATED GAIN', + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Colors.white60, + letterSpacing: 0.8, + ), + ), + const SizedBox(height: 4), + Text( + '${factor.delta.rangeDisplay} months', + style: const TextStyle( + fontSize: 24, + fontWeight: FontWeight.w700, + color: Colors.white, + ), + ), + ], + ), + ), + Container( + padding: + const EdgeInsets.symmetric(horizontal: 12, vertical: 6), + decoration: BoxDecoration( + color: Colors.white.withAlpha(51), + borderRadius: BorderRadius.circular(8), + ), + child: Text( + _getConfidenceLabel(factor.delta.confidence), + style: const TextStyle( + fontSize: 13, + fontWeight: FontWeight.w600, + color: Colors.white, + ), + ), + ), + ], + ), + ], + ), + ); + } + + Widget _buildSecondaryCard(RankedFactor factor) { + return Container( + width: double.infinity, + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + color: AppColors.surface, + borderRadius: BorderRadius.circular(16), + border: Border.all(color: AppColors.divider), + ), + child: Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + factor.displayName, + style: Theme.of(context).textTheme.headlineSmall, + ), + const SizedBox(height: 4), + Text( + '${factor.delta.rangeDisplay} months', + style: Theme.of(context).textTheme.bodyLarge?.copyWith( + color: AppColors.primary, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), + _buildConfidenceBadge(factor.delta.confidence), + ], + ), + ); + } + + Widget _buildFactorRow(RankedFactor factor) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + decoration: BoxDecoration( + color: AppColors.surfaceVariant, + borderRadius: BorderRadius.circular(12), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + factor.displayName, + style: Theme.of(context).textTheme.bodyLarge, + ), + Text( + '${factor.delta.rangeDisplay} mo', + style: Theme.of(context).textTheme.bodyLarge?.copyWith( + color: AppColors.primary, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ); + } + + Widget _buildOptimalCard() { + return Container( + width: double.infinity, + padding: const EdgeInsets.all(24), + decoration: BoxDecoration( + color: AppColors.success.withAlpha(26), + borderRadius: BorderRadius.circular(20), + border: Border.all(color: AppColors.success.withAlpha(77)), + ), + child: Column( + children: [ + const Icon( + Icons.check_circle_outline, + size: 48, + color: AppColors.success, + ), + const SizedBox(height: 16), + Text( + 'No significant factors identified', + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + color: AppColors.success, + ), + textAlign: TextAlign.center, + ), + const SizedBox(height: 8), + Text( + 'Your current behaviors are near optimal based on our model.', + style: Theme.of(context).textTheme.bodyMedium, + textAlign: TextAlign.center, + ), + ], + ), + ); + } + + Widget _buildConfidenceBadge(Confidence confidence) { + Color color; + switch (confidence) { + case Confidence.high: + color = AppColors.success; + break; + case Confidence.moderate: + color = AppColors.warning; + break; + case Confidence.emerging: + color = AppColors.textTertiary; + break; + } + + return Container( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), + decoration: BoxDecoration( + color: color.withAlpha(26), + borderRadius: BorderRadius.circular(6), + ), + child: Text( + _getConfidenceLabel(confidence), + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: color, + ), + ), + ); + } + + String _getConfidenceLabel(Confidence confidence) { + switch (confidence) { + case Confidence.high: + return 'High'; + case Confidence.moderate: + return 'Moderate'; + case Confidence.emerging: + return 'Emerging'; + } + } + + void _recalculate() { + Navigator.of(context).pushAndRemoveUntil( + MaterialPageRoute(builder: (_) => const BaselineScreen()), + (route) => false, + ); + } + + void _showDeleteConfirmation() { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Delete All Data'), + content: const Text( + 'This will permanently delete all your data from this device. This action cannot be undone.', + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text('Cancel'), + ), + TextButton( + onPressed: () async { + final navigator = Navigator.of(context); + await LocalStorage.deleteAllData(); + navigator.pushAndRemoveUntil( + MaterialPageRoute(builder: (_) => const OnboardingScreen()), + (route) => false, + ); + }, + style: TextButton.styleFrom(foregroundColor: AppColors.error), + child: const Text('Delete'), + ), + ], + ), + ); + } + + void _saveRun() { + final controller = TextEditingController(); + + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Save Run'), + content: TextField( + controller: controller, + autofocus: true, + decoration: const InputDecoration( + hintText: 'Enter a label for this run', + ), + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text('Cancel'), + ), + TextButton( + onPressed: () async { + final label = controller.text.trim(); + if (label.isNotEmpty) { + final navigator = Navigator.of(context); + final messenger = ScaffoldMessenger.of(context); + await LocalStorage.saveSavedRun( + label: label, + result: _result, + profile: widget.profile, + behaviors: widget.behaviors, + ); + navigator.pop(); + messenger.showSnackBar( + const SnackBar(content: Text('Run saved')), + ); + } + }, + child: const Text('Save'), + ), + ], + ), + ); + } + + void _viewSavedRuns() { + Navigator.push( + context, + MaterialPageRoute(builder: (_) => const SavedRunsScreen()), + ); + } +} diff --git a/lib/screens/saved_run_detail_screen.dart b/lib/screens/saved_run_detail_screen.dart new file mode 100644 index 0000000..7026613 --- /dev/null +++ b/lib/screens/saved_run_detail_screen.dart @@ -0,0 +1,495 @@ +import 'package:flutter/material.dart'; +import '../models/models.dart'; +import '../storage/local_storage.dart'; +import '../theme.dart'; +import 'about_screen.dart'; +import 'baseline_screen.dart'; +import 'compare_runs_screen.dart'; + +class SavedRunDetailScreen extends StatefulWidget { + final SavedRun savedRun; + + const SavedRunDetailScreen({super.key, required this.savedRun}); + + @override + State createState() => _SavedRunDetailScreenState(); +} + +class _SavedRunDetailScreenState extends State { + late SavedRun _savedRun; + int _savedRunsCount = 0; + + @override + void initState() { + super.initState(); + _savedRun = widget.savedRun; + _loadSavedRunsCount(); + } + + Future _loadSavedRunsCount() async { + final count = await LocalStorage.getSavedRunsCount(); + setState(() => _savedRunsCount = count); + } + + @override + Widget build(BuildContext context) { + final result = _savedRun.result; + final dominant = result.dominantFactor; + final secondary = result.secondaryFactor; + + return Scaffold( + appBar: AppBar( + title: const Text('Saved Run'), + leading: IconButton( + icon: const Icon(Icons.arrow_back), + onPressed: () => Navigator.pop(context), + ), + actions: [ + IconButton( + icon: const Icon(Icons.info_outline), + onPressed: () => Navigator.push( + context, + MaterialPageRoute(builder: (_) => const AboutScreen()), + ), + ), + ], + ), + body: SafeArea( + child: SingleChildScrollView( + padding: const EdgeInsets.all(24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Label (editable) + _buildLabelRow(), + const SizedBox(height: 8), + Text( + _savedRun.displayDate, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: AppColors.textSecondary, + ), + ), + const SizedBox(height: 24), + + if (dominant != null) ...[ + // Dominant challenge card + _buildDominantCard(dominant), + const SizedBox(height: 24), + + // Secondary factor + if (secondary != null) ...[ + Text( + 'Secondary Factor', + style: Theme.of(context).textTheme.headlineSmall, + ), + const SizedBox(height: 12), + _buildSecondaryCard(secondary), + const SizedBox(height: 24), + ], + + // All factors + if (result.rankedFactors.length > 2) ...[ + Text( + 'All Factors', + style: Theme.of(context).textTheme.headlineSmall, + ), + const SizedBox(height: 12), + ...result.rankedFactors.skip(2).map((factor) { + return Padding( + padding: const EdgeInsets.only(bottom: 8), + child: _buildFactorRow(factor), + ); + }), + const SizedBox(height: 16), + ], + ] else ...[ + _buildOptimalCard(), + const SizedBox(height: 24), + ], + + // Profile summary + _buildProfileSummary(), + const SizedBox(height: 24), + + // Model version + Center( + child: Text( + 'Model v${result.modelVersion}', + style: Theme.of(context).textTheme.bodySmall, + ), + ), + const SizedBox(height: 32), + + // Action buttons + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: _viewInputs, + child: const Text('View Inputs'), + ), + ), + const SizedBox(height: 12), + SizedBox( + width: double.infinity, + child: OutlinedButton( + onPressed: _useAsStartingPoint, + child: const Text('Use as Starting Point'), + ), + ), + if (_savedRunsCount >= 2) ...[ + const SizedBox(height: 12), + SizedBox( + width: double.infinity, + child: OutlinedButton( + onPressed: _compare, + child: const Text('Compare'), + ), + ), + ], + const SizedBox(height: 16), + ], + ), + ), + ), + ); + } + + Widget _buildLabelRow() { + return Row( + children: [ + Expanded( + child: Text( + _savedRun.label, + style: Theme.of(context).textTheme.headlineMedium, + ), + ), + IconButton( + icon: const Icon(Icons.edit_outlined, size: 20), + onPressed: _editLabel, + ), + ], + ); + } + + Widget _buildDominantCard(RankedFactor factor) { + return Container( + width: double.infinity, + padding: const EdgeInsets.all(24), + decoration: BoxDecoration( + gradient: const LinearGradient( + colors: [AppColors.primary, AppColors.primaryDark], + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + borderRadius: BorderRadius.circular(20), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'DOMINANT CHALLENGE', + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w700, + color: Colors.white70, + letterSpacing: 1.2, + ), + ), + const SizedBox(height: 12), + Text( + factor.displayName, + style: const TextStyle( + fontSize: 28, + fontWeight: FontWeight.w700, + color: Colors.white, + letterSpacing: -0.5, + ), + ), + const SizedBox(height: 20), + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'ESTIMATED GAIN', + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Colors.white60, + letterSpacing: 0.8, + ), + ), + const SizedBox(height: 4), + Text( + '${factor.delta.rangeDisplay} months', + style: const TextStyle( + fontSize: 24, + fontWeight: FontWeight.w700, + color: Colors.white, + ), + ), + ], + ), + ), + Container( + padding: + const EdgeInsets.symmetric(horizontal: 12, vertical: 6), + decoration: BoxDecoration( + color: Colors.white.withAlpha(51), + borderRadius: BorderRadius.circular(8), + ), + child: Text( + _getConfidenceLabel(factor.delta.confidence), + style: const TextStyle( + fontSize: 13, + fontWeight: FontWeight.w600, + color: Colors.white, + ), + ), + ), + ], + ), + ], + ), + ); + } + + Widget _buildSecondaryCard(RankedFactor factor) { + return Container( + width: double.infinity, + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + color: AppColors.surface, + borderRadius: BorderRadius.circular(16), + border: Border.all(color: AppColors.divider), + ), + child: Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + factor.displayName, + style: Theme.of(context).textTheme.headlineSmall, + ), + const SizedBox(height: 4), + Text( + '${factor.delta.rangeDisplay} months', + style: Theme.of(context).textTheme.bodyLarge?.copyWith( + color: AppColors.primary, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), + _buildConfidenceBadge(factor.delta.confidence), + ], + ), + ); + } + + Widget _buildFactorRow(RankedFactor factor) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + decoration: BoxDecoration( + color: AppColors.surfaceVariant, + borderRadius: BorderRadius.circular(12), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + factor.displayName, + style: Theme.of(context).textTheme.bodyLarge, + ), + Text( + '${factor.delta.rangeDisplay} mo', + style: Theme.of(context).textTheme.bodyLarge?.copyWith( + color: AppColors.primary, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ); + } + + Widget _buildOptimalCard() { + return Container( + width: double.infinity, + padding: const EdgeInsets.all(24), + decoration: BoxDecoration( + color: AppColors.success.withAlpha(26), + borderRadius: BorderRadius.circular(20), + border: Border.all(color: AppColors.success.withAlpha(77)), + ), + child: Column( + children: [ + const Icon( + Icons.check_circle_outline, + size: 48, + color: AppColors.success, + ), + const SizedBox(height: 16), + Text( + 'No significant factors identified', + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + color: AppColors.success, + ), + textAlign: TextAlign.center, + ), + const SizedBox(height: 8), + Text( + 'Behaviors were near optimal at this time.', + style: Theme.of(context).textTheme.bodyMedium, + textAlign: TextAlign.center, + ), + ], + ), + ); + } + + Widget _buildProfileSummary() { + final profile = _savedRun.profile; + return Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: AppColors.surfaceVariant, + borderRadius: BorderRadius.circular(12), + ), + child: Row( + children: [ + const Icon(Icons.person_outline, color: AppColors.textSecondary), + const SizedBox(width: 12), + Expanded( + child: Text( + '${profile.age} years old, ${profile.sex.name}, ${profile.country}', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: AppColors.textSecondary, + ), + ), + ), + ], + ), + ); + } + + Widget _buildConfidenceBadge(Confidence confidence) { + Color color; + switch (confidence) { + case Confidence.high: + color = AppColors.success; + break; + case Confidence.moderate: + color = AppColors.warning; + break; + case Confidence.emerging: + color = AppColors.textTertiary; + break; + } + + return Container( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), + decoration: BoxDecoration( + color: color.withAlpha(26), + borderRadius: BorderRadius.circular(6), + ), + child: Text( + _getConfidenceLabel(confidence), + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: color, + ), + ), + ); + } + + String _getConfidenceLabel(Confidence confidence) { + switch (confidence) { + case Confidence.high: + return 'High'; + case Confidence.moderate: + return 'Moderate'; + case Confidence.emerging: + return 'Emerging'; + } + } + + void _editLabel() { + final controller = TextEditingController(text: _savedRun.label); + + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Edit Label'), + content: TextField( + controller: controller, + autofocus: true, + decoration: const InputDecoration( + hintText: 'Enter a label', + ), + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text('Cancel'), + ), + TextButton( + onPressed: () async { + final newLabel = controller.text.trim(); + final navigator = Navigator.of(context); + if (newLabel.isNotEmpty) { + await LocalStorage.updateSavedRunLabel(_savedRun.id, newLabel); + setState(() { + _savedRun = _savedRun.copyWith(label: newLabel); + }); + } + navigator.pop(); + }, + child: const Text('Save'), + ), + ], + ), + ); + } + + void _viewInputs() { + // Navigate to read-only baseline screen with saved data + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => BaselineScreen( + readOnly: true, + initialProfile: _savedRun.profile, + ), + ), + ); + } + + void _useAsStartingPoint() { + // Navigate to editable baseline screen with saved data pre-filled + Navigator.pushAndRemoveUntil( + context, + MaterialPageRoute( + builder: (_) => BaselineScreen( + initialProfile: _savedRun.profile, + ), + ), + (route) => false, + ); + } + + void _compare() { + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => CompareRunsScreen(initialRun: _savedRun), + ), + ); + } +} diff --git a/lib/screens/saved_runs_screen.dart b/lib/screens/saved_runs_screen.dart new file mode 100644 index 0000000..83e5584 --- /dev/null +++ b/lib/screens/saved_runs_screen.dart @@ -0,0 +1,196 @@ +import 'package:flutter/material.dart'; +import '../models/models.dart'; +import '../storage/local_storage.dart'; +import '../theme.dart'; +import 'about_screen.dart'; +import 'saved_run_detail_screen.dart'; + +class SavedRunsScreen extends StatefulWidget { + const SavedRunsScreen({super.key}); + + @override + State createState() => _SavedRunsScreenState(); +} + +class _SavedRunsScreenState extends State { + List _savedRuns = []; + bool _loading = true; + + @override + void initState() { + super.initState(); + _loadSavedRuns(); + } + + Future _loadSavedRuns() async { + final runs = await LocalStorage.getSavedRuns(); + setState(() { + _savedRuns = runs; + _loading = false; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Saved Runs'), + leading: IconButton( + icon: const Icon(Icons.arrow_back), + onPressed: () => Navigator.pop(context), + ), + actions: [ + IconButton( + icon: const Icon(Icons.info_outline), + onPressed: () => Navigator.push( + context, + MaterialPageRoute(builder: (_) => const AboutScreen()), + ), + ), + ], + ), + body: _loading + ? const Center(child: CircularProgressIndicator()) + : _savedRuns.isEmpty + ? _buildEmptyState() + : _buildRunsList(), + ); + } + + Widget _buildEmptyState() { + return Center( + child: Padding( + padding: const EdgeInsets.all(32), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.bookmark_outline, + size: 64, + color: AppColors.textSecondary.withAlpha(128), + ), + const SizedBox(height: 16), + Text( + 'No saved runs yet', + style: Theme.of(context).textTheme.titleMedium?.copyWith( + color: AppColors.textSecondary, + ), + ), + const SizedBox(height: 8), + Text( + 'Save a calculation from the results screen to compare runs over time.', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: AppColors.textSecondary, + ), + textAlign: TextAlign.center, + ), + ], + ), + ), + ); + } + + Widget _buildRunsList() { + return ListView.builder( + padding: const EdgeInsets.all(16), + itemCount: _savedRuns.length, + itemBuilder: (context, index) { + final run = _savedRuns[index]; + return _buildRunCard(run); + }, + ); + } + + Widget _buildRunCard(SavedRun run) { + return Card( + margin: const EdgeInsets.only(bottom: 12), + child: InkWell( + onTap: () => _openRunDetail(run), + borderRadius: BorderRadius.circular(12), + child: Padding( + padding: const EdgeInsets.all(16), + child: Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + run.label, + style: Theme.of(context).textTheme.titleMedium, + ), + const SizedBox(height: 4), + Text( + run.displayDate, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: AppColors.textSecondary, + ), + ), + const SizedBox(height: 8), + Text( + run.dominantFactorSummary, + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: AppColors.primary, + ), + ), + ], + ), + ), + IconButton( + icon: const Icon(Icons.delete_outline), + color: AppColors.error, + onPressed: () => _confirmDelete(run), + ), + ], + ), + ), + ), + ); + } + + void _openRunDetail(SavedRun run) async { + await Navigator.push( + context, + MaterialPageRoute( + builder: (_) => SavedRunDetailScreen(savedRun: run), + ), + ); + // Refresh list in case label was edited + _loadSavedRuns(); + } + + void _confirmDelete(SavedRun run) { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Delete Run?'), + content: Text('Delete "${run.label}"? This cannot be undone.'), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text('Cancel'), + ), + TextButton( + onPressed: () { + Navigator.pop(context); + _deleteRun(run); + }, + style: TextButton.styleFrom(foregroundColor: AppColors.error), + child: const Text('Delete'), + ), + ], + ), + ); + } + + Future _deleteRun(SavedRun run) async { + await LocalStorage.deleteSavedRun(run.id); + _loadSavedRuns(); + + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Run deleted')), + ); + } + } +} diff --git a/lib/screens/screens.dart b/lib/screens/screens.dart new file mode 100644 index 0000000..def862a --- /dev/null +++ b/lib/screens/screens.dart @@ -0,0 +1,10 @@ +export 'about_screen.dart'; +export 'baseline_screen.dart'; +export 'behavioral_screen.dart'; +export 'compare_runs_screen.dart'; +export 'lifestyle_screen.dart'; +export 'onboarding_screen.dart'; +export 'results_screen.dart'; +export 'saved_run_detail_screen.dart'; +export 'saved_runs_screen.dart'; +export 'welcome_screen.dart'; diff --git a/lib/screens/welcome_screen.dart b/lib/screens/welcome_screen.dart new file mode 100644 index 0000000..6e90a64 --- /dev/null +++ b/lib/screens/welcome_screen.dart @@ -0,0 +1,85 @@ +import 'package:flutter/material.dart'; +import '../theme.dart'; +import 'about_screen.dart'; +import 'baseline_screen.dart'; + +class WelcomeScreen extends StatelessWidget { + const WelcomeScreen({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SafeArea( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 32), + child: Column( + children: [ + const Spacer(flex: 1), + // Main question - large and centered + Text( + 'Simple questions.\nHonest answers.', + style: Theme.of(context).textTheme.headlineLarge?.copyWith( + fontSize: 32, + height: 1.3, + ), + textAlign: TextAlign.center, + ), + const SizedBox(height: 40), + Text( + "What's the single biggest change I can make to live a longer, healthier life?", + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + fontWeight: FontWeight.w400, + color: AppColors.textSecondary, + height: 1.4, + ), + textAlign: TextAlign.center, + ), + const Spacer(flex: 2), + // Privacy note + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.lock_outline, + size: 16, + color: AppColors.textSecondary, + ), + const SizedBox(width: 8), + Text( + 'All data stays on your device', + style: Theme.of(context).textTheme.bodySmall, + ), + ], + ), + const SizedBox(height: 24), + // Start button + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: () => _navigateToBaseline(context), + child: const Text('Start'), + ), + ), + const SizedBox(height: 16), + // About link + TextButton( + onPressed: () => Navigator.push( + context, + MaterialPageRoute(builder: (_) => const AboutScreen()), + ), + child: const Text('About'), + ), + const SizedBox(height: 16), + ], + ), + ), + ), + ); + } + + void _navigateToBaseline(BuildContext context) { + Navigator.of(context).push( + MaterialPageRoute(builder: (_) => const BaselineScreen()), + ); + } +} diff --git a/lib/storage/local_storage.dart b/lib/storage/local_storage.dart new file mode 100644 index 0000000..100bd73 --- /dev/null +++ b/lib/storage/local_storage.dart @@ -0,0 +1,273 @@ +import 'dart:convert'; +import 'package:sqflite/sqflite.dart'; +import 'package:path/path.dart'; +import 'package:uuid/uuid.dart'; +import '../models/models.dart'; + +class LocalStorage { + static const _dbName = 'add_months.db'; + static const _tableName = 'user_data'; + static const _savedRunsTable = 'saved_runs'; + static const _version = 2; + + static Database? _database; + static const _uuid = Uuid(); + + static Future get database async { + if (_database != null) return _database!; + _database = await _initDatabase(); + return _database!; + } + + static Future _initDatabase() async { + final dbPath = await getDatabasesPath(); + final path = join(dbPath, _dbName); + + return await openDatabase( + path, + version: _version, + onCreate: (db, version) async { + await db.execute(''' + CREATE TABLE $_tableName ( + key TEXT PRIMARY KEY, + value TEXT NOT NULL, + updated_at INTEGER NOT NULL + ) + '''); + await db.execute(''' + CREATE TABLE $_savedRunsTable ( + id TEXT PRIMARY KEY, + label TEXT NOT NULL, + result TEXT NOT NULL, + profile TEXT NOT NULL, + behaviors TEXT NOT NULL, + created_at INTEGER NOT NULL + ) + '''); + }, + onUpgrade: (db, oldVersion, newVersion) async { + if (oldVersion < 2) { + await db.execute(''' + CREATE TABLE $_savedRunsTable ( + id TEXT PRIMARY KEY, + label TEXT NOT NULL, + result TEXT NOT NULL, + profile TEXT NOT NULL, + behaviors TEXT NOT NULL, + created_at INTEGER NOT NULL + ) + '''); + } + }, + ); + } + + // Generic key-value operations + static Future _put(String key, Map value) async { + final db = await database; + await db.insert( + _tableName, + { + 'key': key, + 'value': jsonEncode(value), + 'updated_at': DateTime.now().millisecondsSinceEpoch, + }, + conflictAlgorithm: ConflictAlgorithm.replace, + ); + } + + static Future?> _get(String key) async { + final db = await database; + final results = await db.query( + _tableName, + where: 'key = ?', + whereArgs: [key], + ); + + if (results.isEmpty) return null; + return jsonDecode(results.first['value'] as String) as Map; + } + + // Profile operations + static Future saveProfile(UserProfile profile) async { + await _put('profile', profile.toJson()); + } + + static Future getProfile() async { + final json = await _get('profile'); + if (json == null) return null; + return UserProfile.fromJson(json); + } + + // Behavioral inputs operations + static Future saveBehaviors(BehavioralInputs behaviors) async { + await _put('behaviors', behaviors.toJson()); + } + + static Future getBehaviors() async { + final json = await _get('behaviors'); + if (json == null) return null; + return BehavioralInputs.fromJson(json); + } + + // Result operations + static Future saveResult(CalculationResult result) async { + await _put('lastResult', result.toJson()); + } + + static Future getLastResult() async { + final json = await _get('lastResult'); + if (json == null) return null; + return CalculationResult.fromJson(json); + } + + // Check if user has completed setup + static Future hasCompletedSetup() async { + final profile = await getProfile(); + final behaviors = await getBehaviors(); + return profile != null && behaviors != null; + } + + // Delete all data (including saved runs) + static Future deleteAllData() async { + final db = await database; + await db.delete(_tableName); + await db.delete(_savedRunsTable); + } + + // Get last updated timestamp + static Future getLastUpdated() async { + final db = await database; + final results = await db.query( + _tableName, + columns: ['updated_at'], + orderBy: 'updated_at DESC', + limit: 1, + ); + + if (results.isEmpty) return null; + return DateTime.fromMillisecondsSinceEpoch( + results.first['updated_at'] as int, + ); + } + + // ============================================ + // Saved Runs operations + // ============================================ + + static Future saveSavedRun({ + required String label, + required CalculationResult result, + required UserProfile profile, + required BehavioralInputs behaviors, + }) async { + final db = await database; + final id = _uuid.v4(); + final now = DateTime.now(); + + await db.insert(_savedRunsTable, { + 'id': id, + 'label': label, + 'result': jsonEncode(result.toJson()), + 'profile': jsonEncode(profile.toJson()), + 'behaviors': jsonEncode(behaviors.toJson()), + 'created_at': now.millisecondsSinceEpoch, + }); + + return id; + } + + static Future> getSavedRuns() async { + final db = await database; + final results = await db.query( + _savedRunsTable, + orderBy: 'created_at DESC', + ); + + return results.map((row) => SavedRun( + id: row['id'] as String, + label: row['label'] as String, + result: CalculationResult.fromJson( + jsonDecode(row['result'] as String) as Map, + ), + profile: UserProfile.fromJson( + jsonDecode(row['profile'] as String) as Map, + ), + behaviors: BehavioralInputs.fromJson( + jsonDecode(row['behaviors'] as String) as Map, + ), + createdAt: DateTime.fromMillisecondsSinceEpoch(row['created_at'] as int), + )).toList(); + } + + static Future getSavedRun(String id) async { + final db = await database; + final results = await db.query( + _savedRunsTable, + where: 'id = ?', + whereArgs: [id], + ); + + if (results.isEmpty) return null; + + final row = results.first; + return SavedRun( + id: row['id'] as String, + label: row['label'] as String, + result: CalculationResult.fromJson( + jsonDecode(row['result'] as String) as Map, + ), + profile: UserProfile.fromJson( + jsonDecode(row['profile'] as String) as Map, + ), + behaviors: BehavioralInputs.fromJson( + jsonDecode(row['behaviors'] as String) as Map, + ), + createdAt: DateTime.fromMillisecondsSinceEpoch(row['created_at'] as int), + ); + } + + static Future updateSavedRunLabel(String id, String newLabel) async { + final db = await database; + await db.update( + _savedRunsTable, + {'label': newLabel}, + where: 'id = ?', + whereArgs: [id], + ); + } + + static Future deleteSavedRun(String id) async { + final db = await database; + await db.delete( + _savedRunsTable, + where: 'id = ?', + whereArgs: [id], + ); + } + + static Future deleteAllSavedRuns() async { + final db = await database; + await db.delete(_savedRunsTable); + } + + static Future getSavedRunsCount() async { + final db = await database; + final result = await db.rawQuery('SELECT COUNT(*) as count FROM $_savedRunsTable'); + return result.first['count'] as int; + } + + // ============================================ + // Unit preference operations + // ============================================ + + static Future setUseMetricUnits(bool useMetric) async { + await _put('useMetricUnits', {'value': useMetric}); + } + + static Future getUseMetricUnits() async { + final json = await _get('useMetricUnits'); + if (json == null) return false; // Default to imperial (US) + return json['value'] as bool; + } +} diff --git a/lib/theme.dart b/lib/theme.dart new file mode 100644 index 0000000..13231e8 --- /dev/null +++ b/lib/theme.dart @@ -0,0 +1,153 @@ +import 'package:flutter/material.dart'; + +/// Muted clinical color palette. +class AppColors { + static const primary = Color(0xFF4A90A4); // Muted teal + static const primaryDark = Color(0xFF2D6073); + static const primaryLight = Color(0xFF7BB8CC); + + static const surface = Color(0xFFF8FAFB); + static const surfaceVariant = Color(0xFFEEF2F4); + static const background = Color(0xFFFFFFFF); + + static const textPrimary = Color(0xFF1A2B33); + static const textSecondary = Color(0xFF5A6B73); + static const textTertiary = Color(0xFF8A9BA3); + + static const success = Color(0xFF4A9A7C); + static const warning = Color(0xFFB8934A); + static const error = Color(0xFFA45A5A); + + static const divider = Color(0xFFDDE4E8); +} + +/// App-wide theme. +ThemeData buildAppTheme() { + return ThemeData( + useMaterial3: true, + colorScheme: ColorScheme.light( + primary: AppColors.primary, + onPrimary: Colors.white, + secondary: AppColors.primaryLight, + surface: AppColors.surface, + onSurface: AppColors.textPrimary, + ), + scaffoldBackgroundColor: AppColors.background, + appBarTheme: const AppBarTheme( + backgroundColor: AppColors.background, + foregroundColor: AppColors.textPrimary, + elevation: 0, + centerTitle: true, + titleTextStyle: TextStyle( + fontFamily: 'SF Pro Display', + fontSize: 17, + fontWeight: FontWeight.w600, + color: AppColors.textPrimary, + letterSpacing: -0.3, + ), + ), + textTheme: const TextTheme( + headlineLarge: TextStyle( + fontSize: 28, + fontWeight: FontWeight.w600, + color: AppColors.textPrimary, + letterSpacing: -0.5, + height: 1.2, + ), + headlineMedium: TextStyle( + fontSize: 22, + fontWeight: FontWeight.w600, + color: AppColors.textPrimary, + letterSpacing: -0.3, + height: 1.3, + ), + headlineSmall: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w600, + color: AppColors.textPrimary, + letterSpacing: -0.2, + ), + bodyLarge: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w400, + color: AppColors.textPrimary, + height: 1.5, + ), + bodyMedium: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w400, + color: AppColors.textSecondary, + height: 1.5, + ), + bodySmall: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w400, + color: AppColors.textTertiary, + height: 1.4, + ), + labelLarge: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: AppColors.textPrimary, + letterSpacing: 0.1, + ), + ), + elevatedButtonTheme: ElevatedButtonThemeData( + style: ElevatedButton.styleFrom( + backgroundColor: AppColors.primary, + foregroundColor: Colors.white, + elevation: 0, + padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 16), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + textStyle: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + letterSpacing: 0.2, + ), + ), + ), + outlinedButtonTheme: OutlinedButtonThemeData( + style: OutlinedButton.styleFrom( + foregroundColor: AppColors.primary, + side: const BorderSide(color: AppColors.primary, width: 1.5), + padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 16), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + textStyle: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + letterSpacing: 0.2, + ), + ), + ), + inputDecorationTheme: InputDecorationTheme( + filled: true, + fillColor: AppColors.surfaceVariant, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide.none, + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: const BorderSide(color: AppColors.primary, width: 2), + ), + contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14), + labelStyle: const TextStyle(color: AppColors.textSecondary), + ), + dividerTheme: const DividerThemeData( + color: AppColors.divider, + thickness: 1, + ), + cardTheme: CardThemeData( + color: AppColors.surface, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + side: const BorderSide(color: AppColors.divider, width: 1), + ), + ), + ); +} diff --git a/linux/.gitignore b/linux/.gitignore new file mode 100644 index 0000000..d3896c9 --- /dev/null +++ b/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt new file mode 100644 index 0000000..d5ba186 --- /dev/null +++ b/linux/CMakeLists.txt @@ -0,0 +1,128 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.13) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "add_months") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "com.payfrit.add_months") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/linux/flutter/CMakeLists.txt b/linux/flutter/CMakeLists.txt new file mode 100644 index 0000000..d5bd016 --- /dev/null +++ b/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..d0e7f79 --- /dev/null +++ b/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include + +void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin"); + flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar); +} diff --git a/linux/flutter/generated_plugin_registrant.h b/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..e0f0a47 --- /dev/null +++ b/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake new file mode 100644 index 0000000..b29e9ba --- /dev/null +++ b/linux/flutter/generated_plugins.cmake @@ -0,0 +1,24 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + flutter_secure_storage_linux +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/linux/runner/CMakeLists.txt b/linux/runner/CMakeLists.txt new file mode 100644 index 0000000..e97dabc --- /dev/null +++ b/linux/runner/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.13) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the application ID. +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") diff --git a/linux/runner/main.cc b/linux/runner/main.cc new file mode 100644 index 0000000..e7c5c54 --- /dev/null +++ b/linux/runner/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/linux/runner/my_application.cc b/linux/runner/my_application.cc new file mode 100644 index 0000000..5061eab --- /dev/null +++ b/linux/runner/my_application.cc @@ -0,0 +1,148 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Called when first Flutter frame received. +static void first_frame_cb(MyApplication* self, FlView* view) { + gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view))); +} + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "add_months"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "add_months"); + } + + gtk_window_set_default_size(window, 1280, 720); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments( + project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + GdkRGBA background_color; + // Background defaults to black, override it here if necessary, e.g. #00000000 + // for transparent. + gdk_rgba_parse(&background_color, "#000000"); + fl_view_set_background_color(view, &background_color); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + // Show the window when Flutter renders. + // Requires the view to be realized so we can start rendering. + g_signal_connect_swapped(view, "first-frame", G_CALLBACK(first_frame_cb), + self); + gtk_widget_realize(GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, + gchar*** arguments, + int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GApplication::startup. +static void my_application_startup(GApplication* application) { + // MyApplication* self = MY_APPLICATION(object); + + // Perform any actions required at application startup. + + G_APPLICATION_CLASS(my_application_parent_class)->startup(application); +} + +// Implements GApplication::shutdown. +static void my_application_shutdown(GApplication* application) { + // MyApplication* self = MY_APPLICATION(object); + + // Perform any actions required at application shutdown. + + G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = + my_application_local_command_line; + G_APPLICATION_CLASS(klass)->startup = my_application_startup; + G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + // Set the program name to the application ID, which helps various systems + // like GTK and desktop environments map this running application to its + // corresponding .desktop file. This ensures better integration by allowing + // the application to be recognized beyond its binary name. + g_set_prgname(APPLICATION_ID); + + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, "flags", + G_APPLICATION_NON_UNIQUE, nullptr)); +} diff --git a/linux/runner/my_application.h b/linux/runner/my_application.h new file mode 100644 index 0000000..db16367 --- /dev/null +++ b/linux/runner/my_application.h @@ -0,0 +1,21 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, + my_application, + MY, + APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/macos/.gitignore b/macos/.gitignore new file mode 100644 index 0000000..746adbb --- /dev/null +++ b/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/macos/Flutter/Flutter-Debug.xcconfig b/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 0000000..c2efd0b --- /dev/null +++ b/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/Flutter-Release.xcconfig b/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 0000000..c2efd0b --- /dev/null +++ b/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 0000000..8419574 --- /dev/null +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,14 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import flutter_secure_storage_macos +import sqflite_darwin + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin")) + SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) +} diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..a711d7a --- /dev/null +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,705 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC10EC2044A3C60003C045; + remoteInfo = Runner; + }; + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* add_months.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "add_months.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 331C80D2294CF70F00263BE5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C80D6294CF71000263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C80D7294CF71000263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 331C80D6294CF71000263BE5 /* RunnerTests */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* add_months.app */, + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C80D4294CF70F00263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C80D1294CF70F00263BE5 /* Sources */, + 331C80D2294CF70F00263BE5 /* Frameworks */, + 331C80D3294CF70F00263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C80DA294CF71000263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* add_months.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C80D4294CF70F00263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 33CC10EC2044A3C60003C045; + }; + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 331C80D4294CF70F00263BE5 /* RunnerTests */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C80D3294CF70F00263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C80D1294CF70F00263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC10EC2044A3C60003C045 /* Runner */; + targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; + }; + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 331C80DB294CF71000263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.payfrit.addMonths.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/add_months.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/add_months"; + }; + name = Debug; + }; + 331C80DC294CF71000263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.payfrit.addMonths.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/add_months.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/add_months"; + }; + name = Release; + }; + 331C80DD294CF71000263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.payfrit.addMonths.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/add_months.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/add_months"; + }; + name = Profile; + }; + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C80DB294CF71000263BE5 /* Debug */, + 331C80DC294CF71000263BE5 /* Release */, + 331C80DD294CF71000263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..a9bba92 --- /dev/null +++ b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macos/Runner.xcworkspace/contents.xcworkspacedata b/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/macos/Runner/AppDelegate.swift b/macos/Runner/AppDelegate.swift new file mode 100644 index 0000000..b3c1761 --- /dev/null +++ b/macos/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import Cocoa +import FlutterMacOS + +@main +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } + + override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { + return true + } +} diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..a2ec33f --- /dev/null +++ b/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 0000000..82b6f9d Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 0000000..13b35eb Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 0000000..0a3f5fa Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 0000000..bdb5722 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 0000000..f083318 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 0000000..326c0e7 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 0000000..2f1632c Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/macos/Runner/Base.lproj/MainMenu.xib b/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 0000000..80e867a --- /dev/null +++ b/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macos/Runner/Configs/AppInfo.xcconfig b/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 0000000..3502871 --- /dev/null +++ b/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = add_months + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.payfrit.addMonths + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2026 com.payfrit. All rights reserved. diff --git a/macos/Runner/Configs/Debug.xcconfig b/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 0000000..36b0fd9 --- /dev/null +++ b/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/macos/Runner/Configs/Release.xcconfig b/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 0000000..dff4f49 --- /dev/null +++ b/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/macos/Runner/Configs/Warnings.xcconfig b/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 0000000..42bcbf4 --- /dev/null +++ b/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/macos/Runner/DebugProfile.entitlements b/macos/Runner/DebugProfile.entitlements new file mode 100644 index 0000000..dddb8a3 --- /dev/null +++ b/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + + diff --git a/macos/Runner/Info.plist b/macos/Runner/Info.plist new file mode 100644 index 0000000..4789daa --- /dev/null +++ b/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/macos/Runner/MainFlutterWindow.swift b/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 0000000..3cc05eb --- /dev/null +++ b/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/macos/Runner/Release.entitlements b/macos/Runner/Release.entitlements new file mode 100644 index 0000000..852fa1a --- /dev/null +++ b/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/macos/RunnerTests/RunnerTests.swift b/macos/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..61f3bd1 --- /dev/null +++ b/macos/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Cocoa +import FlutterMacOS +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..f664e5d --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,666 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + archive: + dependency: transitive + description: + name: archive + sha256: a96e8b390886ee8abb49b7bd3ac8df6f451c621619f52a26e815fdcf568959ff + url: "https://pub.dev" + source: hosted + version: "4.0.9" + args: + dependency: transitive + description: + name: args + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.dev" + source: hosted + version: "2.7.0" + async: + dependency: transitive + description: + name: async + sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + url: "https://pub.dev" + source: hosted + version: "2.13.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + characters: + dependency: transitive + description: + name: characters + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: "959525d3162f249993882720d52b7e0c833978df229be20702b33d48d91de70f" + url: "https://pub.dev" + source: hosted + version: "2.0.4" + cli_util: + dependency: transitive + description: + name: cli_util + sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c + url: "https://pub.dev" + source: hosted + version: "0.4.2" + clock: + dependency: transitive + description: + name: clock + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" + source: hosted + version: "1.1.2" + code_assets: + dependency: transitive + description: + name: code_assets + sha256: "83ccdaa064c980b5596c35dd64a8d3ecc68620174ab9b90b6343b753aa721687" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + collection: + dependency: transitive + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" + source: hosted + version: "1.19.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf + url: "https://pub.dev" + source: hosted + version: "3.0.7" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + url: "https://pub.dev" + source: hosted + version: "1.0.8" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + url: "https://pub.dev" + source: hosted + version: "1.3.3" + ffi: + dependency: transitive + description: + name: ffi + sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + file: + dependency: transitive + description: + name: file + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 + url: "https://pub.dev" + source: hosted + version: "7.0.1" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.dev" + source: hosted + version: "1.1.1" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_launcher_icons: + dependency: "direct dev" + description: + name: flutter_launcher_icons + sha256: "10f13781741a2e3972126fae08393d3c4e01fa4cd7473326b94b72cf594195e7" + url: "https://pub.dev" + source: hosted + version: "0.14.4" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "3105dc8492f6183fb076ccf1f351ac3d60564bff92e20bfc4af9cc1651f4e7e1" + url: "https://pub.dev" + source: hosted + version: "6.0.0" + flutter_secure_storage: + dependency: "direct main" + description: + name: flutter_secure_storage + sha256: "9cad52d75ebc511adfae3d447d5d13da15a55a92c9410e50f67335b6d21d16ea" + url: "https://pub.dev" + source: hosted + version: "9.2.4" + flutter_secure_storage_linux: + dependency: transitive + description: + name: flutter_secure_storage_linux + sha256: be76c1d24a97d0b98f8b54bce6b481a380a6590df992d0098f868ad54dc8f688 + url: "https://pub.dev" + source: hosted + version: "1.2.3" + flutter_secure_storage_macos: + dependency: transitive + description: + name: flutter_secure_storage_macos + sha256: "6c0a2795a2d1de26ae202a0d78527d163f4acbb11cde4c75c670f3a0fc064247" + url: "https://pub.dev" + source: hosted + version: "3.1.3" + flutter_secure_storage_platform_interface: + dependency: transitive + description: + name: flutter_secure_storage_platform_interface + sha256: cf91ad32ce5adef6fba4d736a542baca9daf3beac4db2d04be350b87f69ac4a8 + url: "https://pub.dev" + source: hosted + version: "1.1.2" + flutter_secure_storage_web: + dependency: transitive + description: + name: flutter_secure_storage_web + sha256: f4ebff989b4f07b2656fb16b47852c0aab9fed9b4ec1c70103368337bc1886a9 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + flutter_secure_storage_windows: + dependency: transitive + description: + name: flutter_secure_storage_windows + sha256: b20b07cb5ed4ed74fc567b78a72936203f587eba460af1df11281c9326cd3709 + url: "https://pub.dev" + source: hosted + version: "3.1.2" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + glob: + dependency: transitive + description: + name: glob + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de + url: "https://pub.dev" + source: hosted + version: "2.1.3" + hooks: + dependency: transitive + description: + name: hooks + sha256: "7a08a0d684cb3b8fb604b78455d5d352f502b68079f7b80b831c62220ab0a4f6" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + image: + dependency: transitive + description: + name: image + sha256: f9881ff4998044947ec38d098bc7c8316ae1186fa786eddffdb867b9bc94dfce + url: "https://pub.dev" + source: hosted + version: "4.8.0" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: cb09e7dac6210041fad964ed7fbee004f14258b4eca4040f72d1234062ace4c8 + url: "https://pub.dev" + source: hosted + version: "4.11.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" + url: "https://pub.dev" + source: hosted + version: "11.0.2" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" + url: "https://pub.dev" + source: hosted + version: "3.0.10" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + lints: + dependency: transitive + description: + name: lints + sha256: "12f842a479589fea194fe5c5a3095abc7be0c1f2ddfa9a0e76aed1dbd26a87df" + url: "https://pub.dev" + source: hosted + version: "6.1.0" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + url: "https://pub.dev" + source: hosted + version: "0.12.17" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" + source: hosted + version: "0.11.1" + meta: + dependency: transitive + description: + name: meta + sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" + url: "https://pub.dev" + source: hosted + version: "1.17.0" + native_toolchain_c: + dependency: transitive + description: + name: native_toolchain_c + sha256: "89e83885ba09da5fdf2cdacc8002a712ca238c28b7f717910b34bcd27b0d03ac" + url: "https://pub.dev" + source: hosted + version: "0.17.4" + objective_c: + dependency: transitive + description: + name: objective_c + sha256: "100a1c87616ab6ed41ec263b083c0ef3261ee6cd1dc3b0f35f8ddfa4f996fe52" + url: "https://pub.dev" + source: hosted + version: "9.3.0" + path: + dependency: "direct main" + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + path_provider: + dependency: transitive + description: + name: path_provider + sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" + url: "https://pub.dev" + source: hosted + version: "2.1.5" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: f2c65e21139ce2c3dad46922be8272bb5963516045659e71bb16e151c93b580e + url: "https://pub.dev" + source: hosted + version: "2.2.22" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "2a376b7d6392d80cd3705782d2caa734ca4727776db0b6ec36ef3f1855197699" + url: "https://pub.dev" + source: hosted + version: "2.6.0" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 + url: "https://pub.dev" + source: hosted + version: "2.3.0" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: "91bd59303e9f769f108f8df05e371341b15d59e995e6806aefab827b58336675" + url: "https://pub.dev" + source: hosted + version: "7.0.2" + platform: + dependency: transitive + description: + name: platform + sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" + url: "https://pub.dev" + source: hosted + version: "3.1.6" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + posix: + dependency: transitive + description: + name: posix + sha256: "6323a5b0fa688b6a010df4905a56b00181479e6d10534cecfecede2aa55add61" + url: "https://pub.dev" + source: hosted + version: "6.0.3" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + source_span: + dependency: transitive + description: + name: source_span + sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab" + url: "https://pub.dev" + source: hosted + version: "1.10.2" + sqflite: + dependency: "direct main" + description: + name: sqflite + sha256: e2297b1da52f127bc7a3da11439985d9b536f75070f3325e62ada69a5c585d03 + url: "https://pub.dev" + source: hosted + version: "2.4.2" + sqflite_android: + dependency: transitive + description: + name: sqflite_android + sha256: ecd684501ebc2ae9a83536e8b15731642b9570dc8623e0073d227d0ee2bfea88 + url: "https://pub.dev" + source: hosted + version: "2.4.2+2" + sqflite_common: + dependency: transitive + description: + name: sqflite_common + sha256: "6ef422a4525ecc601db6c0a2233ff448c731307906e92cabc9ba292afaae16a6" + url: "https://pub.dev" + source: hosted + version: "2.5.6" + sqflite_darwin: + dependency: transitive + description: + name: sqflite_darwin + sha256: "279832e5cde3fe99e8571879498c9211f3ca6391b0d818df4e17d9fff5c6ccb3" + url: "https://pub.dev" + source: hosted + version: "2.4.2" + sqflite_platform_interface: + dependency: transitive + description: + name: sqflite_platform_interface + sha256: "8dd4515c7bdcae0a785b0062859336de775e8c65db81ae33dd5445f35be61920" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" + source: hosted + version: "1.12.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" + source: hosted + version: "1.4.1" + synchronized: + dependency: transitive + description: + name: synchronized + sha256: c254ade258ec8282947a0acbbc90b9575b4f19673533ee46f2f6e9b3aeefd7c0 + url: "https://pub.dev" + source: hosted + version: "3.4.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.dev" + source: hosted + version: "1.2.2" + test_api: + dependency: transitive + description: + name: test_api + sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 + url: "https://pub.dev" + source: hosted + version: "0.7.7" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + sha256: f6a7e5c4835bb4e3026a04793a4199ca2d14c739ec378fdfe23fc8075d0439f8 + url: "https://pub.dev" + source: hosted + version: "6.3.2" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "767344bf3063897b5cf0db830e94f904528e6dd50a6dfaf839f0abf509009611" + url: "https://pub.dev" + source: hosted + version: "6.3.28" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: "580fe5dfb51671ae38191d316e027f6b76272b026370708c2d898799750a02b0" + url: "https://pub.dev" + source: hosted + version: "6.4.1" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: d5e14138b3bc193a0f63c10a53c94b91d399df0512b1f29b94a043db7482384a + url: "https://pub.dev" + source: hosted + version: "3.2.2" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: "368adf46f71ad3c21b8f06614adb38346f193f3a59ba8fe9a2fd74133070ba18" + url: "https://pub.dev" + source: hosted + version: "3.2.5" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: d0412fcf4c6b31ecfdb7762359b7206ffba3bbffd396c6d9f9c4616ece476c1f + url: "https://pub.dev" + source: hosted + version: "2.4.2" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "712c70ab1b99744ff066053cbe3e80c73332b38d46e5e945c98689b2e66fc15f" + url: "https://pub.dev" + source: hosted + version: "3.1.5" + uuid: + dependency: "direct main" + description: + name: uuid + sha256: "1fef9e8e11e2991bb773070d4656b7bd5d850967a2456cfc83cf47925ba79489" + url: "https://pub.dev" + source: hosted + version: "4.5.3" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + url: "https://pub.dev" + source: hosted + version: "2.2.0" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60" + url: "https://pub.dev" + source: hosted + version: "15.0.2" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + win32: + dependency: transitive + description: + name: win32 + sha256: d7cb55e04cd34096cd3a79b3330245f54cb96a370a1c27adb3c84b917de8b08e + url: "https://pub.dev" + source: hosted + version: "5.15.0" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + xml: + dependency: transitive + description: + name: xml + sha256: "971043b3a0d3da28727e40ed3e0b5d18b742fa5a68665cca88e74b7876d5e025" + url: "https://pub.dev" + source: hosted + version: "6.6.1" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.dev" + source: hosted + version: "3.1.3" +sdks: + dart: ">=3.10.4 <4.0.0" + flutter: ">=3.38.4" diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..91c10c0 --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,94 @@ +name: add_months +description: "Identify the single change most likely to extend your lifespan." +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +# In Windows, build-name is used as the major, minor, and patch parts +# of the product and file versions while build-number is used as the build suffix. +version: 1.0.0+1 + +environment: + sdk: ^3.10.4 + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + cupertino_icons: ^1.0.8 + sqflite: ^2.3.0 + path: ^1.8.3 + flutter_secure_storage: ^9.0.0 + uuid: ^4.3.3 + url_launcher: ^6.2.4 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^6.0.0 + flutter_launcher_icons: ^0.14.1 + +flutter_launcher_icons: + android: true + ios: true + remove_alpha_ios: true + image_path: "assets/icon/app_icon.png" + adaptive_icon_background: "#FFFFFF" + adaptive_icon_foreground: "assets/icon/app_icon_foreground.png" + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/to/resolution-aware-images + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/to/asset-from-package + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/to/font-from-package diff --git a/test/risk_engine/calculator_test.dart b/test/risk_engine/calculator_test.dart new file mode 100644 index 0000000..03a9a05 --- /dev/null +++ b/test/risk_engine/calculator_test.dart @@ -0,0 +1,244 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:add_months/models/models.dart'; +import 'package:add_months/risk_engine/risk_engine.dart'; + +void main() { + group('Hazard Ratios', () { + test('smoking current produces HR > 1.8', () { + expect(getSmokingHR(SmokingStatus.current, 10), greaterThanOrEqualTo(1.8)); + }); + + test('smoking heavy (>20/day) produces highest HR', () { + final lightHR = getSmokingHR(SmokingStatus.current, 5); + final moderateHR = getSmokingHR(SmokingStatus.current, 15); + final heavyHR = getSmokingHR(SmokingStatus.current, 25); + + expect(heavyHR, greaterThan(moderateHR)); + expect(moderateHR, greaterThan(lightHR)); + expect(heavyHR, equals(2.8)); + }); + + test('never smoker has HR of 1.0', () { + expect(getSmokingHR(SmokingStatus.never, 0), equals(1.0)); + }); + + test('sedentary activity has higher HR than active', () { + expect( + getActivityHR(ActivityLevel.sedentary), + greaterThan(getActivityHR(ActivityLevel.high)), + ); + }); + + test('very heavy alcohol has highest HR', () { + expect(getAlcoholHR(AlcoholLevel.veryHeavy), equals(1.6)); + expect(getAlcoholHR(AlcoholLevel.none), equals(1.0)); + }); + + test('short sleep has higher HR than optimal', () { + expect(getSleepHR(5.0, true), greaterThan(getSleepHR(7.5, true))); + }); + + test('inconsistent sleep adds to HR', () { + expect(getSleepHR(7.0, false), greaterThan(getSleepHR(7.0, true))); + }); + }); + + group('Mortality Tables', () { + test('Japan is in Group A', () { + expect(getCountryGroup('Japan'), equals(MortalityGroup.groupA)); + }); + + test('United States is in Group B', () { + expect(getCountryGroup('United States'), equals(MortalityGroup.groupB)); + }); + + test('female LE is higher than male', () { + final maleLE = + getLifeExpectancyAtBirth(MortalityGroup.groupB, Sex.male); + final femaleLE = + getLifeExpectancyAtBirth(MortalityGroup.groupB, Sex.female); + + expect(femaleLE, greaterThan(maleLE)); + }); + + test('remaining LE decreases with age', () { + final le30 = getRemainingLifeExpectancy(30, Sex.male, 'United States'); + final le50 = getRemainingLifeExpectancy(50, Sex.male, 'United States'); + + expect(le30, greaterThan(le50)); + }); + + test('getSupportedCountries returns sorted list', () { + final countries = getSupportedCountries(); + expect(countries, isNotEmpty); + expect(countries.first, equals('Argentina')); + expect(countries, contains('United States')); + }); + }); + + group('Calculator', () { + final healthyProfile = UserProfile( + age: 40, + sex: Sex.male, + country: 'United States', + heightCm: 175, + weightKg: 75, + ); + + final optimalInputs = BehavioralInputs.optimal; + + final unhealthyInputs = BehavioralInputs( + smoking: SmokingStatus.current, + cigarettesPerDay: 20, + alcohol: AlcoholLevel.heavy, + sleepHours: 5.0, + sleepConsistent: false, + activity: ActivityLevel.sedentary, + diet: DietQuality.poor, + processedFood: ProcessedFoodLevel.daily, + drugUse: DrugUse.regular, + social: SocialConnection.isolated, + stress: StressLevel.chronic, + driving: DrivingExposure.veryHigh, + workHours: WorkHoursLevel.extreme, + ); + + test('optimal inputs produce low combined HR', () { + final hr = computeCombinedHazard(optimalInputs, 22.0); + expect(hr, closeTo(1.0, 0.1)); + }); + + test('unhealthy inputs produce high combined HR', () { + final hr = computeCombinedHazard(unhealthyInputs, 35.0); + expect(hr, greaterThan(3.0)); + }); + + test('combined HR is capped at 4.0', () { + final hr = computeCombinedHazard(unhealthyInputs, 45.0); + expect(hr, lessThanOrEqualTo(4.0)); + }); + + test('ranking puts smoking above driving for heavy smoker', () { + final smokerInputs = BehavioralInputs( + smoking: SmokingStatus.current, + cigarettesPerDay: 20, + alcohol: AlcoholLevel.none, + sleepHours: 7.5, + sleepConsistent: true, + activity: ActivityLevel.high, + diet: DietQuality.excellent, + processedFood: ProcessedFoodLevel.rarely, + drugUse: DrugUse.none, + social: SocialConnection.strong, + stress: StressLevel.low, + driving: DrivingExposure.veryHigh, + workHours: WorkHoursLevel.normal, + ); + + final result = calculateRankedFactors(healthyProfile, smokerInputs); + + expect(result.rankedFactors, isNotEmpty); + expect(result.dominantFactor?.behaviorKey, equals('smoking')); + }); + + test('optimal profile returns empty factors', () { + final result = calculateRankedFactors(healthyProfile, optimalInputs); + expect(result.rankedFactors, isEmpty); + }); + + test('result includes model version', () { + final result = calculateRankedFactors(healthyProfile, unhealthyInputs); + expect(result.modelVersion, equals('1.1')); + }); + + test('sedentary person sees activity as factor', () { + final sedentaryInputs = BehavioralInputs( + smoking: SmokingStatus.never, + cigarettesPerDay: 0, + alcohol: AlcoholLevel.none, + sleepHours: 7.5, + sleepConsistent: true, + activity: ActivityLevel.sedentary, + diet: DietQuality.excellent, + processedFood: ProcessedFoodLevel.rarely, + drugUse: DrugUse.none, + social: SocialConnection.strong, + stress: StressLevel.low, + driving: DrivingExposure.low, + workHours: WorkHoursLevel.normal, + ); + + final result = calculateRankedFactors(healthyProfile, sedentaryInputs); + + expect(result.rankedFactors, isNotEmpty); + expect(result.dominantFactor?.behaviorKey, equals('activity')); + }); + + test('delta ranges are reasonable', () { + final result = calculateRankedFactors(healthyProfile, unhealthyInputs); + + for (final factor in result.rankedFactors) { + // Low should be less than or equal to high + expect(factor.delta.lowMonths, lessThanOrEqualTo(factor.delta.highMonths)); + // Months should be reasonable (not hundreds of years) + expect(factor.delta.highMonths, lessThan(240)); // < 20 years + } + }); + }); + + group('Existing Conditions', () { + test('cardiovascular disease increases diagnosis HR', () { + final hr = getDiagnosisHR({Diagnosis.cardiovascular}); + expect(hr, equals(1.5)); + }); + + test('multiple conditions compound', () { + final singleHR = getDiagnosisHR({Diagnosis.diabetes}); + final multiHR = getDiagnosisHR({Diagnosis.diabetes, Diagnosis.hypertension}); + + expect(multiHR, greaterThan(singleHR)); + }); + + test('conditions reduce effective baseline', () { + final healthyProfile = UserProfile( + age: 50, + sex: Sex.male, + country: 'United States', + heightCm: 175, + weightKg: 80, + diagnoses: {}, + ); + + final unhealthyProfile = healthyProfile.copyWith( + diagnoses: {Diagnosis.cardiovascular, Diagnosis.diabetes}, + ); + + final sedentaryInputs = BehavioralInputs( + smoking: SmokingStatus.never, + cigarettesPerDay: 0, + alcohol: AlcoholLevel.none, + sleepHours: 7.5, + sleepConsistent: true, + activity: ActivityLevel.sedentary, + diet: DietQuality.excellent, + processedFood: ProcessedFoodLevel.rarely, + drugUse: DrugUse.none, + social: SocialConnection.strong, + stress: StressLevel.low, + driving: DrivingExposure.low, + workHours: WorkHoursLevel.normal, + ); + + final healthyResult = calculateRankedFactors(healthyProfile, sedentaryInputs); + final unhealthyResult = calculateRankedFactors(unhealthyProfile, sedentaryInputs); + + // Unhealthy person has less to gain (lower baseline) + if (healthyResult.dominantFactor != null && unhealthyResult.dominantFactor != null) { + expect( + unhealthyResult.dominantFactor!.delta.highMonths, + lessThan(healthyResult.dominantFactor!.delta.highMonths), + ); + } + }); + }); +} diff --git a/test/widget_test.dart b/test/widget_test.dart new file mode 100644 index 0000000..83284a6 --- /dev/null +++ b/test/widget_test.dart @@ -0,0 +1,7 @@ +// Widget tests require SQLite mocking which is complex. +// Core logic is covered by risk_engine tests. +// Integration testing should be done on device. + +void main() { + // Run: flutter test test/risk_engine/ for unit tests +} diff --git a/tool/generate_icon.dart b/tool/generate_icon.dart new file mode 100644 index 0000000..b20b6d5 --- /dev/null +++ b/tool/generate_icon.dart @@ -0,0 +1,198 @@ +import 'dart:io'; +import 'dart:typed_data'; +import 'dart:math'; + +/// Generates a simple tree icon PNG +void main() async { + const size = 1024; + final pixels = Uint8List(size * size * 4); + + // Fill with white background + for (var i = 0; i < pixels.length; i += 4) { + pixels[i] = 255; // R + pixels[i + 1] = 255; // G + pixels[i + 2] = 255; // B + pixels[i + 3] = 255; // A + } + + // Tree colors (muted teal from our theme) + const treeR = 74; // 0x4A + const treeG = 144; // 0x90 + const treeB = 164; // 0xA4 + + // Trunk color (darker) + const trunkR = 90; + const trunkG = 70; + const trunkB = 55; + + // Draw tree trunk (rectangle) + final trunkLeft = (size * 0.44).round(); + final trunkRight = (size * 0.56).round(); + final trunkTop = (size * 0.65).round(); + final trunkBottom = (size * 0.85).round(); + + for (var y = trunkTop; y < trunkBottom; y++) { + for (var x = trunkLeft; x < trunkRight; x++) { + final i = (y * size + x) * 4; + pixels[i] = trunkR; + pixels[i + 1] = trunkG; + pixels[i + 2] = trunkB; + pixels[i + 3] = 255; + } + } + + // Draw tree canopy (three triangles stacked) + void drawTriangle(int centerX, int topY, int height, int baseWidth) { + for (var y = topY; y < topY + height; y++) { + final progress = (y - topY) / height; + final halfWidth = (baseWidth * progress / 2).round(); + for (var x = centerX - halfWidth; x <= centerX + halfWidth; x++) { + if (x >= 0 && x < size && y >= 0 && y < size) { + final i = (y * size + x) * 4; + pixels[i] = treeR; + pixels[i + 1] = treeG; + pixels[i + 2] = treeB; + pixels[i + 3] = 255; + } + } + } + } + + final centerX = size ~/ 2; + + // Top triangle (smallest) + drawTriangle(centerX, (size * 0.15).round(), (size * 0.20).round(), (size * 0.35).round()); + + // Middle triangle + drawTriangle(centerX, (size * 0.28).round(), (size * 0.22).round(), (size * 0.48).round()); + + // Bottom triangle (largest) + drawTriangle(centerX, (size * 0.42).round(), (size * 0.26).round(), (size * 0.58).round()); + + // Encode as PNG + final png = encodePng(size, size, pixels); + + // Write to file + final file = File('assets/icon/app_icon.png'); + await file.writeAsBytes(png); + print('Generated app_icon.png'); + + // Also create foreground version (same but smaller for adaptive icons) + final foregroundFile = File('assets/icon/app_icon_foreground.png'); + await foregroundFile.writeAsBytes(png); + print('Generated app_icon_foreground.png'); +} + +/// Simple PNG encoder (no compression for simplicity) +Uint8List encodePng(int width, int height, Uint8List rgba) { + final output = BytesBuilder(); + + // PNG signature + output.add([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]); + + // IHDR chunk + final ihdr = BytesBuilder(); + ihdr.add(_int32be(width)); + ihdr.add(_int32be(height)); + ihdr.addByte(8); // bit depth + ihdr.addByte(6); // color type (RGBA) + ihdr.addByte(0); // compression + ihdr.addByte(0); // filter + ihdr.addByte(0); // interlace + _writeChunk(output, 'IHDR', ihdr.toBytes()); + + // IDAT chunk (image data with zlib compression) + // For simplicity, we'll use store (no compression) + final rawData = BytesBuilder(); + for (var y = 0; y < height; y++) { + rawData.addByte(0); // filter type: None + for (var x = 0; x < width; x++) { + final i = (y * width + x) * 4; + rawData.addByte(rgba[i]); // R + rawData.addByte(rgba[i + 1]); // G + rawData.addByte(rgba[i + 2]); // B + rawData.addByte(rgba[i + 3]); // A + } + } + + final compressed = _deflateStore(rawData.toBytes()); + _writeChunk(output, 'IDAT', compressed); + + // IEND chunk + _writeChunk(output, 'IEND', Uint8List(0)); + + return output.toBytes(); +} + +Uint8List _int32be(int value) { + return Uint8List.fromList([ + (value >> 24) & 0xFF, + (value >> 16) & 0xFF, + (value >> 8) & 0xFF, + value & 0xFF, + ]); +} + +void _writeChunk(BytesBuilder output, String type, Uint8List data) { + output.add(_int32be(data.length)); + final typeBytes = type.codeUnits; + output.add(typeBytes); + output.add(data); + + // CRC32 of type + data + final crcData = Uint8List(typeBytes.length + data.length); + crcData.setAll(0, typeBytes); + crcData.setAll(typeBytes.length, data); + output.add(_int32be(_crc32(crcData))); +} + +/// Simple deflate with store (no compression) +Uint8List _deflateStore(Uint8List data) { + final output = BytesBuilder(); + + // zlib header + output.addByte(0x78); // CMF + output.addByte(0x01); // FLG (no dict, fastest) + + // Split into blocks of max 65535 bytes + const maxBlock = 65535; + var offset = 0; + + while (offset < data.length) { + final remaining = data.length - offset; + final blockSize = remaining > maxBlock ? maxBlock : remaining; + final isLast = offset + blockSize >= data.length; + + output.addByte(isLast ? 0x01 : 0x00); // BFINAL + BTYPE (store) + output.addByte(blockSize & 0xFF); + output.addByte((blockSize >> 8) & 0xFF); + output.addByte((~blockSize) & 0xFF); + output.addByte(((~blockSize) >> 8) & 0xFF); + + output.add(data.sublist(offset, offset + blockSize)); + offset += blockSize; + } + + // Adler-32 checksum + var s1 = 1; + var s2 = 0; + for (var i = 0; i < data.length; i++) { + s1 = (s1 + data[i]) % 65521; + s2 = (s2 + s1) % 65521; + } + final adler = (s2 << 16) | s1; + output.add(_int32be(adler)); + + return output.toBytes(); +} + +int _crc32(Uint8List data) { + var crc = 0xFFFFFFFF; + for (var byte in data) { + crc ^= byte; + for (var i = 0; i < 8; i++) { + crc = (crc & 1) != 0 ? (crc >> 1) ^ 0xEDB88320 : crc >> 1; + } + } + return crc ^ 0xFFFFFFFF; +} diff --git a/web/favicon.png b/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/web/favicon.png differ diff --git a/web/icons/Icon-192.png b/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/web/icons/Icon-192.png differ diff --git a/web/icons/Icon-512.png b/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/web/icons/Icon-512.png differ diff --git a/web/icons/Icon-maskable-192.png b/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/web/icons/Icon-maskable-192.png differ diff --git a/web/icons/Icon-maskable-512.png b/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/web/icons/Icon-maskable-512.png differ diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..dcd6917 --- /dev/null +++ b/web/index.html @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + add_months + + + + + + diff --git a/web/manifest.json b/web/manifest.json new file mode 100644 index 0000000..31b8d14 --- /dev/null +++ b/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "add_months", + "short_name": "add_months", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +}