11import 'package:flutter/material.dart' ;
22import 'package:flutter_riverpod/flutter_riverpod.dart' ;
33import 'package:apidash/providers/providers.dart' ;
4+ import 'package:apidash/extensions/extensions.dart' ;
45import 'package:apidash/consts.dart' ;
56import 'details_card/details_card.dart' ;
7+ import 'details_card/request_pane/request_pane.dart' ;
68import 'url_card.dart' ;
79
810class RequestEditor extends StatelessWidget {
911 const RequestEditor ({super .key});
1012
1113 @override
1214 Widget build (BuildContext context) {
13- return const Column (
14- children: [
15- RequestEditorTopBar (),
16- EditorPaneRequestURLCard (),
17- kVSpacer10,
18- Expanded (
19- child: EditorPaneRequestDetailsCard (),
20- ),
21- ],
22- );
15+ return context.isMobile
16+ ? const Padding (
17+ padding: kPb10,
18+ child: Column (
19+ children: [
20+ kVSpacer5,
21+ Padding (
22+ padding: kPh8,
23+ child: EditorPaneRequestURLCard (),
24+ ),
25+ kVSpacer10,
26+ Expanded (
27+ child: EditRequestPane (),
28+ ),
29+ ],
30+ ),
31+ )
32+ : Padding (
33+ padding: kIsMacOS || kIsWindows ? kPt24o8 : kP8,
34+ child: const Column (
35+ children: [
36+ RequestEditorTopBar (),
37+ EditorPaneRequestURLCard (),
38+ kVSpacer10,
39+ Expanded (
40+ child: EditorPaneRequestDetailsCard (),
41+ ),
42+ ],
43+ ),
44+ );
2345 }
2446}
2547
@@ -59,41 +81,11 @@ class RequestEditorTopBar extends ConsumerWidget {
5981 padding: MaterialStatePropertyAll (EdgeInsets .zero),
6082 ),
6183 onPressed: () {
62- showDialog (
63- context: context,
64- builder: (context) {
65- final controller =
66- TextEditingController (text: name ?? "" );
67- controller.selection = TextSelection (
68- baseOffset: 0 , extentOffset: controller.text.length);
69- return AlertDialog (
70- title: const Text ('Rename Request' ),
71- content: TextField (
72- autofocus: true ,
73- controller: controller,
74- decoration:
75- const InputDecoration (hintText: "Enter new name" ),
76- ),
77- actions: < Widget > [
78- OutlinedButton (
79- onPressed: () {
80- Navigator .pop (context);
81- },
82- child: const Text ('CANCEL' )),
83- FilledButton (
84- onPressed: () {
85- final val = controller.text.trim ();
86- ref
87- .read (collectionStateNotifierProvider
88- .notifier)
89- .update (id! , name: val);
90- Navigator .pop (context);
91- controller.dispose ();
92- },
93- child: const Text ('OK' )),
94- ],
95- );
96- });
84+ showRenameDialog (context, name, (val) {
85+ ref
86+ .read (collectionStateNotifierProvider.notifier)
87+ .update (id! , name: val);
88+ });
9789 },
9890 icon: const Icon (
9991 Icons .edit,
@@ -110,3 +102,42 @@ class RequestEditorTopBar extends ConsumerWidget {
110102 );
111103 }
112104}
105+
106+ showRenameDialog (
107+ BuildContext context,
108+ String ? name,
109+ Function (String ) onRename,
110+ ) {
111+ showDialog (
112+ context: context,
113+ builder: (context) {
114+ final controller = TextEditingController (text: name ?? "" );
115+ controller.selection =
116+ TextSelection (baseOffset: 0 , extentOffset: controller.text.length);
117+ return AlertDialog (
118+ title: const Text ('Rename Request' ),
119+ content: TextField (
120+ autofocus: true ,
121+ controller: controller,
122+ decoration: const InputDecoration (hintText: "Enter new name" ),
123+ ),
124+ actions: < Widget > [
125+ OutlinedButton (
126+ onPressed: () {
127+ Navigator .pop (context);
128+ },
129+ child: const Text ('CANCEL' )),
130+ FilledButton (
131+ onPressed: () {
132+ final val = controller.text.trim ();
133+ onRename (val);
134+ Navigator .pop (context);
135+ Future .delayed (const Duration (milliseconds: 100 ), () {
136+ controller.dispose ();
137+ });
138+ },
139+ child: const Text ('OK' )),
140+ ],
141+ );
142+ });
143+ }
0 commit comments