mirror of
https://github.com/foss42/apidash.git
synced 2025-06-27 11:02:33 +08:00
Adding a code pane
This commit is contained in:
@ -8,6 +8,7 @@ const _uuid = Uuid();
|
|||||||
|
|
||||||
final activeIdStateProvider = StateProvider<String?>((ref) => null);
|
final activeIdStateProvider = StateProvider<String?>((ref) => null);
|
||||||
final sentRequestIdStateProvider = StateProvider<String?>((ref) => null);
|
final sentRequestIdStateProvider = StateProvider<String?>((ref) => null);
|
||||||
|
final codePaneVisibleStateProvider = StateProvider<bool>((ref) => false);
|
||||||
|
|
||||||
final StateNotifierProvider<CollectionStateNotifier, List<RequestModel>>
|
final StateNotifierProvider<CollectionStateNotifier, List<RequestModel>>
|
||||||
collectionStateNotifierProvider =
|
collectionStateNotifierProvider =
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class CodePane extends StatefulWidget {
|
||||||
|
const CodePane({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CodePane> createState() => _CodePaneState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CodePaneState extends State<CodePane> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container();
|
||||||
|
}
|
||||||
|
}
|
@ -1,19 +1,22 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:multi_split_view/multi_split_view.dart';
|
import 'package:multi_split_view/multi_split_view.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:apidash/providers/providers.dart';
|
||||||
import 'package:apidash/consts.dart';
|
import 'package:apidash/consts.dart';
|
||||||
import 'request_pane/request_pane.dart';
|
import 'request_pane/request_pane.dart';
|
||||||
import 'response_pane/response_pane.dart';
|
import 'response_pane/response_pane.dart';
|
||||||
|
import 'code_pane/code_pane.dart';
|
||||||
|
|
||||||
class EditorPaneRequestDetailsCard extends StatefulWidget {
|
class EditorPaneRequestDetailsCard extends ConsumerStatefulWidget {
|
||||||
const EditorPaneRequestDetailsCard({super.key});
|
const EditorPaneRequestDetailsCard({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<EditorPaneRequestDetailsCard> createState() =>
|
ConsumerState<EditorPaneRequestDetailsCard> createState() =>
|
||||||
_EditorPaneRequestDetailsCardState();
|
_EditorPaneRequestDetailsCardState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _EditorPaneRequestDetailsCardState
|
class _EditorPaneRequestDetailsCardState
|
||||||
extends State<EditorPaneRequestDetailsCard> {
|
extends ConsumerState<EditorPaneRequestDetailsCard> {
|
||||||
final MultiSplitViewController _controller = MultiSplitViewController(
|
final MultiSplitViewController _controller = MultiSplitViewController(
|
||||||
areas: [
|
areas: [
|
||||||
Area(minimalSize: 300),
|
Area(minimalSize: 300),
|
||||||
@ -23,6 +26,7 @@ class _EditorPaneRequestDetailsCardState
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final codePaneVisible = ref.watch(codePaneVisibleStateProvider);
|
||||||
return Card(
|
return Card(
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
side: BorderSide(
|
side: BorderSide(
|
||||||
@ -44,9 +48,9 @@ class _EditorPaneRequestDetailsCardState
|
|||||||
),
|
),
|
||||||
child: MultiSplitView(
|
child: MultiSplitView(
|
||||||
controller: _controller,
|
controller: _controller,
|
||||||
children: const [
|
children: [
|
||||||
EditRequestPane(),
|
const EditRequestPane(),
|
||||||
ResponsePane(),
|
codePaneVisible ? const CodePane() : const ResponsePane(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -30,6 +30,7 @@ class _EditRequestPaneState extends ConsumerState<EditRequestPane>
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final activeId = ref.watch(activeIdStateProvider);
|
final activeId = ref.watch(activeIdStateProvider);
|
||||||
|
final codePaneVisible = ref.watch(codePaneVisibleStateProvider);
|
||||||
_controller.index = ref
|
_controller.index = ref
|
||||||
.read(collectionStateNotifierProvider.notifier)
|
.read(collectionStateNotifierProvider.notifier)
|
||||||
.getRequestModel(activeId!)
|
.getRequestModel(activeId!)
|
||||||
@ -48,11 +49,20 @@ class _EditRequestPaneState extends ConsumerState<EditRequestPane>
|
|||||||
style: Theme.of(context).textTheme.titleMedium,
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
),
|
),
|
||||||
FilledButton.tonalIcon(
|
FilledButton.tonalIcon(
|
||||||
onPressed: () {},
|
onPressed: () {
|
||||||
icon: const Icon(
|
ref
|
||||||
Icons.code_rounded,
|
.read(codePaneVisibleStateProvider.notifier)
|
||||||
|
.update((state) => !codePaneVisible);
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
codePaneVisible
|
||||||
|
? Icons.code_off_rounded
|
||||||
|
: Icons.code_rounded,
|
||||||
|
),
|
||||||
|
label: SizedBox(
|
||||||
|
width: 75,
|
||||||
|
child: Text(codePaneVisible ? "Hide Code" : "Show Code"),
|
||||||
),
|
),
|
||||||
label: const Text("Generate Code"),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user