Link UI bugfix

This commit is contained in:
Imran Remtulla
2023-12-16 04:02:10 -05:00
parent ede65eda6c
commit 65988f4e08

View File

@@ -36,6 +36,7 @@ class _HomePageState extends State<HomePage> {
bool prevIsLoading = true; bool prevIsLoading = true;
late AppLinks _appLinks; late AppLinks _appLinks;
StreamSubscription<Uri>? _linkSubscription; StreamSubscription<Uri>? _linkSubscription;
bool isLinkActivity = false;
List<NavigationPageItem> pages = [ List<NavigationPageItem> pages = [
NavigationPageItem(tr('appsString'), Icons.apps, NavigationPageItem(tr('appsString'), Icons.apps,
@@ -69,6 +70,7 @@ class _HomePageState extends State<HomePage> {
} }
interpretLink(Uri uri) async { interpretLink(Uri uri) async {
isLinkActivity = true;
var action = uri.host; var action = uri.host;
var data = uri.path.length > 1 ? uri.path.substring(1) : ""; var data = uri.path.length > 1 ? uri.path.substring(1) : "";
try { try {
@@ -124,12 +126,6 @@ class _HomePageState extends State<HomePage> {
} else if (selectedIndexHistory.isEmpty || } else if (selectedIndexHistory.isEmpty ||
(selectedIndexHistory.isNotEmpty && (selectedIndexHistory.isNotEmpty &&
selectedIndexHistory.last != index)) { selectedIndexHistory.last != index)) {
// while (index == 1 &&
// (pages[0].widget.key as GlobalKey<AppsPageState>).currentState !=
// null) {
// // Avoid duplicate GlobalKey error
// await Future.delayed(const Duration(microseconds: 1));
// }
setState(() { setState(() {
int existingInd = selectedIndexHistory.indexOf(index); int existingInd = selectedIndexHistory.indexOf(index);
if (existingInd >= 0) { if (existingInd >= 0) {
@@ -145,13 +141,14 @@ class _HomePageState extends State<HomePage> {
AppsProvider appsProvider = context.watch<AppsProvider>(); AppsProvider appsProvider = context.watch<AppsProvider>();
SettingsProvider settingsProvider = context.watch<SettingsProvider>(); SettingsProvider settingsProvider = context.watch<SettingsProvider>();
// if (!prevIsLoading && if (!prevIsLoading &&
// prevAppCount >= 0 && prevAppCount >= 0 &&
// appsProvider.apps.length > prevAppCount && appsProvider.apps.length > prevAppCount &&
// selectedIndexHistory.isNotEmpty && selectedIndexHistory.isNotEmpty &&
// selectedIndexHistory.last == 1) { selectedIndexHistory.last == 1 &&
// switchToPage(0); !isLinkActivity) {
// } switchToPage(0);
}
prevAppCount = appsProvider.apps.length; prevAppCount = appsProvider.apps.length;
prevIsLoading = appsProvider.loadingApps; prevIsLoading = appsProvider.loadingApps;
@@ -197,6 +194,11 @@ class _HomePageState extends State<HomePage> {
), ),
), ),
onWillPop: () async { onWillPop: () async {
if (isLinkActivity &&
selectedIndexHistory.length == 1 &&
selectedIndexHistory.last == 1) {
return true;
}
setIsReversing(selectedIndexHistory.length >= 2 setIsReversing(selectedIndexHistory.length >= 2
? selectedIndexHistory.reversed.toList()[1] ? selectedIndexHistory.reversed.toList()[1]
: 0); : 0);