mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-30 04:20:16 +02:00
Merge pull request #678 from ImranR98/dev
Make transition animation directional (#675), Fix missing update button bug (perform full load on foreground)
This commit is contained in:
@@ -21,7 +21,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart';
|
||||
// ignore: implementation_imports
|
||||
import 'package:easy_localization/src/localization.dart';
|
||||
|
||||
const String currentVersion = '0.13.16';
|
||||
const String currentVersion = '0.13.17';
|
||||
const String currentReleaseTag =
|
||||
'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
|
||||
|
||||
|
@@ -26,6 +26,7 @@ class NavigationPageItem {
|
||||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
List<int> selectedIndexHistory = [];
|
||||
bool isReversing = false;
|
||||
int prevAppCount = -1;
|
||||
bool prevIsLoading = true;
|
||||
|
||||
@@ -42,7 +43,16 @@ class _HomePageState extends State<HomePage> {
|
||||
Widget build(BuildContext context) {
|
||||
AppsProvider appsProvider = context.watch<AppsProvider>();
|
||||
|
||||
setIsReversing(int targetIndex) {
|
||||
bool reversing = selectedIndexHistory.isNotEmpty &&
|
||||
selectedIndexHistory.last > targetIndex;
|
||||
setState(() {
|
||||
isReversing = reversing;
|
||||
});
|
||||
}
|
||||
|
||||
switchToPage(int index) async {
|
||||
setIsReversing(index);
|
||||
if (index == 0) {
|
||||
while ((pages[0].widget.key as GlobalKey<AppsPageState>).currentState !=
|
||||
null) {
|
||||
@@ -79,6 +89,7 @@ class _HomePageState extends State<HomePage> {
|
||||
child: Scaffold(
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
body: PageTransitionSwitcher(
|
||||
reverse: isReversing,
|
||||
transitionBuilder: (
|
||||
Widget child,
|
||||
Animation<double> animation,
|
||||
@@ -104,13 +115,16 @@ class _HomePageState extends State<HomePage> {
|
||||
.toList(),
|
||||
onDestinationSelected: (int index) async {
|
||||
HapticFeedback.selectionClick();
|
||||
await switchToPage(index);
|
||||
switchToPage(index);
|
||||
},
|
||||
selectedIndex:
|
||||
selectedIndexHistory.isEmpty ? 0 : selectedIndexHistory.last,
|
||||
),
|
||||
),
|
||||
onWillPop: () async {
|
||||
setIsReversing(selectedIndexHistory.length >= 2
|
||||
? selectedIndexHistory.reversed.toList()[1]
|
||||
: 0);
|
||||
if (selectedIndexHistory.isNotEmpty) {
|
||||
setState(() {
|
||||
selectedIndexHistory.removeLast();
|
||||
|
@@ -117,7 +117,7 @@ class AppsProvider with ChangeNotifier {
|
||||
foregroundStream = FGBGEvents.stream.asBroadcastStream();
|
||||
foregroundSubscription = foregroundStream?.listen((event) async {
|
||||
isForeground = event == FGBGType.foreground;
|
||||
if (isForeground) await refreshInstallStatuses();
|
||||
if (isForeground) await loadApps();
|
||||
});
|
||||
() async {
|
||||
var cacheDirs = await getExternalCacheDirectories();
|
||||
@@ -744,47 +744,35 @@ class AppsProvider with ChangeNotifier {
|
||||
// Put Apps into memory to list them (fast)
|
||||
if (app != null) {
|
||||
try {
|
||||
apps[app.id] = AppInMemory(app, null, null);
|
||||
sp.getSource(app.url, overrideSource: app.overrideSource);
|
||||
apps.update(
|
||||
app.id,
|
||||
(value) =>
|
||||
AppInMemory(app, value.downloadProgress, value.installedInfo),
|
||||
ifAbsent: () => AppInMemory(app, null, null));
|
||||
} catch (e) {
|
||||
errors.add([app.id, app.finalName, e.toString()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
notifyListeners();
|
||||
for (var app in newApps) {
|
||||
// Check install status for each App (slow)
|
||||
if (app != null) {
|
||||
try {
|
||||
apps[app.id]?.installedInfo = await getInstalledInfo(app.id);
|
||||
sp.getSource(app.url, overrideSource: app.overrideSource);
|
||||
} catch (e) {
|
||||
apps.remove(app.id);
|
||||
errors.add([app.id, app.finalName, e.toString()]);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
if (errors.isNotEmpty) {
|
||||
removeApps(errors.map((e) => e[0]).toList());
|
||||
NotificationsProvider().notify(
|
||||
AppsRemovedNotification(errors.map((e) => [e[1], e[2]]).toList()));
|
||||
}
|
||||
loadingApps = false;
|
||||
notifyListeners();
|
||||
|
||||
refreshInstallStatuses(useExistingInstalledInfo: true);
|
||||
}
|
||||
|
||||
Future<void> refreshInstallStatuses(
|
||||
{bool useExistingInstalledInfo = false}) async {
|
||||
if (await doesInstalledAppsPluginWork()) {
|
||||
for (var app in apps.values) {
|
||||
// Check install status for each App (slow)
|
||||
apps[app.app.id]?.installedInfo = await getInstalledInfo(app.app.id);
|
||||
notifyListeners();
|
||||
}
|
||||
// Reconcile version differences
|
||||
List<App> modifiedApps = [];
|
||||
for (var app in apps.values) {
|
||||
var moddedApp = getCorrectedInstallStatusAppIfPossible(
|
||||
app.app,
|
||||
useExistingInstalledInfo
|
||||
? app.installedInfo
|
||||
: await getInstalledInfo(app.app.id));
|
||||
var moddedApp =
|
||||
getCorrectedInstallStatusAppIfPossible(app.app, app.installedInfo);
|
||||
if (moddedApp != null) {
|
||||
modifiedApps.add(moddedApp);
|
||||
}
|
||||
@@ -795,6 +783,7 @@ class AppsProvider with ChangeNotifier {
|
||||
.where((a) => a.installedVersion == null)
|
||||
.map((e) => e.id)
|
||||
.toList();
|
||||
// After reconciliation, delete externally uninstalled Apps if needed
|
||||
if (removedAppIds.isNotEmpty) {
|
||||
var settingsProvider = SettingsProvider();
|
||||
await settingsProvider.initializeSettings();
|
||||
@@ -804,6 +793,9 @@ class AppsProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loadingApps = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> saveApps(List<App> apps,
|
||||
|
@@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 0.13.16+180 # When changing this, update the tag in main() accordingly
|
||||
version: 0.13.17+181 # When changing this, update the tag in main() accordingly
|
||||
|
||||
environment:
|
||||
sdk: '>=2.18.2 <3.0.0'
|
||||
|
Reference in New Issue
Block a user