~repos /only-bible-app

#kotlin#android#ios

git clone https://pyrossh.dev/repos/only-bible-app.git
Discussions: https://groups.google.com/g/rust-embed-devs

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


61c943af pyrossh

2 years ago
move routes
bible_app/lib/components/header.dart CHANGED
@@ -1,16 +1,17 @@
1
1
  import "dart:math";
2
2
  import "package:flutter/material.dart";
3
3
  import "package:just_audio/just_audio.dart";
4
- import 'package:kannada_bible_app/routes.dart';
4
+ import "package:kannada_bible_app/domain/book.dart";
5
+ import "../routes/select.dart";
5
6
  import "../state.dart";
6
7
  import "../domain/kannada_gen.dart";
7
8
 
8
9
  class Header extends StatelessWidget {
9
- final String bookName;
10
+ final int book;
10
11
  final int chapter;
11
12
  final player = AudioPlayer();
12
13
 
13
- Header({super.key, required this.bookName, required this.chapter}) {
14
+ Header({super.key, required this.book, required this.chapter}) {
14
15
  player.setUrl("https://github.com/pyrossh/bible-app/raw/master/public/audio/output.mp3");
15
16
  player.setUrl("asset:output.mp3");
16
17
  }
@@ -33,7 +34,7 @@ class Header extends StatelessWidget {
33
34
  child: Row(
34
35
  crossAxisAlignment: CrossAxisAlignment.center,
35
36
  children: [
36
- Text("$bookName ${chapter + 1}", style: Theme.of(context).textTheme.headlineLarge),
37
+ Text("${allBooks[book]} ${chapter + 1}", style: Theme.of(context).textTheme.headlineLarge),
37
38
  Container(
38
39
  margin: const EdgeInsets.only(left: 3),
39
40
  child: Transform.rotate(
@@ -48,8 +49,8 @@ class Header extends StatelessWidget {
48
49
  IconButton(
49
50
  icon: const Icon(Icons.play_circle_fill, size: 36),
50
51
  onPressed: () async {
51
- final verses = kannadaBible[bookIndex.value]
52
+ final verses = kannadaBible[book]
52
- .chapters[chapterIndex.value]
53
+ .chapters[chapter]
53
54
  .verses
54
55
  .where((v) => selectedVerses.value.contains(v.index - 1));
55
56
  // Todo: play/pause button
bible_app/lib/components/{verse.dart → verse_view.dart} RENAMED
@@ -2,11 +2,11 @@ import "package:flutter/material.dart";
2
2
  import "package:flutter_reactive_value/flutter_reactive_value.dart";
3
3
  import "../state.dart";
4
4
 
5
- class Verse extends StatelessWidget {
5
+ class VerseText extends StatelessWidget {
6
6
  final int index;
7
7
  final String text;
8
8
 
9
- const Verse({super.key, required this.index, required this.text});
9
+ const VerseText({super.key, required this.index, required this.text});
10
10
 
11
11
  @override
12
12
  Widget build(BuildContext context) {
bible_app/lib/main.dart CHANGED
@@ -1,7 +1,10 @@
1
1
  import "package:flutter/material.dart";
2
2
  import 'package:go_router/go_router.dart';
3
3
  import "package:flutter_persistent_value_notifier/flutter_persistent_value_notifier.dart";
4
+ import 'package:kannada_bible_app/domain/book.dart';
5
+ import 'package:kannada_bible_app/state.dart';
4
- import 'routes.dart' as routes2;
6
+ import 'routes/index.dart';
7
+ import 'routes/select.dart';
5
8
  import "components/sidebar.dart";
6
9
 
7
10
  void main() async {
@@ -14,11 +17,14 @@ final _rootNavigatorKey = GlobalKey<NavigatorState>();
14
17
  final _shellNavigatorKey = GlobalKey<NavigatorState>();
15
18
  final _router = GoRouter(
16
19
  navigatorKey: _rootNavigatorKey,
17
- initialLocation: "/Genesis/1",
20
+ initialLocation: "/${allBooks[bookIndex.value]}/${chapterIndex.value}",
18
21
  routes: [
19
22
  ShellRoute(
20
23
  navigatorKey: _shellNavigatorKey,
24
+ routes: [
21
- routes: routes2.$appRoutes,
25
+ $homeScreenRoute,
26
+ $selectScreenRoute,
27
+ ],
22
28
  builder: (context, state, child) {
23
29
  return Scaffold(
24
30
  backgroundColor: Colors.white,
bible_app/lib/routes.dart DELETED
@@ -1,106 +0,0 @@
1
- import "package:flutter/material.dart";
2
- import 'package:go_router/go_router.dart';
3
- import 'screens/book_selector.dart';
4
- import 'components/header.dart';
5
- import 'domain/kannada_gen.dart';
6
- import 'components/verse.dart';
7
- import 'state.dart';
8
-
9
- part 'routes.g.dart';
10
-
11
- @TypedGoRoute<HomeScreenRoute>(
12
- path: "/:book/:chapter",
13
- )
14
- @immutable
15
- class HomeScreenRoute extends GoRouteData {
16
- final String book;
17
- final int chapter;
18
-
19
- HomeScreenRoute({required this.book, required this.chapter}) {
20
- selectedVerses.value.clear();
21
- }
22
-
23
- @override
24
- Page buildPage(BuildContext context, GoRouterState state) {
25
- final selectedBook = kannadaBible.firstWhere((it) => book == it.name);
26
- final verses = selectedBook.chapters[chapter].verses;
27
-
28
- return NoPageTransition(
29
- child: Column(
30
- children: [
31
- Header(bookName: selectedBook.name, chapter: chapter),
32
- Flexible(
33
- child: ListView.builder(
34
- padding: const EdgeInsets.symmetric(
35
- vertical: 20,
36
- horizontal: 40,
37
- ),
38
- itemCount: verses.length,
39
- itemBuilder: (BuildContext context, int index) {
40
- final v = verses[index];
41
- return Container(
42
- margin: const EdgeInsets.symmetric(vertical: 6),
43
- child: Verse(index: v.index - 1, text: v.text),
44
- );
45
- },
46
- ),
47
- ),
48
- ],
49
- ),
50
- );
51
- }
52
- }
53
-
54
- @TypedGoRoute<SelectScreenRoute>(
55
- path: "/select",
56
- )
57
- @immutable
58
- class SelectScreenRoute extends GoRouteData {
59
-
60
- @override
61
- Page buildPage(BuildContext context, GoRouterState state) {
62
- final width = MediaQuery.of(context).size.width;
63
- final right = width/10;
64
- return NoPageTransition(
65
- child: Column(
66
- crossAxisAlignment: CrossAxisAlignment.start,
67
- children: [
68
- Flexible(
69
- child: Container(
70
- margin: EdgeInsets.only(left: 40, top: 20, right: right),
71
- child: const BookSelectorScreen(),
72
- ),
73
- ),
74
- ],
75
- ),
76
- );
77
- }
78
- }
79
-
80
- class NoPageTransition extends CustomTransitionPage {
81
- NoPageTransition({required super.child})
82
- : super(
83
- transitionDuration: const Duration(milliseconds: 0),
84
- reverseTransitionDuration: const Duration(milliseconds: 0),
85
- transitionsBuilder: (context, animation, secondaryAnimation, child) {
86
- return FadeTransition(
87
- opacity: animation,
88
- child: child,
89
- );
90
- });
91
- }
92
-
93
- // key: state.pageKey,
94
- // barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
95
- // barrierDismissible: true,
96
- // barrierColor: Colors.black.withOpacity(0.7),
97
- // transitionDuration: const Duration(milliseconds: 0),
98
- // reverseTransitionDuration: const Duration(milliseconds: 0),
99
- // transitionsBuilder: (context, animation, secondaryAnimation, child) {
100
- // return FadeTransition(
101
- // opacity: animation,
102
- // child: child,
103
- // );
104
- // },
105
- // opaque: false,
106
- // fullscreenDialog: false,
bible_app/lib/routes.g.dart DELETED
@@ -1,60 +0,0 @@
1
- // GENERATED CODE - DO NOT MODIFY BY HAND
2
-
3
- part of 'routes.dart';
4
-
5
- // **************************************************************************
6
- // GoRouterGenerator
7
- // **************************************************************************
8
-
9
- List<RouteBase> get $appRoutes => [
10
- $homeScreenRoute,
11
- $selectScreenRoute,
12
- ];
13
-
14
- RouteBase get $homeScreenRoute => GoRouteData.$route(
15
- path: '/:book/:chapter',
16
- factory: $HomeScreenRouteExtension._fromState,
17
- );
18
-
19
- extension $HomeScreenRouteExtension on HomeScreenRoute {
20
- static HomeScreenRoute _fromState(GoRouterState state) => HomeScreenRoute(
21
- book: state.pathParameters['book']!,
22
- chapter: int.parse(state.pathParameters['chapter']!),
23
- );
24
-
25
- String get location => GoRouteData.$location(
26
- '/${Uri.encodeComponent(book)}/${Uri.encodeComponent(chapter.toString())}',
27
- );
28
-
29
- void go(BuildContext context) => context.go(location);
30
-
31
- Future<T?> push<T>(BuildContext context) => context.push<T>(location);
32
-
33
- void pushReplacement(BuildContext context) =>
34
- context.pushReplacement(location);
35
-
36
- void replace(BuildContext context) => context.replace(location);
37
- }
38
-
39
- RouteBase get $selectScreenRoute => GoRouteData.$route(
40
- path: '/select',
41
- factory: $SelectScreenRouteExtension._fromState,
42
- );
43
-
44
- extension $SelectScreenRouteExtension on SelectScreenRoute {
45
- static SelectScreenRoute _fromState(GoRouterState state) =>
46
- SelectScreenRoute();
47
-
48
- String get location => GoRouteData.$location(
49
- '/select',
50
- );
51
-
52
- void go(BuildContext context) => context.go(location);
53
-
54
- Future<T?> push<T>(BuildContext context) => context.push<T>(location);
55
-
56
- void pushReplacement(BuildContext context) =>
57
- context.pushReplacement(location);
58
-
59
- void replace(BuildContext context) => context.replace(location);
60
- }
bible_app/lib/screens/book_selector.dart DELETED
@@ -1,171 +0,0 @@
1
- import 'dart:io' show Platform;
2
- import "package:flutter/material.dart";
3
- import "package:flutter_reactive_value/flutter_reactive_value.dart";
4
- import 'package:kannada_bible_app/routes.dart';
5
- import '../domain/book.dart';
6
- import '../domain/kannada_gen.dart';
7
-
8
- final tabBookIndex = ValueNotifier(0);
9
-
10
- onTabBookChange(int i) {
11
- tabBookIndex.value = i;
12
- }
13
-
14
- class BookSelectorScreen extends StatelessWidget {
15
- const BookSelectorScreen({super.key});
16
-
17
- @override
18
- Widget build(BuildContext context) {
19
- return DefaultTabController(
20
- length: 2,
21
- // animationDuration: Platform.isMacOS ? Duration.zero: const Duration(milliseconds: 300),
22
- child: Column(
23
- children: [
24
- SizedBox(
25
- width: 250,
26
- child: TabBar(
27
- labelPadding: EdgeInsets.zero,
28
- labelColor: Colors.black,
29
- labelStyle: const TextStyle(
30
- fontSize: 14,
31
- fontWeight: FontWeight.w600,
32
- ),
33
- indicator: BoxDecoration(
34
- border: Border.all(color: Colors.blue.shade700, width: 3),
35
- borderRadius: BorderRadius.circular(50),
36
- ),
37
- tabs: const [
38
- Tab(
39
- child: Row(
40
- mainAxisSize: MainAxisSize.min,
41
- children: [
42
- Icon(Icons.book_outlined, color: Colors.red, size: 24),
43
- SizedBox(width: 8),
44
- Text('BOOK'),
45
- ],
46
- ),
47
- ),
48
- Tab(
49
- child: Row(
50
- mainAxisSize: MainAxisSize.min,
51
- children: [
52
- Icon(Icons.bookmark_outline, color: Colors.blue, size: 24),
53
- SizedBox(width: 8),
54
- Text('CHAPTER'),
55
- ],
56
- ),
57
- ),
58
- ],
59
- ),
60
- ),
61
- Container(
62
- margin: const EdgeInsets.symmetric(vertical: 20),
63
- decoration: const BoxDecoration(
64
- border: Border(bottom: BorderSide(width: 1.5)),
65
- ),
66
- ),
67
- Expanded(
68
- child: TabBarView(
69
- children: [
70
- ListView(children: [
71
- Container(
72
- margin: const EdgeInsets.only(bottom: 20, left: 10),
73
- child: Text("Old Testament", style: Theme.of(context).textTheme.headlineMedium),
74
- ),
75
- BooksList(offset: 0, books: oldTestament),
76
- Container(
77
- padding: const EdgeInsets.only(bottom: 20, top: 40, left: 10),
78
- child: Text("New Testament", style: Theme.of(context).textTheme.headlineMedium),
79
- ),
80
- BooksList(offset: 39, books: newTestament),
81
- ]),
82
- const ChaptersList(),
83
- ],
84
- ),
85
- ),
86
- ],
87
- ),
88
- );
89
- }
90
- }
91
-
92
- class BooksList extends StatelessWidget {
93
- final int offset;
94
- final List<String> books;
95
-
96
- const BooksList({super.key, required this.offset, required this.books});
97
-
98
- @override
99
- Widget build(BuildContext context) {
100
- return Wrap(
101
- children: List.generate(books.length, (index) {
102
- final name = books[index].replaceAll(" ", "").substring(0, 3).toUpperCase();
103
- return InkWell(
104
- borderRadius: const BorderRadius.all(Radius.circular(30)),
105
- onTap: () {
106
- DefaultTabController.of(context).animateTo(1);
107
- tabBookIndex.value = offset + index;
108
- },
109
- child: Container(
110
- width: 90,
111
- height: 50,
112
- margin: const EdgeInsets.all(8),
113
- child: Material(
114
- elevation: 3,
115
- borderRadius: const BorderRadius.all(Radius.circular(30)),
116
- child: Center(
117
- child: Text(
118
- name,
119
- textAlign: TextAlign.center,
120
- style: Theme.of(context).textTheme.labelMedium,
121
- ),
122
- ),
123
- ),
124
- ),
125
- );
126
- }),
127
- );
128
- }
129
- }
130
-
131
- class ChaptersList extends StatelessWidget {
132
- const ChaptersList({super.key});
133
-
134
- @override
135
- Widget build(BuildContext context) {
136
- final bookIndex = tabBookIndex.reactiveValue(context);
137
- final book = kannadaBible[bookIndex];
138
- return ListView(children: [
139
- Container(
140
- margin: const EdgeInsets.only(bottom: 10, left: 10),
141
- child: Text(book.name, style: Theme.of(context).textTheme.headlineMedium),
142
- ),
143
- Wrap(
144
- children: List.generate(book.chapters.length, (index) {
145
- return InkWell(
146
- borderRadius: const BorderRadius.all(Radius.circular(30)),
147
- onTap: () {
148
- HomeScreenRoute(book: book.name, chapter: index).go(context);
149
- },
150
- child: Container(
151
- width: 90,
152
- height: 50,
153
- margin: const EdgeInsets.all(8),
154
- child: Material(
155
- elevation: 3,
156
- borderRadius: const BorderRadius.all(Radius.circular(30)),
157
- child: Center(
158
- child: Text(
159
- "${index + 1}",
160
- textAlign: TextAlign.center,
161
- style: Theme.of(context).textTheme.labelMedium,
162
- ),
163
- ),
164
- ),
165
- ),
166
- );
167
- }),
168
- )
169
- ]);
170
- }
171
- }
bible_app/lib/state.dart CHANGED
@@ -31,3 +31,9 @@ onVerseSelected(int i) {
31
31
  selectedVerses.value = [...selectedVerses.value, i];
32
32
  }
33
33
  }
34
+
35
+ final tabBookIndex = ValueNotifier(0);
36
+
37
+ onTabBookChange(int i) {
38
+ tabBookIndex.value = i;
39
+ }
bible_app/lib/utils/dialog.dart CHANGED
@@ -1,4 +1,5 @@
1
1
  import "package:flutter/material.dart";
2
+ import "package:go_router/go_router.dart";
2
3
 
3
4
  Future<T?> showCustomDialog<T>(BuildContext context, Widget child) {
4
5
  return showGeneralDialog<T>(
@@ -143,4 +144,16 @@ void showSlideCustomDialog(BuildContext context) {
143
144
  // tabIndex.value = 0;
144
145
  // });
145
146
  // }
146
- // });
147
+ // });
148
+ class NoPageTransition extends CustomTransitionPage {
149
+ NoPageTransition({required super.child})
150
+ : super(
151
+ transitionDuration: const Duration(milliseconds: 0),
152
+ reverseTransitionDuration: const Duration(milliseconds: 0),
153
+ transitionsBuilder: (context, animation, secondaryAnimation, child) {
154
+ return FadeTransition(
155
+ opacity: animation,
156
+ child: child,
157
+ );
158
+ });
159
+ }
bible_app/pubspec.lock CHANGED
@@ -201,6 +201,22 @@ packages:
201
201
  url: "https://pub.dev"
202
202
  source: hosted
203
203
  version: "2.3.2"
204
+ directed_graph:
205
+ dependency: transitive
206
+ description:
207
+ name: directed_graph
208
+ sha256: "82061c9ce3ac74d9c4c173fb03daac515d503a0f9f77c0010a872f8c344a4f03"
209
+ url: "https://pub.dev"
210
+ source: hosted
211
+ version: "0.3.9"
212
+ exception_templates:
213
+ dependency: transitive
214
+ description:
215
+ name: exception_templates
216
+ sha256: e9303fd16ecdb845a14b397cb93476f807dd2b4706f5ee44f708dbc95c256c33
217
+ url: "https://pub.dev"
218
+ source: hosted
219
+ version: "0.2.4"
204
220
  fake_async:
205
221
  dependency: transitive
206
222
  description:
@@ -384,6 +400,14 @@ packages:
384
400
  url: "https://pub.dev"
385
401
  source: hosted
386
402
  version: "0.4.8"
403
+ lazy_memo:
404
+ dependency: transitive
405
+ description:
406
+ name: lazy_memo
407
+ sha256: ca4be412d65726f79a30ba6e40b7056f1dbefbb35ec42913365b3f3e86d49279
408
+ url: "https://pub.dev"
409
+ source: hosted
410
+ version: "0.1.9"
387
411
  lints:
388
412
  dependency: transitive
389
413
  description:
@@ -416,6 +440,14 @@ packages:
416
440
  url: "https://pub.dev"
417
441
  source: hosted
418
442
  version: "0.2.0"
443
+ merging_builder:
444
+ dependency: "direct dev"
445
+ description:
446
+ name: merging_builder
447
+ sha256: dbe9c12c9c0c675f2684d24c0c4ce91c046f7b32a414f02343507951e1a6f6b7
448
+ url: "https://pub.dev"
449
+ source: hosted
450
+ version: "0.2.5"
419
451
  meta:
420
452
  dependency: transitive
421
453
  description:
@@ -544,6 +576,14 @@ packages:
544
576
  url: "https://pub.dev"
545
577
  source: hosted
546
578
  version: "1.2.3"
579
+ quote_buffer:
580
+ dependency: transitive
581
+ description:
582
+ name: quote_buffer
583
+ sha256: a9eefd3ddc63bb310ffbc855b6ebe0363d925235485bc5778e28c492b1224b31
584
+ url: "https://pub.dev"
585
+ source: hosted
586
+ version: "0.2.5"
547
587
  rxdart:
548
588
  dependency: transitive
549
589
  description: