chore: optimize the workspace menu hover status (#5865)

This commit is contained in:
Lucas.Xu 2024-08-02 16:10:49 +08:00 committed by GitHub
parent e9fc003e10
commit 46bad4e7e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 63 additions and 28 deletions

View File

@ -141,7 +141,9 @@ class _SidebarSpaceHeaderState extends State<SidebarSpaceHeader> {
onAction: _onAction, onAction: _onAction,
), ),
const HSpace(8.0), const HSpace(8.0),
ViewAddButton( FlowyTooltip(
message: LocaleKeys.sideBar_addAPage.tr(),
child: ViewAddButton(
parentViewId: widget.space.id, parentViewId: widget.space.id,
onEditing: (_) {}, onEditing: (_) {},
onSelected: ( onSelected: (
@ -156,6 +158,7 @@ class _SidebarSpaceHeaderState extends State<SidebarSpaceHeader> {
} }
}, },
), ),
),
], ],
), ),
), ),

View File

@ -29,6 +29,15 @@ class SidebarWorkspace extends StatefulWidget {
class _SidebarWorkspaceState extends State<SidebarWorkspace> { class _SidebarWorkspaceState extends State<SidebarWorkspace> {
Loading? loadingIndicator; Loading? loadingIndicator;
final ValueNotifier<bool> onHover = ValueNotifier(false);
@override
void dispose() {
onHover.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocConsumer<UserWorkspaceBloc, UserWorkspaceState>( return BlocConsumer<UserWorkspaceBloc, UserWorkspaceState>(
@ -40,7 +49,24 @@ class _SidebarWorkspaceState extends State<SidebarWorkspace> {
if (currentWorkspace == null) { if (currentWorkspace == null) {
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
return Row( return MouseRegion(
onEnter: (_) => onHover.value = true,
onExit: (_) => onHover.value = false,
child: ValueListenableBuilder(
valueListenable: onHover,
builder: (_, onHover, child) {
return Container(
margin: const EdgeInsets.only(right: 8.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
color: onHover
? Theme.of(context).colorScheme.secondary
: Colors.transparent,
),
child: child,
);
},
child: Row(
children: [ children: [
Expanded( Expanded(
child: SidebarSwitchWorkspaceButton( child: SidebarSwitchWorkspaceButton(
@ -51,8 +77,10 @@ class _SidebarWorkspaceState extends State<SidebarWorkspace> {
UserSettingButton(userProfile: widget.userProfile), UserSettingButton(userProfile: widget.userProfile),
const HSpace(8.0), const HSpace(8.0),
const NotificationButton(), const NotificationButton(),
const HSpace(12.0), const HSpace(4.0),
], ],
),
),
); );
}, },
); );
@ -201,6 +229,7 @@ class _SidebarSwitchWorkspaceButtonState
}, },
child: FlowyIconTextButton( child: FlowyIconTextButton(
margin: EdgeInsets.zero, margin: EdgeInsets.zero,
hoverColor: Colors.transparent,
textBuilder: (onHover) => SizedBox( textBuilder: (onHover) => SizedBox(
height: 30, height: 30,
child: Row( child: Row(

View File

@ -268,8 +268,11 @@ class FlowyButton extends StatelessWidget {
return Container( return Container(
decoration: decoration, decoration: decoration,
child: Padding( child: Padding(
padding: padding: margin ??
margin ?? const EdgeInsets.symmetric(horizontal: 6, vertical: 4), const EdgeInsets.symmetric(
horizontal: 6,
vertical: 4,
),
child: child, child: child,
), ),
); );