diff --git a/lib/features/practice/presentation/screens/select_session_screen.dart b/lib/features/practice/presentation/screens/select_session_screen.dart index 42494891..a891a44e 100644 --- a/lib/features/practice/presentation/screens/select_session_screen.dart +++ b/lib/features/practice/presentation/screens/select_session_screen.dart @@ -13,6 +13,7 @@ import 'package:flutter_pecha/features/practice/domain/entities/practice_item.da import 'package:flutter_pecha/features/practice/domain/entities/practice_items_tab.dart'; import 'package:flutter_pecha/features/practice/presentation/providers/practice_items_paginated_provider.dart'; import 'package:flutter_pecha/features/practice/presentation/providers/practice_recitations_paginated_provider.dart'; +import 'package:flutter_pecha/features/practice/presentation/widgets/practice_chant_list_tile.dart'; import 'package:flutter_pecha/features/recitation/data/models/recitation_model.dart'; import 'package:flutter_pecha/features/recitation/presentation/widgets/recitation_list_skeleton.dart'; import 'package:flutter_pecha/features/timer/domain/entities/preset_timer.dart'; @@ -377,14 +378,15 @@ class _ChantsTab extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final isDark = Theme.of(context).brightness == Brightness.dark; final recitationsState = ref.watch(practiceRecitationsPaginatedProvider); Future onRefresh() => ref.read(practiceRecitationsPaginatedProvider.notifier).refresh(); if (recitationsState.isLoading && recitationsState.recitations.isEmpty) { - return const RecitationListSkeleton(); + return const RecitationListSkeleton( + variant: RecitationListSkeletonVariant.chantTile, + ); } if (recitationsState.error != null && @@ -425,65 +427,17 @@ class _ChantsTab extends ConsumerWidget { } final recitation = recitations[index]; - final description = recitation.firstSegment?.content; return Padding( padding: const EdgeInsets.only(bottom: 8), - child: _SessionCard( - isDark: isDark, + child: PracticeChantListTile( + recitation: recitation, + showTrailingCaret: false, + includeOuterPadding: false, onTap: enrollingItemId == null ? () => onRecitationSelected(recitation) : null, - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: 4, - height: description != null ? null : 44, - constraints: const BoxConstraints(minHeight: 44), - decoration: BoxDecoration( - color: - isDark - ? AppColors.textTertiaryDark - : AppColors.grey400, - borderRadius: BorderRadius.circular(2), - ), - ), - const SizedBox(width: 12), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - recitation.title, - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w600, - ), - maxLines: 2, - overflow: TextOverflow.ellipsis, - ), - if (description != null && description.isNotEmpty) ...[ - const SizedBox(height: 4), - Text( - description, - style: TextStyle( - fontSize: 13, - color: - isDark - ? AppColors.textTertiaryDark - : AppColors.textSecondary, - ), - maxLines: 3, - overflow: TextOverflow.ellipsis, - ), - ], - ], - ), - ), - ], - ), ), ); }, diff --git a/lib/features/practice/presentation/widgets/practice_chant_list_tile.dart b/lib/features/practice/presentation/widgets/practice_chant_list_tile.dart index f7ed210b..f6c9fdb3 100644 --- a/lib/features/practice/presentation/widgets/practice_chant_list_tile.dart +++ b/lib/features/practice/presentation/widgets/practice_chant_list_tile.dart @@ -9,11 +9,15 @@ class PracticeChantListTile extends StatelessWidget { const PracticeChantListTile({ super.key, required this.recitation, - required this.onTap, + this.onTap, + this.showTrailingCaret = true, + this.includeOuterPadding = true, }); final RecitationModel recitation; - final VoidCallback onTap; + final VoidCallback? onTap; + final bool showTrailingCaret; + final bool includeOuterPadding; @override Widget build(BuildContext context) { @@ -35,54 +39,53 @@ class PracticeChantListTile extends StatelessWidget { ), ); - return Padding( - padding: const EdgeInsets.fromLTRB(16, 0, 16, 8), - child: Material( - color: isDark ? AppColors.cardBackgroundDark : Colors.white, - borderRadius: BorderRadius.circular(12), - clipBehavior: Clip.antiAlias, - child: InkWell( - onTap: onTap, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), - child: IntrinsicHeight( - child: Row( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Container( - width: 4, - decoration: BoxDecoration( - color: isDark ? Colors.white : AppColors.grey800, - borderRadius: BorderRadius.circular(2), - ), + final tile = Material( + color: isDark ? AppColors.cardBackgroundDark : Colors.white, + borderRadius: BorderRadius.circular(12), + clipBehavior: Clip.antiAlias, + child: InkWell( + onTap: onTap, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + child: IntrinsicHeight( + child: Row( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Container( + width: 4, + decoration: BoxDecoration( + color: isDark ? Colors.white : AppColors.grey800, + borderRadius: BorderRadius.circular(2), ), - const SizedBox(width: 12), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + recitation.title, + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + ), + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + if (hasFirstSegment) ...[ + const SizedBox(height: 4), Text( - recitation.title, - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.bold, - ), + firstSegmentContent, + style: firstSegmentStyle, maxLines: 2, overflow: TextOverflow.ellipsis, ), - if (hasFirstSegment) ...[ - const SizedBox(height: 4), - Text( - firstSegmentContent, - style: firstSegmentStyle, - maxLines: 2, - overflow: TextOverflow.ellipsis, - ), - ], ], - ), + ], ), + ), + if (showTrailingCaret) ...[ const SizedBox(width: 8), Center( child: Container( @@ -99,12 +102,21 @@ class PracticeChantListTile extends StatelessWidget { ), ), ], - ), + ], ), ), ), ), ); + + if (!includeOuterPadding) { + return tile; + } + + return Padding( + padding: const EdgeInsets.fromLTRB(16, 0, 16, 8), + child: tile, + ); } bool _containsTibetan(String value) {