Skip to content

Commit

Permalink
Fix iterator issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrossh committed Aug 26, 2023
1 parent 89a99c6 commit b536cc6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
25 changes: 10 additions & 15 deletions lib/providers/app_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,10 @@ class AppModel extends ChangeNotifier {
);
}

clearEvents(
BuildContext context,
) {
if (isPlaying) {
pause();
}
clearEvents(BuildContext context) {
// if (isPlaying) {
// pause();
// }
clearSelections();
hideActions(context);
}
Expand Down Expand Up @@ -484,12 +482,7 @@ class AppModel extends ChangeNotifier {
}

bool isVerseSelected(Verse v) {
return selectedVerses.any((el) => el.index == v.index);
}

bool isVerseHighlighted(BuildContext context) {
// box.read("${book}:${chapter}:${verse}", "color");
return false;
return selectedVerses.any((el) => el.book == v.book && el.chapter == v.chapter && el.index == v.index);
}

void onVerseSelected(BuildContext context, Verse v) {
Expand Down Expand Up @@ -522,13 +515,13 @@ class AppModel extends ChangeNotifier {
}

onPlay(BuildContext context) async {
final versesToPlay = List.from(selectedVerses);
if (isPlaying) {
pause();
} else {
isPlaying = true;
notifyListeners();
// add locks todo
for (final v in selectedVerses) {
for (final v in versesToPlay) {
final bibleName = bible.name;
final book = (v.book + 1).toString().padLeft(2, "0");
final chapter = (v.chapter + 1).toString().padLeft(3, "0");
Expand All @@ -542,7 +535,9 @@ class AppModel extends ChangeNotifier {
} catch (err) {
log("Could not play audio", name: "play", error: (err.toString(), pathname));
FirebaseCrashlytics.instance.recordFlutterError(FlutterErrorDetails(exception: (err.toString(), pathname)));
showError(context, "Could not play audio");
if (context.mounted) {
showError(context, "Could not play audio");
}
return;
} finally {
pause();
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/verses_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class VersesView extends StatelessWidget {
backgroundColor: app.darkMode ? Colors.grey.shade800 : Colors.grey.shade200,
)
: TextStyle(
backgroundColor: app.getHighlight(v) ?? Theme.of(context).colorScheme.background,
backgroundColor: app.getHighlight(v) ?? context.theme.colorScheme.background,
),
recognizer: TapGestureRecognizer()
..onTap = () {
Expand Down

0 comments on commit b536cc6

Please sign in to comment.