-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fa2c8d
commit 8f7ac12
Showing
10 changed files
with
196 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "flipub", | ||
"request": "launch", | ||
"type": "dart" | ||
}, | ||
{ | ||
"name": "flipub (profile mode)", | ||
"request": "launch", | ||
"type": "dart", | ||
"flutterMode": "profile" | ||
}, | ||
{ | ||
"name": "flipub (release mode)", | ||
"request": "launch", | ||
"type": "dart", | ||
"flutterMode": "release" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "generate sources", | ||
"type": "shell", | ||
"command": "dart run build_runner build", | ||
"problemMatcher": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import 'dart:io'; | ||
|
||
const sharedPreferencesFontSizeKey = 'fontSize'; | ||
const sharedPreferencesThemeKey = 'theme'; | ||
|
||
bool get isMobile => Platform.isAndroid || Platform.isIOS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:flipub/data/constants.dart'; | ||
import 'package:flipub/providers/preferences_provider.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
part 'theme_provider.g.dart'; | ||
|
||
@riverpod | ||
class ThemeNotifier extends _$ThemeNotifier { | ||
@override | ||
ThemeMode build() { | ||
_readPreferences(); | ||
return ThemeMode.dark; | ||
} | ||
|
||
Future<void> _readPreferences() async { | ||
final sharedPreferences = await ref.read(preferencesProvider.future); | ||
final isDark = | ||
sharedPreferences.getBool(sharedPreferencesThemeKey) ?? false; | ||
state = isDark ? ThemeMode.dark : ThemeMode.light; | ||
} | ||
|
||
Future<void> toggle() async { | ||
state = state == ThemeMode.light ? ThemeMode.dark : ThemeMode.light; | ||
final sharedPreferences = await ref.read(preferencesProvider.future); | ||
sharedPreferences.setBool( | ||
sharedPreferencesThemeKey, | ||
state == ThemeMode.dark, | ||
); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters