~repos /only-bible-app

#kotlin#android#ios

git clone https://pyrossh.dev/repos/only-bible-app.git

The only bible app you will ever need. No ads. No in-app purchases. No distractions.


b7284601 pyrossh

2 years ago
fix issues with play
lib/app.dart CHANGED
@@ -1,8 +1,7 @@
1
1
  import 'package:flutter/material.dart';
2
+ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
2
3
  import 'package:flutter_reactive_value/flutter_reactive_value.dart';
3
- import 'package:flutter_localizations/flutter_localizations.dart';
4
4
  import 'package:go_router/go_router.dart';
5
- import 'package:one_context/one_context.dart';
6
5
  import 'package:only_bible_app/routes/home_screen.dart';
7
6
  import 'package:only_bible_app/state.dart';
8
7
  import 'package:only_bible_app/widgets/sidebar.dart';
@@ -15,17 +14,9 @@ class App extends StatelessWidget {
15
14
  Widget build(BuildContext context) {
16
15
  return MaterialApp.router(
17
16
  title: "Only Bible App",
18
- localizationsDelegates: const [
19
- GlobalMaterialLocalizations.delegate,
17
+ localizationsDelegates: AppLocalizations.localizationsDelegates,
20
- GlobalWidgetsLocalizations.delegate,
18
+ supportedLocales: AppLocalizations.supportedLocales,
21
- GlobalCupertinoLocalizations.delegate,
22
- ],
23
- supportedLocales: const [
24
- Locale('en'),
25
- Locale('kn-IN'),
26
- ],
27
19
  debugShowCheckedModeBanner: false,
28
- builder: OneContext().builder,
29
20
  themeMode: darkMode.reactiveValue(context) ? ThemeMode.dark : ThemeMode.light,
30
21
  theme: lightTheme,
31
22
  darkTheme: darkTheme,
lib/main.dart CHANGED
@@ -1,17 +1,34 @@
1
1
  import 'package:flutter/material.dart';
2
+ import 'package:flutter/foundation.dart';
2
3
  import 'package:firebase_core/firebase_core.dart';
4
+ // import 'package:firebase_crashlytics/firebase_crashlytics.dart';
3
5
  import 'package:only_bible_app/options.dart';
4
6
  import 'package:flutter_persistent_value_notifier/flutter_persistent_value_notifier.dart';
5
7
  import 'package:flutter_native_splash/flutter_native_splash.dart';
6
8
  import 'package:only_bible_app/state.dart';
7
9
  import 'package:only_bible_app/app.dart';
8
10
 
11
+ // Toggle this to cause an async error to be thrown during initialization
12
+ // and to test that runZonedGuarded() catches the error
13
+ const _kShouldTestAsyncErrorOnInit = false;
14
+
15
+ // Toggle this for testing Crashlytics in your app locally.
16
+ const _kTestingCrashlytics = true;
17
+
18
+
9
19
  void main() async {
10
20
  WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
11
- FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
12
21
  await Firebase.initializeApp(
13
22
  options: DefaultFirebaseOptions.currentPlatform,
14
23
  );
24
+ // FlutterError.onError = (errorDetails) {
25
+ // FirebaseCrashlytics.instance.recordFlutterError(errorDetails);
26
+ // };
27
+ // PlatformDispatcher.instance.onError = (error, stack) {
28
+ // FirebaseCrashlytics.instance.recordError(error, stack);
29
+ // return true;
30
+ // };
31
+ FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
15
32
  await initPersistentValueNotifier();
16
33
  await loadBible();
17
34
  await updateStatusBar();
lib/state.dart CHANGED
@@ -150,29 +150,28 @@ getBibleFromAsset(String file) async {
150
150
  return getBibleFromText(utf8.decode(bytes.buffer.asUint8List(), allowMalformed: false));
151
151
  }
152
152
 
153
+ final player = AudioPlayer();
154
+
153
155
  onPlay(BuildContext context) async {
154
- final verses = selectedBible.value!.books[bookIndex.value].chapters[chapterIndex.value].verses;
155
- final filteredVerses = verses.asMap().keys.where((it) => selectedVerses.value.contains(it)).map((it) => verses[it]);
156
- final player = AudioPlayer();
157
- player.setUrl(
158
- "https://github.com/pyrossh/only-bible-app/raw/master/assets/output.mp3",
159
- );
160
- // player.setUrl("asset:output.mp3");
161
156
  if (isPlaying.value) {
162
157
  await player.pause();
163
158
  isPlaying.value = false;
164
159
  } else {
165
160
  try {
166
161
  isPlaying.value = true;
167
- for (final v in filteredVerses) {
162
+ for (final v in selectedVerses.value) {
163
+ final bibleName = selectedBible.value!.name;
164
+ final book = (bookIndex.value + 1).toString().padLeft(2, '0');
165
+ final chapter = (chapterIndex.value + 1).toString().padLeft(3, '0');
166
+ final verse = (v + 1).toString().padLeft(3, '0');
168
- await player.setClip(
167
+ await player.setUrl(
169
- start: Duration(milliseconds: (v.audioRange.start * 1000).toInt()),
168
+ "http://localhost:3000/$bibleName/$book-$chapter-$verse.mp3",
170
- end: Duration(milliseconds: (v.audioRange.end * 1000).toInt()),
171
169
  );
172
170
  await player.play();
173
- await player.pause();
171
+ await player.stop();
174
172
  }
175
173
  } catch (err) {
174
+ print(err.toString());
176
175
  showError(context, "Could not play audio");
177
176
  } finally {
178
177
  await player.pause();
lib/utils/dialog.dart CHANGED
@@ -1,6 +1,5 @@
1
1
  import "dart:ui";
2
2
  import "package:flutter/material.dart";
3
- import "package:go_router/go_router.dart";
4
3
 
5
4
  Future<T?> showCustomDialog<T>(BuildContext context, Widget child) {
6
5
  return showGeneralDialog<T>(
@@ -40,7 +39,9 @@ showAlert(BuildContext context, String title, String message) {
40
39
  actionsOverflowButtonSpacing: 8.0,
41
40
  actions: [
42
41
  TextButton(
43
- onPressed: context.pop,
42
+ onPressed: () {
43
+ Navigator.of(context).pop();
44
+ },
44
45
  child: const Text("OK"),
45
46
  ),
46
47
  ],
macos/Runner.xcodeproj/project.pbxproj CHANGED
@@ -198,7 +198,6 @@
198
198
  0A2423C648D8FA7609578CB3 /* Pods-RunnerTests.release.xcconfig */,
199
199
  00794A8931EF6D4D545A59C5 /* Pods-RunnerTests.profile.xcconfig */,
200
200
  );
201
- name = Pods;
202
201
  path = Pods;
203
202
  sourceTree = "<group>";
204
203
  };
@@ -384,7 +383,7 @@
384
383
  );
385
384
  runOnlyForDeploymentPostprocessing = 0;
386
385
  shellPath = /bin/sh;
387
- shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire";
386
+ shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire\n";
388
387
  };
389
388
  492DE6FEE85F5F00ADEF999B /* [CP] Embed Pods Frameworks */ = {
390
389
  isa = PBXShellScriptBuildPhase;
macos/Runner/DebugProfile.entitlements CHANGED
@@ -8,5 +8,7 @@
8
8
  <true/>
9
9
  <key>com.apple.security.network.server</key>
10
10
  <true/>
11
+ <key>com.apple.security.network.client</key>
12
+ <true/>
11
13
  </dict>
12
14
  </plist>
macos/Runner/Release.entitlements CHANGED
@@ -4,5 +4,7 @@
4
4
  <dict>
5
5
  <key>com.apple.security.app-sandbox</key>
6
6
  <true/>
7
+ <key>com.apple.security.network.client</key>
8
+ <true/>
7
9
  </dict>
8
10
  </plist>