Skip to content

Commit

Permalink
if user chooses accent color while use system color option is enabled…
Browse files Browse the repository at this point in the history
…, turn it off
  • Loading branch information
gokadzev committed Nov 6, 2022
1 parent 39de7b6 commit 756c9d2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ class MyApp extends StatefulWidget {
static Future<void> setAccentColor(
BuildContext context,
Color newAccentColor,
bool systemColorStatus,
) async {
final state = context.findAncestorStateOfType<_MyAppState>()!;
state.changeAccentColor(newAccentColor);
state.changeAccentColor(newAccentColor, systemColorStatus);
}

@override
Expand All @@ -84,8 +85,9 @@ class _MyAppState extends State<MyApp> {
});
}

void changeAccentColor(Color newAccentColor) {
void changeAccentColor(Color newAccentColor, bool systemColorStatus) {
setState(() {
useSystemColor.value = systemColorStatus;
accent = ColorScheme.fromSwatch(
primarySwatch: getMaterialColorFromColor(
newAccentColor,
Expand Down
3 changes: 3 additions & 0 deletions lib/ui/morePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class SettingsCards extends StatelessWidget {
MyApp.setAccentColor(
context,
colors[index],
false,
);
showToast(
AppLocalizations.of(context)!
Expand Down Expand Up @@ -396,6 +397,7 @@ class SettingsCards extends StatelessWidget {
MyApp.setAccentColor(
context,
accent.primary,
true,
);
showToast(
AppLocalizations.of(context)!
Expand Down Expand Up @@ -424,6 +426,7 @@ class SettingsCards extends StatelessWidget {
MyApp.setAccentColor(
context,
accent.primary,
false,
);
showToast(
AppLocalizations.of(context)!
Expand Down

0 comments on commit 756c9d2

Please sign in to comment.