wip: history panes

This commit is contained in:
DenserMeerkat
2024-07-20 22:05:08 +05:30
parent 8eadd7f8fa
commit f8ede1edc8
26 changed files with 473 additions and 71 deletions

View File

@ -1,9 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:apidash/extensions/extensions.dart';
import 'package:apidash/consts.dart';
import 'tabs.dart';
import 'package:apidash/extensions/extensions.dart';
class RequestPane extends StatefulWidget {
class RequestPane extends StatefulHookWidget {
const RequestPane({
super.key,
required this.selectedId,
@ -13,6 +14,7 @@ class RequestPane extends StatefulWidget {
this.onTapTabBar,
required this.children,
this.showIndicators = const [false, false, false],
this.showViewCodeButton,
});
final String? selectedId;
@ -22,6 +24,7 @@ class RequestPane extends StatefulWidget {
final void Function(int)? onTapTabBar;
final List<Widget> children;
final List<bool> showIndicators;
final bool? showViewCodeButton;
@override
State<RequestPane> createState() => _RequestPaneState();
@ -29,28 +32,19 @@ class RequestPane extends StatefulWidget {
class _RequestPaneState extends State<RequestPane>
with TickerProviderStateMixin {
late final TabController _controller;
@override
void initState() {
super.initState();
_controller = TabController(
length: 3,
animationDuration: kTabAnimationDuration,
vsync: this,
);
}
@override
Widget build(BuildContext context) {
final TabController controller = useTabController(
initialLength: 3,
vsync: this,
);
if (widget.tabIndex != null) {
_controller.index = widget.tabIndex!;
controller.index = widget.tabIndex!;
}
return Column(
children: [
context.isMediumWindow
? const SizedBox.shrink()
: Padding(
(widget.showViewCodeButton ?? !context.isMediumWindow)
? Padding(
padding: kP8,
child: SizedBox(
height: kHeaderHeight,
@ -76,10 +70,11 @@ class _RequestPaneState extends State<RequestPane>
],
),
),
),
)
: const SizedBox.shrink(),
TabBar(
key: Key(widget.selectedId!),
controller: _controller,
controller: controller,
overlayColor: kColorTransparentState,
labelPadding: kPh2,
onTap: widget.onTapTabBar,
@ -101,7 +96,7 @@ class _RequestPaneState extends State<RequestPane>
kVSpacer5,
Expanded(
child: TabBarView(
controller: _controller,
controller: controller,
physics: const NeverScrollableScrollPhysics(),
children: widget.children,
),
@ -109,10 +104,4 @@ class _RequestPaneState extends State<RequestPane>
],
);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
}