diff --git a/.gitignore b/.gitignore index 87bfa98..24cee8e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,9 @@ local.properties artifacts/ __pycache__/ .venv/ +.dart_tool/ +.flutter-plugins-dependencies +.packages +.idea/ +*.iml +coverage/ diff --git a/.metadata b/.metadata new file mode 100644 index 0000000..235886b --- /dev/null +++ b/.metadata @@ -0,0 +1,33 @@ +# 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: "6a19cca56475dbfba1478ee68d7bd0c2ef891da1" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 6a19cca56475dbfba1478ee68d7bd0c2ef891da1 + base_revision: 6a19cca56475dbfba1478ee68d7bd0c2ef891da1 + - platform: android + create_revision: 6a19cca56475dbfba1478ee68d7bd0c2ef891da1 + base_revision: 6a19cca56475dbfba1478ee68d7bd0c2ef891da1 + - platform: ios + create_revision: 6a19cca56475dbfba1478ee68d7bd0c2ef891da1 + base_revision: 6a19cca56475dbfba1478ee68d7bd0c2ef891da1 + + # 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/README.md b/README.md index ccd98d9..bc41dec 100644 --- a/README.md +++ b/README.md @@ -1,106 +1,92 @@ -# Lumen — The Last Light (Android 1.7) +# Lumen — The Last Light (Flutter 2.0) -A native Android 7.0+ app styled as a lightkeeper’s family notebook: faded blue cloth, stitched binding, warm ruled paper, a ribbon bookmark and pressed heather. A hand-drawn twilight harbour connects the home screen to the island story. No account or game backend. Players restore a darkened island through picture puzzles, or play generated 5×5 daily and classic grids. +An illustrated island notebook about grandmother Mara, her grandchild, and restoring a lighthouse. The active app is now written in **Dart and Flutter**, with a thin Android Kotlin entry point. All puzzle generation, deductions, story navigation, progress, audio controls and advertising behavior live in `lib/`. -The opening six-leaf storybook prototype is implemented. The wider [product roadmap](ROADMAP.md) describes the next chapters and further exploration features. +Android is the tested target. iOS project scaffolding and test AdMob configuration are included, but iOS has not been built or tested on this Linux workstation. It still needs Apple signing, device testing, store icons and platform release configuration. -## Opening notebook prototype +## Play -Open Mara’s notebook from the home screen. The opening trail contains: +- Six opening notebook leaves: a dedication, illustrated cottage entry, match puzzle, memory, folded note and inspectable lantern. +- Margin swipes and corner arrows turn leaves. Grid gestures never turn pages. Navigation stays fixed; overflow scrolling supports smaller screens and larger text. +- A saved ribbon bookmark, opened note, inspected repair, viewed pages and current reading place. +- Twelve 7×7 picture puzzles across three chapters, with overlapping-area deductions on entries 3–12. Later chapters retain their earlier briefing/puzzle/reveal structure until the roadmap expands them. +- Deterministic daily grids and generated Easy, Medium and Hard 5×5 practice. The grades measure deduction-chain depth, not expert-level difficulty. Every board has a unique solution and needs no guessing. +- Undo, one free explained hint per puzzle, then optional rewarded hints. Later hints require the AdMob reward callback. An unavailable ad never blocks the board. +- Local daily streaks, independent difficulty levels and exactly-once puzzle completion awards. +- AdMob/UMP consent, optional rewarded hints, practice interstitials after every fourth completion and one-time campaign chapter transitions. No ads interrupt opening notebook leaves or recorded readings. -1. Gran’s handwritten dedication. -2. A cottage entry with an original watercolour illustration. -3. The existing match puzzle, using its original save key. -4. A match sketch and a personal memory. -5. A folded note that can be opened and kept. -6. A lantern illustration with a repair detail to inspect. +Progress starts fresh in Flutter, as requested. Old Java `lumen.xml` saves are **not imported or read**. Flutter keeps its own local preferences through `shared_preferences`; no account or game backend is required. Uninstalling loses local progress, and the daily date follows the device calendar. -Use the corner arrows or swipe horizontally from a page margin. Gestures starting inside the grid cannot turn the page. Navigation stays fixed below the reading area; text can overflow-scroll for larger fonts or landscape. A short fade/slide respects disabled system animations. Contents links to these leaves, a ribbon bookmark, and the existing three-chapter campaign. The final lantern leaf links to the next existing entry; the rest of the campaign still uses the earlier screens. +## Artwork and readings -Five pre-rendered readings ship as lossless FLAC files, with editable 24 kHz mono WAV masters in `assets/narration/wav/`. Android MediaPlayer provides play, pause, exact-position resume, stop and replay, optional speed settings, and passage highlighting. There is no Android text-to-speech service, runtime synthesis, voice download, or per-listen network request. These are synthetic British-English readings rendered during development, not a human actor’s performance. Playback stops on page changes and when the app backgrounds. See [audio provenance and regeneration](assets/narration/README.md). +All app-created text uses the bundled Dancing Script handwriting font, including grid clues and menus. Original watercolour harbour, cloth cover, cottage, lantern and single-page art remain bundled for offline use. Native text sits directly on the page’s blank writing area. Art prompts and provenance are in [assets/artwork](assets/artwork/README.md); the font’s OFL license ships in the app’s open-source licenses. -The last leaf, explicit ribbon bookmark, opened note, inspected handle and viewed-page flags are saved independently of puzzle completion. Closing the app in the notebook restores the same leaf. Reading ahead from an unsolved puzzle asks once per attempted turn and keeps all marks without awarding completion. Existing campaign grids and counts are preserved; the original match can be revisited if already solved. The opening prototype contains no interstitials, and narration/discoveries require no ad. +Five fixed, pre-rendered synthetic British-English readings ship as lossless FLAC assets, with PCM16 WAV masters for review. `just_audio` plays bundled files; there is no Android reader, runtime synthesis or audio download. Controls support play, pause, resume at the same position, stop, replay, speed and passage highlighting. Leaving a page or backgrounding the app stops playback. See [narration provenance](assets/narration/README.md). -The cottage and lantern PNGs were generated using the built-in image tool with alpha backgrounds. Originals and exact prompts are in `assets/artwork/`; sampled decoded copies are used for the small on-page illustrations. +## Build and run -For isolated tablet smoke tests: +Tested with Flutter 3.47.5 / Dart 3.13.4, JDK 21 and Android SDK 36. Flutter uses the standard `android/` platform project; the former root Gradle project is archived in `legacy/android/` and is not compiled into the Flutter app. ```sh -JAVA_HOME=/path/to/jdk-21 ./gradlew :app:assembleDebug -PqaBuild=true -adb -s YOUR_SERIAL install -r app/build/outputs/apk/debug/app-debug.apk -python3 scripts/check_storybook.py --serial YOUR_SERIAL +flutter pub get +flutter analyze +flutter test +flutter run --flavor prod -d YOUR_ANDROID_DEVICE ``` -The test script enforces a `.qa` package because it writes disposable fixtures. It checks edge swipes, bundled recording playback, pause/resume and speed settings, grid gesture isolation, read-ahead, folded-note persistence, bookmarks, process restart, completion without duplicate awards, and rotation. It restores the tablet’s original rotation settings. Screenshots and results go to `artifacts/storybook-check/`. - -## The Last Light - -Twelve 7×7 picture puzzles across three chapters: the keeper’s cottage, the tidal crossing, and the lighthouse. Follow grandmother Mara’s notebook to recover a match, lantern, key, compass, boat, anchor, bridge, bell, gear, lens, lighthouse and home. Each solution is the actual pictured object, shown as clean pixel art after completion. Story pages appear before and after each puzzle; recovered pictures remain in the notebook. Everything ships in the APK. - -The first two patterns teach row and column totals. Patterns 3–12 add three overlapping rectangular areas. Select A, B or C to highlight its cells; shared cells count in both totals. Later puzzles **cannot** be completed by line saturation alone. Subtracting overlapping constraints resolves cells outside their overlap; tests verify this technique is necessary and sufficient, without branching/guessing. These are introductory area puzzles, not a promise of expert-level challenge. - -Campaign completion unlocks the next page, increments the existing solved counter once, and preserves all prior classic/daily data. Campaign progress is separate from the daily streak. Every fourth story page can show an interstitial when turning to the next chapter, once per chapter transition; re-reading never repeats it. No ad interrupts a story reveal. Campaign replay currently means re-reading recovered pages, not resetting puzzles. - -Hints now explain a forced line or area deduction and mark one cell. If an earlier player mark is wrong, a hint corrects one such cell first. Each puzzle has one free hint, with additional hints requiring the AdMob reward callback. - -## Notebook theme - -The home screen now uses newly generated watercolour harbour and faded-blue notebook-cover PNGs (`HomeArtwork.java`), with a native handwritten cover label. All app-created headings, passages, menus, captions, puzzle clues and dialogs use the cursive handwriting family; system consent screens retain their provider styling. Recovered objects sit on taped paper keepsakes. The lighthouse app icon uses a vector drawable. - -The book cover on the home screen opens a generated 1024×1536 single diary page, bundled without density scaling. `NotebookPage.java` positions transparent content directly on its blank writing area, with no floating panel. Portrait shows the whole page; landscape crops vertically through the blank paper, retaining the binding. Handwritten menu actions have a fine ink underline, and empty puzzle cells have thin pencil outlines so the paper stays visible. The grid sizes to available width and scrolls into view on entry. Source artwork and the exact generation prompt are in `assets/artwork/`. All drawings are static apart from the existing short picture fade; paper texture work is limited to the visible part of the page. Existing puzzle definitions and save keys are unchanged. - -## Classic and daily modes - -- Deterministic generated practice levels and a date-seeded daily puzzle. -- Easy, Medium, and Hard practice, with independent saved progress and a remembered selection. -- Solver checks uniqueness and rates boards by simultaneous deduction rounds: Easy 1–2, Medium 3–4, Hard 5. A round fills lines where all unknown cells must be lit or all must be crossed out; later rounds use those deductions. No guessing is needed. -- Generation tries up to 256 deterministic candidates, then uses a permuted known board of the requested grade. These are relative chain-depth ratings, not a calibrated measure of solve time. -- Existing daily grids retain their original generation. Earlier in-progress practice is accessible through “Continue earlier puzzle.” -- Saved boards, level progress, daily streaks and completion counts on device. -- Undo, one free explained hint per board, then optional rewarded hints. -- Interstitials at a natural transition after every fourth practice completion across all difficulties. No ads during a board or when returning home. -- AdMob and UMP consent flow; ads only requested when consent information permits. -- Google test IDs by default. Games remain playable without connectivity or ad availability. - -Campaign grids use fixed `story_v1_…` save keys. Preserve the order, pictures, givens and area layouts of existing entries when adding future pages; changing an existing puzzle requires a new save-key version. - -## Build - -Requires JDK 17–24 (JDK 21 recommended) and Android SDK 36. Set `sdk.dir` in your own `local.properties` or configure `ANDROID_HOME`. +Use `JAVA_HOME=/path/to/jdk-21` if your default JDK is incompatible with Gradle. Use `flutter doctor -v` to inspect your setup. ```sh -JAVA_HOME=/path/to/jdk-21 ./gradlew :app:testDebugUnitTest :app:assembleDebug +# Separate QA package: com.lumen.daily.qa +flutter build apk --debug --flavor qa + +# Optimized development APK for the connected arm64 tablet +flutter build apk --release --flavor prod --target-platform android-arm64 ``` -Debug APK: `app/build/outputs/apk/debug/app-debug.apk`. A shareable copy of version 1.7 is in `artifacts/lumen-1.7.apk`. +The normal application ID remains `com.lumen.daily`; version 2.0.0 uses build number 9. The review APK is `artifacts/lumen-flutter-2.0-arm64.apk`. Build outputs, screenshots, local SDK paths, IDE state and private signing keys are ignored by Git. `pubspec.lock` is tracked for reproducible package resolution. -For an isolated device test build, add `-PqaBuild=true` to `assembleDebug`; it installs as `com.lumen.daily.qa`, with independent progress. Build without that property for the normal app. Device smoke-test screenshots and results are under `artifacts/`. +The development release build currently uses the Android debug signing key so it can update the installed prototype. **Configure your private upload key before publishing.** No production signing material is included. -## Before publishing on Google Play +## Verification -1. Choose a permanent application ID in `app/build.gradle` (currently `com.lumen.daily`). -2. Create the Android app and rewarded/interstitial ad units in AdMob. Configure Privacy & messaging for the markets you serve. -3. Supply production IDs via Gradle properties `ADMOB_APP_ID`, `ADMOB_REWARDED_ID`, and `ADMOB_INTERSTITIAL_ID`. Keep Google test IDs in development builds. -4. Configure your private upload signing key outside version control, then build a signed release AAB. Release signing is intentionally not supplied by this repository. -5. Supply a public privacy policy, store artwork, support contact, content rating, target audience, ads declaration and accurate Data safety answers based on the Google ads SDK and your final configuration. The in-app privacy summary is not a replacement for a published policy. -6. Test consent (including refusal/revocation), reward completion/cancellation, no-fill, offline play, process restart, device rotation and small screens on physical devices. Complete Play testing requirements for your developer account. +```sh +flutter analyze +flutter test +python3 scripts/check_narration_assets.py -The daily date uses the device’s local calendar. Progress and streaks are local, not protected against clock changes or restored after uninstall. A daily puzzle remains available to replay after completion; a solved practice board advances the practice counter. Puzzle generation guarantees a unique answer and grades deduction depth. +# Launch/playback/restart smoke test after installing the normal APK +python3 scripts/check_flutter_install.py --serial YOUR_ANDROID_DEVICE + +# Real tablet integration, isolated from the normal app +flutter drive --driver test_driver/integration_test.dart \ + --target integration_test/notebook_test.dart --flavor qa \ + --dart-define=QA_TEST=true -d YOUR_ANDROID_DEVICE +``` + +The nine unit/widget tests cover 40 Java reference boards (including signed 64-bit seeds), 300 graded generated boards, solver counts against 300 exhaustive small systems, all twelve campaign solutions, streaks, fresh progress, read-ahead, completion awards, gesture isolation, landscape and larger text. Reference parity protects the port’s rules; it is not used to migrate saves. + +The physical-device integration test uses a disposable in-memory game plus an isolated QA disk round-trip. It plays all five real FLAC files, checks pause/resume, explores the six leaves, verifies bookmarks/discoveries, solves match and lantern puzzles and checks exactly-once awards. Screenshots are saved in `artifacts/flutter-check/`. The release smoke script exercises the actual play/pause/resume UI and restores the last page after process restart, without injecting puzzle fixtures. The release build includes a targeted R8 keep rule for the database constructor used reflectively by AdMob’s WorkManager dependency. Advertising is disabled for the automated story tests; real UMP startup is checked separately in the normal build. Reward delivery, cancellation and ad no-fill still need manual release testing with your final AdMob configuration. ## Source map -- `Campaign.java`: authored story, 7×7 pixel patterns, precomputed fixed clues and area layouts. -- `LogicSolver.java`: count-constraint search, line/area deductions and explained hints. -- `CampaignTest.java`: all twelve unique pictures; necessary area deductions on pages 3–12; hint completion and restoration checks. -- `LogicSolverTest.java`: deductions and solution counts compared with exhaustive enumeration over 1,000 small overlapping constraint systems. -- `Puzzle.java`: seeded classic generation, general constraints, solution counting, deduction grading, completion validation. -- `Difficulty.java`: difficulty names, descriptions and grade thresholds. -- `DifficultyTest.java`: 1,500 generated boards checked for requested grades and uniqueness, deterministic regeneration, legacy compatibility and ambiguous-board rejection. -- `StoryBook.java`: stable six-leaf story records and narration sentence boundaries. -- `StoryNotebook.java`: page layouts, fixed navigation, folded note and inspection interaction. -- `StoryNarrator.java`: bundled recording playback, passage progress, audio focus and speed settings. -- `PageTurnGesture.java`: page-margin gesture recognition, tested against grid drags. -- `MainActivity.java`: notebook routing, puzzle completion, local progress, streaks, hints. -- `Ads.java`: consent, ad loading and presentation. -- `PuzzleTest.java`: uniqueness, determinism and completion across 500 seeds. -- `DailyStreakTest.java`: consecutive days, replay handling and missed-day reset. +| Location | Responsibility | +| --- | --- | +| `lib/main.dart` | Handwritten home, notebook, campaign, dialogs and lifecycle | +| `lib/domain/puzzle.dart` | Seeded generation, uniqueness, constraint deductions, hints and difficulty | +| `lib/domain/book.dart` | Stable story records and campaign asset loading | +| `lib/domain/game.dart` | Routing, marks, undo, progress, streaks and completion | +| `lib/ui/` | Page layout, margin gestures, native grid semantics and illustrated keepsakes | +| `lib/services/` | Local storage, bundled playback and consent-gated AdMob | +| `assets/campaign.json` | Authored twelve-picture campaign | +| `assets/narration/scripts.json` | Canonical spoken diary text | +| `assets/audio/` | Runtime FLAC files and passage timing manifest | +| `legacy/` | Archived Java version 1.7, excluded from Flutter builds | + +## Before publishing + +Create your production Android AdMob app and ad units, configure Privacy & messaging, supply a public privacy policy and support contact, complete Play disclosures and ratings, and configure an upload key outside Git. The SDK still uses Google test IDs by default. + +For Android, supply the app ID using Gradle property `ADMOB_APP_ID`. Rewarded/interstitial unit IDs use Dart compile-time defines `ADMOB_REWARDED_ID` and `ADMOB_INTERSTITIAL_ID`. iOS needs its own app ID in `ios/Runner/Info.plist` and iOS-specific ad unit IDs. Verify consent refusal/revocation, reward completion/cancellation, offline/no-fill behavior, lifecycle interruptions, accessibility and release signing on physical devices before submitting an AAB. + +See [ROADMAP.md](ROADMAP.md) for the proposed 30–40-leaf campaign, page variety and further exploration ideas. diff --git a/ROADMAP.md b/ROADMAP.md index 1f74d2c..5d27677 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,6 +1,6 @@ # Lumen — a notebook worth exploring -Status: opening slice updated in Android version 1.7. The six-leaf opening slice below is implemented and ready for review: page-margin swipes, arrows, five bundled recorded readings, two on-page illustrations and refreshed home art, a saved ribbon bookmark, a folded note, a lantern inspection, and the existing match puzzle/reveal. Full chapter pagination, the larger 30–40-leaf story and later exploration features remain proposed. There are no delivery dates yet; review the opening slice before expanding it. +Status: opening slice ported to Dart and Flutter in version 2.0. The six-leaf opening slice below is implemented and ready for review: page-margin swipes, arrows, five bundled recorded readings, two on-page illustrations and refreshed home art, a saved ribbon bookmark, a folded note, a lantern inspection, and the existing match puzzle/reveal. Full chapter pagination, the larger 30–40-leaf story and later exploration features remain proposed. The Flutter port retains these features and starts fresh progress, as requested. Android is the tested target; iOS scaffolding is present but not yet validated. There are no delivery dates yet; review the opening slice before expanding it. ## The experience we are building diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..30827dc --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,7 @@ +include: package:flutter_lints/flutter.yaml +analyzer: + exclude: + - legacy/** + - build/** + - android/** + - ios/** 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..8771d4b --- /dev/null +++ b/android/app/build.gradle.kts @@ -0,0 +1,57 @@ +plugins { + id("com.android.application") + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id("dev.flutter.flutter-gradle-plugin") +} + +android { + namespace = "com.lumen.daily" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId = "com.lumen.daily" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + minSdk = 24 + targetSdk = flutter.targetSdkVersion + // Uses the version code from pubspec.yaml. When using split APKs, 1000 * ABI_VERSION + // is added automatically by Flutter. (https://developer.android.com/studio/build/configure-apk-splits#configure-APK-versions) + // You can force using the value of versionCode by specifying the `-P force-version-code-ignoring-abi=true` + // flag during build. + versionCode = flutter.versionCode + versionName = flutter.versionName + manifestPlaceholders["admobAppId"] = providers.gradleProperty("ADMOB_APP_ID").getOrElse("ca-app-pub-3940256099942544~3347511713") + } + + flavorDimensions += "edition" + productFlavors { + create("prod") { dimension = "edition" } + create("qa") { dimension = "edition"; applicationIdSuffix = ".qa"; versionNameSuffix = "-qa" } + } + buildTypes { + release { + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + // Supply a private upload key before publishing. Never release with a debug key. + signingConfig = signingConfigs.getByName("debug") + } + } +} + +kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 + } +} + +flutter { + source = "../.." +} diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro new file mode 100644 index 0000000..7821332 --- /dev/null +++ b/android/app/proguard-rules.pro @@ -0,0 +1,7 @@ +# AdMob transitively uses Room 2.2.5 through WorkManager 2.7. Its consumer +# rule preserves database class names, but R8 full mode also needs the public +# constructor used by Room.getGeneratedImplementation(). Keep this one entry +# point rather than disabling shrinking for the dependency or whole app. +-keepclassmembers class * extends androidx.room.RoomDatabase { + public (); +} 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..90cb6c2 --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/kotlin/com/lumen/daily/MainActivity.kt b/android/app/src/main/kotlin/com/lumen/daily/MainActivity.kt new file mode 100644 index 0000000..f499fc5 --- /dev/null +++ b/android/app/src/main/kotlin/com/lumen/daily/MainActivity.kt @@ -0,0 +1,5 @@ +package com.lumen.daily + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity : FlutterActivity() 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/app/src/main/res/drawable/ic_launcher.xml b/android/app/src/main/res/drawable/ic_launcher.xml similarity index 100% rename from app/src/main/res/drawable/ic_launcher.xml rename to android/app/src/main/res/drawable/ic_launcher.xml 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-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..db77bb4 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..17987b7 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..09d4391 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..d5f1c8d 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..4d6372e 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..f1b78b9 --- /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/styles.xml b/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..f4f55ce --- /dev/null +++ b/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/app/src/main/res/xml/data_extraction_rules.xml b/android/app/src/main/res/xml/data_extraction_rules.xml similarity index 100% rename from app/src/main/res/xml/data_extraction_rules.xml rename to android/app/src/main/res/xml/data_extraction_rules.xml 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..e96108c --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,6 @@ +org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError +android.useAndroidX=true +# This newDsl flag was added by the Flutter template +android.newDsl=false +# This builtInKotlin flag was added by the Flutter template +android.builtInKotlin=false diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..a20f2c4 --- /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-9.3.1-all.zip diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts new file mode 100644 index 0000000..b28021a --- /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 "9.1.0" apply false + id("org.jetbrains.kotlin.android") version "2.4.0" apply false +} + +include(":app") diff --git a/assets/artwork/README.md b/assets/artwork/README.md index 0e9ee1e..943f9a4 100644 --- a/assets/artwork/README.md +++ b/assets/artwork/README.md @@ -15,3 +15,7 @@ The earlier `mara-notebook-background-v1.png` and its prompt are preserved for c `home-harbour-v2.png` and `home-notebook-cover-v2.png` were generated with the built-in image generation tool, using new-image generation with transparent backgrounds. Their exact prompts are preserved in `home-harbour-v2.prompt.txt` and `home-notebook-cover-v2.prompt.txt`. Originals are copied to `drawable-nodpi/home_harbour.png` and `home_notebook_cover.png` for offline use. The harbour is a soft-edged northern-island watercolour; the closed cover is faded blue linen with heather, repairs and a red ribbon. `HomeArtwork.java` preserves aspect ratio and places a native handwritten label on the cover’s blank paper label. These replace the earlier Canvas harbour and cover on the “A light to come home to” screen. No readable text was generated into either image. + +## Flutter migration (2.0) + +Flutter bundles the existing originals from this folder directly. `lib/ui/paper.dart` positions content on the single page and overlays native Flutter handwriting on the cover label. `lib/main.dart` displays the harbour, cottage and lantern art. The earlier Android resource paths above now live under `legacy/android/` for reference. No new pictures were generated for the migration. diff --git a/app/src/main/res/raw/narration_cottage_dedication.flac b/assets/audio/narration_cottage_dedication.flac similarity index 100% rename from app/src/main/res/raw/narration_cottage_dedication.flac rename to assets/audio/narration_cottage_dedication.flac diff --git a/app/src/main/res/raw/narration_cottage_folded_note.flac b/assets/audio/narration_cottage_folded_note.flac similarity index 100% rename from app/src/main/res/raw/narration_cottage_folded_note.flac rename to assets/audio/narration_cottage_folded_note.flac diff --git a/app/src/main/res/raw/narration_cottage_lantern_sketch.flac b/assets/audio/narration_cottage_lantern_sketch.flac similarity index 100% rename from app/src/main/res/raw/narration_cottage_lantern_sketch.flac rename to assets/audio/narration_cottage_lantern_sketch.flac diff --git a/app/src/main/res/raw/narration_cottage_match_memory.flac b/assets/audio/narration_cottage_match_memory.flac similarity index 100% rename from app/src/main/res/raw/narration_cottage_match_memory.flac rename to assets/audio/narration_cottage_match_memory.flac diff --git a/app/src/main/res/raw/narration_cottage_window.flac b/assets/audio/narration_cottage_window.flac similarity index 100% rename from app/src/main/res/raw/narration_cottage_window.flac rename to assets/audio/narration_cottage_window.flac diff --git a/app/src/main/res/raw/narration_manifest.json b/assets/audio/narration_manifest.json similarity index 100% rename from app/src/main/res/raw/narration_manifest.json rename to assets/audio/narration_manifest.json diff --git a/assets/campaign.json b/assets/campaign.json new file mode 100644 index 0000000..26ffb65 --- /dev/null +++ b/assets/campaign.json @@ -0,0 +1,125 @@ +{ + "premise": "The storm has passed, but the island is still dark. In your grandmother Mara’s notebook, you find a promise: no one comes home to an unlit shore. Recover what the storm scattered. Bring the lighthouse back to life.", + "levels": [ + { + "chapter": "I · The keeper’s cottage", + "title": "A spark in the drawer", + "object": "A match", + "before": "You find Mara’s cottage with its windows shuttered. On the table is her notebook: ‘Start with one small light.’ The first page is water-stained. Restore its pattern.", + "after": "A dry match, hidden in a tin. You strike it against the hearth. For a moment, the cottage feels like it remembers you.", + "picture": "0011000011110000110000001000000100000010000001000", + "clues": "", + "areas": "" + }, + { + "chapter": "I · The keeper’s cottage", + "title": "Something to carry the flame", + "object": "The lantern", + "before": "A small flame will not survive the wind. Mara’s next page shows what she carried on her evening rounds.", + "after": "The lantern is soot-black but sound. Its warm circle of light reaches the cottage door. Beneath the handle, Mara has scratched your initials.", + "picture": "0011100001010001111100100010010101001000100111110", + "clues": "1,5,9,11", + "areas": "" + }, + { + "chapter": "I · The keeper’s cottage", + "title": "Under the loose floorboard", + "object": "The brass key", + "before": "‘Some clues belong to more than one place,’ Mara wrote. Compare the overlapping areas on this page; a shared cell counts in both. A loose floorboard waits by the door.", + "after": "A brass key turns up beneath the board. The tag reads ‘harbour store’. Someone prepared for a journey and never quite made it out of the cottage.", + "picture": "0011100010001001000100011100000100000011000001000", + "clues": "", + "areas": "1,2,4,3;3,2,2,4;3,2,2,3" + }, + { + "chapter": "I · The keeper’s cottage", + "title": "A direction in the dark", + "object": "Mara’s compass", + "before": "The lane has vanished beneath fallen branches. One last page in the cottage points you towards the harbour. Use what the areas share to work out what lies outside them.", + "after": "The compass needle settles towards the sea. Tucked inside its lid is a note: ‘When the path disappears, keep your bearings.’ You step into the rain.", + "picture": "0001000001110001010101111111010101000111000001000", + "clues": "15,36", + "areas": "1,3,2,2;3,2,3,3;2,0,3,5" + }, + { + "chapter": "II · Across the tide", + "title": "At the water’s edge", + "object": "The little boat", + "before": "The tide has covered the causeway. A shape knocks gently against the harbour steps. Mara’s notebook has a page for this crossing too.", + "after": "The little boat is still tied fast. You bail out the rainwater, set the lantern in the bow, and push away from the steps.", + "picture": "0001000000110000011100001000111111101111101000001", + "clues": "", + "areas": "0,3,5,2;3,1,3,3;2,2,4,4" + }, + { + "chapter": "II · Across the tide", + "title": "What holds us steady", + "object": "The anchor", + "before": "The current tugs you towards the outer rocks. Something heavy is tangled beneath the seat. The pattern tells you what to reach for.", + "after": "The anchor catches. The boat swings into calmer water. In the pause, you hear a bell somewhere beyond the fog.", + "picture": "0011100001010000111000001000100100101010100011100", + "clues": "11,36,40", + "areas": "2,3,3,3;2,1,4,2;1,1,3,4" + }, + { + "chapter": "II · Across the tide", + "title": "The old crossing", + "object": "The stone bridge", + "before": "You land beneath the lighthouse hill. The old crossing is hidden by reeds. Mara marked its outline long before the storm.", + "after": "The bridge is intact. You cross with the lantern held high. On the far bank, a fresh bootprint tells you someone else has passed this way.", + "picture": "0000000011111011000111000001100000111111110000000", + "clues": "", + "areas": "2,1,3,5;0,2,5,3;2,3,2,2" + }, + { + "chapter": "II · Across the tide", + "title": "An answer through the fog", + "object": "The harbour bell", + "before": "A rope hangs from a timber frame. The bell above it has fallen silent. Restore the pattern before you call out across the water.", + "after": "One clear note travels into the fog. Two notes answer from the hill. Someone is waiting at the lighthouse.", + "picture": "0001000001110000101000100010010001011111110001000", + "clues": "2", + "areas": "3,2,3,3;2,0,4,4;0,3,5,2" + }, + { + "chapter": "III · The last light", + "title": "Inside the turning room", + "object": "The missing gear", + "before": "Mara opens the lighthouse door. ‘I knew you’d find the notebook,’ she says. The storm stopped the turning mechanism. Together, you lay out its scattered parts.", + "after": "The missing gear slips into place. You turn the handle; the mechanism answers with a familiar, steady ticking. Mara smiles without looking up.", + "picture": "0010100011111011000110101010110001101111100010100", + "clues": "9,24", + "areas": "2,3,3,3;1,3,5,3;1,2,4,3" + }, + { + "chapter": "III · The last light", + "title": "A circle of glass", + "object": "The beacon lens", + "before": "The great lens is clouded with salt. Mara holds the lantern while you work. The areas overlap like the rings in the glass; compare them carefully.", + "after": "You wipe the last salt from the lens. The lantern’s tiny flame stretches into a bright arc across the walls. Everything is ready.", + "picture": "0011100010001010010011001101100100101000100011100", + "clues": "7,13,36,40", + "areas": "1,2,5,3;2,3,3,2;2,2,3,2" + }, + { + "chapter": "III · The last light", + "title": "No unlit shore", + "object": "The lighthouse", + "before": "Mara gives you the handle. Below the windows, the island lies dark. This is the pattern all the other pages were leading towards.", + "after": "The beacon turns. Its light sweeps the harbour, the bridge, the little boat. Far offshore, a ship sounds its horn. The island has its light again.", + "picture": "0001000001110011111110011100001010001101101111111", + "clues": "", + "areas": "1,3,4,2;0,3,2,2;2,2,4,2" + }, + { + "chapter": "III · The last light", + "title": "A light in the window", + "object": "Home", + "before": "Dawn finds you walking back with Mara. There is one blank page at the end of the notebook. ‘That one is yours,’ she says.", + "after": "You light the cottage window. Mara puts the kettle on. Beneath your new drawing, you write: ‘No one comes home to an unlit shore.’ The notebook closes. Your watch has begun.", + "picture": "0001000001110001111101111111010001001010100111110", + "clues": "", + "areas": "0,1,6,2;2,3,4,3;0,2,4,3" + } + ] +} diff --git a/assets/fonts/DancingScript.ttf b/assets/fonts/DancingScript.ttf new file mode 100644 index 0000000..9f521e7 Binary files /dev/null and b/assets/fonts/DancingScript.ttf differ diff --git a/assets/fonts/OFL.txt b/assets/fonts/OFL.txt new file mode 100644 index 0000000..07ff8df --- /dev/null +++ b/assets/fonts/OFL.txt @@ -0,0 +1,93 @@ +Copyright 2016 The Dancing Script Project Authors (https://github.com/googlefonts/DancingScript), with Reserved Font Name 'Dancing Script'. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/assets/narration/README.md b/assets/narration/README.md index bce13d3..d77c778 100644 --- a/assets/narration/README.md +++ b/assets/narration/README.md @@ -1,11 +1,11 @@ # Bundled diary readings -Five fixed readings accompany the opening notebook leaves. They are **synthetic narration rendered during development**, using Kokoro v1.0 / `bf_emma` (British female), not human voice-actor recordings. The app only plays files using Android MediaPlayer. It contains no speech model, Android reader integration, runtime synthesis, or audio download. +Five fixed readings accompany the opening notebook leaves. They are **synthetic narration rendered during development**, using Kokoro v1.0 / `bf_emma` (British female), not human voice-actor recordings. The app only plays files using just_audio’s platform decoder. It contains no speech model, Android reader integration, runtime synthesis, or audio download. -- `scripts.json`: exact current non-puzzle text exported from `StoryBook.java`. +- `scripts.json`: canonical non-puzzle text loaded directly by the Flutter story pages. - `wav/`: reviewable 24 kHz mono PCM16 WAV masters. - `manifest.json`: model/voice checksums, generator versions, exact scripts, passage timings and FLAC checksums. -- `app/src/main/res/raw/narration_*.flac`: lossless bundled copies. FLAC compression is disabled in APK packaging so MediaPlayer can open resource file descriptors. +- `assets/audio/narration_*.flac`: lossless bundled copies. - `licenses/`: Kokoro ONNX wrapper MIT and model Apache 2.0 licenses. The voice uses generation speed 0.82, short fades, paragraph pauses and peak normalization. The in-app speed control changes playback speed without changing pitch. Pausing preserves the actual recording position; leaving a page releases playback. Readings never autoplay on entry. @@ -14,16 +14,13 @@ The voice uses generation speed 0.82, short fades, paragraph pauses and peak nor Generator: [kokoro-onnx](https://github.com/thewh1teagle/kokoro-onnx). Model and voice data: `kokoro-v1.0.onnx` and `voices-v1.0.bin` from its [model-files-v1.0 release](https://github.com/thewh1teagle/kokoro-onnx/releases/tag/model-files-v1.0). See the upstream [voice guide](https://huggingface.co/hexgrad/Kokoro-82M/blob/main/VOICES.md). -Use Python 3.12, dependencies pinned in `requirements.txt`, ffmpeg and a JDK. Keep model data outside the Android project. Export updated scripts before regenerating: +Use Python 3.12, dependencies pinned in `requirements.txt` and ffmpeg. Keep model data outside the app project. Edit the canonical `scripts.json` text before regenerating: ```sh -mkdir -p /tmp/lumen-narration-export -javac -d /tmp/lumen-narration-export app/src/main/java/com/lumen/daily/StoryBook.java scripts/ExportNarration.java -java -cp /tmp/lumen-narration-export com.lumen.daily.ExportNarration > assets/narration/scripts.json python scripts/render_narration.py --model /path/to/kokoro-v1.0.onnx --voices /path/to/voices-v1.0.bin python3 scripts/check_narration_assets.py ``` -The check requires only Python’s standard library, a JDK and ffmpeg. It verifies script freshness, cue coverage, master format, checksums and bit-identical WAV/FLAC decoding. It also rejects Android reader imports in app code. Listen to new takes before accepting them; automated checks cannot judge performance or pronunciation. +The check requires only Python’s standard library and ffmpeg. It verifies script freshness, cue coverage, master format, checksums and bit-identical WAV/FLAC decoding. It also rejects Flutter device-reader imports in app code. Listen to new takes before accepting them; automated checks cannot judge performance or pronunciation. A future actor recording can replace the masters and bundled assets while preserving stable page IDs. Update passage timings and checksums with that recording; never silently change the written script to fit audio. diff --git a/integration_test/notebook_test.dart b/integration_test/notebook_test.dart new file mode 100644 index 0000000..65bd11a --- /dev/null +++ b/integration_test/notebook_test.dart @@ -0,0 +1,158 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; +import 'package:lumen/main.dart'; +import 'package:lumen/domain/book.dart'; +import 'package:lumen/domain/game.dart'; +import 'package:lumen/services/progress.dart'; +import 'package:lumen/services/narrator.dart'; + +void main() { + final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + testWidgets('six leaves, recorded audio, discoveries and puzzle completion', ( + tester, + ) async { + expect( + const bool.fromEnvironment('QA_TEST'), + true, + reason: 'Run only with the QA flavor and QA_TEST=true', + ); + final book = await Book.load(), + store = Progress.memory(), + g = Game(book, store); + await tester.pumpWidget(LumenApp(game: g, adsEnabled: false)); + await tester.pumpAndSettle(); + await binding.convertFlutterSurfaceToImage(); + Future shot(String name) async { + await tester.pumpAndSettle(); + await binding.takeScreenshot(name); + } + + Future tap(String text) async { + final f = find.text(text); + await tester.ensureVisible(f); + await tester.tap(f); + await tester.pumpAndSettle(); + } + + await shot('00-home'); + await tap('Open Mara’s notebook · 0 / 12'); + expect(g.storyIndex, 0); + await shot('01-dedication'); + final width = tester.view.physicalSize.width / tester.view.devicePixelRatio; + await tester.dragFrom(Offset(width - 12, 300), const Offset(-180, 0)); + await tester.pumpAndSettle(); + expect(g.storyIndex, 1); + expect( + tester + .getBottomRight(find.text('A recorded reading, kept with this page')) + .dy, + lessThan(tester.getTopLeft(find.text('Contents')).dy), + ); + await shot('02-cottage'); + // Actual native decoder, all five files. Position must survive pause/resume. + final narrator = Narrator(book.tracks); + for (final id in book.tracks.keys) { + await narrator.toggle(id, 1); + await Future.delayed(const Duration(seconds: 2)); + await narrator.pause(); + expect(narrator.error, isEmpty, reason: id); + expect(narrator.position.inMilliseconds, greaterThan(600), reason: id); + final paused = narrator.position; + await Future.delayed(const Duration(milliseconds: 350)); + expect((narrator.position - paused).inMilliseconds.abs(), lessThan(200)); + await narrator.toggle(id, 1); + await Future.delayed(const Duration(seconds: 1)); + await narrator.pause(); + expect(narrator.position, greaterThan(paused)); + await narrator.stop(); + } + narrator.dispose(); + await tap('Next leaf →'); + expect(g.storyIndex, 2); + expect( + tester.getBottomRight(find.text('Hint · free')).dy, + lessThan(tester.getTopLeft(find.text('Contents')).dy), + ); + await shot('03-puzzle'); + final before = List.of(g.cells); + await tester.drag( + find.byKey(const ValueKey('cell-20')), + const Offset(65, 0), + ); + await tester.pumpAndSettle(); + expect(g.storyIndex, 2); + await tester.tap(find.byKey(const ValueKey('cell-0'))); + await tester.pumpAndSettle(); + expect(g.cells[0], 1); + await tap('Undo a mark'); + expect(g.cells, before); + await tap('Next leaf →'); + await tap('Read ahead'); + expect(g.solved, 0); + expect(g.storyIndex, 3); + await shot('04-memory'); + await tap('Next leaf →'); + await shot('05-folded-note'); + await tap('Unfold Gran’s note'); + expect(store.flag('notebook_note_open'), true); + await shot('05-open-note'); + await tap('Bookmark'); + await tap('Next leaf →'); + await shot('06-lantern'); + await tester.tap( + find.bySemanticsLabel( + 'Watercolour of Mara’s blue storm lantern. Tap to examine the repaired handle.', + ), + ); + await tester.pumpAndSettle(); + await tap('Keep that thought'); + expect(store.flag('notebook_handle_seen'), true); + await tap('Contents'); + await tap('Return to my ribbon bookmark'); + expect(g.storyIndex, 4); + final restarted = Game(book, Progress.memory(store.snapshot)); + await restarted.restore(); + expect(restarted.storyIndex, 4); + expect(restarted.progress.flag('notebook_note_open'), true); + g.showStory(2); + await tester.pumpAndSettle(); + final p = g.puzzle!; + for (var i = 0; i < 49; i++) { + while (g.cells[i] != (p.solution[i] == 1 ? 1 : 2)) { + await tester.tap(find.byKey(ValueKey('cell-$i'))); + await tester.pump(); + } + } + await tester.pumpAndSettle(); + expect(g.storyIndex, 3); + expect(g.solved, 1); + g.showStory(2); + g.check(); + expect(g.solved, 1); + g.showStory(5); + await tester.pumpAndSettle(); + await tap('Follow the lantern into the next entry →'); + expect(g.screen, Screen.briefing); + await tap('Restore the pattern →'); + expect(g.screen, Screen.game); + final lantern = g.puzzle!; + for (var i = 0; i < 49; i++) { + while (g.cells[i] != (lantern.solution[i] == 1 ? 1 : 2)) { + g.mark(i); + } + } + await tester.pumpAndSettle(); + expect(g.screen, Screen.reveal); + expect(g.solved, 2); + await shot('07-campaign-reveal'); + // Exercise real plugin persistence without touching main-app data. + final disk = await Progress.load(); + await disk.set('qa_roundtrip', 'notebook-and-audio'); + await disk.flushed; + expect((await Progress.load()).text('qa_roundtrip'), 'notebook-and-audio'); + expect(tester.takeException(), isNull); + await tester.pumpWidget(const SizedBox()); + await tester.pumpAndSettle(); + }); +} 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..391a902 --- /dev/null +++ b/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.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..6030543 --- /dev/null +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,647 @@ +// !$*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 */; }; + 7884E8682EC3CC0700C636F2 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */; }; + 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; }; + 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 = ""; }; + 7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; 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 = ( + 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */, + 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 */, + 7884E8672EC3CC0400C636F2 /* SceneDelegate.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; + packageProductDependencies = ( + 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */, + ); + 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; + packageReferences = ( + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */, + ); + 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 */, + 7884E8682EC3CC0700C636F2 /* SceneDelegate.swift 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 = 15.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + STRING_CATALOG_GENERATE_SYMBOLS = YES; + 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.lumen.daily; + 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.lumen.daily.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.lumen.daily.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.lumen.daily.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 = 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; + 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 = 15.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + STRING_CATALOG_GENERATE_SYMBOLS = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + 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 = 15.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + STRING_CATALOG_GENERATE_SYMBOLS = YES; + 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.lumen.daily; + 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.lumen.daily; + 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 */ + +/* Begin XCLocalSwiftPackageReference section */ + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = { + isa = XCSwiftPackageProductDependency; + productName = FlutterGeneratedPluginSwiftPackage; + }; +/* End XCSwiftPackageProductDependency 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..c3fedb2 --- /dev/null +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..c30b367 --- /dev/null +++ b/ios/Runner/AppDelegate.swift @@ -0,0 +1,16 @@ +import Flutter +import UIKit + +@main +@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } + + func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) { + GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry) + } +} 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..d36b1fa --- /dev/null +++ b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "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" : "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" : "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" + } +} 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..dc9ada4 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..7353c41 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..797d452 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..6ed2d93 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..4cd7b00 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..fe73094 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..321773c 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..797d452 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..502f463 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..0ec3034 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-60x60@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000..0ec3034 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..e9f5fea 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-76x76@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000..84ac32a 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..8953cba 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..0467bf1 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..ce851fa --- /dev/null +++ b/ios/Runner/Info.plist @@ -0,0 +1,72 @@ + + + + + CADisableMinimumFrameDurationOnPhone + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Lumen + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Lumen + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneClassName + UIWindowScene + UISceneConfigurationName + flutter + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + GADApplicationIdentifier + ca-app-pub-3940256099942544~1458002511 + + 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/Runner/SceneDelegate.swift b/ios/Runner/SceneDelegate.swift new file mode 100644 index 0000000..b9ce8ea --- /dev/null +++ b/ios/Runner/SceneDelegate.swift @@ -0,0 +1,6 @@ +import Flutter +import UIKit + +class SceneDelegate: FlutterSceneDelegate { + +} 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/legacy/README.md b/legacy/README.md new file mode 100644 index 0000000..4b82701 --- /dev/null +++ b/legacy/README.md @@ -0,0 +1,5 @@ +# Archived Java implementation + +`android/` is the pre-Flutter version 1.7, retained as an implementation reference. The active application is the root Flutter project (`lib/`, `android/`, `ios/`). This archive is not compiled into the Flutter APK. Original app artwork/audio copies are retained here; Flutter bundles canonical assets from root `assets/`. + +Old Android `lumen.xml` saves are not imported. The Flutter version intentionally starts fresh, as requested. Git commit `07e9253` also preserves the complete original application. diff --git a/app/build.gradle b/legacy/android/app/build.gradle similarity index 100% rename from app/build.gradle rename to legacy/android/app/build.gradle diff --git a/app/src/main/AndroidManifest.xml b/legacy/android/app/src/main/AndroidManifest.xml similarity index 100% rename from app/src/main/AndroidManifest.xml rename to legacy/android/app/src/main/AndroidManifest.xml diff --git a/app/src/main/java/com/lumen/daily/Ads.java b/legacy/android/app/src/main/java/com/lumen/daily/Ads.java similarity index 100% rename from app/src/main/java/com/lumen/daily/Ads.java rename to legacy/android/app/src/main/java/com/lumen/daily/Ads.java diff --git a/app/src/main/java/com/lumen/daily/Campaign.java b/legacy/android/app/src/main/java/com/lumen/daily/Campaign.java similarity index 100% rename from app/src/main/java/com/lumen/daily/Campaign.java rename to legacy/android/app/src/main/java/com/lumen/daily/Campaign.java diff --git a/app/src/main/java/com/lumen/daily/DailyStreak.java b/legacy/android/app/src/main/java/com/lumen/daily/DailyStreak.java similarity index 100% rename from app/src/main/java/com/lumen/daily/DailyStreak.java rename to legacy/android/app/src/main/java/com/lumen/daily/DailyStreak.java diff --git a/app/src/main/java/com/lumen/daily/Difficulty.java b/legacy/android/app/src/main/java/com/lumen/daily/Difficulty.java similarity index 100% rename from app/src/main/java/com/lumen/daily/Difficulty.java rename to legacy/android/app/src/main/java/com/lumen/daily/Difficulty.java diff --git a/app/src/main/java/com/lumen/daily/HomeArtwork.java b/legacy/android/app/src/main/java/com/lumen/daily/HomeArtwork.java similarity index 100% rename from app/src/main/java/com/lumen/daily/HomeArtwork.java rename to legacy/android/app/src/main/java/com/lumen/daily/HomeArtwork.java diff --git a/app/src/main/java/com/lumen/daily/JournalArt.java b/legacy/android/app/src/main/java/com/lumen/daily/JournalArt.java similarity index 100% rename from app/src/main/java/com/lumen/daily/JournalArt.java rename to legacy/android/app/src/main/java/com/lumen/daily/JournalArt.java diff --git a/app/src/main/java/com/lumen/daily/LogicSolver.java b/legacy/android/app/src/main/java/com/lumen/daily/LogicSolver.java similarity index 100% rename from app/src/main/java/com/lumen/daily/LogicSolver.java rename to legacy/android/app/src/main/java/com/lumen/daily/LogicSolver.java diff --git a/app/src/main/java/com/lumen/daily/MainActivity.java b/legacy/android/app/src/main/java/com/lumen/daily/MainActivity.java similarity index 100% rename from app/src/main/java/com/lumen/daily/MainActivity.java rename to legacy/android/app/src/main/java/com/lumen/daily/MainActivity.java diff --git a/app/src/main/java/com/lumen/daily/NotebookPage.java b/legacy/android/app/src/main/java/com/lumen/daily/NotebookPage.java similarity index 100% rename from app/src/main/java/com/lumen/daily/NotebookPage.java rename to legacy/android/app/src/main/java/com/lumen/daily/NotebookPage.java diff --git a/app/src/main/java/com/lumen/daily/PageTurnGesture.java b/legacy/android/app/src/main/java/com/lumen/daily/PageTurnGesture.java similarity index 100% rename from app/src/main/java/com/lumen/daily/PageTurnGesture.java rename to legacy/android/app/src/main/java/com/lumen/daily/PageTurnGesture.java diff --git a/app/src/main/java/com/lumen/daily/Puzzle.java b/legacy/android/app/src/main/java/com/lumen/daily/Puzzle.java similarity index 100% rename from app/src/main/java/com/lumen/daily/Puzzle.java rename to legacy/android/app/src/main/java/com/lumen/daily/Puzzle.java diff --git a/app/src/main/java/com/lumen/daily/StoryBook.java b/legacy/android/app/src/main/java/com/lumen/daily/StoryBook.java similarity index 100% rename from app/src/main/java/com/lumen/daily/StoryBook.java rename to legacy/android/app/src/main/java/com/lumen/daily/StoryBook.java diff --git a/app/src/main/java/com/lumen/daily/StoryNarrator.java b/legacy/android/app/src/main/java/com/lumen/daily/StoryNarrator.java similarity index 100% rename from app/src/main/java/com/lumen/daily/StoryNarrator.java rename to legacy/android/app/src/main/java/com/lumen/daily/StoryNarrator.java diff --git a/app/src/main/java/com/lumen/daily/StoryNotebook.java b/legacy/android/app/src/main/java/com/lumen/daily/StoryNotebook.java similarity index 100% rename from app/src/main/java/com/lumen/daily/StoryNotebook.java rename to legacy/android/app/src/main/java/com/lumen/daily/StoryNotebook.java diff --git a/app/src/main/res/drawable-nodpi/home_harbour.png b/legacy/android/app/src/main/res/drawable-nodpi/home_harbour.png similarity index 100% rename from app/src/main/res/drawable-nodpi/home_harbour.png rename to legacy/android/app/src/main/res/drawable-nodpi/home_harbour.png diff --git a/app/src/main/res/drawable-nodpi/home_notebook_cover.png b/legacy/android/app/src/main/res/drawable-nodpi/home_notebook_cover.png similarity index 100% rename from app/src/main/res/drawable-nodpi/home_notebook_cover.png rename to legacy/android/app/src/main/res/drawable-nodpi/home_notebook_cover.png diff --git a/app/src/main/res/drawable-nodpi/mara_diary_page.png b/legacy/android/app/src/main/res/drawable-nodpi/mara_diary_page.png similarity index 100% rename from app/src/main/res/drawable-nodpi/mara_diary_page.png rename to legacy/android/app/src/main/res/drawable-nodpi/mara_diary_page.png diff --git a/app/src/main/res/drawable-nodpi/mara_notebook_background.png b/legacy/android/app/src/main/res/drawable-nodpi/mara_notebook_background.png similarity index 100% rename from app/src/main/res/drawable-nodpi/mara_notebook_background.png rename to legacy/android/app/src/main/res/drawable-nodpi/mara_notebook_background.png diff --git a/app/src/main/res/drawable-nodpi/story_cottage.png b/legacy/android/app/src/main/res/drawable-nodpi/story_cottage.png similarity index 100% rename from app/src/main/res/drawable-nodpi/story_cottage.png rename to legacy/android/app/src/main/res/drawable-nodpi/story_cottage.png diff --git a/app/src/main/res/drawable-nodpi/story_lantern.png b/legacy/android/app/src/main/res/drawable-nodpi/story_lantern.png similarity index 100% rename from app/src/main/res/drawable-nodpi/story_lantern.png rename to legacy/android/app/src/main/res/drawable-nodpi/story_lantern.png diff --git a/legacy/android/app/src/main/res/drawable/ic_launcher.xml b/legacy/android/app/src/main/res/drawable/ic_launcher.xml new file mode 100644 index 0000000..d04b2ca --- /dev/null +++ b/legacy/android/app/src/main/res/drawable/ic_launcher.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/legacy/android/app/src/main/res/raw/narration_cottage_dedication.flac b/legacy/android/app/src/main/res/raw/narration_cottage_dedication.flac new file mode 100644 index 0000000..5b5356b Binary files /dev/null and b/legacy/android/app/src/main/res/raw/narration_cottage_dedication.flac differ diff --git a/legacy/android/app/src/main/res/raw/narration_cottage_folded_note.flac b/legacy/android/app/src/main/res/raw/narration_cottage_folded_note.flac new file mode 100644 index 0000000..69171ea Binary files /dev/null and b/legacy/android/app/src/main/res/raw/narration_cottage_folded_note.flac differ diff --git a/legacy/android/app/src/main/res/raw/narration_cottage_lantern_sketch.flac b/legacy/android/app/src/main/res/raw/narration_cottage_lantern_sketch.flac new file mode 100644 index 0000000..e975059 Binary files /dev/null and b/legacy/android/app/src/main/res/raw/narration_cottage_lantern_sketch.flac differ diff --git a/legacy/android/app/src/main/res/raw/narration_cottage_match_memory.flac b/legacy/android/app/src/main/res/raw/narration_cottage_match_memory.flac new file mode 100644 index 0000000..3aa05c1 Binary files /dev/null and b/legacy/android/app/src/main/res/raw/narration_cottage_match_memory.flac differ diff --git a/legacy/android/app/src/main/res/raw/narration_cottage_window.flac b/legacy/android/app/src/main/res/raw/narration_cottage_window.flac new file mode 100644 index 0000000..747c282 Binary files /dev/null and b/legacy/android/app/src/main/res/raw/narration_cottage_window.flac differ diff --git a/legacy/android/app/src/main/res/raw/narration_manifest.json b/legacy/android/app/src/main/res/raw/narration_manifest.json new file mode 100644 index 0000000..e2eaeb6 --- /dev/null +++ b/legacy/android/app/src/main/res/raw/narration_manifest.json @@ -0,0 +1,144 @@ +{ + "tracks": { + "cottage.dedication": { + "pageId": "cottage.dedication", + "resource": "narration_cottage_dedication", + "text": "My dear,\n\nI never could keep a proper diary. I wrote down the tides, the things that needed mending, and whatever I was afraid I might forget.\n\nYou will find a little of all three in here. Take your time. There is no right way to turn these pages.\n\nWith all my love,\nGran", + "file": "narration_cottage_dedication.flac", + "sampleRate": 24000, + "channels": 1, + "frames": 441184, + "durationMs": 18383, + "textSha256": "7ecbea473a70ab48a49861535bf30a3909005ce5735dcd048bc6abe576b1e017", + "flacSha256": "7606f2ea97386ed864155438d2785f6d8e6593fc04d785d432dfceb07bff52b7", + "cues": [ + { + "startMs": 180, + "endMs": 9268, + "text": "My dear,\n\nI never could keep a proper diary. I wrote down the tides, the things that needed mending, and whatever I was afraid I might forget." + }, + { + "startMs": 9868, + "endMs": 17783, + "text": "You will find a little of all three in here. Take your time. There is no right way to turn these pages.\n\nWith all my love,\nGran" + } + ] + }, + "cottage.window": { + "pageId": "cottage.window", + "resource": "narration_cottage_window", + "text": "The wind has finally gone quiet. I have put the blue cup by the window, where you always liked to sit.\n\nThe latch still sticks. Lift it a little before you turn it. Some things on this island need a gentle hand, not a stronger one.\n\nIf you arrive after dark, there is something in the little drawer beside the hearth.", + "file": "narration_cottage_window.flac", + "sampleRate": 24000, + "channels": 1, + "frames": 499104, + "durationMs": 20796, + "textSha256": "10b04750290618c667a1ab3e92247d59ea6796ac33c910906b292b6735da204c", + "flacSha256": "01864da94337c06445b60694faf2484c4a59f5f11fabc0f8d8b87a620ee09193", + "cues": [ + { + "startMs": 180, + "endMs": 6473, + "text": "The wind has finally gone quiet. I have put the blue cup by the window, where you always liked to sit." + }, + { + "startMs": 7073, + "endMs": 15009, + "text": "The latch still sticks. Lift it a little before you turn it. Some things on this island need a gentle hand, not a stronger one." + }, + { + "startMs": 15609, + "endMs": 20196, + "text": "If you arrive after dark, there is something in the little drawer beside the hearth." + } + ] + }, + "cottage.match.memory": { + "pageId": "cottage.match.memory", + "resource": "narration_cottage_match_memory", + "text": "You used to insist on lighting the evening lantern yourself. I held the matchbox, and you held your breath.\n\nOnce, you asked how such a little flame could help anyone out at sea.\n\nIt cannot, I told you. But it can help us find the next light.\n\nI kept one dry match in a tin after that. Just in case.", + "file": "narration_cottage_match_memory.flac", + "sampleRate": 24000, + "channels": 1, + "frames": 506848, + "durationMs": 21119, + "textSha256": "b047af77227d4084883babe2d7bec9cbebf8a3d807cf8d45b72e76f72db9eac5", + "flacSha256": "6cd5fadf22ce6f8ebc6a9c8968e87fb1b31a0f1e52693c7e942d8498691a533c", + "cues": [ + { + "startMs": 180, + "endMs": 6644, + "text": "You used to insist on lighting the evening lantern yourself. I held the matchbox, and you held your breath." + }, + { + "startMs": 7244, + "endMs": 11212, + "text": "Once, you asked how such a little flame could help anyone out at sea." + }, + { + "startMs": 11812, + "endMs": 15801, + "text": "It cannot, I told you. But it can help us find the next light." + }, + { + "startMs": 16401, + "endMs": 20519, + "text": "I kept one dry match in a tin after that. Just in case." + } + ] + }, + "cottage.folded.note": { + "pageId": "cottage.folded.note", + "resource": "narration_cottage_folded_note", + "text": "If the tide has covered the causeway, use the little boat by the harbour steps. The knot looks worse than it is.\n\nTake the lantern. When you reach the bell, ring twice. I will know it is you.\n\nAnd do not let the tea go cold while you are deciding.\n\nLove, Gran", + "file": "narration_cottage_folded_note.flac", + "sampleRate": 24000, + "channels": 1, + "frames": 425888, + "durationMs": 17745, + "textSha256": "2101efa580ab39cff6956a3e0011d5399e820aca79f9f60a25848487c6bcb9ad", + "flacSha256": "3675b260102c1b157e8741ff6ed9d062735860d33a15d1bbe397d997e91a2403", + "cues": [ + { + "startMs": 180, + "endMs": 6964, + "text": "If the tide has covered the causeway, use the little boat by the harbour steps. The knot looks worse than it is." + }, + { + "startMs": 7564, + "endMs": 12108, + "text": "Take the lantern. When you reach the bell, ring twice. I will know it is you." + }, + { + "startMs": 12708, + "endMs": 17145, + "text": "And do not let the tea go cold while you are deciding.\n\nLove, Gran" + } + ] + }, + "cottage.lantern.sketch": { + "pageId": "cottage.lantern.sketch", + "resource": "narration_cottage_lantern_sketch", + "text": "Your grandfather repaired this handle with a piece of wire and far too much confidence. I wrapped the join so it would not catch your fingers.\n\nPeople notice the flame first. I tend to notice the things that let us carry it.", + "file": "narration_cottage_lantern_sketch.flac", + "sampleRate": 24000, + "channels": 1, + "frames": 366944, + "durationMs": 15289, + "textSha256": "fbfc663172995a1beb20b48e65b8f469b44b7bf26609721fe34b158ecc9bdf97", + "flacSha256": "60a823473a66b1ea4c5156889f66fe276bc103db475a3e6c831cd41649d7cbd3", + "cues": [ + { + "startMs": 180, + "endMs": 8735, + "text": "Your grandfather repaired this handle with a piece of wire and far too much confidence. I wrapped the join so it would not catch your fingers." + }, + { + "startMs": 9335, + "endMs": 14689, + "text": "People notice the flame first. I tend to notice the things that let us carry it." + } + ] + } + } +} diff --git a/app/src/main/res/values-v27/styles.xml b/legacy/android/app/src/main/res/values-v27/styles.xml similarity index 100% rename from app/src/main/res/values-v27/styles.xml rename to legacy/android/app/src/main/res/values-v27/styles.xml diff --git a/app/src/main/res/values/styles.xml b/legacy/android/app/src/main/res/values/styles.xml similarity index 100% rename from app/src/main/res/values/styles.xml rename to legacy/android/app/src/main/res/values/styles.xml diff --git a/legacy/android/app/src/main/res/xml/data_extraction_rules.xml b/legacy/android/app/src/main/res/xml/data_extraction_rules.xml new file mode 100644 index 0000000..4e0689e --- /dev/null +++ b/legacy/android/app/src/main/res/xml/data_extraction_rules.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/test/java/com/lumen/daily/CampaignTest.java b/legacy/android/app/src/test/java/com/lumen/daily/CampaignTest.java similarity index 100% rename from app/src/test/java/com/lumen/daily/CampaignTest.java rename to legacy/android/app/src/test/java/com/lumen/daily/CampaignTest.java diff --git a/app/src/test/java/com/lumen/daily/DailyStreakTest.java b/legacy/android/app/src/test/java/com/lumen/daily/DailyStreakTest.java similarity index 100% rename from app/src/test/java/com/lumen/daily/DailyStreakTest.java rename to legacy/android/app/src/test/java/com/lumen/daily/DailyStreakTest.java diff --git a/app/src/test/java/com/lumen/daily/DifficultyTest.java b/legacy/android/app/src/test/java/com/lumen/daily/DifficultyTest.java similarity index 100% rename from app/src/test/java/com/lumen/daily/DifficultyTest.java rename to legacy/android/app/src/test/java/com/lumen/daily/DifficultyTest.java diff --git a/app/src/test/java/com/lumen/daily/LogicSolverTest.java b/legacy/android/app/src/test/java/com/lumen/daily/LogicSolverTest.java similarity index 100% rename from app/src/test/java/com/lumen/daily/LogicSolverTest.java rename to legacy/android/app/src/test/java/com/lumen/daily/LogicSolverTest.java diff --git a/app/src/test/java/com/lumen/daily/PageTurnGestureTest.java b/legacy/android/app/src/test/java/com/lumen/daily/PageTurnGestureTest.java similarity index 100% rename from app/src/test/java/com/lumen/daily/PageTurnGestureTest.java rename to legacy/android/app/src/test/java/com/lumen/daily/PageTurnGestureTest.java diff --git a/app/src/test/java/com/lumen/daily/PuzzleTest.java b/legacy/android/app/src/test/java/com/lumen/daily/PuzzleTest.java similarity index 100% rename from app/src/test/java/com/lumen/daily/PuzzleTest.java rename to legacy/android/app/src/test/java/com/lumen/daily/PuzzleTest.java diff --git a/app/src/test/java/com/lumen/daily/StoryBookTest.java b/legacy/android/app/src/test/java/com/lumen/daily/StoryBookTest.java similarity index 100% rename from app/src/test/java/com/lumen/daily/StoryBookTest.java rename to legacy/android/app/src/test/java/com/lumen/daily/StoryBookTest.java diff --git a/build.gradle b/legacy/android/build.gradle similarity index 100% rename from build.gradle rename to legacy/android/build.gradle diff --git a/gradle.properties b/legacy/android/gradle.properties similarity index 100% rename from gradle.properties rename to legacy/android/gradle.properties diff --git a/gradle/wrapper/gradle-wrapper.jar b/legacy/android/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from gradle/wrapper/gradle-wrapper.jar rename to legacy/android/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/wrapper/gradle-wrapper.properties b/legacy/android/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from gradle/wrapper/gradle-wrapper.properties rename to legacy/android/gradle/wrapper/gradle-wrapper.properties diff --git a/gradlew b/legacy/android/gradlew similarity index 100% rename from gradlew rename to legacy/android/gradlew diff --git a/settings.gradle b/legacy/android/settings.gradle similarity index 100% rename from settings.gradle rename to legacy/android/settings.gradle diff --git a/lib/domain/book.dart b/lib/domain/book.dart new file mode 100644 index 0000000..ebc0cdb --- /dev/null +++ b/lib/domain/book.dart @@ -0,0 +1,98 @@ +import 'dart:convert'; + +import 'package:flutter/services.dart'; + +import 'puzzle.dart'; + +class CampaignLevel { + CampaignLevel(Map data) + : chapter = data['chapter'], + title = data['title'], + object = data['object'], + before = data['before'], + after = data['after'], + picture = (data['picture'] as String).split('').map(int.parse).toList(), + clues = data['clues'], + areas = data['areas']; + final String chapter, title, object, before, after, clues, areas; + final List picture; + Puzzle puzzle() { + final p = Puzzle(7, picture); + if (clues.isNotEmpty) { + for (final c in clues.split(',')) { + p.given[int.parse(c)] = true; + } + } + if (areas.isNotEmpty) { + var i = 0; + for (final a in areas.split(';')) { + final v = a.split(',').map(int.parse).toList(); + p.regions.add( + Region(String.fromCharCode(65 + i++), v[0], v[1], v[2], v[3]), + ); + } + } + return p; + } +} + +class StoryPage { + const StoryPage(this.id, this.title, this.text); + final String id, title, text; +} + +class Book { + Book(this.premise, this.levels, this.pages, this.tracks); + final String premise; + final List levels; + final List pages; + final Map tracks; + static Future load() async { + final campaign = jsonDecode( + await rootBundle.loadString('assets/campaign.json'), + ) as Map; + final scripts = jsonDecode( + await rootBundle.loadString('assets/narration/scripts.json'), + ) as List; + final tracks = + jsonDecode( + await rootBundle.loadString( + 'assets/audio/narration_manifest.json', + ), + )['tracks'] + as Map; + const ids = [ + 'cottage.dedication', + 'cottage.window', + 'cottage.match.puzzle', + 'cottage.match.memory', + 'cottage.folded.note', + 'cottage.lantern.sketch', + ]; + const titles = [ + 'For you, when you are ready', + 'By the cottage window', + 'A spark in the drawer', + 'One small light', + 'A note I nearly forgot', + 'The handle, carefully mended', + ]; + return Book( + campaign['premise'], + (campaign['levels'] as List).map((e) => CampaignLevel(e)).toList(), + List.generate( + 6, + (i) => StoryPage( + ids[i], + titles[i], + scripts + .where((s) => s['pageId'] == ids[i]) + .map((s) => s['text'] as String) + .firstOrNull ?? + '', + ), + ), + tracks, + ); + } +} diff --git a/lib/domain/game.dart b/lib/domain/game.dart new file mode 100644 index 0000000..5845f1e --- /dev/null +++ b/lib/domain/game.dart @@ -0,0 +1,298 @@ +import 'dart:async'; +import 'dart:math' as math; + +import 'package:flutter/foundation.dart'; + +import '../services/progress.dart'; +import 'book.dart'; +import 'puzzle.dart'; + +enum Screen { home, story, contents, briefing, game, reveal } + +enum Mode { daily, classic, campaign } + +Puzzle generatePractice(Map args) => Puzzle.generate( + BigInt.parse(args['seed'] as String), + Difficulty.fromStored(args['difficulty'] as String), +); + +class Game extends ChangeNotifier { + Game(this.book, this.progress); + final Book book; + final Progress progress; + Screen screen = Screen.home; + Mode mode = Mode.classic; + Difficulty get difficulty => + Difficulty.fromStored(progress.text('difficulty', 'EASY')); + int storyIndex = 0, campaignIndex = 0, playingLevel = 1, selectedArea = 0; + DateTime date = DateTime.now(); + Puzzle? puzzle; + List cells = []; + final List> _undo = []; + String key = ''; + bool busy = false; + int _request = 0; + bool get won => progress.flag('done_$key'); + bool get canUndo => _undo.isNotEmpty && !won; + int get solved => progress.number('solved'); + int get recoveredCount => + List.generate(12, (i) => recovered(i)).where((v) => v).length; + int get unlocked => progress.number('campaignUnlocked').clamp(0, 11); + int get accessible => + math.max(unlocked, progress.number('story_access_level').clamp(0, 11)); + int get practiceLevel => progress.number('level_${difficulty.stored}', 1); + int get streak => visibleStreak( + progress.number('lastDaily', -99999), + progress.number('streak'), + epochDay(DateTime.now()), + ); + bool recovered(int i) => progress.flag('done_story_v1_$i'); + Future restore() async { + final saved = progress.text('flutter_screen', 'home'); + campaignIndex = progress.number('flutter_campaign').clamp(0, 11); + if (saved == 'story') { + showStory( + book.pages + .indexWhere((p) => p.id == progress.text('notebook_last_page')) + .clamp(0, 5), + ); + } else if (saved == 'contents') { + contents(); + } else if (saved == 'briefing') { + briefing(campaignIndex); + } else if (saved == 'reveal' && recovered(campaignIndex)) { + reveal(campaignIndex); + } else if (saved == 'game') { + final mode = progress.text('flutter_mode'); + if (mode == 'campaign') { + startCampaign(campaignIndex); + } else if (mode == 'daily') { + startDaily( + DateTime.tryParse(progress.text('flutter_date')) ?? DateTime.now(), + ); + } else { + await startPractice(progress.number('flutter_level', 1)); + } + } + } + + void _route(Screen value) { + screen = value; + unawaited(progress.set('flutter_screen', value.name)); + unawaited(progress.set('flutter_campaign', campaignIndex)); + unawaited(progress.set('flutter_mode', mode.name)); + unawaited(progress.set('flutter_date', date.toIso8601String())); + unawaited(progress.set('flutter_level', playingLevel)); + notifyListeners(); + } + + void home() { + _request++; + busy = false; + _route(Screen.home); + } + + void openNotebook() { + final i = book.pages.indexWhere( + (p) => p.id == progress.text('notebook_last_page'), + ); + showStory(i < 0 ? 0 : i); + } + + void showStory(int i) { + _request++; + busy = false; + storyIndex = i.clamp(0, 5); + mode = Mode.campaign; + campaignIndex = 0; + if (storyIndex == 2 && key != 'story_v1_0') { + _read(book.levels[0].puzzle(), 'story_v1_0'); + } + unawaited(progress.set('notebook_last_page', book.pages[storyIndex].id)); + unawaited(progress.set('viewed_${book.pages[storyIndex].id}', true)); + _route(Screen.story); + } + + void contents() { + _request++; + busy = false; + _route(Screen.contents); + } + + void briefing(int i) { + campaignIndex = i.clamp(0, accessible); + mode = Mode.campaign; + _route(Screen.briefing); + } + + void reveal(int i) { + if (!recovered(i)) { + briefing(i); + return; + } + campaignIndex = i; + mode = Mode.campaign; + _route(Screen.reveal); + } + + void selectDifficulty(Difficulty d) { + unawaited(progress.set('difficulty', d.stored)); + notifyListeners(); + } + + void startDaily(DateTime day) { + _request++; + busy = false; + mode = Mode.daily; + date = DateTime(day.year, day.month, day.day); + _read( + Puzzle.seeded(BigInt.from(epochDay(date)) * BigInt.from(7919)), + 'd${date.toIso8601String().substring(0, 10)}', + ); + _route(Screen.game); + } + + Future startPractice([int? level]) async { + final request = ++_request; + busy = true; + notifyListeners(); + final d = difficulty; + final n = level ?? practiceLevel; + final p = await compute(generatePractice, { + 'seed': '${1000000 + n}', + 'difficulty': d.stored, + }); + if (request != _request) return; + busy = false; + mode = Mode.classic; + playingLevel = n; + _read(p, 'v2_${d.stored}_$n'); + _route(Screen.game); + } + + void startCampaign(int i) { + _request++; + busy = false; + if (i > accessible) return; + if (recovered(i)) { + reveal(i); + return; + } + campaignIndex = i; + mode = Mode.campaign; + _read(book.levels[i].puzzle(), 'story_v1_$i'); + _route(Screen.game); + } + + void _read(Puzzle p, String id) { + puzzle = p; + key = id; + final saved = progress.text('grid_$id'); + cells = List.generate(p.solution.length, (i) { + if (p.given[i]) return p.solution[i] == 1 ? 1 : 2; + final value = saved.length == p.solution.length + ? int.tryParse(saved[i]) ?? 0 + : 0; + return value >= 0 && value <= 2 ? value : 0; + }); + selectedArea = 0; + _undo.clear(); + _save(); + } + + void _save() { + unawaited(progress.set('grid_$key', cells.join())); + } + + void mark(int index) { + if (busy || puzzle == null || won || puzzle!.given[index]) return; + _undo.add(List.of(cells)); + cells[index] = (cells[index] + 1) % 3; + _save(); + check(); + notifyListeners(); + } + + void undo() { + if (!canUndo) return; + cells = _undo.removeLast(); + _save(); + notifyListeners(); + } + + void area(int i) { + selectedArea = i; + notifyListeners(); + } + + Hint? applyHint() { + if (won || puzzle == null) return null; + Hint? hint; + for (var i = 0; i < cells.length; i++) { + if (cells[i] != 0 && cells[i] != (puzzle!.solution[i] == 1 ? 1 : 2)) { + hint = Hint( + i, + puzzle!.solution[i], + 'An earlier mark conflicts with the clues. Correct it, then continue comparing the totals.', + ); + break; + } + } + hint ??= LogicSolver(cells.length, puzzle!.constraints).nextHint( + cells + .map( + (v) => v == 0 + ? -1 + : v == 1 + ? 1 + : 0, + ) + .toList(), + ); + if (hint == null) return null; + _undo.add(List.of(cells)); + cells[hint.cell] = hint.value == 1 ? 1 : 2; + _save(); + notifyListeners(); + return hint; + } + + void check() { + if (won || puzzle == null || !puzzle!.solved(cells)) return; + unawaited(progress.set('done_$key', true)); + unawaited(progress.set('solved', solved + 1)); + if (mode == Mode.daily) { + final day = epochDay(date), last = progress.number('lastDaily', -99999); + if (day > last) { + unawaited( + progress.set( + 'streak', + completedStreak(last, progress.number('streak'), day), + ), + ); + unawaited(progress.set('lastDaily', day)); + } + } else if (mode == Mode.campaign) { + unawaited( + progress.set( + 'campaignUnlocked', + math.max(unlocked, math.min(11, campaignIndex + 1)), + ), + ); + if (screen == Screen.story) { + showStory(3); + } else { + reveal(campaignIndex); + } + } else { + unawaited(progress.set('level_${difficulty.stored}', playingLevel + 1)); + unawaited( + progress.set( + 'practiceCompleted', + progress.number('practiceCompleted') + 1, + ), + ); + } + notifyListeners(); + } +} diff --git a/lib/domain/puzzle.dart b/lib/domain/puzzle.dart new file mode 100644 index 0000000..03b17bc --- /dev/null +++ b/lib/domain/puzzle.dart @@ -0,0 +1,375 @@ +import 'dart:math' as math; + +enum Difficulty { + easy('Easy', 'Short deductions. A gentle place to begin.'), + medium('Medium', 'Link deductions across rows and columns.'), + hard('Hard', 'Follow longer chains to uncover the pattern.'); + + const Difficulty(this.label, this.description); + final String label, description; + String get stored => name.toUpperCase(); + static Difficulty fromStored(String value) => + values.firstWhere((d) => d.stored == value, orElse: () => easy); + static Difficulty fromRounds(int n) => n <= 2 + ? easy + : n <= 4 + ? medium + : hard; +} + +/// Explicit Java-compatible PRNG keeps generated boards stable across platforms. +class JavaRandom { + JavaRandom(BigInt seed) : _seed = (seed ^ _multiplier) & _mask; + static final _multiplier = BigInt.from(0x5DEECE66D); + static final _mask = (BigInt.one << 48) - BigInt.one; + BigInt _seed; + int next(int bits) { + _seed = (_seed * _multiplier + BigInt.from(11)) & _mask; + return (_seed >> (48 - bits)).toInt(); + } + + int nextInt(int bound) { + if ((bound & -bound) == bound) { + return ((BigInt.from(bound) * BigInt.from(next(31))) >> 31).toInt(); + } + while (true) { + final bits = next(31), value = bits % bound; + if (bits - value + bound - 1 < 0x80000000) return value; + } + } + + BigInt nextLong() { + final high = BigInt.from(next(32)).toSigned(32); + final low = BigInt.from(next(32)).toSigned(32); + return ((high << 32) + low).toSigned(64); + } + + void shuffle(List list) { + for (var i = list.length; i > 1; i--) { + final j = nextInt(i), old = list[i - 1]; + list[i - 1] = list[j]; + list[j] = old; + } + } +} + +class Region { + const Region(this.label, this.top, this.left, this.height, this.width); + final String label; + final int top, left, height, width; + bool contains(int index, int size) => + index ~/ size >= top && + index ~/ size < top + height && + index % size >= left && + index % size < left + width; +} + +class Constraint { + Constraint(this.cells, this.total, this.name); + final List cells; + final int total; + final String name; +} + +class Hint { + const Hint(this.cell, this.value, this.explanation); + final int cell, value; + final String explanation; +} + +class Analysis { + const Analysis(this.solved, this.areaDeductions, this.cells); + final bool solved; + final int areaDeductions; + final List cells; +} + +class LogicSolver { + LogicSolver(this.cellCount, this.constraints); + final int cellCount; + final List constraints; + int _need(Constraint c, List known) => + c.total - c.cells.where((i) => known[i] == 1).length; + List _unknown(Constraint c, List known) => + c.cells.where((i) => known[i] < 0).toList(); + int _singles(List known) { + var changes = 0; + for (final c in constraints) { + final need = _need(c, known), unknown = _unknown(c, known); + if (need < 0 || need > unknown.length) return -1; + if (unknown.isEmpty || (need != 0 && need != unknown.length)) continue; + for (final i in unknown) { + known[i] = need == 0 ? 0 : 1; + changes++; + } + } + return changes; + } + + Hint? nextHint(List known) { + for (final c in constraints) { + final need = _need(c, known), unknown = _unknown(c, known); + if (need < 0 || need > unknown.length) return null; + if (unknown.isNotEmpty && (need == 0 || need == unknown.length)) { + return Hint( + unknown.first, + need == 0 ? 0 : 1, + need == 0 + ? '${c.name} already has all its lights. Every remaining cell in it must be crossed out.' + : '${c.name} needs $need more lights and has exactly ${unknown.length} empty cells. They must all be lit.', + ); + } + } + for (var a = 0; a < constraints.length; a++) { + final first = constraints[a]; + for (var b = a + 1; b < constraints.length; b++) { + final second = constraints[b]; + final onlyA = _unknown( + first, + known, + ).where((i) => !second.cells.contains(i)).toList(); + final onlyB = _unknown( + second, + known, + ).where((i) => !first.cells.contains(i)).toList(); + final needA = _need(first, known), + needB = _need(second, known), + diff = needA - needB; + if (onlyA.isEmpty && onlyB.isEmpty || + (diff != onlyA.length && diff != -onlyB.length)) { + continue; + } + final valueA = diff == onlyA.length ? 1 : 0; + final explanation = + 'Compare ${first.name} ($needA more lights) with ${second.name} ($needB more). Shared empty cells cancel. The difference forces the cells outside their overlap.'; + return onlyA.isNotEmpty + ? Hint(onlyA.first, valueA, explanation) + : Hint(onlyB.first, 1 - valueA, explanation); + } + } + return null; + } + + Analysis analyze(List initial, {bool useAreas = true}) { + final known = List.of(initial); + var areas = 0; + while (true) { + final changed = _singles(known); + if (changed < 0) return Analysis(false, areas, known); + if (changed > 0) continue; + if (useAreas) { + final hint = nextHint(known); + if (hint != null) { + known[hint.cell] = hint.value; + areas++; + continue; + } + } + return Analysis(!known.contains(-1), areas, known); + } + } + + int countSolutions(List initial) { + int search(List known) { + int changed; + do { + changed = _singles(known); + if (changed < 0) return 0; + } while (changed > 0); + var choice = -1, degree = -1; + for (var i = 0; i < cellCount; i++) { + if (known[i] >= 0) continue; + final d = constraints.where((c) => c.cells.contains(i)).length; + if (d > degree) { + choice = i; + degree = d; + } + } + if (choice < 0) return 1; + final branch = List.of(known)..[choice] = 0; + final count = search(branch); + if (count >= 2) return 2; + known[choice] = 1; + return math.min(2, count + search(known)); + } + + return search(List.of(initial)); + } +} + +class Puzzle { + Puzzle(this.size, List picture) + : solution = List.of(picture), + given = List.filled(size * size, false) { + if (picture.length != size * size || picture.any((v) => v != 0 && v != 1)) { + throw ArgumentError('Invalid picture'); + } + } + final int size; + final List solution; + final List given; + final List regions = []; + List get rows => List.generate( + size, + (r) => List.generate( + size, + (c) => solution[r * size + c], + ).reduce((a, b) => a + b), + ); + List get cols => List.generate( + size, + (c) => List.generate( + size, + (r) => solution[r * size + c], + ).reduce((a, b) => a + b), + ); + int regionTotal(Region r) => List.generate( + solution.length, + (i) => r.contains(i, size) ? solution[i] : 0, + ).reduce((a, b) => a + b); + List get constraints => [ + for (var l = 0; l < size; l++) ...[ + Constraint( + List.generate(size, (p) => l * size + p), + rows[l], + 'Row ${l + 1}', + ), + Constraint( + List.generate(size, (p) => p * size + l), + cols[l], + 'Column ${l + 1}', + ), + ], + for (final r in regions) + Constraint( + [ + for (var y = r.top; y < r.top + r.height; y++) + for (var x = r.left; x < r.left + r.width; x++) y * size + x, + ], + regionTotal(r), + 'Area ${r.label}', + ), + ]; + List get initial => + List.generate(solution.length, (i) => given[i] ? solution[i] : -1); + factory Puzzle.seeded(BigInt seed) { + final random = JavaRandom(seed); + final puzzle = Puzzle(5, List.generate(25, (_) => random.next(1))); + final order = List.generate(25, (i) => i); + random.shuffle(order); + for (final i in order) { + if (puzzle.countSolutions() == 1) break; + puzzle.given[i] = true; + } + return puzzle; + } + static Puzzle generate(BigInt seed, Difficulty difficulty) { + final random = JavaRandom(seed); + for (var i = 0; i < 256; i++) { + final p = Puzzle.seeded(random.nextLong()); + if (difficulty != Difficulty.easy) p._removeRedundant(); + if (p.difficulty == difficulty) return p; + } + final p = Puzzle.seeded(BigInt.from(difficulty == Difficulty.hard ? 2 : 0)); + if (difficulty != Difficulty.easy) p._removeRedundant(); + final r = List.generate(5, (i) => i), c = List.generate(5, (i) => i); + random.shuffle(r); + random.shuffle(c); + final old = List.of(p.solution), g = List.of(p.given); + for (var i = 0; i < 25; i++) { + final from = r[i ~/ 5] * 5 + c[i % 5]; + p.solution[i] = old[from]; + p.given[i] = g[from]; + } + return p; + } + + void _removeRedundant() { + for (var i = 0; i < 25; i++) { + if (!given[i]) continue; + given[i] = false; + if (countSolutions() != 1) given[i] = true; + } + } + + int countSolutions() { + if (size != 5 || regions.isNotEmpty) { + return LogicSolver(solution.length, constraints).countSolutions(initial); + } + final rs = rows, cs = cols; + int search(int row, List totals) { + if (row == 5) { + return List.generate(5, (i) => totals[i] == cs[i]).every((v) => v) + ? 1 + : 0; + } + var count = 0; + for (var mask = 0; mask < 32; mask++) { + var bits = 0; + for (var c = 0; c < 5; c++) { + bits += (mask >> c) & 1; + } + if (bits != rs[row]) continue; + final next = List.of(totals); + var ok = true; + for (var c = 0; c < 5; c++) { + final v = (mask >> c) & 1, i = row * 5 + c; + next[c] += v; + if (given[i] && solution[i] != v || + next[c] > cs[c] || + next[c] + 4 - row < cs[c]) { + ok = false; + } + } + if (ok) count += search(row + 1, next); + if (count >= 2) return 2; + } + return count; + } + + return search(0, List.filled(5, 0)); + } + + int get deductionRounds { + var known = initial; + var rounds = 0; + final lines = constraints; + while (known.contains(-1)) { + final next = List.of(known); + var changed = false; + for (final c in lines) { + final unknown = c.cells.where((i) => known[i] < 0).toList(); + final need = c.total - c.cells.where((i) => known[i] == 1).length; + if (unknown.isNotEmpty && (need == 0 || need == unknown.length)) { + for (final i in unknown) { + next[i] = need == 0 ? 0 : 1; + changed = true; + } + } + } + if (!changed) throw StateError('Puzzle requires guessing'); + known = next; + rounds++; + } + return rounds; + } + + Difficulty get difficulty => Difficulty.fromRounds(deductionRounds); + bool solved(List cells) => + cells.length == solution.length && + List.generate( + cells.length, + (i) => cells[i] == (solution[i] == 1 ? 1 : 2), + ).every((v) => v); +} + +int epochDay(DateTime date) => + DateTime.utc(date.year, date.month, date.day).millisecondsSinceEpoch ~/ + Duration.millisecondsPerDay; +int visibleStreak(int last, int count, int today) => + last >= today - 1 ? count : 0; +int completedStreak(int last, int count, int day) => day <= last + ? count + : last == day - 1 + ? count + 1 + : 1; diff --git a/lib/main.dart b/lib/main.dart new file mode 100644 index 0000000..8dbcf88 --- /dev/null +++ b/lib/main.dart @@ -0,0 +1,925 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:intl/intl.dart'; + +import 'domain/book.dart'; +import 'domain/game.dart'; +import 'domain/puzzle.dart'; +import 'services/ads.dart'; +import 'services/narrator.dart'; +import 'services/progress.dart'; +import 'ui/board.dart'; +import 'ui/paper.dart'; + +Future main() async { + WidgetsFlutterBinding.ensureInitialized(); + LicenseRegistry.addLicense(() async* { + yield LicenseEntryWithLineBreaks([ + 'Dancing Script', + ], await rootBundle.loadString('assets/fonts/OFL.txt')); + }); + SystemChrome.setSystemUIOverlayStyle( + const SystemUiOverlayStyle( + statusBarColor: cream, + statusBarIconBrightness: Brightness.dark, + systemNavigationBarColor: Color(0xff314345), + ), + ); + final book = await Book.load(), progress = await Progress.load(); + final game = Game(book, progress); + await game.restore(); + runApp(LumenApp(game: game)); +} + +class LumenApp extends StatelessWidget { + const LumenApp({super.key, required this.game, this.adsEnabled = true}); + final Game game; + final bool adsEnabled; + @override + Widget build(BuildContext context) => MaterialApp( + title: 'Lumen', + debugShowCheckedModeBanner: false, + theme: ThemeData( + colorScheme: ColorScheme.fromSeed(seedColor: blue, surface: cream), + scaffoldBackgroundColor: cream, + fontFamily: 'MaraHand', + textTheme: ThemeData.light().textTheme.apply( + fontFamily: 'MaraHand', + bodyColor: ink, + displayColor: ink, + ), + dialogTheme: const DialogThemeData(backgroundColor: cream), + textButtonTheme: TextButtonThemeData( + style: TextButton.styleFrom(textStyle: hand(22), foregroundColor: blue), + ), + ), + home: Notebook(game: game, adsEnabled: adsEnabled), + ); +} + +class Notebook extends StatefulWidget { + const Notebook({super.key, required this.game, required this.adsEnabled}); + final Game game; + final bool adsEnabled; + @override + State createState() => _NotebookState(); +} + +class _NotebookState extends State with WidgetsBindingObserver { + Game get g => widget.game; + Progress get prefs => g.progress; + late final Narrator narrator; + late final Ads ads; + String _route = ''; + String get route => + '${g.screen.name}:${g.screen == Screen.story ? g.storyIndex : g.campaignIndex}'; + @override + void initState() { + super.initState(); + narrator = Narrator(g.book.tracks); + ads = Ads(enabled: widget.adsEnabled); + g.addListener(_changed); + _route = route; + WidgetsBinding.instance.addObserver(this); + WidgetsBinding.instance.addPostFrameCallback((_) { + unawaited(ads.start()); + }); + } + + void _changed() { + if (_route != route) { + _route = route; + unawaited(narrator.stop()); + } + if (mounted) setState(() {}); + } + + @override + void didChangeAppLifecycleState(AppLifecycleState state) { + if (state != AppLifecycleState.resumed) { + unawaited(narrator.stop()); + unawaited(prefs.flushed); + } + } + + @override + void dispose() { + WidgetsBinding.instance.removeObserver(this); + g.removeListener(_changed); + narrator.dispose(); + ads.dispose(); + super.dispose(); + } + + void toast(String text) { + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(text, style: hand(20, color: cream)), + ), + ); + } + } + + Future confirm( + String title, + String text, + String yes, { + String no = 'Keep reading', + }) async => + await showDialog( + context: context, + builder: (c) => AlertDialog( + title: Text(title, style: hand(29)), + content: Text(text, style: hand(23)), + actions: [ + TextButton( + onPressed: () => Navigator.pop(c, false), + child: Text(no), + ), + TextButton( + onPressed: () => Navigator.pop(c, true), + child: Text(yes), + ), + ], + ), + ) ?? + false; + Future message( + String title, + String text, { + String close = 'Keep going', + }) async { + await showDialog( + context: context, + builder: (c) => AlertDialog( + title: Text(title, style: hand(29)), + content: SingleChildScrollView(child: Text(text, style: hand(23))), + actions: [ + TextButton(onPressed: () => Navigator.pop(c), child: Text(close)), + ], + ), + ); + } + + Future turn(int direction) async { + final next = (g.storyIndex + direction).clamp(0, 5); + if (next == g.storyIndex) return; + if (g.storyIndex == 2 && direction > 0 && !g.won) { + unawaited(narrator.stop()); + if (!await confirm( + 'Leave a ribbon here?', + 'Your puzzle marks are saved. You can read the memory now and come back to solve the pattern whenever you like.', + 'Read ahead', + no: 'Keep solving', + )) { + return; + } + await prefs.set('notebook_read_ahead', true); + } + g.showStory(next); + } + + void back() { + if (g.busy) { + g.home(); + return; + } + switch (g.screen) { + case Screen.story: + if (g.storyIndex > 0) { + turn(-1); + } else { + g.home(); + } + case Screen.briefing: + case Screen.reveal: + g.contents(); + case Screen.game: + if (g.mode == Mode.campaign) { + g.contents(); + } else { + g.home(); + } + case Screen.contents: + g.home(); + case Screen.home: + break; + } + } + + @override + Widget build(BuildContext context) => PopScope( + canPop: g.screen == Screen.home && !g.busy, + onPopInvokedWithResult: (didPop, result) { + if (!didPop) back(); + }, + child: Scaffold( + body: Stack( + children: [ + switch (g.screen) { + Screen.home => home(), + Screen.story => story(), + Screen.contents => contents(), + Screen.briefing => briefing(), + Screen.game => game(), + Screen.reveal => reveal(), + }, + if (g.busy) + Positioned.fill( + child: ColoredBox( + color: cream.withValues(alpha: .9), + child: Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const CircularProgressIndicator(color: blue), + writing('Finding a fresh pattern…'), + InkButton('Back to the notebook', g.home), + ], + ), + ), + ), + ), + ], + ), + ), + ); + Widget column(List children) => Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: children, + ); + Widget action(String title, VoidCallback run, {bool primary = false}) => + Padding( + padding: const EdgeInsets.symmetric(vertical: 5), + child: InkButton(title, run, primary: primary), + ); + Widget gap([double n = 16]) => SizedBox(height: n); + Widget divider() => Padding( + padding: const EdgeInsets.symmetric(vertical: 18), + child: Row( + children: [ + Expanded(child: Divider(color: muted.withValues(alpha: .3))), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 12), + child: Text('❦', style: hand(27, color: muted)), + ), + Expanded(child: Divider(color: muted.withValues(alpha: .3))), + ], + ), + ); + Widget folio(String text) => writing(text, size: 15, color: blue); + Widget home() => ColoredBox( + color: cream, + child: SafeArea( + child: SingleChildScrollView( + key: const ValueKey('home-scroll'), + padding: const EdgeInsets.fromLTRB(28, 26, 28, 36), + child: Center( + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 650), + child: column([ + folio('L U M E N / AN ISLAND STORY'), + writing('A light to come\nhome to.', size: 40), + Image.asset( + 'assets/artwork/home-harbour-v2.png', + height: 220, + fit: BoxFit.contain, + semanticLabel: 'Watercolour of the island at dusk, with the lighthouse and Gran’s cottage.', + ), + writing( + 'Some things are worth keeping. — Gran', + size: 25, + color: const Color(0xff70503b), + ), + Cover(onTap: g.openNotebook), + action( + 'Open Mara’s notebook · ${g.recoveredCount} / 12', + g.openNotebook, + primary: true, + ), + gap(), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Text( + '${g.streak}\nDAY STREAK', + textAlign: TextAlign.center, + style: hand(18, color: blue), + ), + Text( + '${g.solved}\nPATTERNS FOUND', + textAlign: TextAlign.center, + style: hand(18, color: blue), + ), + ], + ), + divider(), + folio('A SMALL DAILY RITUAL'), + writing( + DateFormat('EEEE, d MMMM').format(DateTime.now()), + size: 27, + ), + action( + 'Play today’s puzzle →', + () => g.startDaily(DateTime.now()), + ), + gap(), + folio('BY THE COTTAGE WINDOW'), + writing( + 'A few spare pages for practice. For overlapping-area puzzles, follow the notebook’s story.', + size: 22, + color: muted, + ), + action('Difficulty · ${g.difficulty.label} ▾', chooseDifficulty), + action( + 'Practice · ${g.difficulty.label} · Level ${g.practiceLevel}', + () => unawaited(g.startPractice()), + ), + action('How to play', rules), + action('Privacy & advertising', privacy), + action( + 'Open-source licenses', + () => + showLicensePage(context: context, applicationName: 'Lumen'), + ), + gap(), + writing( + 'Leave a light in the window.', + size: 26, + color: const Color(0xff70503b), + ), + ]), + ), + ), + ), + ), + ); + Widget navigation() => column([ + Row( + children: [ + Expanded(child: InkButton('Contents', g.contents, size: 20)), + const SizedBox(width: 6), + Expanded( + child: InkButton('Bookmark', () { + unawaited( + prefs.set( + 'notebook_manual_bookmark', + g.book.pages[g.storyIndex].id, + ), + ); + toast('A ribbon marks this page.'); + }, size: 20), + ), + const SizedBox(width: 6), + Expanded(child: InkButton('Close book', g.home, size: 20)), + ], + ), + Row( + children: [ + Expanded( + child: InkButton( + '← Previous leaf', + g.storyIndex > 0 ? () => turn(-1) : null, + size: 21, + ), + ), + const SizedBox(width: 8), + Expanded( + child: InkButton( + g.storyIndex == 5 ? 'End of this trail' : 'Next leaf →', + g.storyIndex < 5 ? () => turn(1) : null, + size: 21, + ), + ), + ], + ), + ]); + Widget reading(String text) => ListenableBuilder( + listenable: narrator, + builder: (context, _) { + final passage = narrator.passage, + index = passage.isEmpty ? -1 : text.indexOf(passage); + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Text.rich( + TextSpan( + style: hand(g.storyIndex == 0 ? 22 : 21), + children: index < 0 + ? [TextSpan(text: text)] + : [ + TextSpan(text: text.substring(0, index)), + TextSpan( + text: passage, + style: TextStyle( + backgroundColor: amber.withValues(alpha: .35), + ), + ), + TextSpan(text: text.substring(index + passage.length)), + ], + ), + ), + ); + }, + ); + Widget audio() => ListenableBuilder( + listenable: narrator, + builder: (context, _) => column([ + Row( + children: [ + Expanded( + flex: 3, + child: InkButton( + narrator.label, + narrator.loading + ? null + : () => narrator.toggle( + g.book.pages[g.storyIndex].id, + prefs.decimal('recording_speed'), + ), + size: 21, + ), + ), + const SizedBox(width: 5), + Expanded(child: InkButton('Stop', () => narrator.stop(), size: 21)), + const SizedBox(width: 5), + Expanded(child: InkButton('Speed', speed, size: 21)), + ], + ), + writing(narrator.status, size: 17, color: muted), + ]), + ); + Widget illustration( + String asset, + String description, { + VoidCallback? onTap, + }) => Semantics( + image: true, + button: onTap != null, + label: description, + child: GestureDetector( + onTap: onTap, + child: Image.asset( + 'assets/artwork/$asset', + height: 155, + fit: BoxFit.contain, + excludeFromSemantics: true, + ), + ), + ); + Widget story() { + final p = g.book.pages[g.storyIndex]; + final body = [ + folio('MARA’S NOTEBOOK / ${g.storyIndex + 1} OF 6'), + writing(p.title, size: 31), + ]; + switch (g.storyIndex) { + case 0: + body.addAll([ + writing('A few things worth keeping', size: 20, color: muted), + divider(), + reading(p.text), + audio(), + ]); + case 1: + body.addAll([ + illustration( + 'cottage-vignette-v1.png', + 'Watercolour of Gran’s stone cottage, blue door and warm window.', + ), + writing('A note beside the window · Mara', size: 17, color: muted), + reading(p.text), + audio(), + ]); + case 2: + body.addAll([ + writing( + 'Restore a small light, or leave a bookmark and read on.', + size: 21, + color: muted, + ), + puzzleBody(), + ]); + case 3: + body.addAll([ + const Sketch('match'), + writing( + g.recovered(0) + ? 'A pattern restored · a memory kept' + : 'A memory to read · your puzzle can wait', + size: 17, + color: muted, + ), + reading(p.text), + audio(), + ]); + case 4: + if (!prefs.flag('notebook_note_open')) { + body.addAll([ + writing('A folded scrap, tucked between the leaves.'), + GestureDetector( + onTap: openLetter, + child: const Sketch('envelope', height: 190), + ), + action('Unfold Gran’s note', openLetter), + writing( + 'You don’t have to solve anything to discover this.', + size: 20, + color: muted, + ), + ]); + } else { + body.addAll([ + writing( + 'For the crossing', + size: 28, + color: const Color(0xff70503b), + ), + reading(p.text), + audio(), + action('Fold the note again', () { + unawaited(narrator.stop()); + unawaited(prefs.set('notebook_note_open', false)); + setState(() {}); + }), + ]); + } + case 5: + body.addAll([ + illustration( + 'lantern-vignette-v1.png', + 'Watercolour of Mara’s blue storm lantern. Tap to examine the repaired handle.', + onTap: inspect, + ), + writing( + prefs.flag('notebook_handle_seen') + ? 'A repair made to keep small fingers safe.' + : 'Tap the lantern to look a little closer.', + size: 20, + color: muted, + ), + reading(p.text), + audio(), + action('Follow the lantern into the next entry →', () { + unawaited( + prefs.set( + 'story_access_level', + g.accessible < 1 ? 1 : g.accessible, + ), + ); + g.briefing(1); + }), + ]); + } + return Leaf( + key: ValueKey('story-${g.storyIndex}'), + onTurn: (d) => turn(d), + body: column(body), + footer: navigation(), + ); + } + + void openLetter() { + unawaited(prefs.set('notebook_note_open', true)); + setState(() {}); + } + + Future inspect() async { + await prefs.set('notebook_handle_seen', true); + await message( + 'A careful repair', + 'The wire is hidden under a strip of cloth. In the margin, Gran has written: “The light matters. So do the hands carrying it.”', + close: 'Keep that thought', + ); + if (mounted) setState(() {}); + } + + Future speed() async { + await narrator.pause(); + if (!mounted) return; + await showDialog( + context: context, + builder: (c) => SimpleDialog( + title: Text('Recording speed', style: hand(29)), + children: [ + for (final entry in [ + (0.85, 'Unhurried · 0.85×'), + (1.0, 'Original reading · 1.0×'), + (1.15, 'A little faster · 1.15×'), + ]) + SimpleDialogOption( + onPressed: () { + unawaited(prefs.set('recording_speed', entry.$1)); + Navigator.pop(c); + }, + child: Text(entry.$2, style: hand(23)), + ), + ], + ), + ); + } + + Widget contents() => Leaf( + key: const ValueKey('contents'), + body: column([ + folio('THE NOTEBOOK BELONGS TO'), + writing('Mara Wren', size: 40), + writing('The Last Light', size: 33), + writing( + 'For you, when you are ready.\nWith all my love, Gran.', + color: const Color(0xff70503b), + ), + divider(), + folio('THE COTTAGE · OPENING LEAVES'), + for (var i = 0; i < 6; i++) + action('${i + 1} · ${g.book.pages[i].title}', () => g.showStory(i)), + action('Return to my ribbon bookmark', () { + final i = g.book.pages.indexWhere( + (p) => p.id == prefs.text('notebook_manual_bookmark'), + ); + g.showStory(i < 0 ? 0 : i); + }), + divider(), + writing(g.book.premise), + writing( + '${g.recoveredCount} / 12 memories tucked between these pages', + size: 20, + color: muted, + ), + for (var i = 0; i < 12; i++) ...[ + if (i % 4 == 0) ...[ + gap(24), + writing(g.book.levels[i].chapter, size: 28, color: blue), + ], + Padding( + padding: const EdgeInsets.symmetric(vertical: 5), + child: InkButton( + '${(i + 1).toString().padLeft(2, '0')} · ${g.recovered(i) ? '${g.book.levels[i].object} ✓' : g.book.levels[i].title}${i > g.accessible ? ' · not yet' : ''}', + i <= g.accessible + ? () { + if (g.recovered(i)) { + g.reveal(i); + } else { + g.briefing(i); + } + } + : null, + ), + ), + ], + action('Close the notebook', g.home), + ]), + ); + Widget briefing() { + final l = g.book.levels[g.campaignIndex]; + return Leaf( + key: ValueKey('briefing-${g.campaignIndex}'), + body: column([ + folio('MARA’S NOTEBOOK / LEAF ${g.campaignIndex + 1}'), + writing(l.chapter, size: 20, color: blue), + writing(l.title, size: 33), + gap(), + writing(l.before, size: 25), + divider(), + writing( + g.campaignIndex < 2 + ? 'Light the cells to match each row and column total. Cross out the cells that stay dark. The finished grid is a picture from the story.' + : 'A, B and C are outlined areas with their own light totals. Shared cells count in each area they belong to. Compare clues and subtract their shared parts to find new deductions.', + size: 22, + color: muted, + ), + action( + prefs.contains('grid_story_v1_${g.campaignIndex}') + ? 'Continue this pattern →' + : 'Restore the pattern →', + () => g.startCampaign(g.campaignIndex), + primary: true, + ), + action('Back to notebook', g.contents), + ]), + ); + } + + Widget puzzleBody() { + final p = g.puzzle; + if (p == null) return const SizedBox.shrink(); + return column([ + if (p.regions.isNotEmpty) ...[ + Wrap( + spacing: 6, + children: [ + for (var i = 0; i < p.regions.length; i++) + InkButton( + '${p.regions[i].label} · ${List.generate(g.cells.length, (j) => j).where((j) => p.regions[i].contains(j, p.size) && g.cells[j] == 1).length} / ${p.regionTotal(p.regions[i])}', + () => g.area(i), + size: 21, + primary: i == g.selectedArea, + ), + ], + ), + writing('Tap A, B or C to highlight its area', size: 17, color: muted), + ], + Board( + puzzle: p, + cells: g.cells, + onMark: g.mark, + selectedArea: g.selectedArea, + won: g.won, + ), + writing( + g.won + ? 'Already restored. Turn the leaf to revisit the memory.' + : 'Tap: light → cross → clear. Mark every cell.', + size: 18, + color: muted, + ), + if (!g.won) + Row( + children: [ + Expanded( + child: InkButton( + 'Undo a mark', + g.canUndo ? g.undo : null, + size: 22, + ), + ), + const SizedBox(width: 8), + Expanded( + child: InkButton( + prefs.flag('hint_${g.key}') + ? 'Hint · rewarded ad' + : 'Hint · free', + hint, + size: 22, + ), + ), + ], + ), + ]); + } + + Widget game() => Leaf( + key: ValueKey('game-${g.key}'), + body: column([ + folio( + g.mode == Mode.daily + ? 'DAILY / ${DateFormat('d MMMM').format(g.date)}' + : g.mode == Mode.campaign + ? 'THE LAST LIGHT / ${g.campaignIndex + 1} OF 12' + : 'CLASSIC / ${g.difficulty.label} / LEVEL ${g.playingLevel}', + ), + writing( + g.mode == Mode.campaign + ? g.book.levels[g.campaignIndex].title + : 'Find the light.', + size: 32, + ), + writing( + g.puzzle!.regions.isEmpty + ? 'Match the totals. Let the pattern emerge.' + : 'Compare rows, columns and overlapping areas.', + size: 21, + color: muted, + ), + puzzleBody(), + if (g.won) ...[ + writing('A moment of clarity.', size: 29), + action( + g.mode == Mode.daily ? 'Return to the notebook' : 'Next puzzle →', + g.mode == Mode.daily ? g.home : nextPractice, + primary: true, + ), + ], + action('How to play', rules), + action('Back to notebook', g.mode == Mode.campaign ? g.contents : g.home), + ]), + ); + Future hint() async { + final requested = g.key; + void give() async { + if (!mounted || + g.key != requested || + g.won || + !(g.screen == Screen.game || + g.screen == Screen.story && g.storyIndex == 2)) { + return; + } + final h = g.applyHint(); + if (h == null) return; + await message( + 'Row ${h.cell ~/ g.puzzle!.size + 1}, column ${h.cell % g.puzzle!.size + 1}', + '${h.explanation}\n\n${h.value == 1 ? 'This cell is lit.' : 'This cell stays dark.'}', + ); + if (mounted && g.key == requested) g.check(); + } + + if (!prefs.flag('hint_$requested')) { + await prefs.set('hint_$requested', true); + give(); + return; + } + if (!await confirm( + 'A little nudge?', + 'Watch a rewarded ad for one explained hint.', + 'Watch ad', + no: 'Keep thinking', + )) { + return; + } + if (!await ads.hint(give)) { + toast('No ad available. Please try again later.'); + } + } + + void nextPractice() { + final n = prefs.number('practiceCompleted'); + if (n > 0 && n % 4 == 0) { + ads.between(() => unawaited(g.startPractice())); + } else { + unawaited(g.startPractice()); + } + } + + Widget reveal() { + final i = g.campaignIndex, l = g.book.levels[i]; + return Leaf( + key: ValueKey('reveal-$i'), + body: column([ + folio('MARA’S NOTEBOOK / LEAF ${i + 1}'), + writing( + 'Something found. Something remembered.', + size: 23, + color: muted, + ), + writing(l.object, size: 35), + PixelPicture(l.picture, label: l.object), + writing(l.after, size: 25), + gap(), + writing( + 'Kept safe, between these pages. — M.', + size: 23, + color: const Color(0xff70503b), + ), + divider(), + if (i == 11) ...[ + folio('THE END · YOUR WATCH HAS BEGUN'), + writing( + 'Twelve patterns. One light brought home. The daily puzzle will be here whenever you return.', + ), + action('Return to the notebook', g.contents, primary: true), + action('Today’s puzzle', () => g.startDaily(DateTime.now())), + ] else + action('Turn the page →', () { + void next() { + if (mounted) g.briefing(i + 1); + } + + if ((i + 1) % 4 == 0 && !prefs.flag('storyAd_$i')) { + unawaited(prefs.set('storyAd_$i', true)); + ads.between(next); + } else { + next(); + } + }, primary: true), + action('Back to notebook', g.contents), + ]), + ); + } + + Future chooseDifficulty() async { + await showDialog( + context: context, + builder: (c) => SimpleDialog( + title: Text('Classic practice pace', style: hand(29)), + children: [ + for (final d in Difficulty.values) + SimpleDialogOption( + onPressed: () { + g.selectDifficulty(d); + Navigator.pop(c); + }, + child: Text('${d.label} — ${d.description}', style: hand(23)), + ), + ], + ), + ); + } + + void rules() => message( + 'Find the light', + 'Light exactly as many cells as the number beside each row and above each column.\n\nTap to cycle: empty → light → crossed out → empty. Mark every cell to finish. Small dots mark fixed clues.\n\nA, B and C are overlapping areas with their own totals. Shared cells count in both areas. Compare clues and subtract their shared parts to find new deductions.\n\nEvery story grid reveals an object. Later pages require area comparisons; all are solvable without guessing. Classic practice grades the length of simpler row and column chains.\n\nOne free explained hint per puzzle, then optional rewarded hints. Streaks count consecutive daily completions on this device.', + close: 'Got it', + ); + Future privacy() async { + if (!await ads.privacy()) { + await message( + 'Privacy & advertising', + 'Game progress stays on this device. No account or game backend is used. Google advertising services may process device and ad interaction data when ads are available.\n\nNo advertising privacy options are currently required or available for your region.', + close: 'Close', + ); + } + } +} diff --git a/lib/services/ads.dart b/lib/services/ads.dart new file mode 100644 index 0000000..ec495b5 --- /dev/null +++ b/lib/services/ads.dart @@ -0,0 +1,181 @@ +import 'dart:async'; + +import 'package:flutter/foundation.dart'; +import 'package:google_mobile_ads/google_mobile_ads.dart'; + +class Ads { + Ads({this.enabled = true}); + final bool enabled; + RewardedAd? _reward; + InterstitialAd? _interstitial; + bool _started = false, + _rewardLoading = false, + _interstitialLoading = false, + _disposed = false; + DateTime? _rewardAt, _interstitialAt; + bool get supported => + enabled && + !kIsWeb && + (defaultTargetPlatform == TargetPlatform.android || + defaultTargetPlatform == TargetPlatform.iOS); + Future start() async { + if (!supported) return; + ConsentInformation.instance.requestConsentInfoUpdate( + ConsentRequestParameters(), + () { + ConsentForm.loadAndShowConsentFormIfRequired((_) => _initialize()); + }, + (_) => _initialize(), + ); + } + + Future _initialize() async { + if (_disposed || + _started || + !await ConsentInformation.instance.canRequestAds()) { + return; + } + _started = true; + await MobileAds.instance.initialize(); + await _load(); + } + + Future _load() async { + if (_disposed || + !supported || + !await ConsentInformation.instance.canRequestAds()) { + return; + } + final ios = defaultTargetPlatform == TargetPlatform.iOS; + if (_reward == null && !_rewardLoading) { + _rewardLoading = true; + RewardedAd.load( + adUnitId: const String.fromEnvironment('ADMOB_REWARDED_ID').isNotEmpty + ? const String.fromEnvironment('ADMOB_REWARDED_ID') + : ios + ? 'ca-app-pub-3940256099942544/1712485313' + : 'ca-app-pub-3940256099942544/5224354917', + request: const AdRequest(), + rewardedAdLoadCallback: RewardedAdLoadCallback( + onAdLoaded: (a) { + _rewardLoading = false; + if (_disposed) { + a.dispose(); + return; + } + _reward = a; + _rewardAt = DateTime.now(); + }, + onAdFailedToLoad: (_) { + _rewardLoading = false; + }, + ), + ); + } + if (_interstitial == null && !_interstitialLoading) { + _interstitialLoading = true; + InterstitialAd.load( + adUnitId: + const String.fromEnvironment('ADMOB_INTERSTITIAL_ID').isNotEmpty + ? const String.fromEnvironment('ADMOB_INTERSTITIAL_ID') + : ios + ? 'ca-app-pub-3940256099942544/4411468910' + : 'ca-app-pub-3940256099942544/1033173712', + request: const AdRequest(), + adLoadCallback: InterstitialAdLoadCallback( + onAdLoaded: (a) { + _interstitialLoading = false; + if (_disposed) { + a.dispose(); + return; + } + _interstitial = a; + _interstitialAt = DateTime.now(); + }, + onAdFailedToLoad: (_) { + _interstitialLoading = false; + }, + ), + ); + } + } + + Future hint(VoidCallback earned) async { + if (!supported || !await ConsentInformation.instance.canRequestAds()) { + return false; + } + final a = _reward; + _reward = null; + if (a == null || + _rewardAt == null || + DateTime.now().difference(_rewardAt!).inMinutes >= 58) { + a?.dispose(); + unawaited(_load()); + return false; + } + a.fullScreenContentCallback = FullScreenContentCallback( + onAdDismissedFullScreenContent: (ad) { + ad.dispose(); + _load(); + }, + onAdFailedToShowFullScreenContent: (ad, e) { + ad.dispose(); + _load(); + }, + ); + a.show( + onUserEarnedReward: (ad, reward) { + earned(); + }, + ); + return true; + } + + Future between(VoidCallback next) async { + if (!supported || !await ConsentInformation.instance.canRequestAds()) { + next(); + return; + } + final a = _interstitial; + _interstitial = null; + if (a == null || + _interstitialAt == null || + DateTime.now().difference(_interstitialAt!).inMinutes >= 58) { + a?.dispose(); + next(); + unawaited(_load()); + return; + } + var routed = false; + void finish() { + if (routed) return; + routed = true; + a.dispose(); + next(); + _load(); + } + + a.fullScreenContentCallback = FullScreenContentCallback( + onAdDismissedFullScreenContent: (_) => finish(), + onAdFailedToShowFullScreenContent: (_, e) => finish(), + ); + a.show(); + } + + Future privacy() async { + if (!supported) return false; + if (await ConsentInformation.instance + .getPrivacyOptionsRequirementStatus() != + PrivacyOptionsRequirementStatus.required) { + return false; + } + ConsentForm.showPrivacyOptionsForm((_) {}); + return true; + } + + void dispose() { + _disposed = true; + _reward?.dispose(); + _interstitial?.dispose(); + } +} diff --git a/lib/services/narrator.dart b/lib/services/narrator.dart new file mode 100644 index 0000000..d3dd365 --- /dev/null +++ b/lib/services/narrator.dart @@ -0,0 +1,117 @@ +import 'dart:async'; + +import 'package:flutter/foundation.dart'; +import 'package:just_audio/just_audio.dart'; +import 'package:audio_session/audio_session.dart'; + +class Narrator extends ChangeNotifier { + Narrator(this.tracks) { + _subscriptions.add( + _player.playerStateStream.listen((_) => notifyListeners()), + ); + _subscriptions.add(_player.positionStream.listen((_) => notifyListeners())); + } + final Map tracks; + final _player = AudioPlayer(); + final List> _subscriptions = []; + String page = '', error = ''; + bool loading = false; + int _generation = 0; + bool get playing => + _player.playing && _player.processingState != ProcessingState.completed; + bool get finished => _player.processingState == ProcessingState.completed; + bool get paused => page.isNotEmpty && !playing && !finished && !loading; + Duration get position => _player.position; + String get label => loading + ? 'Opening recording…' + : playing + ? 'Pause recording' + : finished + ? 'Replay recording' + : paused + ? 'Resume recording' + : 'Play this reading'; + String _time(Duration d) => + '${d.inMinutes}:${(d.inSeconds % 60).toString().padLeft(2, '0')}'; + String get status => error.isNotEmpty + ? error + : page.isEmpty + ? 'A recorded reading, kept with this page' + : finished + ? 'End of the reading · listen again whenever you like' + : '${playing ? 'Playing' : 'Paused'} · ${_time(position)} / ${_time(_player.duration ?? Duration.zero)}'; + String get passage { + if (page.isEmpty || finished) return ''; + for (final cue in tracks[page]?['cues'] ?? []) { + if (position.inMilliseconds >= cue['startMs'] && + position.inMilliseconds < cue['endMs']) { + return cue['text']; + } + } + return ''; + } + + Future toggle(String id, double speed) async { + if (loading) return; + if (playing && page == id) { + await _player.pause(); + return; + } + final generation = ++_generation; + try { + if (page != id) { + loading = true; + error = ''; + notifyListeners(); + final session = await AudioSession.instance; + await session.configure(const AudioSessionConfiguration.speech()); + if (generation != _generation) return; + page = id; + await _player.setAsset('assets/audio/${tracks[id]['file']}'); + if (generation != _generation) return; + } else if (finished) { + await _player.seek(Duration.zero); + } + await _player.setSpeed(speed); + if (generation != _generation) return; + loading = false; + notifyListeners(); + unawaited( + _player.play().catchError((Object e) { + error = 'This recording could not be played. You can still read the entry.'; + notifyListeners(); + }), + ); + } catch (e) { + if (generation == _generation) { + error = + 'This recording could not be played. You can still read the entry.'; + loading = false; + page = ''; + notifyListeners(); + } + } + } + + Future pause() async { + await _player.pause(); + } + + Future stop() async { + ++_generation; + page = ''; + loading = false; + error = ''; + notifyListeners(); + await _player.stop(); + } + + @override + void dispose() { + for (final s in _subscriptions) { + unawaited(s.cancel()); + } + unawaited(_player.dispose()); + super.dispose(); + } +} diff --git a/lib/services/progress.dart b/lib/services/progress.dart new file mode 100644 index 0000000..fd6c683 --- /dev/null +++ b/lib/services/progress.dart @@ -0,0 +1,47 @@ +import 'package:shared_preferences/shared_preferences.dart'; + +/// Flutter has its own store; the former Android `lumen.xml` is never imported. +class Progress { + Progress._(this._disk, this._values); + final SharedPreferencesAsync? _disk; + final Map _values; + static Future load() async { + final disk = SharedPreferencesAsync(); + return Progress._(disk, (await disk.getAll()).cast()); + } + + factory Progress.memory([Map values = const {}]) => + Progress._(null, Map.of(values)); + int number(String key, [int fallback = 0]) => + (_values[key] as num?)?.toInt() ?? fallback; + double decimal(String key, [double fallback = 1]) => + (_values[key] as num?)?.toDouble() ?? fallback; + bool flag(String key) => _values[key] == true; + String text(String key, [String fallback = '']) => + _values[key] as String? ?? fallback; + bool contains(String key) => _values.containsKey(key); + Map get snapshot => Map.unmodifiable(_values); + Future _writes = Future.value(); + Future set(String key, Object value) { + _values[key] = value; + final disk = _disk; + if (disk == null) return Future.value(); + _writes = _writes.then((_) async { + switch (value) { + case bool v: + await disk.setBool(key, v); + case int v: + await disk.setInt(key, v); + case double v: + await disk.setDouble(key, v); + case String v: + await disk.setString(key, v); + default: + throw ArgumentError('Unsupported preference'); + } + }); + return _writes; + } + + Future get flushed => _writes; +} diff --git a/lib/ui/board.dart b/lib/ui/board.dart new file mode 100644 index 0000000..07a125b --- /dev/null +++ b/lib/ui/board.dart @@ -0,0 +1,227 @@ +import 'package:flutter/material.dart'; + +import '../domain/puzzle.dart'; +import 'paper.dart'; + +class Board extends StatelessWidget { + const Board({ + super.key, + required this.puzzle, + required this.cells, + required this.onMark, + this.selectedArea = 0, + this.won = false, + }); + final Puzzle puzzle; + final List cells; + final ValueChanged onMark; + final int selectedArea; + final bool won; + @override + Widget build(BuildContext context) => Center( + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 350), + child: AspectRatio( + aspectRatio: 1, + child: LayoutBuilder( + builder: (context, c) { + final n = puzzle.size, + u = c.maxWidth / (n + 1.3), + r = puzzle.regions.isEmpty + ? null + : puzzle.regions[selectedArea]; + Widget clue(String text, bool complete) => SizedBox( + width: u, + height: u, + child: Center( + child: Text( + text, + style: hand( + (u * .42).clamp(16, 23), + color: complete ? blue : muted, + ), + ), + ), + ); + bool complete(Iterable indices, int total) => + indices.where((i) => cells[i] == 1).length == total; + return Align( + alignment: Alignment.center, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox(width: u, height: u), + for (var col = 0; col < n; col++) + clue( + '${puzzle.cols[col]}', + complete( + List.generate(n, (i) => i * n + col), + puzzle.cols[col], + ), + ), + ], + ), + for (var row = 0; row < n; row++) + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + clue( + '${puzzle.rows[row]}', + complete( + List.generate(n, (i) => row * n + i), + puzzle.rows[row], + ), + ), + for (var col = 0; col < n; col++) + Builder( + builder: (context) { + final i = row * n + col, + value = cells[i], + fixed = puzzle.given[i], + inside = r?.contains(i, n) ?? false; + final state = value == 0 + ? 'empty' + : value == 1 + ? 'lit' + : 'crossed out'; + return Semantics( + label: + 'Row ${row + 1}, column ${col + 1}, $state${fixed ? ', fixed clue' : ''}', + button: !fixed && !won, + enabled: !fixed && !won, + onTap: fixed || won ? null : () => onMark(i), + excludeSemantics: true, + child: GestureDetector( + key: ValueKey('cell-$i'), + behavior: HitTestBehavior.opaque, + onTap: fixed || won ? null : () => onMark(i), + child: SizedBox( + width: u, + height: u, + child: Padding( + padding: const EdgeInsets.all(2), + child: DecoratedBox( + decoration: BoxDecoration( + color: value == 1 + ? blue + : inside + ? amber.withValues(alpha: .22) + : Colors.transparent, + borderRadius: BorderRadius.circular( + 2, + ), + border: Border.all( + color: inside + ? const Color(0xffaa5b2a) + : muted.withValues(alpha: .48), + width: inside ? 1.4 : .65, + ), + ), + child: Stack( + children: [ + if (value == 2) + Center( + child: Text( + '×', + style: hand( + u * .62, + color: muted, + ), + ), + ), + if (fixed) + Positioned( + right: 3, + bottom: 3, + child: Container( + width: 4, + height: 4, + decoration: BoxDecoration( + color: value == 1 + ? cream + : muted, + shape: BoxShape.circle, + ), + ), + ), + ], + ), + ), + ), + ), + ), + ); + }, + ), + ], + ), + ], + ), + ); + }, + ), + ), + ), + ); +} + +class PixelPicture extends StatelessWidget { + const PixelPicture( + this.picture, { + super.key, + required this.label, + this.height = 230, + }); + final List picture; + final String label; + final double height; + @override + Widget build(BuildContext context) => Semantics( + image: true, + label: 'Recovered pixel picture: $label', + child: Center( + child: SizedBox( + width: height, + height: height, + child: Padding( + padding: const EdgeInsets.all(24), + child: DecoratedBox( + decoration: BoxDecoration( + color: const Color(0xfffaf1d8), + boxShadow: [ + BoxShadow( + color: ink.withValues(alpha: .15), + offset: const Offset(3, 4), + ), + ], + ), + child: Padding( + padding: const EdgeInsets.all(16), + child: CustomPaint(painter: _Pixels(picture)), + ), + ), + ), + ), + ), + ); +} + +class _Pixels extends CustomPainter { + _Pixels(this.picture); + final List picture; + @override + void paint(Canvas c, Size s) { + final p = Paint()..color = blue, u = s.width / 7; + for (var i = 0; i < 49; i++) { + if (picture[i] == 1) { + c.drawRect(Rect.fromLTWH(i % 7 * u, i ~/ 7 * u, u + .3, u + .3), p); + } + } + } + + @override + bool shouldRepaint(_Pixels old) => old.picture != picture; +} diff --git a/lib/ui/paper.dart b/lib/ui/paper.dart new file mode 100644 index 0000000..78454c0 --- /dev/null +++ b/lib/ui/paper.dart @@ -0,0 +1,272 @@ +import 'dart:math' as math; + +import 'package:flutter/material.dart'; + +const ink = Color(0xff36413c), + blue = Color(0xff274956), + muted = Color(0xff796b55), + cream = Color(0xfff3e7cc), + amber = Color(0xffe0b568); +TextStyle hand(double size, {Color color = ink}) => TextStyle( + fontFamily: 'MaraHand', + fontSize: size, + height: 1.30, + color: color, +); +Widget writing(String value, {double size = 23, Color color = ink}) => Padding( + padding: const EdgeInsets.symmetric(vertical: 5), + child: Text(value, style: hand(size, color: color)), +); + +class InkButton extends StatelessWidget { + const InkButton( + this.label, + this.onPressed, { + super.key, + this.size = 23, + this.primary = false, + }); + final String label; + final VoidCallback? onPressed; + final double size; + final bool primary; + @override + Widget build(BuildContext context) => DecoratedBox( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide(color: blue.withValues(alpha: primary ? .5 : .18)), + ), + ), + child: TextButton( + onPressed: onPressed, + style: TextButton.styleFrom( + foregroundColor: blue, + disabledForegroundColor: muted.withValues(alpha: .4), + textStyle: hand(size), + minimumSize: const Size(48, 48), + padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 8), + shape: const RoundedRectangleBorder(), + ), + child: Text(label, textAlign: TextAlign.center), + ), + ); +} + +class Paper extends StatefulWidget { + const Paper({super.key, required this.child, this.onTurn}); + final Widget child; + final ValueChanged? onTurn; + @override + State createState() => _PaperState(); +} + +class _PaperState extends State { + Offset? start; + @override + Widget build(BuildContext context) => ColoredBox( + color: const Color(0xff314345), + child: SafeArea( + child: LayoutBuilder( + builder: (context, c) { + final landscape = c.maxWidth > c.maxHeight; + final scale = landscape + ? c.maxWidth / 1024 + : math.min(c.maxWidth / 1024, c.maxHeight / 1536); + final w = 1024 * scale, + h = 1536 * scale, + left = (c.maxWidth - w) / 2, + top = (c.maxHeight - h) / 2; + final narrow = c.maxWidth < 480; + final content = landscape + ? Rect.fromLTRB( + c.maxWidth * .10, + c.maxHeight * .06, + c.maxWidth * .83, + c.maxHeight * .94, + ) + : Rect.fromLTRB( + left + w * (narrow ? .08 : .11), + top + h * .12, + left + w * (narrow ? .91 : .83), + top + h * .91, + ); + return Listener( + onPointerDown: (e) { + start = + (e.localPosition.dx < content.left || + e.localPosition.dx > content.right) + ? e.localPosition + : null; + }, + onPointerUp: (e) { + final origin = start; + start = null; + if (origin == null) return; + final d = e.localPosition - origin; + if (d.dx.abs() > 55 && d.dx.abs() > d.dy.abs() * 1.5) { + widget.onTurn?.call(d.dx < 0 ? 1 : -1); + } + }, + child: Stack( + clipBehavior: Clip.hardEdge, + children: [ + Positioned( + left: left, + top: top, + width: w, + height: h, + child: Image.asset( + 'assets/artwork/mara-single-page-v2.png', + fit: BoxFit.fill, + excludeFromSemantics: true, + ), + ), + Positioned.fromRect(rect: content, child: widget.child), + ], + ), + ); + }, + ), + ), + ); +} + +class Leaf extends StatelessWidget { + const Leaf({super.key, required this.body, this.footer, this.onTurn}); + final Widget body; + final Widget? footer; + final ValueChanged? onTurn; + @override + Widget build(BuildContext context) => Paper( + onTurn: onTurn, + child: Column( + children: [ + Expanded( + child: SingleChildScrollView( + key: const PageStorageKey('leaf-scroll'), + padding: const EdgeInsets.fromLTRB(4, 0, 4, 8), + child: body, + ), + ), + ?footer, + ], + ), + ); +} + +class Cover extends StatelessWidget { + const Cover({super.key, required this.onTap}); + final VoidCallback onTap; + @override + Widget build(BuildContext context) => Semantics( + button: true, + label: 'Open Mara’s cloth-bound island notebook', + child: GestureDetector( + onTap: onTap, + child: SizedBox( + height: 230, + child: Center( + child: AspectRatio( + aspectRatio: 1.5, + child: LayoutBuilder( + builder: (context, c) => Stack( + children: [ + Positioned.fill( + child: Image.asset( + 'assets/artwork/home-notebook-cover-v2.png', + fit: BoxFit.fill, + excludeFromSemantics: true, + ), + ), + Positioned( + left: c.maxWidth * .27, + top: c.maxHeight * .32, + width: c.maxWidth * .49, + height: c.maxHeight * .34, + child: Center( + child: Transform.rotate( + angle: -.044, + child: Text( + 'Mara’s\nisland notebook', + textAlign: TextAlign.center, + style: hand(28), + ), + ), + ), + ), + ], + ), + ), + ), + ), + ), + ), + ); +} + +class Sketch extends StatelessWidget { + const Sketch(this.kind, {super.key, this.height = 140}); + final String kind; + final double height; + @override + Widget build(BuildContext context) => Semantics( + image: true, + label: kind == 'match' + ? 'A pencil sketch of a match and a small amber flame' + : 'A folded note sealed with red wax', + child: SizedBox( + height: height, + width: double.infinity, + child: CustomPaint(painter: _SketchPainter(kind)), + ), + ); +} + +class _SketchPainter extends CustomPainter { + _SketchPainter(this.kind); + final String kind; + @override + void paint(Canvas c, Size s) { + final p = Paint()..isAntiAlias = true; + final x = s.width * .51, h = s.height; + if (kind == 'match') { + p + ..color = const Color(0xff997445) + ..strokeWidth = h * .045; + c.drawLine(Offset(x - 25, h * .88), Offset(x + 12, h * .36), p); + p.color = const Color(0xff654539); + c.drawOval(Rect.fromLTRB(x + 2, h * .27, x + 26, h * .41), p); + p.color = amber; + final f = Path() + ..moveTo(x + 12, h * .33) + ..cubicTo(x - 24, h * .17, x + 30, h * .19, x + 17, h * .05) + ..cubicTo(x + 56, h * .20, x + 32, h * .33, x + 12, h * .33); + c.drawPath(f, p); + } else { + final r = Rect.fromLTRB(s.width * .10, h * .15, s.width * .90, h * .86); + p.color = const Color(0xffead9b2); + c.drawRect(r, p); + p + ..color = const Color(0xffb8a17c) + ..style = PaintingStyle.stroke + ..strokeWidth = 1.5; + c.drawRect(r, p); + c.drawPath( + Path() + ..moveTo(r.left, r.top) + ..lineTo(s.width * .5, h * .59) + ..lineTo(r.right, r.top), + p, + ); + c.drawLine(r.bottomLeft, Offset(s.width * .4, h * .5), p); + c.drawLine(r.bottomRight, Offset(s.width * .6, h * .5), p); + p + ..style = PaintingStyle.fill + ..color = const Color(0xff9e5f49); + c.drawCircle(Offset(s.width * .5, h * .57), h * .075, p); + } + } + + @override + bool shouldRepaint(_SketchPainter old) => old.kind != kind; +} diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..5b0f737 --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,617 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + 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: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37 + url: "https://pub.dev" + source: hosted + version: "2.13.1" + audio_session: + dependency: "direct main" + description: + name: audio_session + sha256: f9e7711a0e24ca8b40f5d7ac374c3c6e55016f3157912badd18199cdbbca5c4d + url: "https://pub.dev" + source: hosted + version: "0.2.4" + 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: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b + url: "https://pub.dev" + source: hosted + version: "1.4.1" + clock: + dependency: transitive + description: + name: clock + sha256: e51d50bca3217c9a9fa2b41a30e4a38971133f5f9ec7a3d57bae095007f1d28e + url: "https://pub.dev" + source: hosted + version: "1.1.3" + code_assets: + dependency: transitive + description: + name: code_assets + sha256: bf394f466ba9205f1812a0433b392d6af280f155f56651eda7c18cc32ed493b8 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + 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: e3626ae6270383c9e3a549f34c9e4cd26c09ae6a9adaab2bf4737a00340efdc4 + url: "https://pub.dev" + source: hosted + version: "3.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_driver: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "3105dc8492f6183fb076ccf1f351ac3d60564bff92e20bfc4af9cc1651f4e7e1" + url: "https://pub.dev" + source: hosted + version: "6.0.0" + 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" + fuchsia_remote_debug_protocol: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + google_mobile_ads: + dependency: "direct main" + description: + name: google_mobile_ads + sha256: "439e018d73b47565d1cf21410e893a8f46d5fb95110c41c266a6fb78449d7106" + url: "https://pub.dev" + source: hosted + version: "9.2.0" + hooks: + dependency: transitive + description: + name: hooks + sha256: "9a62a50b50b769a737bc0a8ff381f333529df3ab746b2f6b02e83760231455ba" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + integration_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + intl: + dependency: "direct main" + description: + name: intl + sha256: "1ca20c894b1717686a2319b8548763d812bc0aabdac580420a44c5178c57a867" + url: "https://pub.dev" + source: hosted + version: "0.20.3" + jni: + dependency: transitive + description: + name: jni + sha256: d8df6dab6847855512fe44dd9032b0bbe34dda7bf7597e41d30750879779813f + url: "https://pub.dev" + source: hosted + version: "1.1.1" + jni_flutter: + dependency: transitive + description: + name: jni_flutter + sha256: "0dd33d67797560f66e961a6053882d4df54bd345bf063b8fe7ea133f7ad8b191" + url: "https://pub.dev" + source: hosted + version: "1.0.4+1" + jni_util: + dependency: transitive + description: + name: jni_util + sha256: "1ba86da04a5f2bf18fde2edb235587e70c5b0fc5bd4ba955f46b00942c3fc35f" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + just_audio: + dependency: "direct main" + description: + name: just_audio + sha256: e60aa97b233ddea025e13dfac59195207f528fa5e9e4a4a49a8c0766701e5fe6 + url: "https://pub.dev" + source: hosted + version: "0.10.6" + just_audio_platform_interface: + dependency: transitive + description: + name: just_audio_platform_interface + sha256: "2532c8d6702528824445921c5ff10548b518b13f808c2e34c2fd54793b999a6a" + url: "https://pub.dev" + source: hosted + version: "4.6.0" + just_audio_web: + dependency: transitive + description: + name: just_audio_web + sha256: "6ba8a2a7e87d57d32f0f7b42856ade3d6a9fbe0f1a11fabae0a4f00bb73f0663" + url: "https://pub.dev" + source: hosted + version: "0.4.16" + 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: "31bd099b47c10cd1aeb55146a2d46ce0277630ecef3f7dae54ad7873f36696cd" + url: "https://pub.dev" + source: hosted + version: "0.12.20" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" + url: "https://pub.dev" + source: hosted + version: "0.13.0" + meta: + dependency: transitive + description: + name: meta + sha256: c82594181e3312f3d0695fc95aaaf7758d75b8d4ae2bbecf223b9fd5109a059d + url: "https://pub.dev" + source: hosted + version: "1.18.3" + objective_c: + dependency: transitive + description: + name: objective_c + sha256: b7fb95a6d9a4f009edd63dc5ac69f07420b23a16161c6dd8660290b59c602e8e + url: "https://pub.dev" + source: hosted + version: "9.5.0" + package_config: + dependency: transitive + description: + name: package_config + sha256: ffcf4cf3d6c0b74ac43708d9f56625506e8a68aa935abe9d267a7330f320eb5d + url: "https://pub.dev" + source: hosted + version: "3.0.0" + path: + dependency: transitive + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + path_provider: + dependency: transitive + description: + name: path_provider + sha256: a7f4874f987173da295a61c181b8ee71dab59b332a486b391babf26a1b884825 + url: "https://pub.dev" + source: hosted + version: "2.1.6" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: "69cbd515a62b94d32a7944f086b2f82b4ac40a1d45bebfc00813a430ab2dabcd" + url: "https://pub.dev" + source: hosted + version: "2.3.1" + 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: "58c2005f147315b11e9b4a7bc889cd5203e250cba8e3f012dae259b4972b5c16" + url: "https://pub.dev" + source: hosted + version: "2.2.2" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "484838772624c3a4b94f1e44a3e19897fee738f2d5c4ce448443b0417f7c9dda" + url: "https://pub.dev" + source: hosted + version: "2.1.3" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 + url: "https://pub.dev" + source: hosted + version: "2.3.0" + platform: + dependency: transitive + description: + name: platform + sha256: a36d119c13416516a7b5913fbe8af8531e11633d784c550b2125f76c758524ec + url: "https://pub.dev" + source: hosted + version: "3.2.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + process: + dependency: transitive + description: + name: process + sha256: "4242ba3508d37e01808bdf71ad1d5bb93a8d671bf2e7450e6b1b353fb0808891" + url: "https://pub.dev" + source: hosted + version: "5.0.6" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "261236774e8b1d69cfc6b9eabbc96c40f25e7a2d6b171f3385d4f65d5734fb24" + url: "https://pub.dev" + source: hosted + version: "2.2.1" + record_use: + dependency: transitive + description: + name: record_use + sha256: "2551bd8eecfe95d14ae75f6021ad0248be5c27f138c2ec12fcb52b500b3ba1ed" + url: "https://pub.dev" + source: hosted + version: "0.6.0" + rxdart: + dependency: transitive + description: + name: rxdart + sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962" + url: "https://pub.dev" + source: hosted + version: "0.28.0" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + sha256: "1e85e0dccf5b4a016077fea7dfbb4a7cb39c759ac1596fcf60c06deadb7da91f" + url: "https://pub.dev" + source: hosted + version: "2.5.6" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + sha256: "33b38b07d9ac7d16aff0426c61418752fd3e7a8c7dc8be786c875d6ce673b002" + url: "https://pub.dev" + source: hosted + version: "2.5.4" + shared_preferences_foundation: + dependency: transitive + description: + name: shared_preferences_foundation + sha256: "2ec3934efa51e46117f23031cc141b8fc878e8525b94ec1ea4f7f586cf1b47ea" + url: "https://pub.dev" + source: hosted + version: "2.5.7" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + sha256: "649dc798a33931919ea356c4305c2d1f81619ea6e92244070b520187b5140ef9" + url: "https://pub.dev" + source: hosted + version: "2.4.2" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + sha256: c49bd060261c9a3f0ff445892695d6212ff603ef3115edbb448509d407600019 + url: "https://pub.dev" + source: hosted + version: "2.4.3" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + 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" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "277654b3034d17ac6f9f1cb5595db011b1d5d41e8806866db28e0abaa101c490" + url: "https://pub.dev" + source: hosted + version: "1.12.2" + 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" + sync_http: + dependency: transitive + description: + name: sync_http + sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961" + url: "https://pub.dev" + source: hosted + version: "0.3.1" + synchronized: + dependency: transitive + description: + name: synchronized + sha256: b3d516dbd3757ff2a458735e4f6cbac9ff261f576f6e87bcb17feabb39e657c5 + url: "https://pub.dev" + source: hosted + version: "3.5.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: "2a122cbe059f8b610d3a5415f42e255b6c17b1f21eee1d960f31080237fb4f11" + url: "https://pub.dev" + source: hosted + version: "0.7.12" + uuid: + dependency: transitive + description: + name: uuid + sha256: "9b129329f58692f6e6578329498a8fe9fbe98f090beb764ffbb8ee2eadd01dcd" + url: "https://pub.dev" + source: hosted + version: "4.6.0" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "1d774bbdf6b72a0b12122fc1560c9c2d2a67db5a4a4cc2bd8a5c990ab20e3188" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "89b11d62e1040ee681af3b4f1c97a803ecbf010c6e8b9c5896ee5b08c3bf7b78" + url: "https://pub.dev" + source: hosted + version: "15.4.0" + web: + dependency: transitive + description: + name: web + sha256: e119e82ac4795c7925103b7cf3768191f33941b99e7ccffbd6c645201d9f606b + url: "https://pub.dev" + source: hosted + version: "1.1.2" + webdriver: + dependency: transitive + description: + name: webdriver + sha256: "28b82ec894fed45dd71c23ba62d1af973ed97dd59a4f5790a4d38b0b13e5657e" + url: "https://pub.dev" + source: hosted + version: "3.2.0" + webview_flutter: + dependency: transitive + description: + name: webview_flutter + sha256: d53e1ccf5516f25017e3c9d44c39034db352d20fa34fe200674270242c2c5111 + url: "https://pub.dev" + source: hosted + version: "4.14.1" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + sha256: "4de8b3d1ff4ebe1bdb42e68a5e4f809194a3cb0117a8f495f590004f00da3964" + url: "https://pub.dev" + source: hosted + version: "4.14.1" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + sha256: "1221c1b12f5278791042f2ec2841743784cf25c5a644e23d6680e5d718824f04" + url: "https://pub.dev" + source: hosted + version: "2.15.1" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + sha256: acac45e0a8d7beb1d0805521f44842f406c46eb5a69410f53d935e3c62138afc + url: "https://pub.dev" + source: hosted + version: "3.27.2" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: f67cdd8e07d3c6329146aaef1ba043542b3134c12489f553ca9a7435d1068aea + url: "https://pub.dev" + source: hosted + version: "3.1.4" +sdks: + dart: ">=3.13.0 <4.0.0" + flutter: ">=3.47.0" diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..09b6694 --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,36 @@ +name: lumen +description: Mara's island notebook — an offline illustrated logic puzzle. +publish_to: none +version: 2.0.0+9 +environment: + sdk: '>=3.13.0 <4.0.0' +dependencies: + flutter: + sdk: flutter + shared_preferences: ^2.5.6 + google_mobile_ads: ^9.2.0 + just_audio: ^0.10.6 + audio_session: ^0.2.2 + intl: ^0.20.3 +dev_dependencies: + flutter_test: + sdk: flutter + integration_test: + sdk: flutter + flutter_lints: ^6.0.0 +flutter: + uses-material-design: true + assets: + - assets/fonts/OFL.txt + - assets/campaign.json + - assets/artwork/mara-single-page-v2.png + - assets/artwork/home-harbour-v2.png + - assets/artwork/home-notebook-cover-v2.png + - assets/artwork/cottage-vignette-v1.png + - assets/artwork/lantern-vignette-v1.png + - assets/narration/scripts.json + - assets/audio/ + fonts: + - family: MaraHand + fonts: + - asset: assets/fonts/DancingScript.ttf diff --git a/scripts/check_flutter_install.py b/scripts/check_flutter_install.py new file mode 100644 index 0000000..b64326c --- /dev/null +++ b/scripts/check_flutter_install.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +"""Read-only game-progress smoke check of the installed Flutter app; no fixtures/reset.""" +import argparse,re,subprocess,time,xml.etree.ElementTree as ET +from pathlib import Path +p=argparse.ArgumentParser();p.add_argument('--serial',required=True);p.add_argument('--package',default='com.lumen.daily');p.add_argument('--expect-fresh',action='store_true');a=p.parse_args() +assert re.fullmatch(r'[a-zA-Z0-9_.]+',a.package) +base=['/home/ubuntu/Android/Sdk/platform-tools/adb','-s',a.serial];out=Path('artifacts/flutter-check');out.mkdir(parents=True,exist_ok=True) +def adb(*args):return subprocess.check_output(base+list(args)) +def dump(): + adb('shell','uiautomator','dump','/sdcard/lumen-flutter-smoke.xml') + return ET.fromstring(adb('exec-out','cat','/sdcard/lumen-flutter-smoke.xml')) +def value(n):return n.get('text','')+' '+n.get('content-desc','') +def find(text): + root=dump() + for n in root.iter('node'): + if text.casefold() in value(n).casefold():return n + raise AssertionError('Missing '+text+'; screen: '+str([value(n) for n in root.iter('node') if value(n).strip()])) +def tapnode(n): + x1,y1,x2,y2=map(int,re.findall(r'\d+',n.get('bounds')));adb('shell','input','tap',str((x1+x2)//2),str((y1+y2)//2)) +def tap(text):tapnode(find(text)) +def launch():adb('shell','am','start','-n',a.package+'/com.lumen.daily.MainActivity') +def shot(name):(out/name).write_bytes(adb('exec-out','screencap','-p')) +launch();time.sleep(2) +# Leave the player's actual consent decision to them if UMP requires it. +root=dump() +assert not any('Welcome to Publisher Test Ads' in value(n) for n in root.iter('node')),'Consent form is awaiting the player’s choice.' +if any('Close book' in value(n) for n in root.iter('node')):tap('Close book') +if a.expect_fresh:find('0 / 12');find('0\nPATTERNS FOUND') +shot('main-home.png');tap('Open Mara’s notebook');find('For you, when you are ready');tap('Next leaf');find('By the cottage window') +play=find('Play this reading');tapnode(play);time.sleep(2);shot('main-recording.png');tapnode(play);find('Resume recording') +def seconds(): + n=find('Paused ·');m=re.search(r'(\d+):(\d+)',value(n));return int(m[1])*60+int(m[2]) +first=seconds();assert first>=1 +tapnode(play);time.sleep(2);tapnode(play);find('Resume recording');assert seconds()>=first+1 +tap('Stop');find('Play this reading') +adb('shell','am','force-stop',a.package);launch();find('By the cottage window');find('Play this reading');shot('main-restored-page.png') +tap('Close book') +if a.expect_fresh:find('0 / 12');find('0\nPATTERNS FOUND') +print('PASS: optimized app launches, starts fresh, plays through its UI, resumes audio, restores the reading place after process restart and leaves puzzle counts unchanged.') +(out/'release-smoke.txt').write_text('PASS: fresh Flutter progress; release startup; UI FLAC playback/pause/resume/stop; process restart restores page; 0 puzzles awarded by reading.\n') diff --git a/scripts/check_narration_assets.py b/scripts/check_narration_assets.py index da70cae..8d1a4b2 100644 --- a/scripts/check_narration_assets.py +++ b/scripts/check_narration_assets.py @@ -1,13 +1,10 @@ #!/usr/bin/env python3 """Verify every bundled recording matches the current diary text and its WAV master.""" -import array, hashlib, json, math, subprocess, tempfile, wave +import array, hashlib, json, subprocess, wave from pathlib import Path root=Path(__file__).resolve().parents[1] -source=root/'assets/narration';raw=root/'app/src/main/res/raw' -with tempfile.TemporaryDirectory(prefix='lumen-audio-text-') as temp: - subprocess.run(['javac','-d',temp,str(root/'app/src/main/java/com/lumen/daily/StoryBook.java'),str(root/'scripts/ExportNarration.java')],check=True) - canonical=json.loads(subprocess.check_output(['java','-cp',temp,'com.lumen.daily.ExportNarration'])) -assert canonical==json.loads((source/'scripts.json').read_text()),'Regenerate the script export after editing diary text' +source=root/'assets/narration';raw=root/'assets/audio' +canonical=json.loads((source/'scripts.json').read_text()) manifest=json.loads((source/'manifest.json').read_text());runtime=json.loads((raw/'narration_manifest.json').read_text()) assert runtime['tracks']==manifest['tracks'] assert len(canonical)==5==len(manifest['tracks']) @@ -32,7 +29,6 @@ for record in canonical: assert decoded==master,'Runtime FLAC must preserve the WAV master exactly' assert track['flacSha256']==hashlib.sha256(flac.read_bytes()).hexdigest() print(f"PASS {record['pageId']}: {track['durationMs']/1000:.1f}s, lossless, text/cues match") -for p in (root/'app/src/main/java').rglob('*.java'): - assert 'android.speech.tts' not in p.read_text(),f'Android reader reintroduced in {p}' -assert 'TTS_SERVICE' not in (root/'app/src/main/AndroidManifest.xml').read_text() -print('All five recordings verified; no Android text-to-speech dependency.') +for p in (root/'lib').rglob('*.dart'): + assert 'flutter_tts' not in p.read_text(),f'Device reader reintroduced in {p}' +print('All five recordings verified; bundled file playback only.') diff --git a/scripts/ExportNarration.java b/scripts/legacy/ExportNarration.java similarity index 100% rename from scripts/ExportNarration.java rename to scripts/legacy/ExportNarration.java diff --git a/scripts/check_storybook.py b/scripts/legacy/check_storybook.py similarity index 100% rename from scripts/check_storybook.py rename to scripts/legacy/check_storybook.py diff --git a/scripts/render_narration.py b/scripts/render_narration.py index d81e29d..80b6f2e 100644 --- a/scripts/render_narration.py +++ b/scripts/render_narration.py @@ -16,7 +16,7 @@ parser.add_argument('--voice',default='bf_emma') parser.add_argument('--speed',type=float,default=.82) parser.add_argument('--root',type=Path,default=Path(__file__).resolve().parents[1]) a=parser.parse_args() -source=a.root/'assets/narration';raw=a.root/'app/src/main/res/raw' +source=a.root/'assets/narration';raw=a.root/'assets/audio' (source/'wav').mkdir(parents=True,exist_ok=True);raw.mkdir(parents=True,exist_ok=True) options=ort.SessionOptions();options.intra_op_num_threads=4;options.inter_op_num_threads=1 session=ort.InferenceSession(str(a.model),sess_options=options,providers=['CPUExecutionProvider']) diff --git a/test/fixtures/java_boards.json b/test/fixtures/java_boards.json new file mode 100644 index 0000000..951e97e --- /dev/null +++ b/test/fixtures/java_boards.json @@ -0,0 +1,242 @@ +[ + { + "kind": "legacy", + "seed": "0", + "solution": "1101101011000111101000000", + "given": "1110101110011100111101111" + }, + { + "kind": "EASY", + "seed": "0", + "solution": "1100000111001011111011000", + "given": "1111101111011101111101011" + }, + { + "kind": "MEDIUM", + "seed": "0", + "solution": "1111100100000101010001010", + "given": "0000000000000101000000100" + }, + { + "kind": "HARD", + "seed": "0", + "solution": "0010010101110010010011101", + "given": "0000100000110000010000000" + }, + { + "kind": "legacy", + "seed": "1", + "solution": "1000000111001011111001000", + "given": "1101101100000111011100111" + }, + { + "kind": "EASY", + "seed": "1", + "solution": "1000100111011001001110010", + "given": "1101101001111101101111111" + }, + { + "kind": "MEDIUM", + "seed": "1", + "solution": "0111001001011100100000011", + "given": "0000101001011000100000000" + }, + { + "kind": "HARD", + "seed": "1", + "solution": "1000100111011001001110010", + "given": "1000000000011001000000101" + }, + { + "kind": "legacy", + "seed": "2", + "solution": "1010011011100101101100111", + "given": "1111111111001001101001101" + }, + { + "kind": "EASY", + "seed": "2", + "solution": "1000011100100011101010100", + "given": "0100111001010111011001010" + }, + { + "kind": "MEDIUM", + "seed": "2", + "solution": "1000011100100011101010100", + "given": "0000000000000010001001000" + }, + { + "kind": "HARD", + "seed": "2", + "solution": "1000001110001001100111010", + "given": "0001001100001000001000000" + }, + { + "kind": "legacy", + "seed": "-1", + "solution": "0001110010100001111110101", + "given": "0101011010011111111111111" + }, + { + "kind": "EASY", + "seed": "-1", + "solution": "1101110110010011010010101", + "given": "0011000001010010001100110" + }, + { + "kind": "MEDIUM", + "seed": "-1", + "solution": "1101110110010011010010101", + "given": "0010000000010010000000010" + }, + { + "kind": "HARD", + "seed": "-1", + "solution": "1011110101110011110100001", + "given": "0100000100000000000000000" + }, + { + "kind": "legacy", + "seed": "1000001", + "solution": "0101100010001001100010001", + "given": "1101111100010100110111111" + }, + { + "kind": "EASY", + "seed": "1000001", + "solution": "1100111110001000100110101", + "given": "0110010101111100100110001" + }, + { + "kind": "MEDIUM", + "seed": "1000001", + "solution": "1111011011111010101011011", + "given": "0000000100000100000000001" + }, + { + "kind": "HARD", + "seed": "1000001", + "solution": "1011011100110000111000011", + "given": "0010001100000101000000011" + }, + { + "kind": "legacy", + "seed": "1000002", + "solution": "0110111011010101110001010", + "given": "1110100100001001101100000" + }, + { + "kind": "EASY", + "seed": "1000002", + "solution": "1010010100011110110100001", + "given": "1111100001111110110111011" + }, + { + "kind": "MEDIUM", + "seed": "1000002", + "solution": "0011111111000010110100111", + "given": "0000000000000000001000000" + }, + { + "kind": "HARD", + "seed": "1000002", + "solution": "1100110110001001101011011", + "given": "0100100100001000000000000" + }, + { + "kind": "legacy", + "seed": "164371900", + "solution": "0011001011111001000101001", + "given": "1000011011011011111010111" + }, + { + "kind": "EASY", + "seed": "164371900", + "solution": "1100110100011111010100100", + "given": "1011111101010001101110001" + }, + { + "kind": "MEDIUM", + "seed": "164371900", + "solution": "0010001010101001110011010", + "given": "0010010000001000001000000" + }, + { + "kind": "HARD", + "seed": "164371900", + "solution": "0010111000011100110011101", + "given": "0000100110000000000000010" + }, + { + "kind": "legacy", + "seed": "180000000", + "solution": "0100000100011011101111001", + "given": "0111101011010001101111010" + }, + { + "kind": "EASY", + "seed": "180000000", + "solution": "1001100000101100010000001", + "given": "0101101001011101010101001" + }, + { + "kind": "MEDIUM", + "seed": "180000000", + "solution": "1111001100000110011001100", + "given": "0000000000111000100000000" + }, + { + "kind": "HARD", + "seed": "180000000", + "solution": "0110110001001101001111110", + "given": "0100000100000100010000001" + }, + { + "kind": "legacy", + "seed": "9223372036854775807", + "solution": "0001110010100001111110101", + "given": "0101011010011111111111111" + }, + { + "kind": "EASY", + "seed": "9223372036854775807", + "solution": "1101110110010011010010101", + "given": "0011000001010010001100110" + }, + { + "kind": "MEDIUM", + "seed": "9223372036854775807", + "solution": "1101110110010011010010101", + "given": "0010000000010010000000010" + }, + { + "kind": "HARD", + "seed": "9223372036854775807", + "solution": "1011110101110011110100001", + "given": "0100000100000000000000000" + }, + { + "kind": "legacy", + "seed": "-9223372036854775808", + "solution": "1101101011000111101000000", + "given": "1110101110011100111101111" + }, + { + "kind": "EASY", + "seed": "-9223372036854775808", + "solution": "1100000111001011111011000", + "given": "1111101111011101111101011" + }, + { + "kind": "MEDIUM", + "seed": "-9223372036854775808", + "solution": "1111100100000101010001010", + "given": "0000000000000101000000100" + }, + { + "kind": "HARD", + "seed": "-9223372036854775808", + "solution": "0010010101110010010011101", + "given": "0000100000110000010000000" + } +] diff --git a/test/puzzle_test.dart b/test/puzzle_test.dart new file mode 100644 index 0000000..e2536dd --- /dev/null +++ b/test/puzzle_test.dart @@ -0,0 +1,163 @@ +import 'dart:convert'; +import 'dart:io'; +import 'dart:math'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:lumen/domain/puzzle.dart'; +import 'package:lumen/domain/book.dart'; +import 'package:lumen/domain/game.dart'; +import 'package:lumen/services/progress.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + test('Dart generation matches 40 Java reference boards including signed 64-bit seeds', () { + final fixtures = jsonDecode( + File('test/fixtures/java_boards.json').readAsStringSync(), + ) as List; + for (final f in fixtures) { + final seed = BigInt.parse(f['seed']), + p = f['kind'] == 'legacy' + ? Puzzle.seeded(seed) + : Puzzle.generate(seed, Difficulty.fromStored(f['kind'])); + expect(p.solution.join(), f['solution'], reason: '${f['kind']} $seed'); + expect( + p.given.map((v) => v ? 1 : 0).join(), + f['given'], + reason: '${f['kind']} $seed givens', + ); + } + }); + test('300 generated practice boards have requested grades, unique answers and complete hints', () { + for (final d in Difficulty.values) { + for (var seed = 1000001; seed < 1000101; seed++) { + final p = Puzzle.generate(BigInt.from(seed), d); + expect(p.difficulty, d); + expect(p.countSolutions(), 1); + final solver = LogicSolver(25, p.constraints), + analysis = solver.analyze(p.initial); + expect(analysis.solved, true); + expect(analysis.cells, p.solution); + expect(p.solved(p.solution.map((v) => v == 1 ? 1 : 2).toList()), true); + expect(p.solved(List.filled(25, 0)), false); + } + } + }); + test( + 'area solver matches exhaustive enumeration for 300 random small systems', + () { + final rng = Random(42); + for (var trial = 0; trial < 300; trial++) { + final constraints = List.generate(1 + rng.nextInt(5), (k) { + final cells = [ + for (var i = 0; i < 6; i++) + if (rng.nextBool()) i, + ]; + return Constraint(cells, rng.nextInt(cells.length + 1), '$k'); + }); + var count = 0; + for (var mask = 0; mask < 64; mask++) { + if (constraints.every( + (c) => + c.cells.fold(0, (sum, i) => sum + ((mask >> i) & 1)) == + c.total, + )) { + count++; + } + } + expect( + LogicSolver(6, constraints).countSolutions(List.filled(6, -1)), + min(2, count), + ); + } + }, + ); + test('all campaign pictures unique; later entries require comparisons, without guessing', () async { + final book = await Book.load(); + expect(book.levels.length, 12); + for (var i = 0; i < 12; i++) { + final p = book.levels[i].puzzle(), + solver = LogicSolver(49, p.constraints); + expect(p.countSolutions(), 1, reason: 'campaign $i'); + final a = solver.analyze(p.initial); + expect(a.solved, true, reason: 'campaign $i'); + expect(a.cells, p.solution); + if (i >= 2) { + expect(solver.analyze(p.initial, useAreas: false).solved, false); + expect(a.areaDeductions, greaterThan(0)); + } + } + }); + test('calendar streak handles repeats, missed days and DST boundaries', () { + expect(completedStreak(100, 4, 100), 4); + expect(completedStreak(100, 4, 101), 5); + expect(completedStreak(100, 4, 102), 1); + expect(visibleStreak(100, 4, 102), 0); + expect( + epochDay(DateTime(2026, 10, 26)) - epochDay(DateTime(2026, 10, 25)), + 1, + ); + }); + test( + 'fresh Flutter progress ignores old saves; reading never awards completion', + () async { + final store = Progress.memory(), g = Game(await Book.load(), store); + await g.restore(); + expect(g.screen, Screen.home); + expect(g.solved, 0); + expect(g.recoveredCount, 0); + g.showStory(2); + g.mark(0); + final marks = List.of(g.cells); + g.showStory(3); + expect(g.solved, 0); + expect(g.recovered(0), false); + g.showStory(2); + expect(g.cells, marks); + g.undo(); + expect(g.cells[0], 0); + final p = g.puzzle!; + for (var i = 0; i < 49; i++) { + while (g.cells[i] != (p.solution[i] == 1 ? 1 : 2)) { + g.mark(i); + } + } + expect(g.screen, Screen.story); + expect(g.storyIndex, 3); + expect(g.solved, 1); + expect(g.recovered(0), true); + g.showStory(2); + g.check(); + expect(g.solved, 1); + final restored = Game(g.book, Progress.memory(store.snapshot)); + await restored.restore(); + expect(restored.storyIndex, 2); + expect(restored.solved, 1); + }, + ); + test('daily completion awards once and practice difficulties keep separate levels', () async { + final store = Progress.memory(), g = Game(await Book.load(), store); + g.startDaily(DateTime(2026, 10, 31)); + final p = g.puzzle!; + for (var i = 0; i < 25; i++) { + while (g.cells[i] != (p.solution[i] == 1 ? 1 : 2)) { + g.mark(i); + } + } + expect(g.solved, 1); + expect(g.progress.number('streak'), 1); + g.check(); + expect(g.solved, 1); + g.selectDifficulty(Difficulty.hard); + await g.startPractice(); + expect(g.puzzle!.difficulty, Difficulty.hard); + final hard = g.puzzle!; + for (var i = 0; i < 25; i++) { + while (g.cells[i] != (hard.solution[i] == 1 ? 1 : 2)) { + g.mark(i); + } + } + expect(g.practiceLevel, 2); + g.selectDifficulty(Difficulty.easy); + expect(g.practiceLevel, 1); + }); +} diff --git a/test/widget_test.dart b/test/widget_test.dart new file mode 100644 index 0000000..3cc075d --- /dev/null +++ b/test/widget_test.dart @@ -0,0 +1,78 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:lumen/domain/puzzle.dart'; +import 'package:lumen/ui/board.dart'; +import 'package:lumen/ui/paper.dart'; + +void main() { + testWidgets('page margins turn leaves; grid drags never turn', ( + tester, + ) async { + tester.view.reset(); + tester.view.physicalSize = const Size(600, 960); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + var turns = 0, marks = 0; + final p = Puzzle(7, List.filled(49, 0)); + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Paper( + onTurn: (d) => turns += d, + child: Board( + puzzle: p, + cells: List.filled(49, 0), + onMark: (_) => marks++, + ), + ), + ), + ), + ); + await tester.pumpAndSettle(); + await tester.dragFrom(const Offset(585, 400), const Offset(-180, 0)); + await tester.pumpAndSettle(); + expect(turns, 1); + await tester.drag( + find.byKey(const ValueKey('cell-20')), + const Offset(70, 0), + ); + await tester.pumpAndSettle(); + expect(turns, 1); + await tester.tap(find.byKey(const ValueKey('cell-20'))); + expect(marks, 1); + expect(tester.takeException(), isNull); + }); + testWidgets('paper supports small and landscape viewports and larger text', ( + tester, + ) async { + addTearDown(tester.view.reset); + for (final size in [const Size(360, 640), const Size(960, 600)]) { + tester.view.physicalSize = size; + tester.view.devicePixelRatio = 1; + await tester.pumpWidget( + MaterialApp( + home: MediaQuery( + data: MediaQueryData( + size: size, + textScaler: const TextScaler.linear(1.5), + ), + child: Scaffold( + body: Leaf( + body: Column( + children: [ + writing('For you, when you are ready', size: 31), + writing('A remembered passage. ' * 40), + ], + ), + footer: InkButton('Next leaf', () {}), + ), + ), + ), + ), + ); + await tester.pumpAndSettle(); + expect(find.text('Next leaf'), findsOneWidget); + expect(tester.takeException(), isNull); + } + }); +} diff --git a/test_driver/integration_test.dart b/test_driver/integration_test.dart new file mode 100644 index 0000000..8b0d709 --- /dev/null +++ b/test_driver/integration_test.dart @@ -0,0 +1,14 @@ +import 'dart:io'; + +import 'package:integration_test/integration_test_driver_extended.dart'; + +Future main() async { + await integrationDriver( + onScreenshot: (name, bytes, [args]) async { + final file = File('artifacts/flutter-check/$name.png'); + await file.parent.create(recursive: true); + await file.writeAsBytes(bytes); + return true; + }, + ); +}