diff --git a/.github/workflows/build_android.yml b/.github/workflows/build_android.yml index 646c4cf5..bb50bdf4 100644 --- a/.github/workflows/build_android.yml +++ b/.github/workflows/build_android.yml @@ -9,23 +9,22 @@ on: permissions: contents: write +env: + FLUTTER_VERSION: 3.38.9 + jobs: build-android: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: subosito/flutter-action@v2 + id: flutter-action with: channel: "stable" + flutter-version: ${{ env.FLUTTER_VERSION }} cache: true - - - name: Cache Pub dependencies - uses: actions/cache@v4 - with: - path: ~/.pub-cache - key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} - restore-keys: | - ${{ runner.os }}-pub- + cache-key: flutter-sdk-${{ runner.os }}-stable-${{ env.FLUTTER_VERSION }}-${{ runner.arch }} + pub-cache-key: flutter-pub-${{ runner.os }}-stable-${{ env.FLUTTER_VERSION }}-${{ hashFiles('**/pubspec.lock') }} - name: Cache Gradle packages uses: actions/cache@v4 @@ -41,9 +40,9 @@ jobs: uses: actions/cache@v4 with: path: .dart_tool/build - key: ${{ runner.os }}-build-runner-${{ hashFiles('lib/**/*.dart', 'pubspec.lock') }} + key: ${{ runner.os }}-build-runner-${{ env.FLUTTER_VERSION }}-${{ hashFiles('lib/**/*.dart', 'test/**/*.dart', 'pubspec.lock') }} restore-keys: | - ${{ runner.os }}-build-runner- + ${{ runner.os }}-build-runner-${{ env.FLUTTER_VERSION }}- - name: Decode keystore if: env.KEYSTORE_BASE64 != '' diff --git a/.github/workflows/build_ios.yml b/.github/workflows/build_ios.yml index 1ee21100..a76dd8ea 100644 --- a/.github/workflows/build_ios.yml +++ b/.github/workflows/build_ios.yml @@ -3,23 +3,30 @@ name: Build iOS on: workflow_dispatch: +env: + FLUTTER_VERSION: 3.38.9 + jobs: build-ios: runs-on: macos-latest steps: - uses: actions/checkout@v4 - uses: subosito/flutter-action@v2 + id: flutter-action with: channel: "stable" + flutter-version: ${{ env.FLUTTER_VERSION }} cache: true + cache-key: flutter-sdk-${{ runner.os }}-stable-${{ env.FLUTTER_VERSION }}-${{ runner.arch }} + pub-cache-key: flutter-pub-${{ runner.os }}-stable-${{ env.FLUTTER_VERSION }}-${{ hashFiles('**/pubspec.lock') }} - - name: Cache Pub dependencies + - name: Cache build_runner uses: actions/cache@v4 with: - path: ~/.pub-cache - key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} + path: .dart_tool/build + key: ${{ runner.os }}-build-runner-${{ env.FLUTTER_VERSION }}-${{ hashFiles('lib/**/*.dart', 'test/**/*.dart', 'pubspec.lock') }} restore-keys: | - ${{ runner.os }}-pub- + ${{ runner.os }}-build-runner-${{ env.FLUTTER_VERSION }}- - name: Install dependencies run: flutter pub get diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 84f58a82..eff86ff8 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -3,6 +3,9 @@ name: Build Linux on: workflow_dispatch: +env: + FLUTTER_VERSION: 3.38.9 + jobs: build-linux: runs-on: ubuntu-latest @@ -15,17 +18,21 @@ jobs: sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev - uses: subosito/flutter-action@v2 + id: flutter-action with: channel: "stable" + flutter-version: ${{ env.FLUTTER_VERSION }} cache: true + cache-key: flutter-sdk-${{ runner.os }}-stable-${{ env.FLUTTER_VERSION }}-${{ runner.arch }} + pub-cache-key: flutter-pub-${{ runner.os }}-stable-${{ env.FLUTTER_VERSION }}-${{ hashFiles('**/pubspec.lock') }} - - name: Cache Pub dependencies + - name: Cache build_runner uses: actions/cache@v4 with: - path: ~/.pub-cache - key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} + path: .dart_tool/build + key: ${{ runner.os }}-build-runner-${{ env.FLUTTER_VERSION }}-${{ hashFiles('lib/**/*.dart', 'test/**/*.dart', 'pubspec.lock') }} restore-keys: | - ${{ runner.os }}-pub- + ${{ runner.os }}-build-runner-${{ env.FLUTTER_VERSION }}- - name: Install dependencies run: flutter pub get diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index 21fe21df..98c19476 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -3,23 +3,30 @@ name: Build macOS on: workflow_dispatch: +env: + FLUTTER_VERSION: 3.38.9 + jobs: build-macos: runs-on: macos-latest steps: - uses: actions/checkout@v4 - uses: subosito/flutter-action@v2 + id: flutter-action with: channel: "stable" + flutter-version: ${{ env.FLUTTER_VERSION }} cache: true + cache-key: flutter-sdk-${{ runner.os }}-stable-${{ env.FLUTTER_VERSION }}-${{ runner.arch }} + pub-cache-key: flutter-pub-${{ runner.os }}-stable-${{ env.FLUTTER_VERSION }}-${{ hashFiles('**/pubspec.lock') }} - - name: Cache Pub dependencies + - name: Cache build_runner uses: actions/cache@v4 with: - path: ~/.pub-cache - key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} + path: .dart_tool/build + key: ${{ runner.os }}-build-runner-${{ env.FLUTTER_VERSION }}-${{ hashFiles('lib/**/*.dart', 'test/**/*.dart', 'pubspec.lock') }} restore-keys: | - ${{ runner.os }}-pub- + ${{ runner.os }}-build-runner-${{ env.FLUTTER_VERSION }}- - name: Install dependencies run: flutter pub get diff --git a/.github/workflows/build_web.yml b/.github/workflows/build_web.yml index bd3f9dfb..725ce3eb 100644 --- a/.github/workflows/build_web.yml +++ b/.github/workflows/build_web.yml @@ -3,23 +3,30 @@ name: Build Web on: workflow_dispatch: +env: + FLUTTER_VERSION: 3.38.9 + jobs: build-web: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: subosito/flutter-action@v2 + id: flutter-action with: channel: "stable" + flutter-version: ${{ env.FLUTTER_VERSION }} cache: true + cache-key: flutter-sdk-${{ runner.os }}-stable-${{ env.FLUTTER_VERSION }}-${{ runner.arch }} + pub-cache-key: flutter-pub-${{ runner.os }}-stable-${{ env.FLUTTER_VERSION }}-${{ hashFiles('**/pubspec.lock') }} - - name: Cache Pub dependencies + - name: Cache build_runner uses: actions/cache@v4 with: - path: ~/.pub-cache - key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} + path: .dart_tool/build + key: ${{ runner.os }}-build-runner-${{ env.FLUTTER_VERSION }}-${{ hashFiles('lib/**/*.dart', 'test/**/*.dart', 'pubspec.lock') }} restore-keys: | - ${{ runner.os }}-pub- + ${{ runner.os }}-build-runner-${{ env.FLUTTER_VERSION }}- - name: Install dependencies run: flutter pub get diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index e128ddec..bd599bb7 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -3,23 +3,30 @@ name: Build Windows on: workflow_dispatch: +env: + FLUTTER_VERSION: 3.38.9 + jobs: build-windows: runs-on: windows-latest steps: - uses: actions/checkout@v4 - uses: subosito/flutter-action@v2 + id: flutter-action with: channel: "stable" + flutter-version: ${{ env.FLUTTER_VERSION }} cache: true + cache-key: flutter-sdk-${{ runner.os }}-stable-${{ env.FLUTTER_VERSION }}-${{ runner.arch }} + pub-cache-key: flutter-pub-${{ runner.os }}-stable-${{ env.FLUTTER_VERSION }}-${{ hashFiles('**/pubspec.lock') }} - - name: Cache Pub dependencies + - name: Cache build_runner uses: actions/cache@v4 with: - path: ~\AppData\Local\Pub\Cache - key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} + path: .dart_tool/build + key: ${{ runner.os }}-build-runner-${{ env.FLUTTER_VERSION }}-${{ hashFiles('lib/**/*.dart', 'test/**/*.dart', 'pubspec.lock') }} restore-keys: | - ${{ runner.os }}-pub- + ${{ runner.os }}-build-runner-${{ env.FLUTTER_VERSION }}- - name: Install dependencies run: flutter pub get diff --git a/.github/workflows/pr_checks.yml b/.github/workflows/pr_checks.yml new file mode 100644 index 00000000..0f03abde --- /dev/null +++ b/.github/workflows/pr_checks.yml @@ -0,0 +1,75 @@ +name: PR Checks + +on: + workflow_dispatch: + pull_request: + types: + - opened + - synchronize + - reopened + - ready_for_review + +permissions: + contents: read + +env: + FLUTTER_VERSION: 3.38.9 + +concurrency: + group: pr-checks-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + pr-checks: + if: github.event_name != 'pull_request' || github.event.pull_request.draft == false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: subosito/flutter-action@v2 + id: flutter-action + with: + channel: "stable" + flutter-version: ${{ env.FLUTTER_VERSION }} + cache: true + cache-key: flutter-sdk-${{ runner.os }}-stable-${{ env.FLUTTER_VERSION }}-${{ runner.arch }} + pub-cache-key: flutter-pub-${{ runner.os }}-stable-${{ env.FLUTTER_VERSION }}-${{ hashFiles('**/pubspec.lock') }} + + - name: Cache build_runner + uses: actions/cache@v4 + with: + path: .dart_tool/build + key: ${{ runner.os }}-build-runner-${{ env.FLUTTER_VERSION }}-${{ hashFiles('lib/**/*.dart', 'test/**/*.dart', 'pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-build-runner-${{ env.FLUTTER_VERSION }}- + + - name: Install dependencies + run: flutter pub get + + - name: Snapshot workspace status + shell: bash + run: git status --short --untracked-files=all > /tmp/pre_codegen_status.txt + + - name: Verify generated files + run: dart run build_runner build --delete-conflicting-outputs + + - name: Fail if generated files changed + shell: bash + run: | + before_status="$(cat /tmp/pre_codegen_status.txt)" + after_status="$(git status --short --untracked-files=all)" + + if [[ "$before_status" != "$after_status" ]]; then + echo "Workspace status before code generation:" + printf '%s\n' "$before_status" + echo "Workspace status after code generation:" + printf '%s\n' "$after_status" + echo "::error::Generated files are not up to date. Run build_runner and commit the updated files." + exit 1 + fi + + - name: Static analysis + run: flutter analyze + + - name: Run tests + run: flutter test diff --git a/lib/features/discover/pages/discover_page.dart b/lib/features/discover/pages/discover_page.dart index fa4918c3..64ca32e2 100644 --- a/lib/features/discover/pages/discover_page.dart +++ b/lib/features/discover/pages/discover_page.dart @@ -179,15 +179,18 @@ class _RandomSongsSectionState extends ConsumerState { ? songs.length : (songs.length > 6 ? 6 : songs.length); + // 根据屏幕宽度计算列数:手机2列,平板及以上3列 + final screenWidth = MediaQuery.of(context).size.width; + final crossAxisCount = screenWidth >= 600 ? 3 : 2; + return Column( children: [ GridView.builder( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), - gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( - maxCrossAxisExtent: 350, - mainAxisExtent: - 64, // Fixed height instead of scaling based on width + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: crossAxisCount, + mainAxisExtent: 64, crossAxisSpacing: 12, mainAxisSpacing: 8, ), diff --git a/lib/features/offline/pages/offline_download_status_page.dart b/lib/features/offline/pages/offline_download_status_page.dart index 13449dad..ddf0c41e 100644 --- a/lib/features/offline/pages/offline_download_status_page.dart +++ b/lib/features/offline/pages/offline_download_status_page.dart @@ -245,17 +245,40 @@ class _JobTile extends ConsumerWidget { required this.onSelect, }); + /// 过滤掉包含 URL 的消息 + static bool _isUrl(String text) { + final t = text.trim().toLowerCase(); + return t.startsWith('http://') || + t.startsWith('https://') || + t.startsWith('www.') || + t.contains('://'); + } + @override Widget build(BuildContext context, WidgetRef ref) { - final percent = (job.progressRatio * 100).clamp(0, 100).toStringAsFixed(0); final title = (job.title ?? '').isNotEmpty ? job.title! : job.jobId; - final subtitleParts = [ + + // 构建 artist · album 行 + final metaParts = [ if ((job.artist ?? '').isNotEmpty) job.artist!, - '${job.statusDisplayName} · $percent%', - if (job.message != null && job.message!.trim().isNotEmpty) job.message!, - if (job.isFailed && job.error != null && job.error!.trim().isNotEmpty) - '❌ ${job.error}', + if ((job.album ?? '').isNotEmpty) job.album!, ]; + final metaLine = metaParts.join(' · '); + + // 状态行:活动状态显示百分比,完成/失败状态只显示状态名 + final String statusLine; + if (job.isActive) { + final percent = + (job.progressRatio * 100).clamp(0, 100).toStringAsFixed(0); + statusLine = '${job.statusDisplayName} · $percent%'; + } else { + statusLine = job.statusDisplayName; + } + + // 过滤掉包含 URL 的 message + final showMessage = job.message != null && + job.message!.trim().isNotEmpty && + !_isUrl(job.message!); return InkWell( onTap: selectMode ? onSelect : null, @@ -267,29 +290,58 @@ class _JobTile extends ConsumerWidget { job.isDone ? Icons.check_circle : job.isFailed - ? Icons.error - : job.isCancelled - ? Icons.cancel - : Icons.downloading, + ? Icons.error + : job.isCancelled + ? Icons.cancel + : Icons.downloading, color: job.isDone ? Colors.green : job.isFailed - ? Colors.red - : job.isCancelled - ? Colors.grey - : Theme.of(context).colorScheme.primary, + ? Colors.red + : job.isCancelled + ? Colors.grey + : Theme.of(context).colorScheme.primary, ), title: Text(title, maxLines: 1, overflow: TextOverflow.ellipsis), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - for (final line in subtitleParts) + if (metaLine.isNotEmpty) Text( - line, + metaLine, maxLines: 1, overflow: TextOverflow.ellipsis, style: Theme.of(context).textTheme.bodySmall, ), + Text( + statusLine, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: job.isFailed + ? Colors.red + : Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + if (showMessage) + Text( + job.message!, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: Theme.of(context).textTheme.bodySmall, + ), + if (job.isFailed && + job.error != null && + job.error!.trim().isNotEmpty) + Text( + '❌ ${job.error}', + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: Theme.of(context) + .textTheme + .bodySmall + ?.copyWith(color: Colors.red), + ), if (job.isActive) Padding( padding: const EdgeInsets.only(top: 4), @@ -297,12 +349,7 @@ class _JobTile extends ConsumerWidget { ), ], ), - trailing: selectMode - ? null - : Text( - job.album ?? '', - style: Theme.of(context).textTheme.bodySmall, - ), + trailing: selectMode ? null : const SizedBox.shrink(), ), ); } diff --git a/lib/providers/music_provider.dart b/lib/providers/music_provider.dart index 2da7b66e..a1485f0f 100644 --- a/lib/providers/music_provider.dart +++ b/lib/providers/music_provider.dart @@ -192,8 +192,9 @@ final albumDetailProvider = FutureProvider.autoDispose final repository = ref.watch(musicRepositoryProvider); final cache = ref.watch(metadataCacheRepositoryProvider); final libraryId = ref.watch(activeLibraryProvider)?.id; - if (repository == null || libraryId == null || libraryId.isEmpty) + if (repository == null || libraryId == null || libraryId.isEmpty) { return null; + } return _fetchWithCacheFallback( ref: ref, @@ -255,8 +256,9 @@ final artistDetailProvider = FutureProvider.autoDispose final repository = ref.watch(musicRepositoryProvider); final cache = ref.watch(metadataCacheRepositoryProvider); final libraryId = ref.watch(activeLibraryProvider)?.id; - if (repository == null || libraryId == null || libraryId.isEmpty) + if (repository == null || libraryId == null || libraryId.isEmpty) { return null; + } return _fetchWithCacheFallback( ref: ref, diff --git a/pubspec.yaml b/pubspec.yaml index 5574d17d..67ed2c77 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts -version: 0.4.4+1 +version: 0.4.5+1 environment: sdk: ^3.10.8 diff --git a/test/test_hero_animation.dart b/test/test_hero_animation.dart index 1a436909..801c5d2a 100644 --- a/test/test_hero_animation.dart +++ b/test/test_hero_animation.dart @@ -23,21 +23,9 @@ void main() { BuildContext fromHeroContext, BuildContext toHeroContext, ) { - final fromText = - (fromHeroContext.widget as Hero).child as Text; - final toText = (toHeroContext.widget as Hero).child as Text; - - print('--- Builder Called ---'); - print('Direction: $flightDirection'); - print('fromHero: ${fromText.data}'); - print('toHero: ${toText.data}'); - return AnimatedBuilder( animation: animation, - builder: (context, _) { - print( - 'Animation value: ${animation.value} (Direction: $flightDirection)', - ); + builder: (_, child) { return const Text('Shuttle'); }, ); @@ -72,7 +60,6 @@ void main() { await tester.pump(const Duration(milliseconds: 100)); // During push await tester.pumpAndSettle(); - print('====== NOW POPPING ======'); navKey.currentState!.pop(); await tester.pump(); await tester.pump(const Duration(milliseconds: 100)); // During pop diff --git a/test/widget_test.dart b/test/widget_test.dart index b31de9ab..b375a2c8 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -4,17 +4,11 @@ import 'package:echoes/app.dart'; void main() { testWidgets('App smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget( - const ProviderScope( - child: App(), - ), - ); + await tester.pumpWidget(const ProviderScope(child: App())); - // Verify that the app displays the splash screen - expect(find.text('SubSonic Flow'), findsOneWidget); + expect(find.byType(App), findsOneWidget); + expect(find.byType(ProviderScope), findsOneWidget); - // Drain splash delay timer to avoid pending timer failure. await tester.pump(const Duration(milliseconds: 600)); }); }