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 sentRequestIdStateProvider = StateProvider<String?>((ref) => null);
|
||||
final codePaneVisibleStateProvider = StateProvider<bool>((ref) => false);
|
||||
|
||||
final StateNotifierProvider<CollectionStateNotifier, List<RequestModel>>
|
||||
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: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 'request_pane/request_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});
|
||||
|
||||
@override
|
||||
State<EditorPaneRequestDetailsCard> createState() =>
|
||||
ConsumerState<EditorPaneRequestDetailsCard> createState() =>
|
||||
_EditorPaneRequestDetailsCardState();
|
||||
}
|
||||
|
||||
class _EditorPaneRequestDetailsCardState
|
||||
extends State<EditorPaneRequestDetailsCard> {
|
||||
extends ConsumerState<EditorPaneRequestDetailsCard> {
|
||||
final MultiSplitViewController _controller = MultiSplitViewController(
|
||||
areas: [
|
||||
Area(minimalSize: 300),
|
||||
@ -23,6 +26,7 @@ class _EditorPaneRequestDetailsCardState
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final codePaneVisible = ref.watch(codePaneVisibleStateProvider);
|
||||
return Card(
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(
|
||||
@ -44,9 +48,9 @@ class _EditorPaneRequestDetailsCardState
|
||||
),
|
||||
child: MultiSplitView(
|
||||
controller: _controller,
|
||||
children: const [
|
||||
EditRequestPane(),
|
||||
ResponsePane(),
|
||||
children: [
|
||||
const EditRequestPane(),
|
||||
codePaneVisible ? const CodePane() : const ResponsePane(),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -30,6 +30,7 @@ class _EditRequestPaneState extends ConsumerState<EditRequestPane>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final activeId = ref.watch(activeIdStateProvider);
|
||||
final codePaneVisible = ref.watch(codePaneVisibleStateProvider);
|
||||
_controller.index = ref
|
||||
.read(collectionStateNotifierProvider.notifier)
|
||||
.getRequestModel(activeId!)
|
||||
@ -48,11 +49,20 @@ class _EditRequestPaneState extends ConsumerState<EditRequestPane>
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
FilledButton.tonalIcon(
|
||||
onPressed: () {},
|
||||
icon: const Icon(
|
||||
Icons.code_rounded,
|
||||
onPressed: () {
|
||||
ref
|
||||
.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