Skip to content

Commit 761d5a1

Browse files
Add initial high contrast theme
1 parent d394321 commit 761d5a1

7 files changed

Lines changed: 75 additions & 3 deletions

File tree

lib/common/enums.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ enum CurrentTheme {
1414
light,
1515
dark,
1616
sepia,
17+
highContrast,
1718
}

lib/common/themes.dart

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ abstract class SepiaThemePalette {
8989
static const mediumDarkGray = Color(0xFF414546);
9090
}
9191

92+
abstract class HighContrastThemePalette {
93+
// White
94+
static const white = Color(0xFFFFFFFF);
95+
96+
// Black
97+
static const black = Color(0xFF000000);
98+
}
99+
92100
class AppColorsExtension extends ThemeExtension<AppColorsExtension> {
93101
AppColorsExtension({
94102
required this.primary,
@@ -294,6 +302,40 @@ class AppTheme {
294302
readerAddExtra: ReaderTextPalette.addExtraGreen,
295303
addCopulaPink: ReaderTextPalette.addCopulaPink,
296304
);
305+
306+
// High contrast theme
307+
static final highContrast = ThemeData.dark().copyWith(
308+
textSelectionTheme: const TextSelectionThemeData(
309+
cursorColor: Colors.white,
310+
selectionColor: Color(0xFF444748),
311+
selectionHandleColor: Colors.white,
312+
),
313+
extensions: [
314+
_highContrastAppColors,
315+
],
316+
);
317+
318+
static final _highContrastAppColors = AppColorsExtension(
319+
primary: HighContrastThemePalette.white,
320+
secondary: HighContrastThemePalette.white,
321+
primaryOnDark: HighContrastThemePalette.white,
322+
secondaryOnDark: HighContrastThemePalette.white,
323+
primaryIcon: HighContrastThemePalette.white,
324+
secondaryIcon: HighContrastThemePalette.white,
325+
appbarIcon: HighContrastThemePalette.white,
326+
background: HighContrastThemePalette.black,
327+
appbarBackground: HighContrastThemePalette.black,
328+
popupBackground: HighContrastThemePalette.black,
329+
readerSelectorBackground: HighContrastThemePalette.black,
330+
switchBackground: HighContrastThemePalette.white,
331+
sliderAccent: HighContrastThemePalette.white,
332+
divider: HighContrastThemePalette.white,
333+
readerText: HighContrastThemePalette.white,
334+
readerRedLetter: ReaderTextPalette.redLetterRed,
335+
readerAddArticle: ReaderTextPalette.addArticleOrange,
336+
readerAddExtra: ReaderTextPalette.addExtraGreen,
337+
addCopulaPink: ReaderTextPalette.addCopulaPink,
338+
);
297339
}
298340

299341
extension AppThemeExtension on ThemeData {

lib/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class MainApp extends StatelessWidget {
2727
AppTheme.light,
2828
AppTheme.dark,
2929
AppTheme.sepia,
30+
AppTheme.highContrast,
3031
],
3132
builder: (context, regularTheme, darkTheme, themeMode) => MaterialApp(
3233
title: 'Bibleside',

lib/ui/views/reader/widgets/reader_area_popup/reader_area_popup.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ReaderAreaPopup extends StackedView<ReaderAreaPopupModel> {
5252
child: Container(
5353
width: 14.0,
5454
height: 7.0,
55-
color: context.theme.appColors.popupBackground,
55+
color: context.theme.appColors.primaryOnDark,
5656
),
5757
),
5858
],
@@ -149,7 +149,7 @@ class ReaderAreaPopup extends StackedView<ReaderAreaPopupModel> {
149149
child: Container(
150150
width: 14.0,
151151
height: 7.0,
152-
color: context.theme.appColors.popupBackground,
152+
color: context.theme.appColors.primaryOnDark,
153153
),
154154
),
155155
],

lib/ui/views/settings/settings_view.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,15 @@ class SettingsView extends StackedView<SettingsViewModel> {
271271
themeManger.selectThemeAtIndex(2);
272272
},
273273
),
274+
const SizedBox(width: 7.0),
275+
SettingsThemeItem(
276+
isSelected: getThemeManager(context).selectedThemeIndex == 3,
277+
theme: CurrentTheme.highContrast,
278+
onTap: () {
279+
var themeManger = getThemeManager(context);
280+
themeManger.selectThemeAtIndex(3);
281+
},
282+
),
274283
],
275284
),
276285
),

lib/ui/views/settings/widgets/settings_theme_item/settings_theme_item.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SettingsThemeItem extends StackedView<SettingsThemeItemModel> {
3939
child: Column(
4040
children: [
4141
Text(
42-
theme == CurrentTheme.light ? 'Light' : theme == CurrentTheme.sepia ? 'Sepia' : 'Dark',
42+
viewModel.getThemeName(theme),
4343
style: TextStyle(
4444
color: viewModel.getForegroundColor(theme),
4545
fontSize: 15.0,

lib/ui/views/settings/widgets/settings_theme_item/settings_theme_item_model.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ import '../../../../../common/enums.dart';
44

55

66
class SettingsThemeItemModel extends BaseViewModel {
7+
String getThemeName(CurrentTheme theme) {
8+
switch (theme) {
9+
case CurrentTheme.light:
10+
return 'Light';
11+
case CurrentTheme.dark:
12+
return 'Dark';
13+
case CurrentTheme.sepia:
14+
return 'Sepia';
15+
case CurrentTheme.highContrast:
16+
return 'Contrast';
17+
default:
18+
return '';
19+
}
20+
}
21+
722
Color getForegroundColor(CurrentTheme theme) {
823
switch (theme) {
924
case CurrentTheme.light:
@@ -12,6 +27,8 @@ class SettingsThemeItemModel extends BaseViewModel {
1227
return Colors.white;
1328
case CurrentTheme.sepia:
1429
return const Color(0xFF655F49);
30+
case CurrentTheme.highContrast:
31+
return const Color(0xFFFFFFFF);
1532
default:
1633
return const Color(0xFF515358);
1734
}
@@ -25,6 +42,8 @@ class SettingsThemeItemModel extends BaseViewModel {
2542
return const Color(0xFF1F2123);
2643
case CurrentTheme.sepia:
2744
return const Color(0xFFC7C7AE);
45+
case CurrentTheme.highContrast:
46+
return const Color(0xFF000000);
2847
default:
2948
return Colors.white;
3049
}

0 commit comments

Comments
 (0)