~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.
23d21bcb
—
pyrossh 2 years ago
add theme switcher
- lib/app.dart +134 -0
- lib/main.dart +2 -125
lib/app.dart
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import 'package:flutter/material.dart';
|
|
2
|
+
import 'package:flutter_reactive_value/flutter_reactive_value.dart';
|
|
3
|
+
import 'package:go_router/go_router.dart';
|
|
4
|
+
import 'package:one_context/one_context.dart';
|
|
5
|
+
import 'package:only_bible_app/components/shell.dart';
|
|
6
|
+
import 'package:only_bible_app/routes/home_screen.dart';
|
|
7
|
+
import 'package:only_bible_app/state.dart';
|
|
8
|
+
|
|
9
|
+
class App extends StatelessWidget {
|
|
10
|
+
const App({super.key});
|
|
11
|
+
|
|
12
|
+
@override
|
|
13
|
+
Widget build(BuildContext context) {
|
|
14
|
+
return MaterialApp.router(
|
|
15
|
+
debugShowCheckedModeBanner: false,
|
|
16
|
+
builder: OneContext().builder,
|
|
17
|
+
themeMode: darkMode.reactiveValue(context) ? ThemeMode.dark : ThemeMode.light,
|
|
18
|
+
theme: ThemeData(
|
|
19
|
+
visualDensity: VisualDensity.adaptivePlatformDensity,
|
|
20
|
+
primaryColor: const Color(0xFF4C2323),
|
|
21
|
+
secondaryHeaderColor: const Color(0xFFFFB341),
|
|
22
|
+
highlightColor: const Color(0xAAF8D0DC),
|
|
23
|
+
dividerColor: Colors.black,
|
|
24
|
+
shadowColor: Colors.black,
|
|
25
|
+
colorScheme: const ColorScheme.light(
|
|
26
|
+
background: Colors.white,
|
|
27
|
+
),
|
|
28
|
+
textButtonTheme: TextButtonThemeData(
|
|
29
|
+
style: TextButton.styleFrom(
|
|
30
|
+
padding: EdgeInsets.zero,
|
|
31
|
+
shape: const RoundedRectangleBorder(),
|
|
32
|
+
elevation: 1,
|
|
33
|
+
// backgroundColor: const Color(0xFFF6F6F6),
|
|
34
|
+
backgroundColor: const Color(0xFFEAE9E9),
|
|
35
|
+
foregroundColor: const Color(0xFF9A1111),
|
|
36
|
+
textStyle: const TextStyle(
|
|
37
|
+
fontSize: 18,
|
|
38
|
+
fontWeight: FontWeight.w500,
|
|
39
|
+
color: Color(0xFF9A1111),
|
|
40
|
+
letterSpacing: 0.5,
|
|
41
|
+
),
|
|
42
|
+
),
|
|
43
|
+
),
|
|
44
|
+
textTheme: const TextTheme(
|
|
45
|
+
bodyMedium: TextStyle(
|
|
46
|
+
color: Color(0xFF010101),
|
|
47
|
+
),
|
|
48
|
+
headlineLarge: TextStyle(
|
|
49
|
+
fontSize: 38,
|
|
50
|
+
fontWeight: FontWeight.w700,
|
|
51
|
+
color: Color(0xFFFFB341),
|
|
52
|
+
),
|
|
53
|
+
headlineMedium: TextStyle(
|
|
54
|
+
color: Color(0xFF010101),
|
|
55
|
+
fontSize: 20,
|
|
56
|
+
fontWeight: FontWeight.w500,
|
|
57
|
+
letterSpacing: 0.5,
|
|
58
|
+
),
|
|
59
|
+
labelMedium: TextStyle(
|
|
60
|
+
fontSize: 12,
|
|
61
|
+
fontWeight: FontWeight.w800,
|
|
62
|
+
color: Color(0xFF9A1111),
|
|
63
|
+
letterSpacing: 0.5,
|
|
64
|
+
),
|
|
65
|
+
),
|
|
66
|
+
),
|
|
67
|
+
darkTheme: ThemeData(
|
|
68
|
+
visualDensity: VisualDensity.adaptivePlatformDensity,
|
|
69
|
+
primaryColor: const Color(0xFF4C2323),
|
|
70
|
+
secondaryHeaderColor: const Color(0xFFFFB341),
|
|
71
|
+
highlightColor: const Color(0xAAF8D0DC),
|
|
72
|
+
dividerColor: Colors.white,
|
|
73
|
+
shadowColor: Colors.white,
|
|
74
|
+
colorScheme: const ColorScheme.dark(
|
|
75
|
+
background: Color(0xFF1F1F22),
|
|
76
|
+
),
|
|
77
|
+
textButtonTheme: TextButtonThemeData(
|
|
78
|
+
style: TextButton.styleFrom(
|
|
79
|
+
padding: EdgeInsets.zero,
|
|
80
|
+
shape: const RoundedRectangleBorder(),
|
|
81
|
+
elevation: 1,
|
|
82
|
+
backgroundColor: const Color(0xFF323232),
|
|
83
|
+
foregroundColor: const Color(0xFFBBBBBB),
|
|
84
|
+
textStyle: const TextStyle(
|
|
85
|
+
fontSize: 18,
|
|
86
|
+
fontWeight: FontWeight.w500,
|
|
87
|
+
color: Color(0xFF9A1111),
|
|
88
|
+
letterSpacing: 0.5,
|
|
89
|
+
),
|
|
90
|
+
),
|
|
91
|
+
),
|
|
92
|
+
textTheme: const TextTheme(
|
|
93
|
+
bodyMedium: TextStyle(
|
|
94
|
+
color: Color(0xFFBCBEC4),
|
|
95
|
+
),
|
|
96
|
+
headlineLarge: TextStyle(
|
|
97
|
+
fontSize: 38,
|
|
98
|
+
fontWeight: FontWeight.w700,
|
|
99
|
+
color: Color(0xFFFFB341),
|
|
100
|
+
),
|
|
101
|
+
headlineMedium: TextStyle(
|
|
102
|
+
color: Color(0xFFBCBEC4),
|
|
103
|
+
fontSize: 20,
|
|
104
|
+
fontWeight: FontWeight.w500,
|
|
105
|
+
letterSpacing: 0.5,
|
|
106
|
+
),
|
|
107
|
+
labelMedium: TextStyle(
|
|
108
|
+
color: Color(0xFFBBBBBB),
|
|
109
|
+
fontSize: 12,
|
|
110
|
+
fontWeight: FontWeight.w800,
|
|
111
|
+
letterSpacing: 0.5,
|
|
112
|
+
),
|
|
113
|
+
),
|
|
114
|
+
),
|
|
115
|
+
routerConfig: GoRouter(
|
|
116
|
+
debugLogDiagnostics: true,
|
|
117
|
+
initialLocation: "/${selectedBible.value[bookIndex.value].name}/${chapterIndex.value}",
|
|
118
|
+
routes: [
|
|
119
|
+
Shell(
|
|
120
|
+
routes: [
|
|
121
|
+
GoRouteData.$route(
|
|
122
|
+
path: '/:book/:chapter',
|
|
123
|
+
factory: (GoRouterState state) => HomeScreen(
|
|
124
|
+
book: state.pathParameters['book']!,
|
|
125
|
+
chapter: int.parse(state.pathParameters['chapter']!),
|
|
126
|
+
),
|
|
127
|
+
),
|
|
128
|
+
],
|
|
129
|
+
),
|
|
130
|
+
],
|
|
131
|
+
),
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}
|
lib/main.dart
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import 'package:flutter/material.dart';
|
|
2
2
|
import 'package:flutter_persistent_value_notifier/flutter_persistent_value_notifier.dart';
|
|
3
3
|
import 'package:flutter_native_splash/flutter_native_splash.dart';
|
|
4
|
-
import 'package:go_router/go_router.dart';
|
|
5
|
-
import 'package:one_context/one_context.dart';
|
|
6
|
-
import 'package:only_bible_app/components/shell.dart';
|
|
7
|
-
import 'package:only_bible_app/routes/home_screen.dart';
|
|
8
4
|
import 'package:only_bible_app/state.dart';
|
|
5
|
+
import 'package:only_bible_app/app.dart';
|
|
9
6
|
|
|
10
7
|
void main() async {
|
|
11
8
|
WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
|
|
@@ -13,126 +10,6 @@ void main() async {
|
|
|
13
10
|
await initPersistentValueNotifier();
|
|
14
11
|
await loadBible();
|
|
15
12
|
await updateStatusBar();
|
|
16
|
-
runApp(
|
|
17
|
-
MaterialApp.router(
|
|
18
|
-
debugShowCheckedModeBanner: false,
|
|
19
|
-
builder: OneContext().builder,
|
|
20
|
-
themeMode: ThemeMode.system,
|
|
21
|
-
theme: ThemeData(
|
|
22
|
-
visualDensity: VisualDensity.adaptivePlatformDensity,
|
|
23
|
-
primaryColor: const Color(0xFF4C2323),
|
|
24
|
-
secondaryHeaderColor: const Color(0xFFFFB341),
|
|
25
|
-
highlightColor: const Color(0xAAF8D0DC),
|
|
26
|
-
dividerColor: Colors.black,
|
|
27
|
-
shadowColor: Colors.black,
|
|
28
|
-
colorScheme: const ColorScheme.light(
|
|
29
|
-
background: Colors.white,
|
|
30
|
-
),
|
|
31
|
-
textButtonTheme: TextButtonThemeData(
|
|
32
|
-
style: TextButton.styleFrom(
|
|
33
|
-
padding: EdgeInsets.zero,
|
|
34
|
-
shape: const RoundedRectangleBorder(),
|
|
35
|
-
elevation: 1,
|
|
36
|
-
// backgroundColor: const Color(0xFFF6F6F6),
|
|
37
|
-
backgroundColor: const Color(0xFFEAE9E9),
|
|
38
|
-
foregroundColor: const Color(0xFF9A1111),
|
|
39
|
-
|
|
13
|
+
runApp(const App());
|
|
40
|
-
fontSize: 18,
|
|
41
|
-
fontWeight: FontWeight.w500,
|
|
42
|
-
color: Color(0xFF9A1111),
|
|
43
|
-
letterSpacing: 0.5,
|
|
44
|
-
),
|
|
45
|
-
),
|
|
46
|
-
),
|
|
47
|
-
textTheme: const TextTheme(
|
|
48
|
-
bodyMedium: TextStyle(
|
|
49
|
-
color: Color(0xFF010101),
|
|
50
|
-
),
|
|
51
|
-
headlineLarge: TextStyle(
|
|
52
|
-
fontSize: 38,
|
|
53
|
-
fontWeight: FontWeight.w700,
|
|
54
|
-
color: Color(0xFFFFB341),
|
|
55
|
-
),
|
|
56
|
-
headlineMedium: TextStyle(
|
|
57
|
-
color: Color(0xFF010101),
|
|
58
|
-
fontSize: 20,
|
|
59
|
-
fontWeight: FontWeight.w500,
|
|
60
|
-
letterSpacing: 0.5,
|
|
61
|
-
),
|
|
62
|
-
labelMedium: TextStyle(
|
|
63
|
-
fontSize: 12,
|
|
64
|
-
fontWeight: FontWeight.w800,
|
|
65
|
-
color: Color(0xFF9A1111),
|
|
66
|
-
letterSpacing: 0.5,
|
|
67
|
-
),
|
|
68
|
-
),
|
|
69
|
-
),
|
|
70
|
-
darkTheme: ThemeData(
|
|
71
|
-
visualDensity: VisualDensity.adaptivePlatformDensity,
|
|
72
|
-
primaryColor: const Color(0xFF4C2323),
|
|
73
|
-
secondaryHeaderColor: const Color(0xFFFFB341),
|
|
74
|
-
highlightColor: const Color(0xAAF8D0DC),
|
|
75
|
-
dividerColor: Colors.white,
|
|
76
|
-
shadowColor: Colors.white,
|
|
77
|
-
colorScheme: const ColorScheme.dark(
|
|
78
|
-
background: Color(0xFF1F1F22),
|
|
79
|
-
),
|
|
80
|
-
textButtonTheme: TextButtonThemeData(
|
|
81
|
-
style: TextButton.styleFrom(
|
|
82
|
-
padding: EdgeInsets.zero,
|
|
83
|
-
shape: const RoundedRectangleBorder(),
|
|
84
|
-
elevation: 1,
|
|
85
|
-
backgroundColor: const Color(0xFF323232),
|
|
86
|
-
foregroundColor: const Color(0xFFBBBBBB),
|
|
87
|
-
textStyle: const TextStyle(
|
|
88
|
-
fontSize: 18,
|
|
89
|
-
fontWeight: FontWeight.w500,
|
|
90
|
-
color: Color(0xFF9A1111),
|
|
91
|
-
letterSpacing: 0.5,
|
|
92
|
-
),
|
|
93
|
-
),
|
|
94
|
-
),
|
|
95
|
-
textTheme: const TextTheme(
|
|
96
|
-
bodyMedium: TextStyle(
|
|
97
|
-
color: Color(0xFFBCBEC4),
|
|
98
|
-
),
|
|
99
|
-
headlineLarge: TextStyle(
|
|
100
|
-
fontSize: 38,
|
|
101
|
-
fontWeight: FontWeight.w700,
|
|
102
|
-
color: Color(0xFFFFB341),
|
|
103
|
-
),
|
|
104
|
-
headlineMedium: TextStyle(
|
|
105
|
-
color: Color(0xFFBCBEC4),
|
|
106
|
-
fontSize: 20,
|
|
107
|
-
fontWeight: FontWeight.w500,
|
|
108
|
-
letterSpacing: 0.5,
|
|
109
|
-
),
|
|
110
|
-
labelMedium: TextStyle(
|
|
111
|
-
color: Color(0xFFBBBBBB),
|
|
112
|
-
fontSize: 12,
|
|
113
|
-
fontWeight: FontWeight.w800,
|
|
114
|
-
letterSpacing: 0.5,
|
|
115
|
-
),
|
|
116
|
-
),
|
|
117
|
-
),
|
|
118
|
-
routerConfig: GoRouter(
|
|
119
|
-
debugLogDiagnostics: true,
|
|
120
|
-
initialLocation: "/${selectedBible.value[bookIndex.value].name}/${chapterIndex.value}",
|
|
121
|
-
routes: [
|
|
122
|
-
Shell(
|
|
123
|
-
routes: [
|
|
124
|
-
GoRouteData.$route(
|
|
125
|
-
path: '/:book/:chapter',
|
|
126
|
-
factory: (GoRouterState state) => HomeScreen(
|
|
127
|
-
book: state.pathParameters['book']!,
|
|
128
|
-
chapter: int.parse(state.pathParameters['chapter']!),
|
|
129
|
-
),
|
|
130
|
-
),
|
|
131
|
-
],
|
|
132
|
-
),
|
|
133
|
-
],
|
|
134
|
-
),
|
|
135
|
-
),
|
|
136
|
-
);
|
|
137
14
|
FlutterNativeSplash.remove();
|
|
138
15
|
}
|