Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/onvo tv caching reciters #1546

Merged
merged 4 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified assets/svg/reciter_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions lib/src/const/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ abstract class QuranConstant {
static const String quranMoshafConfigJsonUrl = 'https://cdn.mawaqit.net/quran/tv_config.json';
static const String kIsFirstTime = 'is_first_time_quran';
static const String kQuranReciterImagesBaseUrl = 'https://cdn.mawaqit.net/quran/reciters-pictures/';
static const int kCacheWidth = 50;
static const int kCacheHeight = 50;
}

abstract class AzkarConstant {
Expand Down
32 changes: 20 additions & 12 deletions lib/src/pages/quran/widget/reciter_list_view.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:device_info_plus/device_info_plus.dart';
import 'package:fast_cached_network_image/fast_cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand All @@ -6,6 +7,7 @@ import 'package:auto_size_text/auto_size_text.dart';
import 'package:mawaqit/src/const/constants.dart';
import 'package:mawaqit/src/domain/model/quran/moshaf_model.dart';
import 'package:mawaqit/src/domain/model/quran/reciter_model.dart';
import 'package:mawaqit/src/helpers/TimeShiftManager.dart';
import 'package:mawaqit/src/state_management/quran/recite/recite_notifier.dart';
import 'package:mawaqit/const/resource.dart';
import 'package:sizer/sizer.dart';
Expand Down Expand Up @@ -113,7 +115,7 @@ class _ReciterListViewState extends ConsumerState<ReciterListView> {
}
}

class ReciterCard extends ConsumerWidget {
class ReciterCard extends ConsumerStatefulWidget {
final ReciterModel reciter;
final bool isSelected;
final EdgeInsetsGeometry margin;
Expand All @@ -126,13 +128,18 @@ class ReciterCard extends ConsumerWidget {
});

@override
Widget build(BuildContext context, WidgetRef ref) {
ConsumerState createState() => _ReciterCardState();
}

class _ReciterCardState extends ConsumerState<ReciterCard> {
@override
Widget build(BuildContext context) {
return Container(
width: 25.w,
margin: margin,
margin: widget.margin,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: isSelected ? Border.all(color: Colors.white, width: 2) : null,
border: widget.isSelected ? Border.all(color: Colors.white, width: 2) : null,
),
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
Expand All @@ -141,10 +148,13 @@ class ReciterCard extends ConsumerWidget {
children: [
// CachedNetworkImage with different sizes for online and offline images
FastCachedImage(
url: '${QuranConstant.kQuranReciterImagesBaseUrl}${reciter.id}.jpg',
fit: BoxFit.fitWidth,
loadingBuilder: (context, progress) => Container(color: Colors.transparent),
errorBuilder: (context, error, stackTrace) => _buildOfflineImage()),
url: '${QuranConstant.kQuranReciterImagesBaseUrl}${widget.reciter.id}.jpg',
fit: BoxFit.fitWidth,
cacheWidth: QuranConstant.kCacheWidth,
cacheHeight: QuranConstant.kCacheHeight,
loadingBuilder: (context, progress) => Container(color: Colors.transparent),
errorBuilder: (context, error, stackTrace) => _buildOfflineImage(),
),
// Gradient overlay
Container(
decoration: BoxDecoration(
Expand All @@ -166,7 +176,7 @@ class ReciterCard extends ConsumerWidget {
right: 8,
bottom: 8,
child: AutoSizeText(
reciter.name,
widget.reciter.name,
textAlign: TextAlign.center,
maxLines: 2,
minFontSize: 10,
Expand All @@ -190,12 +200,10 @@ class ReciterCard extends ConsumerWidget {
);
}

// Helper method to build a smaller offline image
// Helper method to build a smaller offline image
Widget _buildOfflineImage() {
return Center(
child: Container(
width: 24.w,
height: 24.w,
padding: EdgeInsets.only(bottom: 2.h),
child: Image.asset(
R.ASSETS_SVG_RECITER_ICON_PNG,
Expand Down
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ dev_dependencies:
flutter_lints: 3.0.1
hive_generator: ^2.0.1
mocktail: ^1.0.3
audio_service: ^0.18.10
dart_mappable_builder: ^4.2.3
json_serializable: ^6.8.0
# For information on the generic Dart part of this file, see the
Expand Down
Loading