~repos /only-bible-app
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.
d11b34af
—
pyrossh 2 years ago
Tab bar
bible_app/lib/components/book_selector.dart
CHANGED
|
@@ -12,45 +12,152 @@ onTabBookChange(int i) {
|
|
|
12
12
|
tabBookIndex.value = i;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
class BookSelector extends StatelessWidget {
|
|
15
|
+
// class BookSelector extends StatelessWidget {
|
|
16
|
+
// const BookSelector({super.key});
|
|
17
|
+
//
|
|
18
|
+
// @override
|
|
19
|
+
// Widget build(BuildContext context) {
|
|
20
|
+
// final tab = tabIndex.reactiveValue(context);
|
|
21
|
+
// if (tab == 1) {
|
|
22
|
+
// final book = kannadaBible[tabBookIndex.reactiveValue(context)];
|
|
23
|
+
// return Container(
|
|
24
|
+
// // margin: const EdgeInsets.symmetric(vertical: 15, horizontal: 30),
|
|
25
|
+
// color: Colors.white,
|
|
26
|
+
// child: Column(
|
|
27
|
+
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
28
|
+
// children: [
|
|
29
|
+
// Container(
|
|
30
|
+
// margin: const EdgeInsets.only(bottom: 10),
|
|
31
|
+
// child: Text(book.name, style: Theme.of(context).textTheme.headlineMedium),
|
|
32
|
+
// ),
|
|
33
|
+
// const Expanded(child: ChaptersList()),
|
|
34
|
+
// ],
|
|
35
|
+
// ),
|
|
36
|
+
// );
|
|
37
|
+
// }
|
|
38
|
+
// return Container(
|
|
39
|
+
// // margin: const EdgeInsets.symmetric(vertical: 15, horizontal: 30),
|
|
40
|
+
// color: Colors.white,
|
|
41
|
+
// child: Column(
|
|
42
|
+
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
43
|
+
// children: [
|
|
44
|
+
// Container(
|
|
45
|
+
// margin: const EdgeInsets.only(bottom: 10),
|
|
46
|
+
// child: Text("Old Testament", style: Theme.of(context).textTheme.headlineMedium),
|
|
47
|
+
// ),
|
|
48
|
+
// Expanded(child: BooksList(offset: 0, books: oldTestament)),
|
|
49
|
+
// Container(
|
|
50
|
+
// margin: const EdgeInsets.symmetric(vertical: 15),
|
|
51
|
+
// child: Text("New Testament", style: Theme.of(context).textTheme.headlineMedium),
|
|
52
|
+
// ),
|
|
53
|
+
// Expanded(child: BooksList(offset: 39, books: newTestament)),
|
|
54
|
+
// ],
|
|
55
|
+
// ),
|
|
56
|
+
// );
|
|
57
|
+
// }
|
|
58
|
+
// }
|
|
59
|
+
|
|
60
|
+
class MyTabbedPage extends StatefulWidget {
|
|
16
|
-
const
|
|
61
|
+
const MyTabbedPage({super.key});
|
|
62
|
+
|
|
63
|
+
@override
|
|
64
|
+
State<MyTabbedPage> createState() => _MyTabbedPageState();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
class _MyTabbedPageState extends State<MyTabbedPage> with SingleTickerProviderStateMixin {
|
|
68
|
+
late TabController _tabController;
|
|
69
|
+
int _selectedIndex = 0;
|
|
70
|
+
|
|
71
|
+
@override
|
|
72
|
+
void initState() {
|
|
73
|
+
super.initState();
|
|
74
|
+
_tabController = TabController(vsync: this, length: 2);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@override
|
|
78
|
+
void dispose() {
|
|
79
|
+
_tabController.dispose();
|
|
80
|
+
super.dispose();
|
|
81
|
+
}
|
|
17
82
|
|
|
18
83
|
@override
|
|
19
84
|
Widget build(BuildContext context) {
|
|
20
|
-
final tab = tabIndex.reactiveValue(context);
|
|
21
|
-
if (tab == 1) {
|
|
22
|
-
|
|
85
|
+
final book = kannadaBible[tabBookIndex.reactiveValue(context)];
|
|
86
|
+
onBookTap(i) {
|
|
87
|
+
_tabController.animateTo(1);
|
|
88
|
+
}
|
|
23
|
-
|
|
89
|
+
return Scaffold(
|
|
24
|
-
// margin: const EdgeInsets.symmetric(vertical: 15, horizontal: 30),
|
|
25
|
-
|
|
90
|
+
appBar: AppBar(
|
|
26
|
-
|
|
91
|
+
flexibleSpace: Column(
|
|
27
|
-
|
|
92
|
+
mainAxisAlignment: MainAxisAlignment.end,
|
|
28
93
|
children: [
|
|
94
|
+
TabBar(
|
|
95
|
+
// overlayColor:
|
|
96
|
+
indicatorWeight: 10,
|
|
97
|
+
dividerColor: Colors.black,
|
|
98
|
+
labelColor: Colors.black,
|
|
99
|
+
labelStyle: TextStyle(
|
|
29
|
-
|
|
100
|
+
fontSize: 22,
|
|
101
|
+
fontWeight: FontWeight.w600,
|
|
102
|
+
),
|
|
103
|
+
indicator: BoxDecoration(
|
|
30
|
-
|
|
104
|
+
borderRadius: BorderRadius.circular(50),
|
|
105
|
+
color: Colors.greenAccent,
|
|
106
|
+
),
|
|
107
|
+
controller: _tabController,
|
|
108
|
+
tabs: const [
|
|
109
|
+
Tab(text: 'Book'),
|
|
31
|
-
|
|
110
|
+
Tab(text: 'Chapter'),
|
|
111
|
+
],
|
|
32
112
|
),
|
|
33
|
-
const Expanded(child: ChaptersList()),
|
|
34
113
|
],
|
|
35
114
|
),
|
|
36
|
-
)
|
|
115
|
+
),
|
|
37
|
-
}
|
|
38
|
-
|
|
116
|
+
body: TabBarView(
|
|
39
|
-
// margin: const EdgeInsets.symmetric(vertical: 15, horizontal: 30),
|
|
40
|
-
|
|
117
|
+
controller: _tabController,
|
|
41
|
-
child: Column(
|
|
42
|
-
crossAxisAlignment: CrossAxisAlignment.start,
|
|
43
118
|
children: [
|
|
44
119
|
Container(
|
|
120
|
+
// margin: const EdgeInsets.symmetric(vertical: 15, horizontal: 30),
|
|
121
|
+
color: Colors.white,
|
|
122
|
+
child: Column(
|
|
123
|
+
crossAxisAlignment: CrossAxisAlignment.start,
|
|
124
|
+
children: [
|
|
125
|
+
Container(
|
|
45
|
-
|
|
126
|
+
margin: const EdgeInsets.only(bottom: 10),
|
|
46
|
-
|
|
127
|
+
child: Text("Old Testament", style: Theme
|
|
128
|
+
.of(context)
|
|
129
|
+
.textTheme
|
|
130
|
+
.headlineMedium),
|
|
131
|
+
),
|
|
132
|
+
Expanded(child: BooksList(offset: 0, books: oldTestament, onBookTap: onBookTap)),
|
|
133
|
+
Container(
|
|
134
|
+
margin: const EdgeInsets.symmetric(vertical: 15),
|
|
135
|
+
child: Text("New Testament", style: Theme
|
|
136
|
+
.of(context)
|
|
137
|
+
.textTheme
|
|
138
|
+
.headlineMedium),
|
|
139
|
+
),
|
|
140
|
+
Expanded(child: BooksList(offset: 39, books: newTestament, onBookTap: onBookTap)),
|
|
141
|
+
],
|
|
142
|
+
),
|
|
47
143
|
),
|
|
48
|
-
Expanded(child: BooksList(offset: 0, books: oldTestament)),
|
|
49
144
|
Container(
|
|
145
|
+
// margin: const EdgeInsets.symmetric(vertical: 15, horizontal: 30),
|
|
146
|
+
color: Colors.white,
|
|
147
|
+
child: Column(
|
|
148
|
+
crossAxisAlignment: CrossAxisAlignment.start,
|
|
149
|
+
children: [
|
|
150
|
+
Container(
|
|
50
|
-
|
|
151
|
+
margin: const EdgeInsets.only(bottom: 10),
|
|
51
|
-
|
|
152
|
+
child: Text(book.name, style: Theme
|
|
153
|
+
.of(context)
|
|
154
|
+
.textTheme
|
|
155
|
+
.headlineMedium),
|
|
156
|
+
),
|
|
157
|
+
const Expanded(child: ChaptersList()),
|
|
158
|
+
],
|
|
159
|
+
),
|
|
52
160
|
),
|
|
53
|
-
Expanded(child: BooksList(offset: 39, books: newTestament)),
|
|
54
161
|
],
|
|
55
162
|
),
|
|
56
163
|
);
|
|
@@ -60,8 +167,9 @@ class BookSelector extends StatelessWidget {
|
|
|
60
167
|
class BooksList extends StatelessWidget {
|
|
61
168
|
final int offset;
|
|
62
169
|
final List<String> books;
|
|
170
|
+
final Function(int) onBookTap;
|
|
63
171
|
|
|
64
|
-
const BooksList({super.key, required this.offset, required this.books});
|
|
172
|
+
const BooksList({super.key, required this.offset, required this.books, required this.onBookTap});
|
|
65
173
|
|
|
66
174
|
@override
|
|
67
175
|
Widget build(BuildContext context) {
|
|
@@ -73,7 +181,7 @@ class BooksList extends StatelessWidget {
|
|
|
73
181
|
final name = books[index].replaceAll(" ", "").substring(0, 3).toUpperCase();
|
|
74
182
|
return InkWell(
|
|
75
183
|
onTap: () {
|
|
76
|
-
|
|
184
|
+
onBookTap(offset + index);
|
|
77
185
|
},
|
|
78
186
|
child: Container(
|
|
79
187
|
margin: const EdgeInsets.all(3),
|
|
@@ -84,7 +192,10 @@ class BooksList extends StatelessWidget {
|
|
|
84
192
|
child: Text(
|
|
85
193
|
name,
|
|
86
194
|
textAlign: TextAlign.center,
|
|
195
|
+
style: Theme
|
|
196
|
+
.of(context)
|
|
197
|
+
.textTheme
|
|
87
|
-
|
|
198
|
+
.labelMedium,
|
|
88
199
|
),
|
|
89
200
|
),
|
|
90
201
|
),
|
|
@@ -121,7 +232,10 @@ class ChaptersList extends StatelessWidget {
|
|
|
121
232
|
child: Text(
|
|
122
233
|
"${index + 1}",
|
|
123
234
|
textAlign: TextAlign.center,
|
|
235
|
+
style: Theme
|
|
236
|
+
.of(context)
|
|
237
|
+
.textTheme
|
|
124
|
-
|
|
238
|
+
.labelMedium,
|
|
125
239
|
),
|
|
126
240
|
),
|
|
127
241
|
),
|
bible_app/lib/main.dart
CHANGED
|
@@ -60,6 +60,9 @@ class App extends StatelessWidget {
|
|
|
60
60
|
return MaterialApp.router(
|
|
61
61
|
routerConfig: _router,
|
|
62
62
|
theme: ThemeData(
|
|
63
|
+
tabBarTheme: TabBarTheme(
|
|
64
|
+
dividerColor: Colors.white,
|
|
65
|
+
),
|
|
63
66
|
brightness: Brightness.light,
|
|
64
67
|
primaryColor: const Color(0xFF4C2323),
|
|
65
68
|
secondaryHeaderColor: const Color(0xFFFFB341),
|
|
@@ -107,10 +110,8 @@ class App extends StatelessWidget {
|
|
|
107
110
|
),
|
|
108
111
|
),
|
|
109
112
|
darkTheme: ThemeData(
|
|
110
|
-
|
|
113
|
+
tabBarTheme: TabBarTheme(
|
|
111
|
-
builders: {
|
|
112
|
-
|
|
114
|
+
dividerColor: Colors.white,
|
|
113
|
-
},
|
|
114
115
|
),
|
|
115
116
|
brightness: Brightness.light,
|
|
116
117
|
primaryColor: const Color(0xFF4C2323),
|
bible_app/lib/screens/home.dart
CHANGED
|
@@ -66,11 +66,10 @@ class SelectScreenRoute extends GoRouteData {
|
|
|
66
66
|
child: Column(
|
|
67
67
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
68
68
|
children: [
|
|
69
|
-
Header(bookName: "", chapter: 1),
|
|
70
69
|
Flexible(
|
|
71
70
|
child: Container(
|
|
72
71
|
margin: const EdgeInsets.only(left: 40, top: 20, right: 300),
|
|
73
|
-
child: const
|
|
72
|
+
child: const MyTabbedPage(),
|
|
74
73
|
),
|
|
75
74
|
),
|
|
76
75
|
],
|
|
@@ -83,7 +82,7 @@ class NoPageTransition extends CustomTransitionPage {
|
|
|
83
82
|
NoPageTransition({required super.child})
|
|
84
83
|
: super(
|
|
85
84
|
transitionDuration: const Duration(milliseconds: 0),
|
|
86
|
-
reverseTransitionDuration:
|
|
85
|
+
reverseTransitionDuration: const Duration(milliseconds: 0),
|
|
87
86
|
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
|
88
87
|
return FadeTransition(
|
|
89
88
|
opacity: animation,
|
bible_app/lib/screens/home.g.dart
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
2
|
+
|
|
3
|
+
part of 'home.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
|
+
}
|