feat: tooltip for open row as page

This commit is contained in:
chiragkr04 2022-08-07 20:01:43 +05:30
parent 25226bf26b
commit 770953ddec
2 changed files with 24 additions and 9 deletions

View File

@ -94,7 +94,8 @@
}, },
"tooltip": { "tooltip": {
"lightMode": "Switch to Light mode", "lightMode": "Switch to Light mode",
"darkMode": "Switch to Dark mode" "darkMode": "Switch to Dark mode",
"openAsPage": "Open as a Page"
}, },
"notifications": { "notifications": {
"export": { "export": {
@ -215,4 +216,4 @@
"timeHintTextInTwentyFourHour": "12:00" "timeHintTextInTwentyFourHour": "12:00"
} }
} }
} }

View File

@ -6,6 +6,8 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:flowy_infra/size.dart'; import 'package:flowy_infra/size.dart';
import 'package:styled_widget/styled_widget.dart'; import 'package:styled_widget/styled_widget.dart';
import 'package:app_flowy/generated/locale_keys.g.dart';
import 'package:easy_localization/easy_localization.dart';
class GridCellAccessoryBuildContext { class GridCellAccessoryBuildContext {
final BuildContext anchorContext; final BuildContext anchorContext;
@ -39,7 +41,13 @@ class PrimaryCellAccessory extends StatelessWidget with GridCellAccessory {
return const SizedBox(); return const SizedBox();
} else { } else {
final theme = context.watch<AppTheme>(); final theme = context.watch<AppTheme>();
return svgWidget("grid/expander", color: theme.main1); return Tooltip(
message: LocaleKeys.tooltip_openAsPage.tr(),
child: svgWidget(
"grid/expander",
color: theme.main1,
),
);
} }
} }
@ -50,7 +58,8 @@ class PrimaryCellAccessory extends StatelessWidget with GridCellAccessory {
bool enable() => !isCellEditing; bool enable() => !isCellEditing;
} }
typedef AccessoryBuilder = List<GridCellAccessory> Function(GridCellAccessoryBuildContext buildContext); typedef AccessoryBuilder = List<GridCellAccessory> Function(
GridCellAccessoryBuildContext buildContext);
abstract class CellAccessory extends Widget { abstract class CellAccessory extends Widget {
const CellAccessory({Key? key}) : super(key: key); const CellAccessory({Key? key}) : super(key: key);
@ -81,7 +90,8 @@ class _AccessoryHoverState extends State<AccessoryHover> {
@override @override
void initState() { void initState() {
_hoverState = AccessoryHoverState(); _hoverState = AccessoryHoverState();
_listenerFn = () => _hoverState.onHover = widget.child.onAccessoryHover?.value ?? false; _listenerFn = () =>
_hoverState.onHover = widget.child.onAccessoryHover?.value ?? false;
widget.child.onAccessoryHover?.addListener(_listenerFn!); widget.child.onAccessoryHover?.addListener(_listenerFn!);
super.initState(); super.initState();
@ -159,7 +169,8 @@ class _Background extends StatelessWidget {
builder: (context, state, child) { builder: (context, state, child) {
if (state.onHover) { if (state.onHover) {
return FlowyHoverContainer( return FlowyHoverContainer(
style: HoverStyle(borderRadius: Corners.s6Border, hoverColor: theme.shader6), style: HoverStyle(
borderRadius: Corners.s6Border, hoverColor: theme.shader6),
); );
} else { } else {
return const SizedBox(); return const SizedBox();
@ -171,14 +182,17 @@ class _Background extends StatelessWidget {
class CellAccessoryContainer extends StatelessWidget { class CellAccessoryContainer extends StatelessWidget {
final List<GridCellAccessory> accessories; final List<GridCellAccessory> accessories;
const CellAccessoryContainer({required this.accessories, Key? key}) : super(key: key); const CellAccessoryContainer({required this.accessories, Key? key})
: super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = context.watch<AppTheme>(); final theme = context.watch<AppTheme>();
final children = accessories.where((accessory) => accessory.enable()).map((accessory) { final children =
accessories.where((accessory) => accessory.enable()).map((accessory) {
final hover = FlowyHover( final hover = FlowyHover(
style: HoverStyle(hoverColor: theme.bg3, backgroundColor: theme.surface), style:
HoverStyle(hoverColor: theme.bg3, backgroundColor: theme.surface),
builder: (_, onHover) => Container( builder: (_, onHover) => Container(
width: 26, width: 26,
height: 26, height: 26,