1
1
import 'package:flutter/material.dart' ;
2
+ import 'package:flutter_riverpod/flutter_riverpod.dart' ;
3
+ import 'package:apidash/providers/collection_providers.dart' ;
2
4
import 'package:apidash/consts.dart' ;
3
5
import 'details_card/details_card.dart' ;
4
6
import 'url_card.dart' ;
@@ -10,6 +12,7 @@ class RequestEditor extends StatelessWidget {
10
12
Widget build (BuildContext context) {
11
13
return const Column (
12
14
children: [
15
+ RequestEditorTopBar (),
13
16
EditorPaneRequestURLCard (),
14
17
kVSpacer10,
15
18
Expanded (
@@ -19,3 +22,91 @@ class RequestEditor extends StatelessWidget {
19
22
);
20
23
}
21
24
}
25
+
26
+ class RequestEditorTopBar extends ConsumerWidget {
27
+ const RequestEditorTopBar ({super .key});
28
+
29
+ @override
30
+ Widget build (BuildContext context, WidgetRef ref) {
31
+ final id = ref.watch (selectedIdStateProvider);
32
+ final name =
33
+ ref.watch (selectedRequestModelProvider.select ((value) => value? .name));
34
+ return Padding (
35
+ padding: const EdgeInsets .only (
36
+ left: 12.0 ,
37
+ top: 4.0 ,
38
+ right: 8.0 ,
39
+ bottom: 4.0 ,
40
+ ),
41
+ child: Row (
42
+ children: [
43
+ Expanded (
44
+ child: Text (
45
+ name ?? "" ,
46
+ style: Theme .of (context).textTheme.bodyMedium,
47
+ overflow: TextOverflow .ellipsis,
48
+ maxLines: 1 ,
49
+ ),
50
+ ),
51
+ const SizedBox (
52
+ width: 6 ,
53
+ ),
54
+ SizedBox (
55
+ width: 90 ,
56
+ height: 24 ,
57
+ child: FilledButton .tonalIcon (
58
+ style: const ButtonStyle (
59
+ padding: MaterialStatePropertyAll (EdgeInsets .zero),
60
+ ),
61
+ 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
+ });
97
+ },
98
+ icon: const Icon (
99
+ Icons .edit,
100
+ size: 12 ,
101
+ ),
102
+ label: Text (
103
+ "Rename" ,
104
+ style: Theme .of (context).textTheme.bodySmall,
105
+ ),
106
+ ),
107
+ )
108
+ ],
109
+ ),
110
+ );
111
+ }
112
+ }
0 commit comments