~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.


c2abd506 pyrossh

2 years ago
add dark theme
lib/components/books_list.dart CHANGED
@@ -22,7 +22,7 @@ class BooksList extends StatelessWidget {
22
22
  children: [
23
23
  Container(
24
24
  margin: const EdgeInsets.only(bottom: 20),
25
- child: Text(title, style: theme.value.titleText),
25
+ child: Text(title, style: Theme.of(context).textTheme.headlineMedium),
26
26
  ),
27
27
  Wrap(
28
28
  children: List.of(
lib/components/chapters_list.dart CHANGED
@@ -20,7 +20,7 @@ class ChaptersList extends StatelessWidget {
20
20
  children: [
21
21
  Container(
22
22
  margin: const EdgeInsets.only(bottom: 20),
23
- child: Text(title, style: theme.value.titleText),
23
+ child: Text(title, style: Theme.of(context).textTheme.headlineMedium),
24
24
  ),
25
25
  Wrap(
26
26
  children: List.generate(length, (index) {
lib/components/header.dart CHANGED
@@ -24,8 +24,13 @@ class Header extends StatelessWidget {
24
24
  top: isWide(context) ? 10 : 0,
25
25
  bottom: isWide(context) ? 10 : 0,
26
26
  ),
27
- decoration: const BoxDecoration(
27
+ decoration: BoxDecoration(
28
+ border: Border(
29
+ bottom: BorderSide(
30
+ width: 1.5,
28
- border: Border(bottom: BorderSide(width: 1.5)),
31
+ color: Theme.of(context).dividerColor,
32
+ ),
33
+ ),
29
34
  ),
30
35
  child: Row(
31
36
  mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -34,16 +39,17 @@ class Header extends StatelessWidget {
34
39
  TextButton.icon(
35
40
  style: TextButton.styleFrom(
36
41
  padding: EdgeInsets.zero,
37
- foregroundColor: const Color(0xFF9A1111),
42
+ backgroundColor: Theme.of(context).colorScheme.background,
43
+ elevation: 0,
38
44
  ),
39
45
  label: Icon(
40
46
  Icons.expand_more,
41
47
  size: 28,
42
- color: theme.value.headerText.color,
48
+ color: Theme.of(context).textTheme.headlineMedium!.color,
43
49
  ),
44
50
  icon: Text(
45
51
  "${selectedBible.value[book].name} ${chapter + 1}",
46
- style: theme.value.headerText,
52
+ style: Theme.of(context).textTheme.headlineMedium,
47
53
  ),
48
54
  onPressed: () {
49
55
  Navigator.of(context).push(SideMenuPage());
lib/components/menu.dart CHANGED
@@ -27,24 +27,23 @@ class Menu extends StatelessWidget {
27
27
  mainAxisAlignment: MainAxisAlignment.center,
28
28
  children: [
29
29
  IconButton(
30
- icon: Icon(modeIcon, color: Colors.black, size: 28),
30
+ icon: Icon(modeIcon, size: 28),
31
31
  onPressed: toggleMode,
32
32
  ),
33
33
  Container(margin: const EdgeInsets.only(top: spacing)),
34
34
  IconButton(
35
- icon: Icon(Icons.format_bold, color: boldColor, size: 28),
35
+ icon: Icon(Icons.format_bold, size: 28),
36
36
  onPressed: toggleBold,
37
37
  ),
38
38
  Container(margin: const EdgeInsets.only(top: spacing)),
39
39
  const IconButton(
40
- icon: Icon(Icons.add_circle, color: Colors.black, size: 28),
40
+ icon: Icon(Icons.add_circle, size: 28),
41
41
  onPressed: increaseFont,
42
42
  ),
43
43
  Container(margin: const EdgeInsets.only(top: spacing)),
44
44
  const IconButton(
45
45
  icon: Icon(
46
46
  Icons.remove_circle,
47
- color: Colors.black,
48
47
  size: 28,
49
48
  ),
50
49
  onPressed: decreaseFont,
lib/components/shell.dart CHANGED
@@ -13,7 +13,7 @@ class Shell extends ShellRoute {
13
13
  @override
14
14
  ShellRouteBuilder? get builder => (context, state, child) {
15
15
  return Scaffold(
16
- backgroundColor: Colors.white,
16
+ backgroundColor: Theme.of(context).colorScheme.background,
17
17
  body: SafeArea(
18
18
  child: isWide(context)
19
19
  ? Row(
lib/components/side_menu_page.dart CHANGED
@@ -33,7 +33,7 @@ class SideMenuPage extends ModalRoute<void> {
33
33
  return Material(
34
34
  type: MaterialType.transparency,
35
35
  child: Container(
36
- color: Colors.white,
36
+ color: Theme.of(context).colorScheme.background,
37
37
  margin: EdgeInsets.only(left: 0, right: isWide(context) ? 650 : 0),
38
38
  child: const BookSelector(),
39
39
  ),
lib/components/sidebar.dart CHANGED
@@ -8,7 +8,7 @@ class Sidebar extends StatelessWidget {
8
8
  @override
9
9
  Widget build(BuildContext context) {
10
10
  final height = MediaQuery.of(context).size.height;
11
- return Container(
11
+ return ColoredBox(
12
12
  color: const Color(0xFF4C2323),
13
13
  child: Stack(
14
14
  children: [
@@ -34,13 +34,13 @@ class Sidebar extends StatelessWidget {
34
34
  crossAxisAlignment: CrossAxisAlignment.end,
35
35
  children: [
36
36
  Flexible(
37
- child: Text("ONLY", style: theme.value.logoText),
37
+ child: Text("ONLY", style: Theme.of(context).textTheme.headlineLarge),
38
38
  ),
39
39
  Flexible(
40
- child: Text("BIBLE", style: theme.value.logoText),
40
+ child: Text("BIBLE", style: Theme.of(context).textTheme.headlineLarge),
41
41
  ),
42
42
  Flexible(
43
- child: Text("APP", style: theme.value.logoText),
43
+ child: Text("APP", style: Theme.of(context).textTheme.headlineLarge),
44
44
  ),
45
45
  ],
46
46
  ),
@@ -99,7 +99,7 @@ class Bookmark extends StatelessWidget {
99
99
  width: 30.0,
100
100
  height: 80.0,
101
101
  decoration: BoxDecoration(
102
- color: theme.value.secondaryColor,
102
+ color: Theme.of(context).secondaryHeaderColor,
103
103
  borderRadius: const BorderRadius.only(
104
104
  topLeft: Radius.circular(4),
105
105
  topRight: Radius.circular(4),
@@ -108,7 +108,7 @@ class Bookmark extends StatelessWidget {
108
108
  ),
109
109
  CustomPaint(
110
110
  painter: TrianglePainter(
111
- color: theme.value.secondaryColor,
111
+ color: Theme.of(context).secondaryHeaderColor,
112
112
  ),
113
113
  ),
114
114
  ],
lib/components/tile.dart CHANGED
@@ -1,5 +1,4 @@
1
1
  import 'package:flutter/material.dart';
2
-
3
2
  import 'package:only_bible_app/state.dart';
4
3
 
5
4
  class Tile extends StatelessWidget {
@@ -15,15 +14,6 @@ class Tile extends StatelessWidget {
15
14
  height: isWide(context) ? 60 : 40,
16
15
  margin: const EdgeInsets.only(right: 16, bottom: 16),
17
16
  child: TextButton(
18
- style: TextButton.styleFrom(
19
- padding: EdgeInsets.zero,
20
- shape: const RoundedRectangleBorder(),
21
- elevation: 1,
22
- // backgroundColor: const Color(0xFFF6F6F6),
23
- backgroundColor: const Color(0xFFEAE9E9),
24
- foregroundColor: const Color(0xFF9A1111),
25
- textStyle: theme.value.tileText,
26
- ),
27
17
  onPressed: onPressed,
28
18
  child: Text(name),
29
19
  ),
lib/components/verse_view.dart CHANGED
@@ -12,9 +12,8 @@ class VerseText extends StatelessWidget {
12
12
  Widget build(BuildContext context) {
13
13
  final selected = selectedVerses.reactiveValue(context).contains(index);
14
14
  final delta = fontSizeDelta.reactiveValue(context);
15
- final bodySize = theme.value.bodyText.fontSize! + delta;
15
+ final bodySize = Theme.of(context).textTheme.bodyMedium!.fontSize! + delta;
16
- final weight =
17
- fontBold.reactiveValue(context) ? FontWeight.w600 : FontWeight.w500;
16
+ final weight = fontBold.reactiveValue(context) ? FontWeight.w600 : FontWeight.w500;
18
17
  onTap() {
19
18
  onVerseSelected(index);
20
19
  }
@@ -25,7 +24,7 @@ class VerseText extends StatelessWidget {
25
24
  onTap: onTap,
26
25
  child: DecoratedBox(
27
26
  decoration: BoxDecoration(
28
- color: selected ? theme.value.highlightColor : Colors.white,
27
+ color: selected ? Theme.of(context).highlightColor : Theme.of(context).colorScheme.background,
29
28
  ),
30
29
  child: Row(
31
30
  crossAxisAlignment: CrossAxisAlignment.start,
@@ -34,7 +33,7 @@ class VerseText extends StatelessWidget {
34
33
  margin: const EdgeInsets.only(right: 4),
35
34
  child: Transform.translate(
36
35
  offset: const Offset(0, 2),
37
- child: Text("${index + 1}", style: theme.value.labelText),
36
+ child: Text("${index + 1}", style: Theme.of(context).textTheme.labelMedium),
38
37
  ),
39
38
  ),
40
39
  Flexible(
lib/main.dart CHANGED
@@ -17,13 +17,107 @@ void main() async {
17
17
  MaterialApp.router(
18
18
  debugShowCheckedModeBanner: false,
19
19
  builder: OneContext().builder,
20
+ themeMode: ThemeMode.system,
20
21
  theme: ThemeData(
21
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
+ textStyle: const TextStyle(
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
+ ),
22
117
  ),
23
118
  routerConfig: GoRouter(
24
119
  debugLogDiagnostics: true,
25
- initialLocation:
26
- "/${selectedBible.value[bookIndex.value].name}/${chapterIndex.value}",
120
+ initialLocation: "/${selectedBible.value[bookIndex.value].name}/${chapterIndex.value}",
27
121
  routes: [
28
122
  Shell(
29
123
  routes: [
lib/models/theme.dart DELETED
@@ -1,89 +0,0 @@
1
- import "package:flutter/material.dart";
2
- import "package:flutter/services.dart";
3
-
4
- const lightPrimary = Color(0xFF4C2323);
5
- const lightPrimaryLighter = Color(0xFF3C1B1C);
6
- const lightSecondary = Color(0xFFFFB341);
7
- const lightTertiary = Color(0xFF4C2323);
8
- const lightHeadline = Color(0xFF010101);
9
- const lightLabel = Color(0xFF9A1111);
10
- const lightBody = Color(0xFF010101);
11
- const lightHighlightColor = Color(0xAAF8D0DC);
12
-
13
- const lightStatusBar = SystemUiOverlayStyle(
14
- systemNavigationBarColor: Colors.white,
15
- systemNavigationBarIconBrightness: Brightness.dark,
16
- statusBarColor: Colors.white,
17
- statusBarIconBrightness: Brightness.dark,
18
- );
19
-
20
- const darkStatusBar = SystemUiOverlayStyle(
21
- systemNavigationBarColor: Colors.black,
22
- systemNavigationBarIconBrightness: Brightness.light,
23
- statusBarColor: Colors.black,
24
- statusBarIconBrightness: Brightness.light,
25
- );
26
-
27
- const lightTheme = AppTheme(
28
- secondaryColor: lightSecondary,
29
- highlightColor: lightHighlightColor,
30
- labelText: TextStyle(
31
- // fontFamily: "SanFrancisco",
32
- fontSize: 12,
33
- fontWeight: FontWeight.w800,
34
- color: lightLabel,
35
- letterSpacing: 0.5,
36
- ),
37
- logoText: TextStyle(
38
- fontSize: 38,
39
- fontWeight: FontWeight.w700,
40
- color: lightSecondary,
41
- ),
42
- bodyText: TextStyle(
43
- color: lightBody,
44
- fontSize: 16,
45
- // fontFamily: "SanFranciscoPro",
46
- fontWeight: FontWeight.w400,
47
- // letterSpacing: 0.5,
48
- ),
49
- headerText: TextStyle(
50
- // color: lightLabel,
51
- color: lightBody,
52
- fontSize: 20,
53
- fontWeight: FontWeight.w500,
54
- letterSpacing: 0.5,
55
- ),
56
- titleText: TextStyle(
57
- color: lightBody,
58
- fontWeight: FontWeight.w600,
59
- fontSize: 20,
60
- ),
61
- tileText: TextStyle(
62
- fontSize: 18,
63
- fontWeight: FontWeight.w500,
64
- color: lightLabel,
65
- letterSpacing: 0.5,
66
- ),
67
- );
68
-
69
- class AppTheme {
70
- const AppTheme({
71
- required this.labelText,
72
- required this.logoText,
73
- required this.bodyText,
74
- required this.headerText,
75
- required this.titleText,
76
- required this.tileText,
77
- required this.secondaryColor,
78
- required this.highlightColor,
79
- });
80
-
81
- final TextStyle labelText;
82
- final TextStyle logoText;
83
- final TextStyle bodyText;
84
- final TextStyle headerText;
85
- final TextStyle titleText;
86
- final TextStyle tileText;
87
- final Color secondaryColor;
88
- final Color highlightColor;
89
- }
lib/state.dart CHANGED
@@ -7,7 +7,6 @@ import 'package:flutter_reactive_value/flutter_reactive_value.dart';
7
7
  import 'package:just_audio/just_audio.dart';
8
8
  import 'package:only_bible_app/utils/dialog.dart';
9
9
  import 'package:only_bible_app/models/book.dart';
10
- import 'package:only_bible_app/models/theme.dart';
11
10
 
12
11
  final darkMode = PersistentValueNotifier<bool>(
13
12
  sharedPreferencesKey: 'darkMode',
@@ -37,7 +36,6 @@ final chapterIndex = PersistentValueNotifier<int>(
37
36
  final selectedBible = ValueNotifier<List<Book>>([]);
38
37
  final selectedVerses = ValueNotifier([]);
39
38
  final isPlaying = ValueNotifier(false);
40
- final theme = ValueNotifier<AppTheme>(lightTheme);
41
39
  final fontSizeDelta = ValueNotifier(0);
42
40
 
43
41
  toggleMode() {
@@ -59,9 +57,19 @@ decreaseFont() {
59
57
 
60
58
  updateStatusBar() {
61
59
  if (darkMode.value) {
62
- SystemChrome.setSystemUIOverlayStyle(darkStatusBar);
60
+ SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
61
+ systemNavigationBarColor: Colors.black,
62
+ systemNavigationBarIconBrightness: Brightness.light,
63
+ statusBarColor: Colors.black,
64
+ statusBarIconBrightness: Brightness.light,
65
+ ));
63
66
  } else {
64
- SystemChrome.setSystemUIOverlayStyle(lightStatusBar);
67
+ SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
68
+ systemNavigationBarColor: Colors.white,
69
+ systemNavigationBarIconBrightness: Brightness.dark,
70
+ statusBarColor: Colors.white,
71
+ statusBarIconBrightness: Brightness.dark,
72
+ ));
65
73
  }
66
74
  }
67
75