From 401d2f4b6959f148964513777e155bac338b668f Mon Sep 17 00:00:00 2001 From: Udhay-Adithya Date: Sun, 21 Sep 2025 12:52:32 +0530 Subject: [PATCH] refactor: hide DashbotTab button in mobile devices --- lib/dashbot/core/utils/show_dashbot.dart | 2 - lib/dashbot/dashbot_tab.dart | 60 +++++++++++++----------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/lib/dashbot/core/utils/show_dashbot.dart b/lib/dashbot/core/utils/show_dashbot.dart index 9e034727..f07bdb1f 100644 --- a/lib/dashbot/core/utils/show_dashbot.dart +++ b/lib/dashbot/core/utils/show_dashbot.dart @@ -4,8 +4,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../../dashbot_dashboard.dart'; import '../providers/dashbot_window_notifier.dart'; -/// Optionally pass provider overrides (e.g., dashbotRequestContextProvider) -/// so the host app can feed live context into Dashbot. void showDashbotWindow(BuildContext context, WidgetRef ref) { final isDashbotActive = ref.read(dashbotWindowNotifierProvider).isActive; final isDashbotPopped = ref.read(dashbotWindowNotifierProvider).isPopped; diff --git a/lib/dashbot/dashbot_tab.dart b/lib/dashbot/dashbot_tab.dart index 63063f56..d112ffd5 100644 --- a/lib/dashbot/dashbot_tab.dart +++ b/lib/dashbot/dashbot_tab.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'core/providers/dashbot_window_notifier.dart'; import 'core/utils/show_dashbot.dart'; +import 'package:apidash/consts.dart'; class DashbotTab extends ConsumerStatefulWidget { const DashbotTab({super.key}); @@ -78,36 +79,39 @@ class _DashbotTabState extends ConsumerState }, ), Spacer(), - ADIconButton( - icon: Icons.close_fullscreen, - onPressed: () { - ref - .read(dashbotWindowNotifierProvider.notifier) - .togglePopped(); - - final newState = - ref.read(dashbotWindowNotifierProvider); - if (newState.isPopped) { - showDashbotWindow(context, ref); - } - }, - ), - ADIconButton( - onPressed: () { - final isActive = - ref.read(dashbotWindowNotifierProvider).isActive; - - ref - .read(dashbotWindowNotifierProvider.notifier) - .togglePopped(); - if (isActive) { + if (!kIsMobile) ...[ + ADIconButton( + icon: Icons.close_fullscreen, + onPressed: () { ref .read(dashbotWindowNotifierProvider.notifier) - .toggleActive(); - } - }, - icon: Icons.close, - ), + .togglePopped(); + + final newState = + ref.read(dashbotWindowNotifierProvider); + if (newState.isPopped) { + showDashbotWindow(context, ref); + } + }, + ), + ADIconButton( + onPressed: () { + final isActive = ref + .read(dashbotWindowNotifierProvider) + .isActive; + + ref + .read(dashbotWindowNotifierProvider.notifier) + .togglePopped(); + if (isActive) { + ref + .read(dashbotWindowNotifierProvider.notifier) + .toggleActive(); + } + }, + icon: Icons.close, + ), + ], ], ), ),