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