mirror of
https://github.com/Auties00/Reboot-Launcher.git
synced 2026-01-13 19:22:22 +01:00
9.0.2
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
@@ -11,6 +12,9 @@ import 'package:reboot_launcher/src/page/implementation/server_browser_page.dart
|
||||
import 'package:reboot_launcher/src/page/implementation/server_host_page.dart';
|
||||
import 'package:reboot_launcher/src/page/implementation/settings_page.dart';
|
||||
|
||||
final StreamController<void> pagesController = StreamController.broadcast();
|
||||
bool hitBack = false;
|
||||
|
||||
final List<RebootPage> pages = [
|
||||
const PlayPage(),
|
||||
const HostPage(),
|
||||
@@ -25,19 +29,47 @@ final RxInt pageIndex = RxInt(0);
|
||||
|
||||
final HashMap<int, GlobalKey> _pageKeys = HashMap();
|
||||
|
||||
GlobalKey appKey = GlobalKey();
|
||||
GlobalKey get pageKey {
|
||||
var index = pageIndex.value;
|
||||
var key = _pageKeys[index];
|
||||
final GlobalKey appKey = GlobalKey();
|
||||
|
||||
GlobalKey get pageKey => getPageKeyByIndex(pageIndex.value);
|
||||
|
||||
GlobalKey getPageKeyByIndex(int index) {
|
||||
final key = _pageKeys[index];
|
||||
if(key != null) {
|
||||
return key;
|
||||
}
|
||||
|
||||
var result = GlobalKey();
|
||||
final result = GlobalKey();
|
||||
_pageKeys[index] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
List<int> get pagesWithButtonIndexes => pages.where((page) => page.hasButton)
|
||||
.map((page) => page.index)
|
||||
.toList();
|
||||
bool get hasPageButton => pages[pageIndex.value].hasButton(pageStack.lastOrNull);
|
||||
|
||||
final Queue<Object?> appStack = _createAppStack();
|
||||
Queue _createAppStack() {
|
||||
final queue = Queue();
|
||||
var lastValue = pageIndex.value;
|
||||
pageIndex.listen((index) {
|
||||
if(!hitBack && lastValue != index) {
|
||||
queue.add(lastValue);
|
||||
pagesController.add(null);
|
||||
}
|
||||
|
||||
hitBack = false;
|
||||
lastValue = index;
|
||||
});
|
||||
return queue;
|
||||
}
|
||||
|
||||
final Map<int, Queue<String>> _pagesStack = Map.fromEntries(List.generate(pages.length, (index) => MapEntry(index, Queue<String>())));
|
||||
|
||||
Queue<String> get pageStack => _pagesStack[pageIndex.value]!;
|
||||
|
||||
void addSubPageToStack(String pageName) {
|
||||
final index = pageIndex.value;
|
||||
final identifier = "${index}_$pageName";
|
||||
appStack.add(identifier);
|
||||
_pagesStack[index]!.add(identifier);
|
||||
pagesController.add(null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user