Skip to content

Commit

Permalink
keep highlight one same salah item until iqama (#1394)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghassenbenzahra123 authored Nov 5, 2024
1 parent c9a2d9c commit 17020e7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
4 changes: 3 additions & 1 deletion lib/src/pages/times/normal_home/landscape_normal_home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ class _LandscapeNormalHomeState extends riverpod.ConsumerState<LandscapeNormalHo
final isIqamaMoreImportant = mosqueManager.mosqueConfig!.iqamaMoreImportant == true;
final iqamaEnabled = mosqueManager.mosqueConfig?.iqamaEnabled == true;

final nextActiveSalah = mosqueManager.nextSalahIndex();
final nextActiveSalah = mosqueManager.mosqueConfig!.iqamaMoreImportant == true
? mosqueManager.nextSalahAfterIqamaIndex()
: mosqueManager.nextSalahIndex();

return Column(
children: [
Expand Down
5 changes: 3 additions & 2 deletions lib/src/pages/times/normal_home/portrait_normal_home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ class _PortraitNormalHomeState extends riverpod.ConsumerState<PortraitNormalHome
final isIqamaMoreImportant = mosqueManager.mosqueConfig!.iqamaMoreImportant == true;
final iqamaEnabled = mosqueManager.mosqueConfig?.iqamaEnabled == true;

final nextActiveSalah = mosqueManager.nextSalahIndex();

final nextActiveSalah = mosqueManager.mosqueConfig!.iqamaMoreImportant == true
? mosqueManager.nextSalahAfterIqamaIndex()
: mosqueManager.nextSalahIndex();
return Column(
children: [
SizedBox(height: 15.vh, child: MosqueHeader(mosque: mosqueManager.mosque!)),
Expand Down
5 changes: 3 additions & 2 deletions lib/src/pages/times/turkish_home/landscape_turkish_home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ class _LandScapeTurkishHomeState extends riverpod.ConsumerState<LandScapeTurkish
final isIqamaMoreImportant = mosqueManager.mosqueConfig!.iqamaMoreImportant == true;
final iqamaEnabled = mosqueManager.mosqueConfig?.iqamaEnabled == true;

final nextActiveSalah = mosqueManager.nextSalahIndex();

final nextActiveSalah = mosqueManager.mosqueConfig!.iqamaMoreImportant == true
? mosqueManager.nextSalahAfterIqamaIndex()
: mosqueManager.nextSalahIndex();
return Column(
children: [
MosqueHeader(mosque: mosqueManager.mosque!),
Expand Down
5 changes: 3 additions & 2 deletions lib/src/pages/times/turkish_home/portrait_turkish_home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ class _PortraitTurkishHomeState extends riverpod.ConsumerState<PortraitTurkishHo
final isIqamaMoreImportant = mosqueManager.mosqueConfig!.iqamaMoreImportant == true;
final iqamaEnabled = mosqueManager.mosqueConfig?.iqamaEnabled == true;

final nextActiveSalah = mosqueManager.nextSalahIndex();

final nextActiveSalah = mosqueManager.mosqueConfig!.iqamaMoreImportant == true
? mosqueManager.nextSalahAfterIqamaIndex()
: mosqueManager.nextSalahIndex();
return Column(
children: [
MosqueHeader(mosque: mosqueManager.mosque!),
Expand Down
14 changes: 14 additions & 0 deletions lib/src/services/mixins/mosque_helpers_mixins.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,20 @@ mixin MosqueHelpersMixin on ChangeNotifier {
return salahIndex;
}

/// return the upcoming salah index
/// return -1 in case of issue(invalid times format)
int nextSalahAfterIqamaIndex() {
final now = mosqueDate();
final nextSalah = actualIqamaTimes().firstWhere(
(element) => element.isAfter(now),
orElse: () => actualIqamaTimes().first,
);
var salahIndex = actualIqamaTimes().indexOf(nextSalah);
if (salahIndex > 4) salahIndex = 0;
if (salahIndex < 0) salahIndex = 4;
return salahIndex;
}

/// the duration until the next salah
Duration nextSalahAfter() {
final now = mosqueDate();
Expand Down

0 comments on commit 17020e7

Please sign in to comment.