Skip to content

Commit

Permalink
Addresses #90
Browse files Browse the repository at this point in the history
  • Loading branch information
Imran Remtulla committed Nov 3, 2022
1 parent 9b99e2b commit 03da23f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/pages/apps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ class AppsPageState extends State<AppsPage> {
sortedApps = sortedApps.reversed.toList();
}

var existingUpdateIdsAllOrSelected = appsProvider
.getExistingUpdates(installedOnly: true)
var existingUpdates = appsProvider.getExistingUpdates(installedOnly: true);

var existingUpdateIdsAllOrSelected = existingUpdates
.where((element) => selectedIds.isEmpty
? sortedApps.where((a) => a.app.id == element).isNotEmpty
: selectedIds.contains(element))
Expand All @@ -133,6 +134,18 @@ class AppsPageState extends State<AppsPage> {
: selectedIds.contains(element))
.toList();

if (settingsProvider.pinUpdates) {
var temp = [];
sortedApps = sortedApps.where((sa) {
if (existingUpdates.contains(sa.app.id)) {
temp.add(sa);
return false;
}
return true;
}).toList();
sortedApps = [...temp, ...sortedApps];
}

return Scaffold(
backgroundColor: Theme.of(context).colorScheme.surface,
body: RefreshIndicator(
Expand Down
14 changes: 14 additions & 0 deletions lib/pages/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,20 @@ class _SettingsPageState extends State<SettingsPage> {
})
],
),
const SizedBox(
height: 16,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text('Pin Updates to Top of Apps View'),
Switch(
value: settingsProvider.pinUpdates,
onChanged: (value) {
settingsProvider.pinUpdates = value;
})
],
),
const Divider(
height: 16,
),
Expand Down
9 changes: 9 additions & 0 deletions lib/providers/settings_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ class SettingsProvider with ChangeNotifier {
notifyListeners();
}

bool get pinUpdates {
return prefs?.getBool('pinUpdates') ?? true;
}

set pinUpdates(bool show) {
prefs?.setBool('pinUpdates', show);
notifyListeners();
}

String? getSettingString(String settingId) {
return prefs?.getString(settingId);
}
Expand Down

0 comments on commit 03da23f

Please sign in to comment.