~repos /only-bible-app
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.
f5009ba7
—
pyrossh 2 years ago
improve stuff
- lib/dialog.dart +0 -25
- lib/state.dart +20 -8
- lib/widgets/more_button.dart +0 -41
- lib/widgets/scaffold_menu.dart +3 -2
- lib/widgets/settings_sheet.dart +3 -6
- lib/widgets/sliver_tile_grid.dart +24 -11
lib/dialog.dart
CHANGED
|
@@ -1,31 +1,6 @@
|
|
|
1
1
|
import "dart:ui";
|
|
2
2
|
import "package:flutter/material.dart";
|
|
3
3
|
|
|
4
|
-
Future<T?> showCustomDialog<T>(BuildContext context, Widget child) {
|
|
5
|
-
return showGeneralDialog<T>(
|
|
6
|
-
context: context,
|
|
7
|
-
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
|
|
8
|
-
barrierDismissible: true,
|
|
9
|
-
barrierColor: Colors.black.withOpacity(0.5),
|
|
10
|
-
transitionDuration: Duration.zero,
|
|
11
|
-
transitionBuilder: (_, anim, __, child) {
|
|
12
|
-
return FadeTransition(
|
|
13
|
-
opacity: anim,
|
|
14
|
-
child: child,
|
|
15
|
-
);
|
|
16
|
-
},
|
|
17
|
-
pageBuilder: (_, __, ___) {
|
|
18
|
-
return Container(
|
|
19
|
-
// width: MediaQuery.of(context).size.width - 10,
|
|
20
|
-
// height: MediaQuery.of(context).size.height - 80,
|
|
21
|
-
color: Colors.white,
|
|
22
|
-
margin: const EdgeInsets.symmetric(horizontal: 250, vertical: 0),
|
|
23
|
-
child: child,
|
|
24
|
-
);
|
|
25
|
-
},
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
4
|
showAlert(BuildContext context, String title, String message) {
|
|
30
5
|
showDialog(
|
|
31
6
|
context: context,
|
lib/state.dart
CHANGED
|
@@ -12,6 +12,7 @@ import "package:only_bible_app/screens/chapter_view_screen.dart";
|
|
|
12
12
|
import 'package:only_bible_app/dialog.dart';
|
|
13
13
|
import "package:only_bible_app/models.dart";
|
|
14
14
|
import "package:only_bible_app/widgets/actions_sheet.dart";
|
|
15
|
+
import "package:only_bible_app/widgets/scaffold_menu.dart";
|
|
15
16
|
import "package:only_bible_app/widgets/settings_sheet.dart";
|
|
16
17
|
import "package:provider/provider.dart";
|
|
17
18
|
import "package:shared_preferences/shared_preferences.dart";
|
|
@@ -133,14 +134,25 @@ class AppModel extends ChangeNotifier {
|
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
showSettings(BuildContext context) {
|
|
137
|
+
// if (isWide(context)) {
|
|
138
|
+
// Navigator.of(context).push(
|
|
139
|
+
// createNoTransitionPageRoute(
|
|
140
|
+
// const ScaffoldMenu(
|
|
141
|
+
// backgroundColor: Color(0xFFF2F2F7),
|
|
142
|
+
// child: SettingsSheet(),
|
|
143
|
+
// ),
|
|
144
|
+
// ),
|
|
145
|
+
// );
|
|
146
|
+
// } else {
|
|
136
|
-
|
|
147
|
+
showModalBottomSheet(
|
|
137
|
-
|
|
148
|
+
context: context,
|
|
138
|
-
|
|
149
|
+
isDismissible: true,
|
|
139
|
-
|
|
150
|
+
enableDrag: true,
|
|
140
|
-
|
|
151
|
+
showDragHandle: true,
|
|
141
|
-
|
|
152
|
+
useSafeArea: true,
|
|
142
|
-
|
|
153
|
+
builder: (context) => const SettingsSheet(),
|
|
143
|
-
|
|
154
|
+
);
|
|
155
|
+
// }
|
|
144
156
|
}
|
|
145
157
|
|
|
146
158
|
showActions(BuildContext context) {
|
lib/widgets/more_button.dart
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import "package:flutter/material.dart";
|
|
2
|
-
import "package:only_bible_app/state.dart";
|
|
3
|
-
|
|
4
|
-
class MoreButton extends StatelessWidget {
|
|
5
|
-
const MoreButton({super.key});
|
|
6
|
-
|
|
7
|
-
@override
|
|
8
|
-
Widget build(BuildContext context) {
|
|
9
|
-
// showModalBottomSheet(
|
|
10
|
-
// context: context,
|
|
11
|
-
// enableDrag: false,
|
|
12
|
-
// shape: RoundedRectangleBorder(
|
|
13
|
-
// borderRadius: BorderRadius.vertical(
|
|
14
|
-
// top: Radius.circular(20),
|
|
15
|
-
// ),
|
|
16
|
-
// ),
|
|
17
|
-
// clipBehavior: Clip.antiAliasWithSaveLayer,
|
|
18
|
-
// builder: (context) => DraggableScrollableSheet(
|
|
19
|
-
// expand: false,
|
|
20
|
-
// initialChildSize: 0.9,
|
|
21
|
-
// minChildSize: 0.5,
|
|
22
|
-
// maxChildSize: 0.9,
|
|
23
|
-
// builder: (context, scrollController) {
|
|
24
|
-
// return SingleChildScrollView(
|
|
25
|
-
// child: new Container(
|
|
26
|
-
// color: Colors.white,
|
|
27
|
-
// child: buildTitleWidget(),
|
|
28
|
-
// ),
|
|
29
|
-
// );
|
|
30
|
-
// },
|
|
31
|
-
// ),
|
|
32
|
-
// isDismissible: false,
|
|
33
|
-
// isScrollControlled: true,
|
|
34
|
-
// );
|
|
35
|
-
return IconButton(
|
|
36
|
-
padding: EdgeInsets.zero,
|
|
37
|
-
onPressed: () => AppModel.ofEvent(context).showSettings(context),
|
|
38
|
-
icon: const Icon(Icons.more_vert),
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
}
|
lib/widgets/scaffold_menu.dart
CHANGED
|
@@ -3,8 +3,9 @@ import "package:only_bible_app/state.dart";
|
|
|
3
3
|
|
|
4
4
|
class ScaffoldMenu extends StatelessWidget {
|
|
5
5
|
final Widget child;
|
|
6
|
+
final Color? backgroundColor;
|
|
6
7
|
|
|
7
|
-
const ScaffoldMenu({super.key, required this.child});
|
|
8
|
+
const ScaffoldMenu({super.key, required this.child, this.backgroundColor});
|
|
8
9
|
|
|
9
10
|
@override
|
|
10
11
|
Widget build(BuildContext context) {
|
|
@@ -15,7 +16,7 @@ class ScaffoldMenu extends StatelessWidget {
|
|
|
15
16
|
color: Colors.black.withOpacity(0.7),
|
|
16
17
|
margin: EdgeInsets.only(left: isWide(context) ? 250 : 0),
|
|
17
18
|
child: Container(
|
|
18
|
-
color: Theme.of(context).colorScheme.background,
|
|
19
|
+
color: backgroundColor ?? Theme.of(context).colorScheme.background,
|
|
19
20
|
margin: EdgeInsets.only(right: isWide(context) ? 650 : 0),
|
|
20
21
|
child: child,
|
|
21
22
|
),
|
lib/widgets/settings_sheet.dart
CHANGED
|
@@ -15,14 +15,11 @@ class SettingsSheet extends StatelessWidget {
|
|
|
15
15
|
final iconColor = Theme.of(context).textTheme.bodyMedium!.color;
|
|
16
16
|
return Column(
|
|
17
17
|
children: [
|
|
18
|
-
|
|
18
|
+
Padding(
|
|
19
|
-
padding: EdgeInsets.only(bottom:
|
|
19
|
+
padding: const EdgeInsets.only(bottom: 20),
|
|
20
20
|
child: Text(
|
|
21
21
|
"Settings",
|
|
22
|
-
style:
|
|
22
|
+
style: Theme.of(context).textTheme.headlineMedium,
|
|
23
|
-
fontSize: 18,
|
|
24
|
-
fontWeight: FontWeight.w500,
|
|
25
|
-
),
|
|
26
23
|
),
|
|
27
24
|
),
|
|
28
25
|
Expanded(
|
lib/widgets/sliver_tile_grid.dart
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
import "package:flutter/material.dart";
|
|
2
2
|
import "package:only_bible_app/state.dart";
|
|
3
3
|
|
|
4
|
+
enum ListType {
|
|
5
|
+
small,
|
|
6
|
+
large;
|
|
7
|
+
|
|
8
|
+
int crossAxisCount() {
|
|
9
|
+
switch (this) {
|
|
4
|
-
|
|
10
|
+
case ListType.small:
|
|
11
|
+
return 5;
|
|
12
|
+
case ListType.large:
|
|
13
|
+
return 2;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
double childAspectRatio(bool isDesktop) {
|
|
18
|
+
switch (this) {
|
|
19
|
+
case ListType.small:
|
|
20
|
+
return isDesktop ? 2.33 : 1.4;
|
|
21
|
+
case ListType.large:
|
|
22
|
+
return isDesktop ? 5 : 4;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
5
26
|
|
|
6
27
|
class SliverTileGrid extends StatelessWidget {
|
|
7
28
|
final ListType listType;
|
|
@@ -16,18 +37,10 @@ class SliverTileGrid extends StatelessWidget {
|
|
|
16
37
|
return SliverPadding(
|
|
17
38
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
18
39
|
sliver: SliverGrid.count(
|
|
19
|
-
crossAxisCount: listType
|
|
40
|
+
crossAxisCount: listType.crossAxisCount(),
|
|
20
|
-
? 2
|
|
21
|
-
: isDesktop
|
|
22
|
-
? 6
|
|
23
|
-
: 5,
|
|
24
41
|
crossAxisSpacing: spacing,
|
|
25
42
|
mainAxisSpacing: spacing,
|
|
26
|
-
childAspectRatio: listType
|
|
43
|
+
childAspectRatio: listType.childAspectRatio(isDesktop),
|
|
27
|
-
? 4
|
|
28
|
-
: isDesktop
|
|
29
|
-
? 1.6
|
|
30
|
-
: 1.5,
|
|
31
44
|
children: children,
|
|
32
45
|
),
|
|
33
46
|
);
|