fix: show database view options for inline as disabled (#4711)

This commit is contained in:
Richard Shiue 2024-02-23 10:49:34 +08:00 committed by GitHub
parent c0b667b4ea
commit 746f0817bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 13 deletions

View File

@ -46,34 +46,44 @@ class MobileDatabaseViewQuickActions extends StatelessWidget {
), ),
); );
}), }),
if (!isInline) ...[
_divider(), _divider(),
_actionButton(context, _Action.duplicate, () { _actionButton(
context,
_Action.duplicate,
() {
context.read<ViewBloc>().add(const ViewEvent.duplicate()); context.read<ViewBloc>().add(const ViewEvent.duplicate());
context.pop(); context.pop();
}), },
!isInline,
),
_divider(), _divider(),
_actionButton(context, _Action.delete, () { _actionButton(
context,
_Action.delete,
() {
context.read<ViewBloc>().add(const ViewEvent.delete()); context.read<ViewBloc>().add(const ViewEvent.delete());
context.pop(); context.pop();
}), },
!isInline,
),
_divider(), _divider(),
], ],
],
); );
} }
Widget _actionButton( Widget _actionButton(
BuildContext context, BuildContext context,
_Action action, _Action action,
VoidCallback onTap, VoidCallback onTap, [
) { bool enable = true,
]) {
return MobileQuickActionButton( return MobileQuickActionButton(
icon: action.icon, icon: action.icon,
text: action.label, text: action.label,
textColor: action.color(context), textColor: action.color(context),
iconColor: action.color(context), iconColor: action.color(context),
onTap: onTap, onTap: onTap,
enable: enable,
); );
} }

View File

@ -10,6 +10,7 @@ class MobileQuickActionButton extends StatelessWidget {
required this.text, required this.text,
this.textColor, this.textColor,
this.iconColor, this.iconColor,
this.enable = true,
}); });
final VoidCallback onTap; final VoidCallback onTap;
@ -17,6 +18,7 @@ class MobileQuickActionButton extends StatelessWidget {
final String text; final String text;
final Color? textColor; final Color? textColor;
final Color? iconColor; final Color? iconColor;
final bool enable;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -25,6 +27,8 @@ class MobileQuickActionButton extends StatelessWidget {
child: InkWell( child: InkWell(
onTap: onTap, onTap: onTap,
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
overlayColor:
enable ? null : const MaterialStatePropertyAll(Colors.transparent),
splashColor: Colors.transparent, splashColor: Colors.transparent,
child: Container( child: Container(
height: 44, height: 44,
@ -34,14 +38,14 @@ class MobileQuickActionButton extends StatelessWidget {
FlowySvg( FlowySvg(
icon, icon,
size: const Size.square(20), size: const Size.square(20),
color: iconColor, color: enable ? iconColor : Theme.of(context).disabledColor,
), ),
const HSpace(12), const HSpace(12),
Expanded( Expanded(
child: FlowyText( child: FlowyText(
text, text,
fontSize: 15, fontSize: 15,
color: textColor, color: enable ? textColor : Theme.of(context).disabledColor,
), ),
), ),
], ],