Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7747ea194c | ||
|
|
6570ad8a87 |
+62
-96
@@ -12,31 +12,26 @@ on:
|
||||
|
||||
# Cancel in-progress runs on new push to same branch
|
||||
concurrency:
|
||||
group: ${{ gitea.workflow }}-${{ gitea.ref }}
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
FLUTTER_VERSION: "stable"
|
||||
FLUTTER_VERSION: "3.41.x"
|
||||
|
||||
jobs:
|
||||
# ── Stage 1: Lint & static analysis ──────────────────────────────
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: [self-hosted, linux]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Flutter
|
||||
run: |
|
||||
# Direct Flutter SDK download — subosito/flutter-action queries
|
||||
# GitHub internal APIs that are unavailable on self-hosted Gitea runners.
|
||||
curl -fsSL "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.44.8-stable.tar.xz" \
|
||||
-o flutter.tar.xz
|
||||
tar -xf flutter.tar.xz
|
||||
export PATH="$PWD/flutter/bin:$PATH"
|
||||
flutter --version
|
||||
echo "$PWD/flutter/bin" >> "$GITHUB_PATH" || echo "$PWD/flutter/bin" >> "$HOME/.env_path"
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||
cache: true
|
||||
|
||||
- name: Install dependencies
|
||||
run: flutter pub get
|
||||
@@ -48,28 +43,24 @@ jobs:
|
||||
- name: Analyze Dart code
|
||||
run: flutter analyze --fatal-warnings
|
||||
|
||||
- name: Check formatting
|
||||
run: dart format --set-exit-if-changed lib/ test/
|
||||
- name: Auto-format source
|
||||
run: dart format lib/ test/
|
||||
|
||||
|
||||
# ── Stage 2: Unit & widget tests ─────────────────────────────────
|
||||
test:
|
||||
name: Test
|
||||
runs-on: [self-hosted, linux]
|
||||
runs-on: ubuntu-latest
|
||||
needs: [lint]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Flutter
|
||||
run: |
|
||||
# Direct Flutter SDK download — self-hosted Gitea runner (Linux)
|
||||
curl -fsSL "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.44.8-stable.tar.xz" \
|
||||
-o flutter.tar.xz
|
||||
tar -xf flutter.tar.xz
|
||||
export PATH="$PWD/flutter/bin:$PATH"
|
||||
flutter --version
|
||||
echo "$PWD/flutter/bin" >> "$GITHUB_PATH" || echo "$PWD/flutter/bin" >> "$HOME/.env_path"
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||
cache: true
|
||||
|
||||
- name: Install dependencies
|
||||
run: flutter pub get
|
||||
@@ -81,14 +72,16 @@ jobs:
|
||||
run: flutter test --reporter=expanded
|
||||
|
||||
- name: Run tests with coverage
|
||||
if: gitea.ref == 'refs/heads/main' && gitea.event_name == 'push'
|
||||
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
||||
run: flutter test --coverage
|
||||
|
||||
- name: "Note: coverage artifact storage not configured"
|
||||
if: gitea.ref == 'refs/heads/main' && gitea.event_name == 'push'
|
||||
run: |
|
||||
echo "WARNING: Gitea Actions artifact storage is not configured."
|
||||
echo "Coverage report available at: coverage/lcov.info"
|
||||
- name: Upload coverage report
|
||||
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: coverage-report
|
||||
path: coverage/lcov.info
|
||||
retention-days: 14
|
||||
|
||||
|
||||
# ── Stage 3: Android build ──────────────────────────────────────
|
||||
@@ -101,41 +94,17 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Java 17
|
||||
run: |
|
||||
# Direct Temurin JDK download — actions/setup-java queries GitHub APIs
|
||||
curl -fsSL "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.12%2B7/OpenJDK17U-jdk_x64_linux_hotspot_17.0.12_7.tar.gz" \
|
||||
-o jdk.tar.gz
|
||||
mkdir -p "$HOME/jdk"
|
||||
tar -xzf jdk.tar.gz -C "$HOME/jdk" --strip-components=1
|
||||
export JAVA_HOME="$HOME/jdk"
|
||||
export PATH="$JAVA_HOME/bin:$PATH"
|
||||
java -version
|
||||
echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV" || export JAVA_HOME="$JAVA_HOME"
|
||||
echo "$JAVA_HOME/bin" >> "$GITHUB_PATH" || export PATH="$JAVA_HOME/bin:$PATH"
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: "17"
|
||||
cache: gradle
|
||||
|
||||
- name: Setup Flutter
|
||||
run: |
|
||||
# Direct Flutter SDK download — Linux build runner
|
||||
curl -fsSL "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.44.8-stable.tar.xz" \
|
||||
-o flutter.tar.xz
|
||||
tar -xf flutter.tar.xz
|
||||
export PATH="$PWD/flutter/bin:$PATH"
|
||||
flutter --version
|
||||
echo "$PWD/flutter/bin" >> "$GITHUB_PATH" || echo "$PWD/flutter/bin" >> "$HOME/.env_path"
|
||||
|
||||
- name: Install Android SDK command-line tools
|
||||
run: |
|
||||
export ANDROID_HOME="${HOME}/android-sdk"
|
||||
mkdir -p "${ANDROID_HOME}/cmdline-tools"
|
||||
curl -fsSL "https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip" -o cmdline-tools.zip
|
||||
unzip -q cmdline-tools.zip -d "${ANDROID_HOME}/cmdline-tools"
|
||||
mv "${ANDROID_HOME}/cmdline-tools/cmdline-tools" "${ANDROID_HOME}/cmdline-tools/latest"
|
||||
export PATH="${ANDROID_HOME}/cmdline-tools/latest/bin:${PATH}"
|
||||
yes | sdkmanager --licenses >/dev/null 2>&1 || true
|
||||
sdkmanager "platform-tools" "platforms;android-35" "build-tools;35.0.0"
|
||||
echo "ANDROID_HOME=${ANDROID_HOME}" >> "$GITHUB_ENV" || echo "ANDROID_HOME=${ANDROID_HOME}" >> "$HOME/.env"
|
||||
echo "${ANDROID_HOME}/cmdline-tools/latest/bin" >> "$GITHUB_PATH" || export PATH="${ANDROID_HOME}/cmdline-tools/latest/bin:${PATH}"
|
||||
echo "${ANDROID_HOME}/platform-tools" >> "$GITHUB_PATH" || export PATH="${ANDROID_HOME}/platform-tools:${PATH}"
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||
cache: true
|
||||
|
||||
- name: Pre-cache Android platform artifacts
|
||||
run: flutter precache --android
|
||||
@@ -144,17 +113,15 @@ jobs:
|
||||
run: |
|
||||
yes | sdkmanager --licenses || true
|
||||
|
||||
- name: Setup Python (for whitelabel build script)
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
|
||||
- name: Install Python dependencies
|
||||
run: |
|
||||
# Use system Python — actions/setup-python queries GitHub APIs
|
||||
if command -v python3 &>/dev/null; then
|
||||
python3 -m pip install --upgrade pip 2>/dev/null || true
|
||||
if [ -f requirements.txt ]; then
|
||||
python3 -m pip install -r requirements.txt
|
||||
fi
|
||||
else
|
||||
echo "WARNING: Python3 not found, skipping pip install"
|
||||
fi
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
|
||||
- name: Install dependencies
|
||||
run: flutter pub get
|
||||
@@ -206,36 +173,35 @@ jobs:
|
||||
echo "=== AAB output ==="
|
||||
ls -lh build/app/outputs/bundle/release/ || true
|
||||
|
||||
- name: "Note: artifact storage not configured"
|
||||
run: |
|
||||
echo "WARNING: Gitea Actions artifact storage is not configured on this instance."
|
||||
echo "Build outputs available in runner workspace:"
|
||||
echo " APK: build/app/outputs/flutter-apk/app-release.apk"
|
||||
echo " AAB: build/app/outputs/bundle/release/app-release.aab"
|
||||
echo "Configure artifact storage in Gitea Actions admin settings to enable uploads."
|
||||
- name: Upload APK artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: android-apk
|
||||
path: build/app/outputs/flutter-apk/app-release.apk
|
||||
retention-days: 90
|
||||
|
||||
- name: Upload AAB artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: android-aab
|
||||
path: build/app/outputs/bundle/release/app-release.aab
|
||||
retention-days: 90
|
||||
|
||||
|
||||
# ── Stage 3 (parallel): iOS build ───────────────────────────────
|
||||
# Note: requires a macOS runner. Uses 'self-hosted' label which
|
||||
# matches our Gitea Actions runner. Falls back to --no-codesign
|
||||
# if Apple signing secrets are not configured.
|
||||
build-ios:
|
||||
name: Build iOS
|
||||
runs-on: [self-hosted, macos]
|
||||
runs-on: macos-latest
|
||||
needs: [test]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Flutter
|
||||
run: |
|
||||
# Direct Flutter SDK download — macOS runner (self-hosted)
|
||||
curl -fsSL "https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_3.44.8-stable.zip" \
|
||||
-o flutter.zip
|
||||
unzip -q flutter.zip
|
||||
export PATH="$PWD/flutter/bin:$PATH"
|
||||
flutter --version
|
||||
echo "$PWD/flutter/bin" >> "$GITHUB_PATH" || echo "$PWD/flutter/bin" >> "$HOME/.env_path"
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||
cache: true
|
||||
|
||||
- name: Install dependencies
|
||||
run: flutter pub get
|
||||
@@ -246,9 +212,9 @@ jobs:
|
||||
- name: Build iOS (release, no-codesign)
|
||||
run: flutter build ios --release --no-codesign
|
||||
|
||||
- name: "Note: iOS artifact storage not configured"
|
||||
run: |
|
||||
echo "WARNING: Gitea Actions artifact storage is not configured on this instance."
|
||||
echo "iOS build outputs available in runner workspace:"
|
||||
echo " build/ios/iphoneos/"
|
||||
echo "Configure artifact storage in Gitea Actions admin settings to enable uploads."
|
||||
- name: Upload iOS build artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ios-app
|
||||
path: build/ios/iphoneos/
|
||||
retention-days: 90
|
||||
|
||||
@@ -10,7 +10,7 @@ on:
|
||||
- "v*"
|
||||
|
||||
env:
|
||||
FLUTTER_VERSION: "stable"
|
||||
FLUTTER_VERSION: "3.41.x"
|
||||
|
||||
jobs:
|
||||
# ── Lint (gate) ─────────────────────────────────────────────
|
||||
@@ -159,12 +159,9 @@ jobs:
|
||||
|
||||
|
||||
# ── iOS release build ───────────────────────────────────────
|
||||
# Note: requires a macOS runner. Uses 'self-hosted' label which
|
||||
# matches our Gitea Actions runner. Falls back to --no-codesign
|
||||
# if Apple signing secrets are not configured.
|
||||
build-ios:
|
||||
name: Build iOS Release
|
||||
runs-on: [self-hosted, macos]
|
||||
runs-on: macos-latest
|
||||
needs: [test]
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -243,7 +240,7 @@ jobs:
|
||||
- name: Create Gitea Release
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
TAG: ${{ gitea.ref_name }}
|
||||
TAG: ${{ github.ref_name }}
|
||||
GITEA_BASE: https://git.westerntechnologies.duckdns.org
|
||||
run: |
|
||||
curl -s -X POST \
|
||||
@@ -255,7 +252,7 @@ jobs:
|
||||
- name: Upload APK to Release
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
TAG: ${{ gitea.ref_name }}
|
||||
TAG: ${{ github.ref_name }}
|
||||
GITEA_BASE: https://git.westerntechnologies.duckdns.org
|
||||
run: |
|
||||
curl -s -X POST \
|
||||
@@ -263,15 +260,3 @@ jobs:
|
||||
-H "Content-Type: application/vnd.android.package-archive" \
|
||||
--data-binary @app-release.apk \
|
||||
"$GITEA_BASE/api/v1/repos/kfj001/kryz-go-flutter/releases/assets?name=app-release.apk&tag_name=$TAG"
|
||||
|
||||
- name: Upload AAB to Release
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
TAG: ${{ gitea.ref_name }}
|
||||
GITEA_BASE: https://git.westerntechnologies.duckdns.org
|
||||
run: |
|
||||
curl -s -X POST \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary @app-release.aab \
|
||||
"$GITEA_BASE/api/v1/repos/kfj001/kryz-go-flutter/releases/assets?name=app-release.aab&tag_name=$TAG"
|
||||
|
||||
@@ -13,7 +13,7 @@ Will build a release build for `<platform>`.
|
||||
## Running in Debug mode
|
||||
With a device or devices connected:
|
||||
|
||||
`flutter run <platform>`
|
||||
`flutter run <platform>`
|
||||
|
||||
Will execute the application in the debugging sandbox.
|
||||
|
||||
@@ -31,70 +31,3 @@ dart run flutter_name_manager:rename_app --name "KRYZ Go!"
|
||||
dart run flutter_launcher_icons
|
||||
```
|
||||
|
||||
## CI/CD Pipeline
|
||||
|
||||
This project uses **Gitea Actions** for continuous integration and release automation.
|
||||
|
||||
### Pipeline Overview
|
||||
|
||||
```
|
||||
┌─────────┐ ┌────────┐ ┌──────────────┐ ┌──────────────┐
|
||||
│ Lint │───►│ Test │───►│ Build Android │ │ Build iOS │
|
||||
│ │ │ │ │ (APK + AAB) │ │ (self-hosted)│
|
||||
└─────────┘ └────────┘ └──────────────┘ └──────────────┘
|
||||
│ │ │
|
||||
▼ ▼ ▼
|
||||
dart fmt flutter test flutter build ios
|
||||
flutter analyze (--no-codesign fallback)
|
||||
```
|
||||
|
||||
### Workflows
|
||||
|
||||
#### CI (`.gitea/workflows/ci.yml`)
|
||||
|
||||
Triggers on:
|
||||
- Push to `main` or `develop`
|
||||
- Pull requests targeting `main`
|
||||
|
||||
Stages:
|
||||
1. **Lint** — `dart format --fix` + `flutter analyze --fatal-warnings`
|
||||
2. **Test** — `flutter test` (coverage on main branch pushes)
|
||||
3. **Build Android** — APK + AAB release builds with artifact upload
|
||||
4. **Build iOS** — `flutter build ios --release --no-codesign` (runs on self-hosted macOS runner)
|
||||
|
||||
#### Release (`.gitea/workflows/release.yml`)
|
||||
|
||||
Triggers on:
|
||||
- Git tags matching `v*` (e.g., `v1.0.0`)
|
||||
|
||||
Stages:
|
||||
1. **Lint** — `dart format --set-exit-if-changed` + `flutter analyze --fatal-warnings`
|
||||
2. **Test** — `flutter test`
|
||||
3. **Build Android Release** — Signed APK + AAB
|
||||
4. **Build iOS Release** — Signed IPA (or `--no-codesign` fallback)
|
||||
5. **Publish Release** — Creates Gitea release + uploads artifacts
|
||||
|
||||
### Configuration
|
||||
|
||||
| Secret | Required | Description |
|
||||
|---|---|---|
|
||||
| `ANDROID_KEYSTORE_BASE64` | No | Base64-encoded Android release keystore |
|
||||
| `ANDROID_KEYSTORE_PASS` | No | Keystore password |
|
||||
| `ANDROID_KEY_ALIAS` | No | Key alias |
|
||||
| `ANDROID_KEY_PASS` | No | Key password |
|
||||
| `APPLE_CERTIFICATE_P12` | No | Base64-encoded Apple signing certificate |
|
||||
| `APPLE_CERTIFICATE_PASS` | No | Certificate password |
|
||||
| `APPLE_PROVISION_PROFILE` | No | Base64-encoded provisioning profile |
|
||||
| `GITEA_TOKEN` | Yes (Release) | Token for creating Gitea releases |
|
||||
|
||||
Without signing secrets, builds use debug keys or `--no-codesign`.
|
||||
|
||||
### CI Status
|
||||
|
||||

|
||||
|
||||
### Troubleshooting
|
||||
|
||||
- **Stubs missing**: The `ci_stub_gen.py` script auto-generates `lib/generated/*.dart` stubs when `theme.json` is absent.
|
||||
- **macOS runner unavailable**: The iOS stage uses `self-hosted` label. Ensure a macOS Gitea runner is registered.
|
||||
- **Format checks**: CI uses `dart format --fix` (auto-fix). Release uses `--set-exit-if-changed` (gate).
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import java.util.Properties
|
||||
import java.io.FileInputStream
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("kotlin-android")
|
||||
@@ -17,9 +14,9 @@ dependencies {
|
||||
|
||||
// Load release signing properties if key.properties exists (set by CI pipeline)
|
||||
val keystorePropertiesFile = rootProject.file("key.properties")
|
||||
val keystoreProperties = Properties()
|
||||
val keystoreProperties = java.util.Properties()
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
|
||||
keystoreProperties.load(java.io.FileInputStream(keystorePropertiesFile))
|
||||
}
|
||||
|
||||
android {
|
||||
@@ -33,7 +30,7 @@ android {
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = "17"
|
||||
jvmTarget = JavaVersion.VERSION_17.toString()
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
@@ -50,10 +47,10 @@ android {
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keyAlias = keystoreProperties.getProperty("keyAlias")
|
||||
keyPassword = keystoreProperties.getProperty("keyPassword")
|
||||
storeFile = file(keystoreProperties.getProperty("storeFile"))
|
||||
storePassword = keystoreProperties.getProperty("storePassword")
|
||||
keyAlias = keystoreProperties["keyAlias"] as String
|
||||
keyPassword = keystoreProperties["keyPassword"] as String
|
||||
storeFile = file(keystoreProperties["storeFile"] as String)
|
||||
storePassword = keystoreProperties["storePassword"] as String
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,52 +25,36 @@ class AppThemeColors {
|
||||
|
||||
/// Website: `primary` → headings (h1–h6)
|
||||
final Color headingColor;
|
||||
|
||||
/// Website: `accent` → links & accent highlights
|
||||
final Color accentColor;
|
||||
|
||||
/// Page background gradient start — website: `background` (cream)
|
||||
final Color scaffoldGradientStart;
|
||||
|
||||
/// Page background gradient end — website: `light`
|
||||
final Color scaffoldGradientEnd;
|
||||
|
||||
/// Top header card surface
|
||||
final Color shellSurface;
|
||||
|
||||
/// Top header card border
|
||||
final Color shellBorder;
|
||||
|
||||
/// Website: `medium` → muted / secondary text
|
||||
final Color mutedText;
|
||||
|
||||
/// Website: `white` → text on dark surfaces
|
||||
final Color textOnDark;
|
||||
|
||||
/// Website: `light` → secondary text on dark surfaces
|
||||
final Color textOnDarkSecondary;
|
||||
|
||||
/// Controls bar / card surface gradient start — website: `primary_dark`
|
||||
final Color controlsGradientStart;
|
||||
|
||||
/// Controls bar / card surface gradient end — website: `primary_dark`
|
||||
final Color controlsGradientEnd;
|
||||
|
||||
/// Shadow color for elevated surfaces
|
||||
final Color controlsShadow;
|
||||
|
||||
/// Website: `text` → body text
|
||||
final Color bodyText;
|
||||
|
||||
/// Inner card background overlay — derived from `primary_dark` / `primary_light`
|
||||
final Color cardSurface;
|
||||
|
||||
/// Inner card border — derived from `primary_dark` / `primary_light`
|
||||
final Color cardBorder;
|
||||
|
||||
/// Website: `success` → live indicator, success states
|
||||
final Color successColor;
|
||||
|
||||
/// Website: `danger` → error states
|
||||
final Color dangerColor;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class CastingBusinessObject extends ChangeNotifier {
|
||||
CastingPlaybackStatus _playbackStatus = CastingPlaybackStatus.unknown;
|
||||
String? _connectedDeviceName;
|
||||
String? _lastError;
|
||||
|
||||
|
||||
/// Callback for when native side requests local audio to stop
|
||||
VoidCallback? onStopLocalAudioRequested;
|
||||
|
||||
|
||||
+21
-25
@@ -28,7 +28,10 @@ class KryzAudioHandler extends BaseAudioHandler with SeekHandler {
|
||||
title: AppConfig.defaultTitle,
|
||||
artist: AppConfig.defaultArtist,
|
||||
album: 'Live',
|
||||
extras: <String, dynamic>{'isLive': true, 'seekable': false},
|
||||
extras: <String, dynamic>{
|
||||
'isLive': true,
|
||||
'seekable': false,
|
||||
},
|
||||
);
|
||||
|
||||
final AudioPlayer _player = AudioPlayer();
|
||||
@@ -80,7 +83,10 @@ class KryzAudioHandler extends BaseAudioHandler with SeekHandler {
|
||||
try {
|
||||
if (!_isSourceLoaded) {
|
||||
await _player.setAudioSource(
|
||||
AudioSource.uri(Uri.parse(streamUrl), tag: mediaItem.value),
|
||||
AudioSource.uri(
|
||||
Uri.parse(streamUrl),
|
||||
tag: mediaItem.value,
|
||||
),
|
||||
);
|
||||
_isSourceLoaded = true;
|
||||
}
|
||||
@@ -153,35 +159,25 @@ class KryzAudioHandler extends BaseAudioHandler with SeekHandler {
|
||||
}
|
||||
|
||||
void _onPlayerStateChanged(PlayerState state) {
|
||||
final AudioProcessingState processingState =
|
||||
switch (state.processingState) {
|
||||
ProcessingState.idle => AudioProcessingState.idle,
|
||||
ProcessingState.loading => AudioProcessingState.loading,
|
||||
ProcessingState.buffering => AudioProcessingState.buffering,
|
||||
ProcessingState.ready => AudioProcessingState.ready,
|
||||
ProcessingState.completed => AudioProcessingState.completed,
|
||||
};
|
||||
final AudioProcessingState processingState = switch (state.processingState) {
|
||||
ProcessingState.idle => AudioProcessingState.idle,
|
||||
ProcessingState.loading => AudioProcessingState.loading,
|
||||
ProcessingState.buffering => AudioProcessingState.buffering,
|
||||
ProcessingState.ready => AudioProcessingState.ready,
|
||||
ProcessingState.completed => AudioProcessingState.completed,
|
||||
};
|
||||
|
||||
final bool isPlaying =
|
||||
state.playing && state.processingState == ProcessingState.ready;
|
||||
final bool isBuffering =
|
||||
(state.playing && state.processingState != ProcessingState.ready) ||
|
||||
(_playRequested &&
|
||||
!state.playing &&
|
||||
state.processingState != ProcessingState.completed);
|
||||
final bool isPlaying = state.playing && state.processingState == ProcessingState.ready;
|
||||
final bool isBuffering = (state.playing && state.processingState != ProcessingState.ready) ||
|
||||
(_playRequested && !state.playing && state.processingState != ProcessingState.completed);
|
||||
|
||||
playbackState.add(
|
||||
playbackState.value.copyWith(
|
||||
controls: <MediaControl>[
|
||||
if (isPlaying || isBuffering)
|
||||
MediaControl.stop
|
||||
else
|
||||
MediaControl.play,
|
||||
if (isPlaying || isBuffering) MediaControl.stop else MediaControl.play,
|
||||
],
|
||||
systemActions: const <MediaAction>{},
|
||||
processingState: isBuffering
|
||||
? AudioProcessingState.buffering
|
||||
: processingState,
|
||||
processingState: isBuffering ? AudioProcessingState.buffering : processingState,
|
||||
playing: isPlaying,
|
||||
),
|
||||
);
|
||||
@@ -224,4 +220,4 @@ class KryzAudioHandler extends BaseAudioHandler with SeekHandler {
|
||||
// Keep existing metadata if live-info fetch fails.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ class LiveInfoBusinessObject extends ChangeNotifier {
|
||||
String? endpoint,
|
||||
int refreshIntervalSeconds = 20,
|
||||
this.requestTimeout = const Duration(seconds: 8),
|
||||
}) : _endpointOverride = endpoint,
|
||||
_refreshIntervalSeconds = refreshIntervalSeconds;
|
||||
}) : _endpointOverride = endpoint,
|
||||
_refreshIntervalSeconds = refreshIntervalSeconds;
|
||||
|
||||
/// Explicit endpoint passed at construction, if any.
|
||||
final String? _endpointOverride;
|
||||
@@ -23,16 +23,12 @@ class LiveInfoBusinessObject extends ChangeNotifier {
|
||||
if (override != null && override.isNotEmpty) {
|
||||
return override;
|
||||
}
|
||||
const envUrl = String.fromEnvironment(
|
||||
'KRYZ_LIVE_INFO_URL',
|
||||
defaultValue: '',
|
||||
);
|
||||
const envUrl = String.fromEnvironment('KRYZ_LIVE_INFO_URL', defaultValue: '');
|
||||
if (envUrl.isNotEmpty) {
|
||||
return envUrl;
|
||||
}
|
||||
return AppConfig.metadataUrl ?? '';
|
||||
}
|
||||
|
||||
final Duration requestTimeout;
|
||||
|
||||
Timer? _pollTimer;
|
||||
|
||||
+3
-2
@@ -139,7 +139,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
||||
_liveInfo.addListener(_handleLiveInfoChanged);
|
||||
_liveInfo.start();
|
||||
_playbackChannel.setMethodCallHandler(_handlePlaybackMethodCall);
|
||||
|
||||
|
||||
// When native code requests local audio to stop (cast media loaded)
|
||||
_casting.onStopLocalAudioRequested = () {
|
||||
unawaited(_audio.stop());
|
||||
@@ -458,7 +458,8 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
||||
label: const Text('Stop'),
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
onPressed: _casting.status == CastingStatus.connecting
|
||||
onPressed:
|
||||
_casting.status == CastingStatus.connecting
|
||||
? null
|
||||
: _toggleCasting,
|
||||
icon: Icon(_castingIcon()),
|
||||
|
||||
+7
-2
@@ -39,7 +39,9 @@ class ShowCard extends StatelessWidget {
|
||||
'$label: ${show?.name ?? 'No scheduled show'}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: titleColor,
|
||||
),
|
||||
@@ -47,7 +49,10 @@ class ShowCard extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
formatStartingTime(show?.starts, sourceTimezone: sourceTimezone),
|
||||
formatStartingTime(
|
||||
show?.starts,
|
||||
sourceTimezone: sourceTimezone,
|
||||
),
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.labelSmall?.copyWith(color: titleColor),
|
||||
|
||||
@@ -35,25 +35,21 @@ class StreamingAudioBusinessObject extends ChangeNotifier {
|
||||
return;
|
||||
}
|
||||
|
||||
_audioHandlerInitFuture ??=
|
||||
AudioService.init(
|
||||
builder: () => KryzAudioHandler(),
|
||||
config: const AudioServiceConfig(
|
||||
androidNotificationChannelId: 'com.kryzgoflutter.audio.channel',
|
||||
androidNotificationChannelName:
|
||||
'${AppConfig.appName} Audio Playback',
|
||||
androidNotificationOngoing: true,
|
||||
androidStopForegroundOnPause: true,
|
||||
),
|
||||
)
|
||||
.then((handler) {
|
||||
_audioHandler = handler;
|
||||
return handler;
|
||||
})
|
||||
.catchError((error) {
|
||||
_audioHandlerInitFuture = null;
|
||||
throw error;
|
||||
});
|
||||
_audioHandlerInitFuture ??= AudioService.init(
|
||||
builder: () => KryzAudioHandler(),
|
||||
config: const AudioServiceConfig(
|
||||
androidNotificationChannelId: 'com.kryzgoflutter.audio.channel',
|
||||
androidNotificationChannelName: '${AppConfig.appName} Audio Playback',
|
||||
androidNotificationOngoing: true,
|
||||
androidStopForegroundOnPause: true,
|
||||
),
|
||||
).then((handler) {
|
||||
_audioHandler = handler;
|
||||
return handler;
|
||||
}).catchError((error) {
|
||||
_audioHandlerInitFuture = null;
|
||||
throw error;
|
||||
});
|
||||
|
||||
await _audioHandlerInitFuture;
|
||||
}
|
||||
@@ -150,12 +146,9 @@ class StreamingAudioBusinessObject extends ChangeNotifier {
|
||||
return;
|
||||
}
|
||||
|
||||
final title = item.title.trim().isEmpty
|
||||
? AppConfig.defaultTitle
|
||||
: item.title;
|
||||
final subtitle = (item.artist ?? '').trim().isEmpty
|
||||
? AppConfig.defaultArtist
|
||||
: item.artist!.trim();
|
||||
final title = item.title.trim().isEmpty ? AppConfig.defaultTitle : item.title;
|
||||
final subtitle =
|
||||
(item.artist ?? '').trim().isEmpty ? AppConfig.defaultArtist : item.artist!.trim();
|
||||
|
||||
if (title == _currentTitle && subtitle == _currentSubtitle) {
|
||||
return;
|
||||
|
||||
@@ -120,9 +120,8 @@ DateTime? _tryParseServerDateTime(String value) {
|
||||
final int second = parsePart(6);
|
||||
|
||||
final String fraction = (match.group(7) ?? '').padRight(6, '0');
|
||||
final int microseconds = fraction.isEmpty
|
||||
? 0
|
||||
: int.parse(fraction.substring(0, 6));
|
||||
final int microseconds =
|
||||
fraction.isEmpty ? 0 : int.parse(fraction.substring(0, 6));
|
||||
|
||||
return DateTime(
|
||||
year,
|
||||
|
||||
+6
-2
@@ -47,7 +47,9 @@ class TrackCard extends StatelessWidget {
|
||||
title,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: titleColor,
|
||||
),
|
||||
@@ -64,7 +66,9 @@ class TrackCard extends StatelessWidget {
|
||||
const Spacer(),
|
||||
Text(
|
||||
window,
|
||||
style: Theme.of(context).textTheme.labelMedium?.copyWith(
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.labelMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: titleColor,
|
||||
),
|
||||
|
||||
@@ -54,51 +54,46 @@ void main() {
|
||||
|
||||
test('does not double-convert timestamps with explicit UTC designator', () {
|
||||
const String utcStamp = '2026-05-15T03:00:00Z';
|
||||
final String expected = DateFormat(
|
||||
'jm',
|
||||
).format(DateTime.parse(utcStamp).toLocal());
|
||||
final String expected = DateFormat('jm').format(DateTime.parse(utcStamp).toLocal());
|
||||
|
||||
expect(
|
||||
formatStartingTime(utcStamp, sourceTimezone: 'America/Los_Angeles'),
|
||||
formatStartingTime(
|
||||
utcStamp,
|
||||
sourceTimezone: 'America/Los_Angeles',
|
||||
),
|
||||
expected,
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'keeps wall-clock time when local matches source zone for naive input',
|
||||
() {
|
||||
const String sourceTime = '2026-05-14 20:00:00';
|
||||
const String sourceZone = 'America/Los_Angeles';
|
||||
test('keeps wall-clock time when local matches source zone for naive input', () {
|
||||
const String sourceTime = '2026-05-14 20:00:00';
|
||||
const String sourceZone = 'America/Los_Angeles';
|
||||
|
||||
final tz.TZDateTime source = tz.TZDateTime(
|
||||
tz.getLocation(sourceZone),
|
||||
2026,
|
||||
5,
|
||||
14,
|
||||
20,
|
||||
);
|
||||
final String expected = DateFormat('jm').format(
|
||||
DateTime.fromMillisecondsSinceEpoch(
|
||||
source.millisecondsSinceEpoch,
|
||||
isUtc: true,
|
||||
).toLocal(),
|
||||
);
|
||||
final tz.TZDateTime source = tz.TZDateTime(
|
||||
tz.getLocation(sourceZone),
|
||||
2026,
|
||||
5,
|
||||
14,
|
||||
20,
|
||||
);
|
||||
final String expected = DateFormat('jm').format(
|
||||
DateTime.fromMillisecondsSinceEpoch(
|
||||
source.millisecondsSinceEpoch,
|
||||
isUtc: true,
|
||||
).toLocal(),
|
||||
);
|
||||
|
||||
expect(
|
||||
formatStartingTime(sourceTime, sourceTimezone: sourceZone),
|
||||
expected,
|
||||
);
|
||||
},
|
||||
);
|
||||
expect(
|
||||
formatStartingTime(sourceTime, sourceTimezone: sourceZone),
|
||||
expected,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('formatTimeWindow', () {
|
||||
test('returns mm:ss style duration from server times', () {
|
||||
expect(
|
||||
formatTimeWindow(
|
||||
'2026-05-15 05:18:46.000000',
|
||||
'2026-05-15 05:23:21.000000',
|
||||
),
|
||||
formatTimeWindow('2026-05-15 05:18:46.000000', '2026-05-15 05:23:21.000000'),
|
||||
'04:35',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -16,13 +16,7 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('KRYZ Go!'), findsWidgets);
|
||||
expect(
|
||||
find.widgetWithIcon(ElevatedButton, Icons.play_arrow_rounded),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.widgetWithIcon(ElevatedButton, Icons.stop_rounded),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.widgetWithIcon(ElevatedButton, Icons.play_arrow_rounded), findsOneWidget);
|
||||
expect(find.widgetWithIcon(ElevatedButton, Icons.stop_rounded), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user