mirror of
https://github.com/foss42/apidash.git
synced 2025-06-08 21:08:00 +08:00
Tooltip sidebar card
This commit is contained in:
@ -15,6 +15,7 @@ class SidebarRequestCard extends StatefulWidget {
|
|||||||
this.editRequestId,
|
this.editRequestId,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
this.onDoubleTap,
|
this.onDoubleTap,
|
||||||
|
this.onSecondaryTap,
|
||||||
this.onChangedNameEditor,
|
this.onChangedNameEditor,
|
||||||
this.onTapOutsideNameEditor,
|
this.onTapOutsideNameEditor,
|
||||||
this.onMenuSelected,
|
this.onMenuSelected,
|
||||||
@ -28,6 +29,7 @@ class SidebarRequestCard extends StatefulWidget {
|
|||||||
final String? editRequestId;
|
final String? editRequestId;
|
||||||
final void Function()? onTap;
|
final void Function()? onTap;
|
||||||
final void Function()? onDoubleTap;
|
final void Function()? onDoubleTap;
|
||||||
|
final void Function()? onSecondaryTap;
|
||||||
final Function(String)? onChangedNameEditor;
|
final Function(String)? onChangedNameEditor;
|
||||||
final Function()? onTapOutsideNameEditor;
|
final Function()? onTapOutsideNameEditor;
|
||||||
final Function(RequestItemMenuOption)? onMenuSelected;
|
final Function(RequestItemMenuOption)? onMenuSelected;
|
||||||
@ -45,71 +47,79 @@ class _SidebarRequestCardState extends State<SidebarRequestCard> {
|
|||||||
final Color surfaceTint = Theme.of(context).colorScheme.primary;
|
final Color surfaceTint = Theme.of(context).colorScheme.primary;
|
||||||
bool isActiveId = widget.activeRequestId == widget.id;
|
bool isActiveId = widget.activeRequestId == widget.id;
|
||||||
bool inEditMode = widget.editRequestId == widget.id;
|
bool inEditMode = widget.editRequestId == widget.id;
|
||||||
return Card(
|
String name = (widget.name != null && widget.name!.trim().isNotEmpty)
|
||||||
shape: const RoundedRectangleBorder(
|
? widget.name!
|
||||||
borderRadius: kBorderRadius12,
|
: getRequestTitleFromUrl(widget.url);
|
||||||
),
|
return Tooltip(
|
||||||
elevation: isActiveId ? 1 : 0,
|
message: name,
|
||||||
surfaceTintColor: isActiveId ? surfaceTint : null,
|
waitDuration: const Duration(seconds: 1),
|
||||||
color: isActiveId
|
child: Card(
|
||||||
? Theme.of(context).colorScheme.brightness == Brightness.dark
|
shape: const RoundedRectangleBorder(
|
||||||
? colorVariant
|
borderRadius: kBorderRadius8,
|
||||||
: color
|
),
|
||||||
: color,
|
elevation: isActiveId ? 1 : 0,
|
||||||
margin: EdgeInsets.zero,
|
surfaceTintColor: isActiveId ? surfaceTint : null,
|
||||||
child: InkWell(
|
color: isActiveId
|
||||||
borderRadius: kBorderRadius12,
|
? Theme.of(context).colorScheme.brightness == Brightness.dark
|
||||||
hoverColor: colorVariant,
|
? colorVariant
|
||||||
focusColor: colorVariant.withOpacity(0.5),
|
: color
|
||||||
onTap: inEditMode ? null : widget.onTap,
|
: color,
|
||||||
onDoubleTap: inEditMode ? null : widget.onDoubleTap,
|
margin: EdgeInsets.zero,
|
||||||
child: Padding(
|
child: InkWell(
|
||||||
padding: EdgeInsets.only(
|
borderRadius: kBorderRadius8,
|
||||||
left: 10,
|
hoverColor: colorVariant,
|
||||||
right: isActiveId ? 0 : 20,
|
focusColor: colorVariant.withOpacity(0.5),
|
||||||
top: 5,
|
onTap: inEditMode ? null : widget.onTap,
|
||||||
bottom: 5,
|
onDoubleTap: inEditMode ? null : widget.onDoubleTap,
|
||||||
),
|
onSecondaryTap: widget.onSecondaryTap,
|
||||||
child: SizedBox(
|
child: Padding(
|
||||||
height: 20,
|
padding: EdgeInsets.only(
|
||||||
child: Row(
|
left: 6,
|
||||||
children: [
|
right: isActiveId ? 6 : 10,
|
||||||
MethodBox(method: widget.method),
|
top: 5,
|
||||||
kHSpacer5,
|
bottom: 5,
|
||||||
Expanded(
|
),
|
||||||
child: inEditMode
|
child: SizedBox(
|
||||||
? TextFormField(
|
height: 20,
|
||||||
key: Key("${widget.id}-name"),
|
child: Row(
|
||||||
initialValue: widget.name,
|
children: [
|
||||||
autofocus: true,
|
MethodBox(method: widget.method),
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
kHSpacer4,
|
||||||
onTapOutside: (_) {
|
Expanded(
|
||||||
widget.onTapOutsideNameEditor?.call();
|
child: inEditMode
|
||||||
FocusScope.of(context).unfocus();
|
? TextFormField(
|
||||||
},
|
key: Key("${widget.id}-name"),
|
||||||
onChanged: widget.onChangedNameEditor,
|
initialValue: widget.name,
|
||||||
decoration: const InputDecoration(
|
autofocus: true,
|
||||||
isCollapsed: true,
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
contentPadding: EdgeInsets.zero,
|
onTapOutside: (_) {
|
||||||
border: InputBorder.none,
|
widget.onTapOutsideNameEditor?.call();
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
},
|
||||||
|
onChanged: widget.onChangedNameEditor,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
isCollapsed: true,
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
border: InputBorder.none,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Text(
|
||||||
|
name,
|
||||||
|
softWrap: false,
|
||||||
|
overflow: TextOverflow.fade,
|
||||||
),
|
),
|
||||||
)
|
|
||||||
: Text(
|
|
||||||
(widget.name != null &&
|
|
||||||
widget.name!.trim().isNotEmpty)
|
|
||||||
? widget.name!
|
|
||||||
: getRequestTitleFromUrl(widget.url),
|
|
||||||
softWrap: false,
|
|
||||||
overflow: TextOverflow.fade,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Visibility(
|
|
||||||
visible: isActiveId && !inEditMode,
|
|
||||||
child: RequestCardMenu(
|
|
||||||
onSelected: widget.onMenuSelected,
|
|
||||||
),
|
),
|
||||||
),
|
Visibility(
|
||||||
],
|
visible: isActiveId && !inEditMode,
|
||||||
|
child: SizedBox(
|
||||||
|
width: 28,
|
||||||
|
child: RequestCardMenu(
|
||||||
|
onSelected: widget.onMenuSelected,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user