mirror of
https://github.com/foss42/apidash.git
synced 2025-06-29 04:16:12 +08:00
Add RequestEditorTopBar
This commit is contained in:
@ -1,14 +1,10 @@
|
|||||||
import 'package:apidash_core/apidash_core.dart';
|
|
||||||
import 'package:apidash_design_system/apidash_design_system.dart';
|
import 'package:apidash_design_system/apidash_design_system.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
import 'package:apidash/providers/providers.dart';
|
|
||||||
import 'package:apidash/extensions/extensions.dart';
|
import 'package:apidash/extensions/extensions.dart';
|
||||||
import 'package:apidash/widgets/widgets.dart';
|
|
||||||
import 'package:apidash/consts.dart';
|
import 'package:apidash/consts.dart';
|
||||||
import 'details_card/details_card.dart';
|
import 'details_card/details_card.dart';
|
||||||
import 'details_card/request_pane/request_pane.dart';
|
import 'details_card/request_pane/request_pane.dart';
|
||||||
import '../../common_widgets/common_widgets.dart';
|
import 'request_editor_top_bar.dart';
|
||||||
import 'url_card.dart';
|
import 'url_card.dart';
|
||||||
|
|
||||||
class RequestEditor extends StatelessWidget {
|
class RequestEditor extends StatelessWidget {
|
||||||
@ -43,56 +39,3 @@ class RequestEditor extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RequestEditorTopBar extends ConsumerWidget {
|
|
||||||
const RequestEditorTopBar({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
final id = ref.watch(selectedIdStateProvider);
|
|
||||||
final name =
|
|
||||||
ref.watch(selectedRequestModelProvider.select((value) => value?.name));
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
left: 12.0,
|
|
||||||
top: 4.0,
|
|
||||||
right: 4.0,
|
|
||||||
bottom: 4.0,
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
DropdownButtonAPIType(
|
|
||||||
apiType: APIType.http,
|
|
||||||
onChanged: (apiType) {},
|
|
||||||
),
|
|
||||||
kHSpacer10,
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
name ?? "",
|
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
maxLines: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
kHSpacer10,
|
|
||||||
EditorTitleActions(
|
|
||||||
onRenamePressed: () {
|
|
||||||
showRenameDialog(context, "Rename Request", name, (val) {
|
|
||||||
ref
|
|
||||||
.read(collectionStateNotifierProvider.notifier)
|
|
||||||
.update(id!, name: val);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onDuplicatePressed: () => ref
|
|
||||||
.read(collectionStateNotifierProvider.notifier)
|
|
||||||
.duplicate(id!),
|
|
||||||
onDeletePressed: () =>
|
|
||||||
ref.read(collectionStateNotifierProvider.notifier).remove(id!),
|
|
||||||
),
|
|
||||||
kHSpacer10,
|
|
||||||
const EnvironmentDropdown(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
import 'package:apidash_core/apidash_core.dart';
|
||||||
|
import 'package:apidash_design_system/apidash_design_system.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:apidash/providers/providers.dart';
|
||||||
|
import 'package:apidash/widgets/widgets.dart';
|
||||||
|
import '../../common_widgets/common_widgets.dart';
|
||||||
|
|
||||||
|
class RequestEditorTopBar extends ConsumerWidget {
|
||||||
|
const RequestEditorTopBar({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final id = ref.watch(selectedIdStateProvider);
|
||||||
|
final name =
|
||||||
|
ref.watch(selectedRequestModelProvider.select((value) => value?.name));
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 12.0,
|
||||||
|
top: 4.0,
|
||||||
|
right: 4.0,
|
||||||
|
bottom: 4.0,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
DropdownButtonAPIType(
|
||||||
|
apiType: APIType.http,
|
||||||
|
onChanged: (apiType) {},
|
||||||
|
),
|
||||||
|
kHSpacer10,
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
name ?? "",
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
maxLines: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
kHSpacer10,
|
||||||
|
EditorTitleActions(
|
||||||
|
onRenamePressed: () {
|
||||||
|
showRenameDialog(context, "Rename Request", name, (val) {
|
||||||
|
ref
|
||||||
|
.read(collectionStateNotifierProvider.notifier)
|
||||||
|
.update(id!, name: val);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onDuplicatePressed: () => ref
|
||||||
|
.read(collectionStateNotifierProvider.notifier)
|
||||||
|
.duplicate(id!),
|
||||||
|
onDeletePressed: () =>
|
||||||
|
ref.read(collectionStateNotifierProvider.notifier).remove(id!),
|
||||||
|
),
|
||||||
|
kHSpacer10,
|
||||||
|
const EnvironmentDropdown(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user