feat: select which properties to show in calendar (#2482)

This commit is contained in:
Richard Shiue 2023-05-09 22:26:25 +08:00 committed by GitHub
parent 6731037a8c
commit 4a1714b537
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -51,5 +51,6 @@ class CalendarSettingEvent with _$CalendarSettingEvent {
} }
enum CalendarSettingAction { enum CalendarSettingAction {
properties,
layout, layout,
} }

View File

@ -2,8 +2,10 @@ import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/database_view/application/field/field_controller.dart'; import 'package:appflowy/plugins/database_view/application/field/field_controller.dart';
import 'package:appflowy/plugins/database_view/calendar/application/calendar_setting_bloc.dart'; import 'package:appflowy/plugins/database_view/calendar/application/calendar_setting_bloc.dart';
import 'package:appflowy/plugins/database_view/grid/presentation/layout/sizes.dart'; import 'package:appflowy/plugins/database_view/grid/presentation/layout/sizes.dart';
import 'package:appflowy/plugins/database_view/grid/presentation/widgets/toolbar/grid_property.dart';
import 'package:appflowy_backend/protobuf/flowy-database/protobuf.dart'; import 'package:appflowy_backend/protobuf/flowy-database/protobuf.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/image.dart';
import 'package:flowy_infra_ui/style_widget/button.dart'; import 'package:flowy_infra_ui/style_widget/button.dart';
import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart'; import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flowy_infra_ui/style_widget/text.dart';
@ -38,6 +40,11 @@ class CalendarSetting extends StatelessWidget {
final CalendarSettingAction? action = final CalendarSettingAction? action =
state.selectedAction.foldLeft(null, (previous, action) => action); state.selectedAction.foldLeft(null, (previous, action) => action);
switch (action) { switch (action) {
case CalendarSettingAction.properties:
return GridPropertyList(
viewId: settingContext.viewId,
fieldController: settingContext.fieldController,
);
case CalendarSettingAction.layout: case CalendarSettingAction.layout:
return CalendarLayoutSetting( return CalendarLayoutSetting(
onUpdated: onUpdated, onUpdated: onUpdated,
@ -78,9 +85,16 @@ class AllCalendarSettings extends StatelessWidget {
} }
Widget _settingItem(BuildContext context, CalendarSettingAction action) { Widget _settingItem(BuildContext context, CalendarSettingAction action) {
Widget? icon;
if (action.iconName() != null) {
icon = FlowySvg(
name: action.iconName()!,
);
}
return SizedBox( return SizedBox(
height: GridSize.popoverItemHeight, height: GridSize.popoverItemHeight,
child: FlowyButton( child: FlowyButton(
leftIcon: icon,
text: FlowyText.medium(action.title()), text: FlowyText.medium(action.title()),
onTap: () { onTap: () {
context context
@ -93,8 +107,19 @@ class AllCalendarSettings extends StatelessWidget {
} }
extension _SettingExtension on CalendarSettingAction { extension _SettingExtension on CalendarSettingAction {
String? iconName() {
switch (this) {
case CalendarSettingAction.properties:
return 'grid/setting/properties';
case CalendarSettingAction.layout:
return null;
}
}
String title() { String title() {
switch (this) { switch (this) {
case CalendarSettingAction.properties:
return LocaleKeys.grid_settings_Properties.tr();
case CalendarSettingAction.layout: case CalendarSettingAction.layout:
return LocaleKeys.grid_settings_layout.tr(); return LocaleKeys.grid_settings_layout.tr();
} }