use stack instead of visibility

This commit is contained in:
Fabian Freund
2025-10-30 07:00:05 +01:00
parent 6fa8a56643
commit 3955859e5b
@@ -218,71 +218,74 @@ class _BrowserViewState extends ConsumerState<BrowserView>
}, },
); );
return Visibility( return Stack(
visible: hasTab, children: [
maintainState: true, GeckoView(
replacement: SizedBox.expand(child: Container(color: Colors.grey[800])), preInitializationStep: () async {
child: GeckoView( await ref
preInitializationStep: () async { .read(eventServiceProvider)
await ref .viewReadyStateEvents
.read(eventServiceProvider) .firstWhere((state) => state == true)
.viewReadyStateEvents .timeout(
.firstWhere((state) => state == true) const Duration(seconds: 3),
.timeout( onTimeout: () {
const Duration(seconds: 3), logger.e(
onTimeout: () { 'Browser fragement not reported ready, trying to intitialize anyways',
logger.e( );
'Browser fragement not reported ready, trying to intitialize anyways', return true;
); },
return true; );
}, },
); postInitializationStep: () async {
}, await widget.postInitializationStep?.call();
postInitializationStep: () async {
await widget.postInitializationStep?.call();
if (!initializationCompleter.isCompleted) { if (!initializationCompleter.isCompleted) {
const quickActions = QuickActions(); const quickActions = QuickActions();
//Debounce: https://github.com/flutter/flutter/issues/131121 //Debounce: https://github.com/flutter/flutter/issues/131121
DateTime? lastAction; DateTime? lastAction;
await quickActions.initialize((type) async { await quickActions.initialize((type) async {
if (lastAction == null || if (lastAction == null ||
DateTime.now().difference(lastAction!) > DateTime.now().difference(lastAction!) >
const Duration(seconds: 5)) { const Duration(seconds: 5)) {
if (type == 'new_tab') { if (type == 'new_tab') {
lastAction = DateTime.now(); lastAction = DateTime.now();
final router = await ref.read(routerProvider.future); final router = await ref.read(routerProvider.future);
const route = SearchRoute(tabType: TabType.regular); const route = SearchRoute(tabType: TabType.regular);
await router.push(route.location); await router.push(route.location);
} else if (type == 'new_private_tab') { } else if (type == 'new_private_tab') {
lastAction = DateTime.now(); lastAction = DateTime.now();
final router = await ref.read(routerProvider.future); final router = await ref.read(routerProvider.future);
const route = SearchRoute(tabType: TabType.private); const route = SearchRoute(tabType: TabType.private);
await router.push(route.location); await router.push(route.location);
} else { } else {
throw UnimplementedError(); throw UnimplementedError();
}
} }
} });
});
await quickActions.setShortcutItems([ await quickActions.setShortcutItems([
//TODO: add icons //TODO: add icons
const ShortcutItem(type: 'new_tab', localizedTitle: 'New Tab'), const ShortcutItem(type: 'new_tab', localizedTitle: 'New Tab'),
const ShortcutItem( const ShortcutItem(
type: 'new_private_tab', type: 'new_private_tab',
localizedTitle: 'New Private Tab', localizedTitle: 'New Private Tab',
), ),
]); ]);
initializationCompleter.complete(); initializationCompleter.complete();
} }
}, },
), ),
if (!hasTab)
Positioned.fill(
child: SizedBox.expand(child: Container(color: Colors.grey[800])),
),
],
); );
} }