mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: grid/kanban toolbar UI improvements (#1634)
This commit is contained in:
@ -13,6 +13,7 @@ import 'package:flowy_infra_ui/style_widget/text.dart';
|
|||||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
|
||||||
import 'board_toolbar.dart';
|
import 'board_toolbar.dart';
|
||||||
|
|
||||||
@ -181,6 +182,6 @@ class _BoardSettingListPopoverState extends State<BoardSettingListPopover> {
|
|||||||
onAction: (action, settingContext) {
|
onAction: (action, settingContext) {
|
||||||
setState(() => _action = action);
|
setState(() => _action = action);
|
||||||
},
|
},
|
||||||
);
|
).padding(all: 6.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:app_flowy/plugins/grid/application/field/field_controller.dart';
|
import 'package:app_flowy/plugins/grid/application/field/field_controller.dart';
|
||||||
|
import 'package:app_flowy/plugins/grid/presentation/layout/sizes.dart';
|
||||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flowy_infra/theme_extension.dart';
|
import 'package:flowy_infra/theme_extension.dart';
|
||||||
@ -67,12 +68,12 @@ class _SettingButtonState extends State<_SettingButton> {
|
|||||||
direction: PopoverDirection.leftWithTopAligned,
|
direction: PopoverDirection.leftWithTopAligned,
|
||||||
triggerActions: PopoverTriggerFlags.none,
|
triggerActions: PopoverTriggerFlags.none,
|
||||||
constraints: BoxConstraints.loose(const Size(260, 400)),
|
constraints: BoxConstraints.loose(const Size(260, 400)),
|
||||||
|
margin: EdgeInsets.zero,
|
||||||
child: FlowyTextButton(
|
child: FlowyTextButton(
|
||||||
LocaleKeys.settings_title.tr(),
|
LocaleKeys.settings_title.tr(),
|
||||||
fontSize: 14,
|
|
||||||
fillColor: Colors.transparent,
|
fillColor: Colors.transparent,
|
||||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||||
padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 6),
|
padding: GridSize.typeOptionContentInsets,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
popoverController.show();
|
popoverController.show();
|
||||||
},
|
},
|
||||||
|
@ -8,6 +8,7 @@ import 'package:flowy_infra_ui/style_widget/button.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
|
import '../../layout/sizes.dart';
|
||||||
import '../filter/create_filter_list.dart';
|
import '../filter/create_filter_list.dart';
|
||||||
|
|
||||||
class FilterButton extends StatefulWidget {
|
class FilterButton extends StatefulWidget {
|
||||||
@ -28,39 +29,34 @@ class _FilterButtonState extends State<FilterButton> {
|
|||||||
? null
|
? null
|
||||||
: Theme.of(context).colorScheme.primary;
|
: Theme.of(context).colorScheme.primary;
|
||||||
|
|
||||||
return wrapPopover(
|
return _wrapPopover(
|
||||||
context,
|
context,
|
||||||
SizedBox(
|
FlowyTextButton(
|
||||||
height: 26,
|
LocaleKeys.grid_settings_filter.tr(),
|
||||||
child: FlowyTextButton(
|
fontColor: textColor,
|
||||||
LocaleKeys.grid_settings_filter.tr(),
|
fillColor: Colors.transparent,
|
||||||
fontSize: 13,
|
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||||
fontColor: textColor,
|
padding: GridSize.typeOptionContentInsets,
|
||||||
fillColor: Colors.transparent,
|
onPressed: () {
|
||||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
final bloc = context.read<GridFilterMenuBloc>();
|
||||||
padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 2),
|
if (bloc.state.filters.isEmpty) {
|
||||||
onPressed: () {
|
_popoverController.show();
|
||||||
final bloc = context.read<GridFilterMenuBloc>();
|
} else {
|
||||||
if (bloc.state.filters.isEmpty) {
|
bloc.add(const GridFilterMenuEvent.toggleMenu());
|
||||||
_popoverController.show();
|
}
|
||||||
} else {
|
},
|
||||||
bloc.add(const GridFilterMenuEvent.toggleMenu());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget wrapPopover(BuildContext buildContext, Widget child) {
|
Widget _wrapPopover(BuildContext buildContext, Widget child) {
|
||||||
return AppFlowyPopover(
|
return AppFlowyPopover(
|
||||||
controller: _popoverController,
|
controller: _popoverController,
|
||||||
direction: PopoverDirection.leftWithTopAligned,
|
direction: PopoverDirection.leftWithTopAligned,
|
||||||
constraints: BoxConstraints.loose(const Size(200, 300)),
|
constraints: BoxConstraints.loose(const Size(200, 300)),
|
||||||
offset: const Offset(0, 10),
|
offset: const Offset(0, 10),
|
||||||
margin: const EdgeInsets.all(6),
|
|
||||||
triggerActions: PopoverTriggerFlags.none,
|
triggerActions: PopoverTriggerFlags.none,
|
||||||
child: child,
|
child: child,
|
||||||
popupBuilder: (BuildContext context) {
|
popupBuilder: (BuildContext context) {
|
||||||
|
@ -46,12 +46,10 @@ class GridGroupList extends StatelessWidget {
|
|||||||
return ListView.separated(
|
return ListView.separated(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
itemCount: cells.length,
|
itemCount: cells.length,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) => cells[index],
|
||||||
return cells[index];
|
separatorBuilder: (BuildContext context, int index) =>
|
||||||
},
|
VSpace(GridSize.typeOptionSeparatorHeight),
|
||||||
separatorBuilder: (BuildContext context, int index) {
|
padding: const EdgeInsets.all(6.0),
|
||||||
return VSpace(GridSize.typeOptionSeparatorHeight);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -59,12 +59,10 @@ class _GridPropertyListState extends State<GridPropertyList> {
|
|||||||
controller: ScrollController(),
|
controller: ScrollController(),
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
itemCount: cells.length,
|
itemCount: cells.length,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) => cells[index],
|
||||||
return cells[index];
|
separatorBuilder: (BuildContext context, int index) =>
|
||||||
},
|
VSpace(GridSize.typeOptionSeparatorHeight),
|
||||||
separatorBuilder: (BuildContext context, int index) {
|
padding: const EdgeInsets.symmetric(vertical: 6.0),
|
||||||
return VSpace(GridSize.typeOptionSeparatorHeight);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -72,10 +70,11 @@ class _GridPropertyListState extends State<GridPropertyList> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _GridPropertyCell extends StatelessWidget {
|
class _GridPropertyCell extends StatefulWidget {
|
||||||
final FieldInfo fieldInfo;
|
final FieldInfo fieldInfo;
|
||||||
final String gridId;
|
final String gridId;
|
||||||
final PopoverMutex popoverMutex;
|
final PopoverMutex popoverMutex;
|
||||||
|
|
||||||
const _GridPropertyCell({
|
const _GridPropertyCell({
|
||||||
required this.gridId,
|
required this.gridId,
|
||||||
required this.fieldInfo,
|
required this.fieldInfo,
|
||||||
@ -83,55 +82,65 @@ class _GridPropertyCell extends StatelessWidget {
|
|||||||
Key? key,
|
Key? key,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_GridPropertyCell> createState() => _GridPropertyCellState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _GridPropertyCellState extends State<_GridPropertyCell> {
|
||||||
|
late PopoverController _popoverController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
_popoverController = PopoverController();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final checkmark = svgWidget(
|
final checkmark = svgWidget(
|
||||||
fieldInfo.visibility ? 'home/show' : 'home/hide',
|
widget.fieldInfo.visibility ? 'home/show' : 'home/hide',
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
);
|
);
|
||||||
|
|
||||||
return Row(
|
return SizedBox(
|
||||||
children: [
|
height: GridSize.typeOptionItemHeight,
|
||||||
Expanded(
|
child: _editFieldButton(context, checkmark),
|
||||||
child: SizedBox(
|
|
||||||
height: GridSize.typeOptionItemHeight,
|
|
||||||
child: _editFieldButton(context),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
FlowyIconButton(
|
|
||||||
width: GridSize.typeOptionItemHeight,
|
|
||||||
onPressed: () {
|
|
||||||
context.read<GridPropertyBloc>().add(
|
|
||||||
GridPropertyEvent.setFieldVisibility(
|
|
||||||
fieldInfo.id, !fieldInfo.visibility));
|
|
||||||
},
|
|
||||||
icon: checkmark.padding(all: 6),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _editFieldButton(BuildContext context) {
|
Widget _editFieldButton(BuildContext context, Widget checkmark) {
|
||||||
return AppFlowyPopover(
|
return AppFlowyPopover(
|
||||||
mutex: popoverMutex,
|
mutex: widget.popoverMutex,
|
||||||
|
controller: _popoverController,
|
||||||
offset: const Offset(20, 0),
|
offset: const Offset(20, 0),
|
||||||
direction: PopoverDirection.leftWithTopAligned,
|
direction: PopoverDirection.leftWithTopAligned,
|
||||||
constraints: BoxConstraints.loose(const Size(240, 400)),
|
constraints: BoxConstraints.loose(const Size(240, 400)),
|
||||||
|
triggerActions: PopoverTriggerFlags.none,
|
||||||
margin: EdgeInsets.zero,
|
margin: EdgeInsets.zero,
|
||||||
child: FlowyButton(
|
child: FlowyButton(
|
||||||
text: FlowyText.medium(fieldInfo.name),
|
text: FlowyText.medium(widget.fieldInfo.name),
|
||||||
leftIcon: svgWidget(
|
leftIcon: svgWidget(
|
||||||
fieldInfo.fieldType.iconName(),
|
widget.fieldInfo.fieldType.iconName(),
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
),
|
),
|
||||||
),
|
rightIcon: FlowyIconButton(
|
||||||
|
hoverColor: Colors.transparent,
|
||||||
|
onPressed: () {
|
||||||
|
context.read<GridPropertyBloc>().add(
|
||||||
|
GridPropertyEvent.setFieldVisibility(
|
||||||
|
widget.fieldInfo.id, !widget.fieldInfo.visibility));
|
||||||
|
},
|
||||||
|
icon: checkmark.padding(all: 6.0),
|
||||||
|
),
|
||||||
|
onTap: () => _popoverController.show(),
|
||||||
|
).padding(horizontal: 6.0),
|
||||||
popupBuilder: (BuildContext context) {
|
popupBuilder: (BuildContext context) {
|
||||||
return FieldEditor(
|
return FieldEditor(
|
||||||
gridId: gridId,
|
gridId: widget.gridId,
|
||||||
fieldName: fieldInfo.name,
|
fieldName: widget.fieldInfo.name,
|
||||||
typeOptionLoader: FieldTypeOptionLoader(
|
typeOptionLoader: FieldTypeOptionLoader(
|
||||||
gridId: gridId,
|
gridId: widget.gridId,
|
||||||
field: fieldInfo.field,
|
field: widget.fieldInfo.field,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -8,7 +8,9 @@ import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
|||||||
import 'package:flowy_infra_ui/style_widget/button.dart';
|
import 'package:flowy_infra_ui/style_widget/button.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
|
||||||
|
import '../../layout/sizes.dart';
|
||||||
import 'grid_property.dart';
|
import 'grid_property.dart';
|
||||||
import 'grid_setting.dart';
|
import 'grid_setting.dart';
|
||||||
|
|
||||||
@ -20,11 +22,11 @@ class SettingButton extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SettingButtonState extends State<SettingButton> {
|
class _SettingButtonState extends State<SettingButton> {
|
||||||
late PopoverController popoverController;
|
late PopoverController _popoverController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
popoverController = PopoverController();
|
_popoverController = PopoverController();
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,21 +43,18 @@ class _SettingButtonState extends State<SettingButton> {
|
|||||||
},
|
},
|
||||||
builder: (context, settingContext) {
|
builder: (context, settingContext) {
|
||||||
return AppFlowyPopover(
|
return AppFlowyPopover(
|
||||||
controller: popoverController,
|
controller: _popoverController,
|
||||||
constraints: BoxConstraints.loose(const Size(260, 400)),
|
constraints: BoxConstraints.loose(const Size(260, 400)),
|
||||||
direction: PopoverDirection.leftWithTopAligned,
|
direction: PopoverDirection.leftWithTopAligned,
|
||||||
offset: const Offset(0, 10),
|
offset: const Offset(0, 10),
|
||||||
margin: const EdgeInsets.all(6),
|
margin: EdgeInsets.zero,
|
||||||
triggerActions: PopoverTriggerFlags.none,
|
triggerActions: PopoverTriggerFlags.none,
|
||||||
child: FlowyTextButton(
|
child: FlowyTextButton(
|
||||||
LocaleKeys.settings_title.tr(),
|
LocaleKeys.settings_title.tr(),
|
||||||
fontSize: 13,
|
|
||||||
fillColor: Colors.transparent,
|
fillColor: Colors.transparent,
|
||||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||||
padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 6),
|
padding: GridSize.typeOptionContentInsets,
|
||||||
onPressed: () {
|
onPressed: () => _popoverController.show(),
|
||||||
popoverController.show();
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
popupBuilder: (BuildContext context) {
|
popupBuilder: (BuildContext context) {
|
||||||
return _GridSettingListPopover(settingContext: settingContext);
|
return _GridSettingListPopover(settingContext: settingContext);
|
||||||
@ -95,6 +94,6 @@ class _GridSettingListPopoverState extends State<_GridSettingListPopover> {
|
|||||||
_action = action;
|
_action = action;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
).padding(all: 6.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user