refactor: hide DashbotTab button in mobile devices

This commit is contained in:
Udhay-Adithya
2025-09-21 12:52:32 +05:30
parent 7cdc286c08
commit 401d2f4b69
2 changed files with 32 additions and 30 deletions

View File

@@ -4,8 +4,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../dashbot_dashboard.dart'; import '../../dashbot_dashboard.dart';
import '../providers/dashbot_window_notifier.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) { void showDashbotWindow(BuildContext context, WidgetRef ref) {
final isDashbotActive = ref.read(dashbotWindowNotifierProvider).isActive; final isDashbotActive = ref.read(dashbotWindowNotifierProvider).isActive;
final isDashbotPopped = ref.read(dashbotWindowNotifierProvider).isPopped; final isDashbotPopped = ref.read(dashbotWindowNotifierProvider).isPopped;

View File

@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'core/providers/dashbot_window_notifier.dart'; import 'core/providers/dashbot_window_notifier.dart';
import 'core/utils/show_dashbot.dart'; import 'core/utils/show_dashbot.dart';
import 'package:apidash/consts.dart';
class DashbotTab extends ConsumerStatefulWidget { class DashbotTab extends ConsumerStatefulWidget {
const DashbotTab({super.key}); const DashbotTab({super.key});
@@ -78,36 +79,39 @@ class _DashbotTabState extends ConsumerState<DashbotTab>
}, },
), ),
Spacer(), Spacer(),
ADIconButton( if (!kIsMobile) ...[
icon: Icons.close_fullscreen, ADIconButton(
onPressed: () { icon: Icons.close_fullscreen,
ref onPressed: () {
.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) {
ref ref
.read(dashbotWindowNotifierProvider.notifier) .read(dashbotWindowNotifierProvider.notifier)
.toggleActive(); .togglePopped();
}
}, final newState =
icon: Icons.close, 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,
),
],
], ],
), ),
), ),