mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-11-02 19:13:28 +00:00
fix: hover color in different color schemes (#6240)
This commit is contained in:
parent
d1d485ee94
commit
7a0c6a829b
@ -474,10 +474,12 @@ class CurrentSpace extends StatelessWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
this.onTapBlankArea,
|
this.onTapBlankArea,
|
||||||
required this.space,
|
required this.space,
|
||||||
|
this.isHovered = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
final ViewPB space;
|
final ViewPB space;
|
||||||
final VoidCallback? onTapBlankArea;
|
final VoidCallback? onTapBlankArea;
|
||||||
|
final bool isHovered;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -497,6 +499,7 @@ class CurrentSpace extends StatelessWidget {
|
|||||||
fontSize: 14.0,
|
fontSize: 14.0,
|
||||||
figmaLineHeight: 18.0,
|
figmaLineHeight: 18.0,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
|
color: isHovered ? Theme.of(context).colorScheme.onSurface : null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const HSpace(4.0),
|
const HSpace(4.0),
|
||||||
@ -504,6 +507,7 @@ class CurrentSpace extends StatelessWidget {
|
|||||||
context.read<SpaceBloc>().state.isExpanded
|
context.read<SpaceBloc>().state.isExpanded
|
||||||
? FlowySvgs.workspace_drop_down_menu_show_s
|
? FlowySvgs.workspace_drop_down_menu_show_s
|
||||||
: FlowySvgs.workspace_drop_down_menu_hide_s,
|
: FlowySvgs.workspace_drop_down_menu_hide_s,
|
||||||
|
color: isHovered ? Theme.of(context).colorScheme.onSurface : null,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -15,7 +15,6 @@ import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
|
|||||||
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/hover.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
class SidebarSpaceHeader extends StatefulWidget {
|
class SidebarSpaceHeader extends StatefulWidget {
|
||||||
@ -53,59 +52,54 @@ class _SidebarSpaceHeaderState extends State<SidebarSpaceHeader> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ValueListenableBuilder(
|
return ValueListenableBuilder(
|
||||||
valueListenable: isHovered,
|
valueListenable: isHovered,
|
||||||
builder: (context, isHovered, child) {
|
builder: (context, onHover, child) {
|
||||||
final style = HoverStyle(
|
return MouseRegion(
|
||||||
hoverColor: isHovered
|
onEnter: (_) => isHovered.value = true,
|
||||||
? Theme.of(context).colorScheme.secondary
|
onExit: (_) => isHovered.value = false,
|
||||||
: Colors.transparent,
|
child: GestureDetector(
|
||||||
);
|
onTap: () => context
|
||||||
return GestureDetector(
|
.read<SpaceBloc>()
|
||||||
onTap: () => context
|
.add(SpaceEvent.expand(widget.space, !widget.isExpanded)),
|
||||||
.read<SpaceBloc>()
|
child: _buildSpaceName(onHover),
|
||||||
.add(SpaceEvent.expand(widget.space, !widget.isExpanded)),
|
|
||||||
child: FlowyHoverContainer(
|
|
||||||
style: style,
|
|
||||||
applyStyle: isHovered,
|
|
||||||
child: _buildSpaceName(),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildSpaceName() {
|
Widget _buildSpaceName(bool isHovered) {
|
||||||
return SizedBox(
|
return Container(
|
||||||
height: HomeSizes.workspaceSectionHeight,
|
height: HomeSizes.workspaceSectionHeight,
|
||||||
child: MouseRegion(
|
decoration: BoxDecoration(
|
||||||
onEnter: (_) => isHovered.value = true,
|
borderRadius: const BorderRadius.all(Radius.circular(6)),
|
||||||
onExit: (_) => isHovered.value = false,
|
color: isHovered ? Theme.of(context).colorScheme.secondary : null,
|
||||||
child: Stack(
|
),
|
||||||
alignment: Alignment.center,
|
child: Stack(
|
||||||
children: [
|
alignment: Alignment.center,
|
||||||
ValueListenableBuilder(
|
children: [
|
||||||
valueListenable: onEditing,
|
ValueListenableBuilder(
|
||||||
builder: (context, onEditing, child) => Positioned(
|
valueListenable: onEditing,
|
||||||
left: 3,
|
builder: (context, onEditing, child) => Positioned(
|
||||||
top: 3,
|
left: 3,
|
||||||
bottom: 3,
|
top: 3,
|
||||||
right: isHovered.value || onEditing ? 88 : 0,
|
bottom: 3,
|
||||||
child: SpacePopup(
|
right: isHovered || onEditing ? 88 : 0,
|
||||||
showCreateButton: true,
|
child: SpacePopup(
|
||||||
child: _buildChild(),
|
showCreateButton: true,
|
||||||
),
|
child: _buildChild(isHovered),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Positioned(
|
),
|
||||||
right: 4,
|
Positioned(
|
||||||
child: _buildRightIcon(),
|
right: 4,
|
||||||
),
|
child: _buildRightIcon(isHovered),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildChild() {
|
Widget _buildChild(bool isHovered) {
|
||||||
final textSpan = TextSpan(
|
final textSpan = TextSpan(
|
||||||
children: [
|
children: [
|
||||||
TextSpan(
|
TextSpan(
|
||||||
@ -124,23 +118,23 @@ class _SidebarSpaceHeaderState extends State<SidebarSpaceHeader> {
|
|||||||
richMessage: textSpan,
|
richMessage: textSpan,
|
||||||
child: CurrentSpace(
|
child: CurrentSpace(
|
||||||
space: widget.space,
|
space: widget.space,
|
||||||
|
isHovered: isHovered,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildRightIcon() {
|
Widget _buildRightIcon(bool isHovered) {
|
||||||
return ValueListenableBuilder(
|
return ValueListenableBuilder(
|
||||||
valueListenable: onEditing,
|
valueListenable: onEditing,
|
||||||
builder: (context, onEditing, child) => ValueListenableBuilder(
|
builder: (context, onEditing, child) => Opacity(
|
||||||
valueListenable: isHovered,
|
opacity: isHovered || onEditing ? 1 : 0,
|
||||||
builder: (context, onHover, child) =>
|
|
||||||
Opacity(opacity: onHover || onEditing ? 1 : 0, child: child),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
SpaceMorePopup(
|
SpaceMorePopup(
|
||||||
space: widget.space,
|
space: widget.space,
|
||||||
onEditing: (value) => this.onEditing.value = value,
|
onEditing: (value) => this.onEditing.value = value,
|
||||||
onAction: _onAction,
|
onAction: _onAction,
|
||||||
|
isHovered: isHovered,
|
||||||
),
|
),
|
||||||
const HSpace(8.0),
|
const HSpace(8.0),
|
||||||
FlowyTooltip(
|
FlowyTooltip(
|
||||||
@ -159,6 +153,7 @@ class _SidebarSpaceHeaderState extends State<SidebarSpaceHeader> {
|
|||||||
widget.onAdded(pluginBuilder.layoutType!);
|
widget.onAdded(pluginBuilder.layoutType!);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
isHovered: isHovered,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -19,11 +19,13 @@ class SpaceMorePopup extends StatelessWidget {
|
|||||||
required this.space,
|
required this.space,
|
||||||
required this.onAction,
|
required this.onAction,
|
||||||
required this.onEditing,
|
required this.onEditing,
|
||||||
|
this.isHovered = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
final ViewPB space;
|
final ViewPB space;
|
||||||
final void Function(SpaceMoreActionType type, dynamic data) onAction;
|
final void Function(SpaceMoreActionType type, dynamic data) onAction;
|
||||||
final void Function(bool value) onEditing;
|
final void Function(bool value) onEditing;
|
||||||
|
final bool isHovered;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -38,7 +40,10 @@ class SpaceMorePopup extends StatelessWidget {
|
|||||||
buildChild: (popover) {
|
buildChild: (popover) {
|
||||||
return FlowyIconButton(
|
return FlowyIconButton(
|
||||||
width: 24,
|
width: 24,
|
||||||
icon: const FlowySvg(FlowySvgs.workspace_three_dots_s),
|
icon: FlowySvg(
|
||||||
|
FlowySvgs.workspace_three_dots_s,
|
||||||
|
color: isHovered ? Theme.of(context).colorScheme.onSurface : null,
|
||||||
|
),
|
||||||
tooltipText: LocaleKeys.space_manage.tr(),
|
tooltipText: LocaleKeys.space_manage.tr(),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
onEditing(true);
|
onEditing(true);
|
||||||
|
|||||||
@ -16,6 +16,7 @@ class ViewAddButton extends StatelessWidget {
|
|||||||
required this.parentViewId,
|
required this.parentViewId,
|
||||||
required this.onEditing,
|
required this.onEditing,
|
||||||
required this.onSelected,
|
required this.onSelected,
|
||||||
|
this.isHovered = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String parentViewId;
|
final String parentViewId;
|
||||||
@ -27,6 +28,7 @@ class ViewAddButton extends StatelessWidget {
|
|||||||
bool openAfterCreated,
|
bool openAfterCreated,
|
||||||
bool createNewView,
|
bool createNewView,
|
||||||
) onSelected;
|
) onSelected;
|
||||||
|
final bool isHovered;
|
||||||
|
|
||||||
List<PopoverAction> get _actions {
|
List<PopoverAction> get _actions {
|
||||||
return [
|
return [
|
||||||
@ -57,7 +59,10 @@ class ViewAddButton extends StatelessWidget {
|
|||||||
buildChild: (popover) {
|
buildChild: (popover) {
|
||||||
return FlowyIconButton(
|
return FlowyIconButton(
|
||||||
width: 24,
|
width: 24,
|
||||||
icon: const FlowySvg(FlowySvgs.view_item_add_s),
|
icon: FlowySvg(
|
||||||
|
FlowySvgs.view_item_add_s,
|
||||||
|
color: isHovered ? Theme.of(context).colorScheme.onSurface : null,
|
||||||
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
onEditing(true);
|
onEditing(true);
|
||||||
popover.show();
|
popover.show();
|
||||||
|
|||||||
@ -153,10 +153,12 @@ class FlowyHoverContainer extends StatelessWidget {
|
|||||||
: style.backgroundColor,
|
: style.backgroundColor,
|
||||||
borderRadius: style.borderRadius,
|
borderRadius: style.borderRadius,
|
||||||
),
|
),
|
||||||
child: Theme(
|
child: applyStyle
|
||||||
data: hoverTheme,
|
? Theme(
|
||||||
child: child,
|
data: hoverTheme,
|
||||||
),
|
child: child,
|
||||||
|
)
|
||||||
|
: child,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user