mobile bluesky app made with flutter
lazurite.stormlightlabs.org/
mobile
bluesky
flutter
1import 'package:riverpod_annotation/riverpod_annotation.dart';
2
3part 'debug_overlay_controller.g.dart';
4
5/// State for the debug overlay.
6class DebugOverlayState {
7 const DebugOverlayState({this.isVisible = false, this.activeTabIndex = 0});
8
9 /// Whether the overlay is currently visible.
10 final bool isVisible;
11
12 /// The currently active tab index.
13 final int activeTabIndex;
14
15 /// Creates a copy of this state with the given fields replaced.
16 DebugOverlayState copyWith({bool? isVisible, int? activeTabIndex}) {
17 return DebugOverlayState(
18 isVisible: isVisible ?? this.isVisible,
19 activeTabIndex: activeTabIndex ?? this.activeTabIndex,
20 );
21 }
22
23 @override
24 bool operator ==(Object other) =>
25 identical(this, other) ||
26 other is DebugOverlayState &&
27 runtimeType == other.runtimeType &&
28 isVisible == other.isVisible &&
29 activeTabIndex == other.activeTabIndex;
30
31 @override
32 int get hashCode => Object.hash(isVisible, activeTabIndex);
33}
34
35/// Controller for the debug overlay visibility and tab state.
36///
37/// Manages overlay visibility, active tab selection, and provides methods
38/// to show, hide, and toggle the overlay.
39@riverpod
40class DebugOverlayController extends _$DebugOverlayController {
41 @override
42 DebugOverlayState build() => const DebugOverlayState();
43
44 /// Shows the debug overlay.
45 void show() => state = state.copyWith(isVisible: true);
46
47 /// Hides the debug overlay.
48 void hide() => state = state.copyWith(isVisible: false);
49
50 /// Toggles the debug overlay visibility.
51 void toggle() => state = state.copyWith(isVisible: !state.isVisible);
52
53 /// Sets the active tab index.
54 void setTab(int index) => state = state.copyWith(activeTabIndex: index);
55}