Skip to content

Commit

Permalink
fix: unstarred light theme icon, settingsservice (#1018)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier authored Nov 15, 2024
1 parent eab977e commit 1bad15e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 97 deletions.
4 changes: 2 additions & 2 deletions lib/common/view/animated_like_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class AnimatedStar extends StatelessWidget {
? Icon(
Iconz.starFilled,
size: iconSize,
color: isStarred ? color : null,
color: color,
)
: Icon(
Iconz.star,
size: iconSize,
color: isStarred ? color : null,
color: color,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/icons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ class Iconz {
? YaruIcons.globe
: appleStyled
? CupertinoIcons.globe
: Icons.link_rounded;
: Icons.language;
static IconData get imageMissing => yaruStyled
? YaruIcons.image_missing
: appleStyled
Expand Down
125 changes: 31 additions & 94 deletions lib/settings/settings_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,19 @@ class SettingsService {
final SharedPreferences _preferences;
final _propertiesChangedController = StreamController<bool>.broadcast();
Stream<bool> get propertiesChanged => _propertiesChangedController.stream;
void notify(bool saved) {
if (saved) _propertiesChangedController.add(true);
}

int get themeIndex => _preferences.getInt(kThemeIndex) ?? 0;
void setThemeIndex(int value) {
_preferences.setInt(kThemeIndex, value).then(
(saved) {
if (saved) _propertiesChangedController.add(true);
},
);
_preferences.setInt(kThemeIndex, value).then(notify);
}

bool get neverShowFailedImports =>
_preferences.getBool(kNeverShowImportFails) ?? false;
void setNeverShowFailedImports(bool value) {
_preferences.setBool(kNeverShowImportFails, value).then(
(saved) {
if (saved) _propertiesChangedController.add(true);
},
);
_preferences.setBool(kNeverShowImportFails, value).then(notify);
}

bool get enableLastFmScrobbling =>
Expand All @@ -43,112 +38,58 @@ class SettingsService {
String? get lastFmSecret => _preferences.getString(klastFmSecret);
String? get lastFmSessionKey => _preferences.getString(kLastFmSessionKey);
String? get lastFmUsername => _preferences.getString(kLastFmUsername);
void setEnableLastFmScrobbling(bool value) {
_preferences.setBool(kEnableLastFmScrobbling, value).then(
(saved) {
if (saved) _propertiesChangedController.add(true);
},
);
}
void setEnableLastFmScrobbling(bool value) =>
_preferences.setBool(kEnableLastFmScrobbling, value).then(notify);

void setLastFmApiKey(String value) {
_preferences.setString(kLastFmApiKey, value).then(
(saved) {
if (saved) _propertiesChangedController.add(true);
},
);
}
void setLastFmApiKey(String value) =>
_preferences.setString(kLastFmApiKey, value).then(notify);

void setLastFmSecret(String value) {
_preferences.setString(klastFmSecret, value).then(
(saved) {
if (saved) _propertiesChangedController.add(true);
},
);
}
void setLastFmSecret(String value) =>
_preferences.setString(klastFmSecret, value).then(notify);

void setLastFmSessionKey(String value) {
_preferences.setString(kLastFmSessionKey, value).then(
(saved) {
if (saved) _propertiesChangedController.add(true);
},
);
}
void setLastFmSessionKey(String value) =>
_preferences.setString(kLastFmSessionKey, value).then(notify);

void setLastFmUsername(String value) {
_preferences.setString(kLastFmUsername, value).then(
(saved) {
if (saved) _propertiesChangedController.add(true);
},
);
}
void setLastFmUsername(String value) =>
_preferences.setString(kLastFmUsername, value).then(notify);

bool get enableDiscordRPC => _preferences.getBool(kEnableDiscordRPC) ?? false;
void setEnableDiscordRPC(bool value) {
_preferences.setBool(kEnableDiscordRPC, value).then(
(saved) {
if (saved) _propertiesChangedController.add(true);
},
);
}
void setEnableDiscordRPC(bool value) =>
_preferences.setBool(kEnableDiscordRPC, value).then(notify);

// TODO: check how this increases cpu usage
bool get useMoreAnimations =>
_preferences.getBool(kUseMoreAnimations) ?? !Platform.isLinux;
void setUseMoreAnimations(bool value) {
_preferences.setBool(kUseMoreAnimations, value).then(
(saved) {
if (saved) _propertiesChangedController.add(true);
},
);
}
void setUseMoreAnimations(bool value) =>
_preferences.setBool(kUseMoreAnimations, value).then(notify);

bool recentPatchNotesDisposed(String version) =>
_preferences.getString(kPatchNotesDisposed) == version;

Future<void> disposePatchNotes(String version) async =>
_preferences.setString(kPatchNotesDisposed, version).then(
(saved) {
if (saved) _propertiesChangedController.add(true);
},
);
_preferences.setString(kPatchNotesDisposed, version).then(notify);

bool get usePodcastIndex => _preferences.getBool(kUsePodcastIndex) ?? false;
Future<void> setUsePodcastIndex(bool value) async {
return _preferences.setBool(kUsePodcastIndex, value).then((value) {
if (value) _propertiesChangedController.add(true);
});
}
Future<void> setUsePodcastIndex(bool value) async =>
_preferences.setBool(kUsePodcastIndex, value).then(notify);

String? get podcastIndexApiKey => _preferences.getString(kPodcastIndexApiKey);
void setPodcastIndexApiKey(String value) {
_preferences.setString(kPodcastIndexApiKey, value).then((saved) {
if (saved) _propertiesChangedController.add(true);
});
}
void setPodcastIndexApiKey(String value) =>
_preferences.setString(kPodcastIndexApiKey, value).then(notify);

String? get podcastIndexApiSecret =>
_preferences.getString(kPodcastIndexApiSecret);
void setPodcastIndexApiSecret(String value) {
_preferences.setString(kPodcastIndexApiSecret, value).then((saved) {
if (saved) _propertiesChangedController.add(true);
});
}
void setPodcastIndexApiSecret(String value) =>
_preferences.setString(kPodcastIndexApiSecret, value).then(notify);

String? get directory => _preferences.getString(kDirectoryProperty);
Future<void> setDirectory(String directory) async {
await _preferences.setString(kDirectoryProperty, directory).then((saved) {
if (saved) _propertiesChangedController.add(true);
});
}
Future<void> setDirectory(String directory) async =>
_preferences.setString(kDirectoryProperty, directory).then(notify);

String? get downloadsDir =>
_preferences.getString(kDownloadsCustomDir) ?? _downloadsDefaultDir;
Future<void> setDownloadsCustomDir(String directory) async {
await _preferences.setString(kDownloadsCustomDir, directory).then((saved) {
if (saved) _propertiesChangedController.add(true);
});
}
Future<void> setDownloadsCustomDir(String directory) async =>
_preferences.setString(kDownloadsCustomDir, directory).then(notify);

CloseBtnAction get closeBtnActionIndex =>
_preferences.getString(kCloseBtnAction) == null
Expand All @@ -159,11 +100,7 @@ class SettingsService {
orElse: () => CloseBtnAction.alwaysAsk,
);
void setCloseBtnActionIndex(CloseBtnAction value) {
_preferences.setString(kCloseBtnAction, value.toString()).then(
(saved) {
if (saved) _propertiesChangedController.add(true);
},
);
_preferences.setString(kCloseBtnAction, value.toString()).then(notify);
}

Future<void> dispose() async => _propertiesChangedController.close();
Expand Down

0 comments on commit 1bad15e

Please sign in to comment.