mirror of
https://github.com/foss42/apidash.git
synced 2025-10-19 20:54:32 +08:00
Refactor Request Details Card
This commit is contained in:
@ -1,11 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:multi_split_view/multi_split_view.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:apidash/providers/providers.dart';
|
import 'package:apidash/providers/providers.dart';
|
||||||
import 'package:apidash/consts.dart';
|
import 'package:apidash/widgets/widgets.dart';
|
||||||
import 'request_pane/request_pane.dart';
|
import 'request_pane/request_pane.dart';
|
||||||
import 'response_pane/response_pane.dart';
|
import 'response_pane.dart';
|
||||||
import 'code_pane/code_pane.dart';
|
import 'code_pane.dart';
|
||||||
|
|
||||||
class EditorPaneRequestDetailsCard extends ConsumerStatefulWidget {
|
class EditorPaneRequestDetailsCard extends ConsumerStatefulWidget {
|
||||||
const EditorPaneRequestDetailsCard({super.key});
|
const EditorPaneRequestDetailsCard({super.key});
|
||||||
@ -17,49 +16,14 @@ class EditorPaneRequestDetailsCard extends ConsumerStatefulWidget {
|
|||||||
|
|
||||||
class _EditorPaneRequestDetailsCardState
|
class _EditorPaneRequestDetailsCardState
|
||||||
extends ConsumerState<EditorPaneRequestDetailsCard> {
|
extends ConsumerState<EditorPaneRequestDetailsCard> {
|
||||||
final MultiSplitViewController _controller = MultiSplitViewController(
|
|
||||||
areas: [
|
|
||||||
Area(minimalSize: 300),
|
|
||||||
Area(minimalSize: 300),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final codePaneVisible = ref.watch(codePaneVisibleStateProvider);
|
final codePaneVisible = ref.watch(codePaneVisibleStateProvider);
|
||||||
return Card(
|
return RequestDetailsCard(
|
||||||
shape: RoundedRectangleBorder(
|
child: EqualSplitView(
|
||||||
side: BorderSide(
|
leftWidget: const EditRequestPane(),
|
||||||
color: Theme.of(context).colorScheme.surfaceVariant,
|
rightWidget: codePaneVisible ? const CodePane() : const ResponsePane(),
|
||||||
),
|
|
||||||
borderRadius: kBorderRadius12,
|
|
||||||
),
|
|
||||||
elevation: 0,
|
|
||||||
child: MultiSplitViewTheme(
|
|
||||||
data: MultiSplitViewThemeData(
|
|
||||||
dividerThickness: 3,
|
|
||||||
dividerPainter: DividerPainters.background(
|
|
||||||
color: Theme.of(context).colorScheme.surfaceVariant,
|
|
||||||
highlightedColor: Theme.of(context).colorScheme.outline.withOpacity(
|
|
||||||
kHintOpacity,
|
|
||||||
),
|
|
||||||
animationEnabled: false,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: MultiSplitView(
|
|
||||||
controller: _controller,
|
|
||||||
children: [
|
|
||||||
const EditRequestPane(),
|
|
||||||
codePaneVisible ? const CodePane() : const ResponsePane(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_controller.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -75,3 +75,27 @@ class _SidebarRequestCardState extends State<SidebarRequestCard> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RequestDetailsCard extends StatefulWidget {
|
||||||
|
const RequestDetailsCard({super.key, this.child});
|
||||||
|
|
||||||
|
final Widget? child;
|
||||||
|
@override
|
||||||
|
State<RequestDetailsCard> createState() => _RequestDetailsCardState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RequestDetailsCardState extends State<RequestDetailsCard> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Card(
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
side: BorderSide(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceVariant,
|
||||||
|
),
|
||||||
|
borderRadius: kBorderRadius12,
|
||||||
|
),
|
||||||
|
elevation: 0,
|
||||||
|
child: widget.child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -67,3 +67,55 @@ class DashboardSplitViewState extends State<DashboardSplitView> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class EqualSplitView extends StatefulWidget {
|
||||||
|
const EqualSplitView({
|
||||||
|
super.key,
|
||||||
|
required this.leftWidget,
|
||||||
|
required this.rightWidget,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Widget leftWidget;
|
||||||
|
final Widget rightWidget;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<EqualSplitView> createState() => _EqualSplitViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _EqualSplitViewState extends State<EqualSplitView> {
|
||||||
|
final MultiSplitViewController _controller = MultiSplitViewController(
|
||||||
|
areas: [
|
||||||
|
Area(minimalSize: 300),
|
||||||
|
Area(minimalSize: 300),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MultiSplitViewTheme(
|
||||||
|
data: MultiSplitViewThemeData(
|
||||||
|
dividerThickness: 3,
|
||||||
|
dividerPainter: DividerPainters.background(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceVariant,
|
||||||
|
highlightedColor: Theme.of(context).colorScheme.outline.withOpacity(
|
||||||
|
kHintOpacity,
|
||||||
|
),
|
||||||
|
animationEnabled: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: MultiSplitView(
|
||||||
|
controller: _controller,
|
||||||
|
children: [
|
||||||
|
widget.leftWidget,
|
||||||
|
widget.rightWidget,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controller.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user