Added update all button + Obtainium added by default

This commit is contained in:
Imran Remtulla
2022-08-25 14:26:15 -04:00
parent aeada9635d
commit 0362cdf8ac
4 changed files with 82 additions and 46 deletions

View File

@@ -14,46 +14,62 @@ class _AppsPageState extends State<AppsPage> {
@override
Widget build(BuildContext context) {
var appsProvider = context.watch<AppsProvider>();
appsProvider.getUpdates();
appsProvider.checkUpdates();
var existingUpdateAppIds = appsProvider.getExistingUpdates();
return Center(
child: appsProvider.loadingApps
? const CircularProgressIndicator()
: appsProvider.apps.isEmpty
? Text(
'No Apps',
style: Theme.of(context).textTheme.headline4,
)
: RefreshIndicator(
onRefresh: appsProvider.getUpdates,
child: ListView(
children: appsProvider.apps.values
.map(
(e) => ListTile(
title: Text('${e.app.author}/${e.app.name}'),
subtitle:
Text(e.app.installedVersion ?? 'Not Installed'),
trailing: e.downloadProgress != null
? Text(
'Downloading - ${e.downloadProgress!.toInt()}%')
: (e.app.installedVersion != null &&
e.app.installedVersion !=
e.app.latestVersion
? const Text('Update Available')
: null),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
AppPage(appId: e.app.id)),
);
},
),
)
.toList(),
),
),
);
return Scaffold(
floatingActionButton: existingUpdateAppIds.isEmpty
? null
: ElevatedButton.icon(
onPressed: appsProvider.apps.values
.where((element) => element.downloadProgress != null)
.isNotEmpty
? null
: () {
for (var e in existingUpdateAppIds) {
appsProvider.downloadAndInstallLatestApp(e);
}
},
icon: const Icon(Icons.update),
label: const Text('Update All')),
body: Center(
child: appsProvider.loadingApps
? const CircularProgressIndicator()
: appsProvider.apps.isEmpty
? Text(
'No Apps',
style: Theme.of(context).textTheme.headline4,
)
: RefreshIndicator(
onRefresh: appsProvider.checkUpdates,
child: ListView(
children: appsProvider.apps.values
.map(
(e) => ListTile(
title: Text('${e.app.author}/${e.app.name}'),
subtitle: Text(
e.app.installedVersion ?? 'Not Installed'),
trailing: e.downloadProgress != null
? Text(
'Downloading - ${e.downloadProgress!.toInt()}%')
: (e.app.installedVersion != null &&
e.app.installedVersion !=
e.app.latestVersion
? const Text('Update Available')
: null),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
AppPage(appId: e.app.id)),
);
},
),
)
.toList(),
),
),
));
}
}