mirror of
				https://github.com/ImranR98/Obtainium.git
				synced 2025-11-04 07:13:28 +01: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
 | 
					// ignore: implementation_imports
 | 
				
			||||||
import 'package:easy_localization/src/localization.dart';
 | 
					import 'package:easy_localization/src/localization.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const String currentVersion = '0.13.16';
 | 
					const String currentVersion = '0.13.17';
 | 
				
			||||||
const String currentReleaseTag =
 | 
					const String currentReleaseTag =
 | 
				
			||||||
    'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
 | 
					    'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,6 +26,7 @@ class NavigationPageItem {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class _HomePageState extends State<HomePage> {
 | 
					class _HomePageState extends State<HomePage> {
 | 
				
			||||||
  List<int> selectedIndexHistory = [];
 | 
					  List<int> selectedIndexHistory = [];
 | 
				
			||||||
 | 
					  bool isReversing = false;
 | 
				
			||||||
  int prevAppCount = -1;
 | 
					  int prevAppCount = -1;
 | 
				
			||||||
  bool prevIsLoading = true;
 | 
					  bool prevIsLoading = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -42,7 +43,16 @@ class _HomePageState extends State<HomePage> {
 | 
				
			|||||||
  Widget build(BuildContext context) {
 | 
					  Widget build(BuildContext context) {
 | 
				
			||||||
    AppsProvider appsProvider = context.watch<AppsProvider>();
 | 
					    AppsProvider appsProvider = context.watch<AppsProvider>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    setIsReversing(int targetIndex) {
 | 
				
			||||||
 | 
					      bool reversing = selectedIndexHistory.isNotEmpty &&
 | 
				
			||||||
 | 
					          selectedIndexHistory.last > targetIndex;
 | 
				
			||||||
 | 
					      setState(() {
 | 
				
			||||||
 | 
					        isReversing = reversing;
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switchToPage(int index) async {
 | 
					    switchToPage(int index) async {
 | 
				
			||||||
 | 
					      setIsReversing(index);
 | 
				
			||||||
      if (index == 0) {
 | 
					      if (index == 0) {
 | 
				
			||||||
        while ((pages[0].widget.key as GlobalKey<AppsPageState>).currentState !=
 | 
					        while ((pages[0].widget.key as GlobalKey<AppsPageState>).currentState !=
 | 
				
			||||||
            null) {
 | 
					            null) {
 | 
				
			||||||
@@ -79,6 +89,7 @@ class _HomePageState extends State<HomePage> {
 | 
				
			|||||||
        child: Scaffold(
 | 
					        child: Scaffold(
 | 
				
			||||||
          backgroundColor: Theme.of(context).colorScheme.surface,
 | 
					          backgroundColor: Theme.of(context).colorScheme.surface,
 | 
				
			||||||
          body: PageTransitionSwitcher(
 | 
					          body: PageTransitionSwitcher(
 | 
				
			||||||
 | 
					            reverse: isReversing,
 | 
				
			||||||
            transitionBuilder: (
 | 
					            transitionBuilder: (
 | 
				
			||||||
              Widget child,
 | 
					              Widget child,
 | 
				
			||||||
              Animation<double> animation,
 | 
					              Animation<double> animation,
 | 
				
			||||||
@@ -104,13 +115,16 @@ class _HomePageState extends State<HomePage> {
 | 
				
			|||||||
                .toList(),
 | 
					                .toList(),
 | 
				
			||||||
            onDestinationSelected: (int index) async {
 | 
					            onDestinationSelected: (int index) async {
 | 
				
			||||||
              HapticFeedback.selectionClick();
 | 
					              HapticFeedback.selectionClick();
 | 
				
			||||||
              await switchToPage(index);
 | 
					              switchToPage(index);
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            selectedIndex:
 | 
					            selectedIndex:
 | 
				
			||||||
                selectedIndexHistory.isEmpty ? 0 : selectedIndexHistory.last,
 | 
					                selectedIndexHistory.isEmpty ? 0 : selectedIndexHistory.last,
 | 
				
			||||||
          ),
 | 
					          ),
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
        onWillPop: () async {
 | 
					        onWillPop: () async {
 | 
				
			||||||
 | 
					          setIsReversing(selectedIndexHistory.length >= 2
 | 
				
			||||||
 | 
					              ? selectedIndexHistory.reversed.toList()[1]
 | 
				
			||||||
 | 
					              : 0);
 | 
				
			||||||
          if (selectedIndexHistory.isNotEmpty) {
 | 
					          if (selectedIndexHistory.isNotEmpty) {
 | 
				
			||||||
            setState(() {
 | 
					            setState(() {
 | 
				
			||||||
              selectedIndexHistory.removeLast();
 | 
					              selectedIndexHistory.removeLast();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -117,7 +117,7 @@ class AppsProvider with ChangeNotifier {
 | 
				
			|||||||
    foregroundStream = FGBGEvents.stream.asBroadcastStream();
 | 
					    foregroundStream = FGBGEvents.stream.asBroadcastStream();
 | 
				
			||||||
    foregroundSubscription = foregroundStream?.listen((event) async {
 | 
					    foregroundSubscription = foregroundStream?.listen((event) async {
 | 
				
			||||||
      isForeground = event == FGBGType.foreground;
 | 
					      isForeground = event == FGBGType.foreground;
 | 
				
			||||||
      if (isForeground) await refreshInstallStatuses();
 | 
					      if (isForeground) await loadApps();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    () async {
 | 
					    () async {
 | 
				
			||||||
      var cacheDirs = await getExternalCacheDirectories();
 | 
					      var cacheDirs = await getExternalCacheDirectories();
 | 
				
			||||||
@@ -744,47 +744,35 @@ class AppsProvider with ChangeNotifier {
 | 
				
			|||||||
      // Put Apps into memory to list them (fast)
 | 
					      // Put Apps into memory to list them (fast)
 | 
				
			||||||
      if (app != null) {
 | 
					      if (app != null) {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
          apps[app.id] = 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);
 | 
					          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) {
 | 
					        } catch (e) {
 | 
				
			||||||
          apps.remove(app.id);
 | 
					 | 
				
			||||||
          errors.add([app.id, app.finalName, e.toString()]);
 | 
					          errors.add([app.id, app.finalName, e.toString()]);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    notifyListeners();
 | 
					    notifyListeners();
 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if (errors.isNotEmpty) {
 | 
					    if (errors.isNotEmpty) {
 | 
				
			||||||
      removeApps(errors.map((e) => e[0]).toList());
 | 
					      removeApps(errors.map((e) => e[0]).toList());
 | 
				
			||||||
      NotificationsProvider().notify(
 | 
					      NotificationsProvider().notify(
 | 
				
			||||||
          AppsRemovedNotification(errors.map((e) => [e[1], e[2]]).toList()));
 | 
					          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()) {
 | 
					    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 = [];
 | 
					      List<App> modifiedApps = [];
 | 
				
			||||||
      for (var app in apps.values) {
 | 
					      for (var app in apps.values) {
 | 
				
			||||||
        var moddedApp = getCorrectedInstallStatusAppIfPossible(
 | 
					        var moddedApp =
 | 
				
			||||||
            app.app,
 | 
					            getCorrectedInstallStatusAppIfPossible(app.app, app.installedInfo);
 | 
				
			||||||
            useExistingInstalledInfo
 | 
					 | 
				
			||||||
                ? app.installedInfo
 | 
					 | 
				
			||||||
                : await getInstalledInfo(app.app.id));
 | 
					 | 
				
			||||||
        if (moddedApp != null) {
 | 
					        if (moddedApp != null) {
 | 
				
			||||||
          modifiedApps.add(moddedApp);
 | 
					          modifiedApps.add(moddedApp);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -795,6 +783,7 @@ class AppsProvider with ChangeNotifier {
 | 
				
			|||||||
            .where((a) => a.installedVersion == null)
 | 
					            .where((a) => a.installedVersion == null)
 | 
				
			||||||
            .map((e) => e.id)
 | 
					            .map((e) => e.id)
 | 
				
			||||||
            .toList();
 | 
					            .toList();
 | 
				
			||||||
 | 
					        // After reconciliation, delete externally uninstalled Apps if needed
 | 
				
			||||||
        if (removedAppIds.isNotEmpty) {
 | 
					        if (removedAppIds.isNotEmpty) {
 | 
				
			||||||
          var settingsProvider = SettingsProvider();
 | 
					          var settingsProvider = SettingsProvider();
 | 
				
			||||||
          await settingsProvider.initializeSettings();
 | 
					          await settingsProvider.initializeSettings();
 | 
				
			||||||
@@ -804,6 +793,9 @@ class AppsProvider with ChangeNotifier {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    loadingApps = false;
 | 
				
			||||||
 | 
					    notifyListeners();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Future<void> saveApps(List<App> apps,
 | 
					  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
 | 
					# 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
 | 
					# 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.
 | 
					# 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:
 | 
					environment:
 | 
				
			||||||
  sdk: '>=2.18.2 <3.0.0'
 | 
					  sdk: '>=2.18.2 <3.0.0'
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user