mirror of
https://github.com/foss42/apidash.git
synced 2025-05-21 08:16:29 +08:00
Refactor design
This commit is contained in:
@ -302,6 +302,13 @@ enum ItemMenuOption {
|
|||||||
final String label;
|
final String label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum SidebarMenuOption {
|
||||||
|
import("Import");
|
||||||
|
|
||||||
|
const SidebarMenuOption(this.label);
|
||||||
|
final String label;
|
||||||
|
}
|
||||||
|
|
||||||
enum HTTPVerb { get, head, post, put, patch, delete }
|
enum HTTPVerb { get, head, post, put, patch, delete }
|
||||||
|
|
||||||
enum FormDataType { text, file }
|
enum FormDataType { text, file }
|
||||||
@ -685,7 +692,7 @@ const kRaiseIssue =
|
|||||||
|
|
||||||
const kHintTextUrlCard = "Enter API endpoint like https://$kDefaultUri/";
|
const kHintTextUrlCard = "Enter API endpoint like https://$kDefaultUri/";
|
||||||
const kLabelPlusNew = "+ New";
|
const kLabelPlusNew = "+ New";
|
||||||
const kLabelImport = "Import";
|
const kLabelMoreOptions = "More Options";
|
||||||
const kLabelSend = "Send";
|
const kLabelSend = "Send";
|
||||||
const kLabelSending = "Sending..";
|
const kLabelSending = "Sending..";
|
||||||
const kLabelBusy = "Busy";
|
const kLabelBusy = "Busy";
|
||||||
|
@ -2,13 +2,18 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:apidash/providers/providers.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 'sidebar_save_button.dart';
|
import 'sidebar_save_button.dart';
|
||||||
|
|
||||||
class SidebarHeader extends ConsumerWidget {
|
class SidebarHeader extends ConsumerWidget {
|
||||||
const SidebarHeader({super.key, this.onAddNew, this.onImport});
|
const SidebarHeader({
|
||||||
final Function()? onAddNew;
|
super.key,
|
||||||
final Function()? onImport;
|
this.onAddNew,
|
||||||
|
this.onImport,
|
||||||
|
});
|
||||||
|
final VoidCallback? onAddNew;
|
||||||
|
final VoidCallback? onImport;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
@ -28,13 +33,14 @@ class SidebarHeader extends ConsumerWidget {
|
|||||||
style: kTextStyleButton,
|
style: kTextStyleButton,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
kHSpacer12,
|
kHSpacer4,
|
||||||
ElevatedButton(
|
SizedBox(
|
||||||
onPressed: onImport,
|
width: 24,
|
||||||
style: kButtonSidebarStyle,
|
child: SidebarTopMenu(
|
||||||
child: const Text(
|
tooltip: kLabelMoreOptions,
|
||||||
kLabelImport,
|
onSelected: (option) => switch (option) {
|
||||||
style: kTextStyleButton,
|
SidebarMenuOption.import => onImport?.call(),
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
context.width <= kMinWindowSize.width
|
context.width <= kMinWindowSize.width
|
||||||
|
44
lib/widgets/menu_sidebar_top.dart
Normal file
44
lib/widgets/menu_sidebar_top.dart
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:apidash/consts.dart';
|
||||||
|
|
||||||
|
class SidebarTopMenu extends StatelessWidget {
|
||||||
|
const SidebarTopMenu({
|
||||||
|
super.key,
|
||||||
|
this.onSelected,
|
||||||
|
this.child,
|
||||||
|
this.offset = Offset.zero,
|
||||||
|
this.splashRadius = 14,
|
||||||
|
this.tooltip,
|
||||||
|
this.shape,
|
||||||
|
});
|
||||||
|
final Widget? child;
|
||||||
|
final Offset offset;
|
||||||
|
final double splashRadius;
|
||||||
|
final String? tooltip;
|
||||||
|
final ShapeBorder? shape;
|
||||||
|
|
||||||
|
final Function(SidebarMenuOption)? onSelected;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return PopupMenuButton<SidebarMenuOption>(
|
||||||
|
tooltip: tooltip,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
splashRadius: splashRadius,
|
||||||
|
icon: const Icon(Icons.more_vert),
|
||||||
|
iconSize: 14,
|
||||||
|
offset: offset,
|
||||||
|
onSelected: onSelected,
|
||||||
|
shape: shape,
|
||||||
|
itemBuilder: (BuildContext context) => SidebarMenuOption.values
|
||||||
|
.map<PopupMenuEntry<SidebarMenuOption>>(
|
||||||
|
(e) => PopupMenuItem<SidebarMenuOption>(
|
||||||
|
value: e,
|
||||||
|
child: Text(e.label),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -31,6 +31,7 @@ export 'intro_message.dart';
|
|||||||
export 'json_previewer.dart';
|
export 'json_previewer.dart';
|
||||||
export 'markdown.dart';
|
export 'markdown.dart';
|
||||||
export 'menu_item_card.dart';
|
export 'menu_item_card.dart';
|
||||||
|
export 'menu_sidebar_top.dart';
|
||||||
export 'overlay_widget.dart';
|
export 'overlay_widget.dart';
|
||||||
export 'popup_menu_codegen.dart';
|
export 'popup_menu_codegen.dart';
|
||||||
export 'popup_menu_env.dart';
|
export 'popup_menu_env.dart';
|
||||||
|
Reference in New Issue
Block a user