mirror of
https://github.com/pd4d10/git-touch.git
synced 2026-04-28 18:39:26 -05:00
refactor: storage keys
This commit is contained in:
@@ -5,11 +5,6 @@ import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class CodeModel with ChangeNotifier {
|
||||
static const _kTheme = 'code-theme';
|
||||
static const _kThemeDark = 'code-theme-dark';
|
||||
static const _kFontSize = 'code-font-size';
|
||||
static const _kFontFamily = 'code-font-family';
|
||||
|
||||
static var themes = themeMap.keys.toList();
|
||||
static const fontSizes = [12, 13, 14, 15, 16, 17, 18, 19, 20];
|
||||
static const fontFamilies = [
|
||||
@@ -35,10 +30,10 @@ class CodeModel with ChangeNotifier {
|
||||
|
||||
Future<void> init() async {
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
var vh = prefs.getString(_kTheme);
|
||||
var vdh = prefs.getString(_kThemeDark);
|
||||
var vs = prefs.getInt(_kFontSize);
|
||||
var vf = prefs.getString(_kFontFamily);
|
||||
var vh = prefs.getString(StorageKeys.codeTheme);
|
||||
var vdh = prefs.getString(StorageKeys.codeThemeDark);
|
||||
var vs = prefs.getInt(StorageKeys.iCodeFontSize);
|
||||
var vf = prefs.getString(StorageKeys.codeFontFamily);
|
||||
|
||||
Fimber.d('read code: $vh, $vs, $vf');
|
||||
if (themeMap.keys.contains(vh)) {
|
||||
@@ -60,7 +55,7 @@ class CodeModel with ChangeNotifier {
|
||||
setTheme(String v) async {
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
|
||||
await prefs.setString(_kTheme, v);
|
||||
await prefs.setString(StorageKeys.codeTheme, v);
|
||||
Fimber.d('write code theme: $v');
|
||||
|
||||
_theme = v;
|
||||
@@ -70,7 +65,7 @@ class CodeModel with ChangeNotifier {
|
||||
setThemeDark(String v) async {
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
|
||||
await prefs.setString(_kThemeDark, v);
|
||||
await prefs.setString(StorageKeys.codeThemeDark, v);
|
||||
Fimber.d('write code theme dark: $v');
|
||||
|
||||
_themeDark = v;
|
||||
@@ -80,7 +75,7 @@ class CodeModel with ChangeNotifier {
|
||||
setFontSize(int v) async {
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
|
||||
await prefs.setInt(_kFontSize, v);
|
||||
await prefs.setInt(StorageKeys.iCodeFontSize, v);
|
||||
Fimber.d('write code font size: $v');
|
||||
|
||||
_fontSize = v;
|
||||
@@ -90,7 +85,7 @@ class CodeModel with ChangeNotifier {
|
||||
setFontFamily(String v) async {
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
|
||||
await prefs.setString(_kFontFamily, v);
|
||||
await prefs.setString(StorageKeys.codeFontFamily, v);
|
||||
Fimber.d('write code font family: $v');
|
||||
|
||||
_fontFamily = v;
|
||||
|
||||
Reference in New Issue
Block a user