mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: Merge branch 'main' into develop
This commit is contained in:
@ -5,7 +5,7 @@ import 'package:dartz/dartz.dart';
|
||||
|
||||
class DatabaseBackendService {
|
||||
static Future<Either<List<DatabaseDescriptionPB>, FlowyError>>
|
||||
getAllDatabase() {
|
||||
getAllDatabases() {
|
||||
return DatabaseEventGetDatabases().send().then((result) {
|
||||
return result.fold((l) => left(l.items), (r) => right(r));
|
||||
});
|
||||
|
@ -2,7 +2,6 @@ import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
import 'field_service.dart';
|
||||
|
||||
part 'field_action_sheet_bloc.freezed.dart';
|
||||
@ -64,11 +63,6 @@ class FieldActionSheetBloc
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() async {
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'dart:async';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'field_service.dart';
|
||||
import 'type_option/type_option_context.dart';
|
||||
@ -17,8 +16,7 @@ class FieldEditorBloc extends Bloc<FieldEditorEvent, FieldEditorState> {
|
||||
required String fieldName,
|
||||
required bool isGroupField,
|
||||
required IFieldTypeOptionLoader loader,
|
||||
}) : dataController =
|
||||
TypeOptionController(viewId: viewId, loader: loader),
|
||||
}) : dataController = TypeOptionController(viewId: viewId, loader: loader),
|
||||
super(FieldEditorState.initial(viewId, fieldName, isGroupField)) {
|
||||
on<FieldEditorEvent>(
|
||||
(event, emit) async {
|
||||
@ -63,11 +61,6 @@ class FieldEditorBloc extends Bloc<FieldEditorEvent, FieldEditorState> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() async {
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
|
@ -2,7 +2,6 @@ import 'package:appflowy_backend/protobuf/flowy-database/date_type_option.pb.dar
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/date_type_option_entities.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
import 'package:protobuf/protobuf.dart';
|
||||
|
||||
import 'type_option_context.dart';
|
||||
@ -52,11 +51,6 @@ class DateTypeOptionBloc
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() async {
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
import 'package:protobuf/protobuf.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
part 'edit_select_option_bloc.freezed.dart';
|
||||
@ -27,11 +26,6 @@ class EditSelectOptionBloc
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() async {
|
||||
return super.close();
|
||||
}
|
||||
|
||||
SelectOptionPB _updateColor(SelectOptionColorPB color) {
|
||||
state.option.freeze();
|
||||
return state.option.rebuild((option) {
|
||||
|
@ -2,7 +2,6 @@ import 'package:appflowy_backend/protobuf/flowy-database/format.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/number_type_option.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
import 'package:protobuf/protobuf.dart';
|
||||
import 'type_option_context.dart';
|
||||
|
||||
@ -29,11 +28,6 @@ class NumberTypeOptionBloc
|
||||
typeOption.format = format;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() async {
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/format.pbenum.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
part 'number_format_bloc.freezed.dart';
|
||||
|
||||
class NumberFormatBloc extends Bloc<NumberFormatEvent, NumberFormatState> {
|
||||
@ -21,11 +20,6 @@ class NumberFormatBloc extends Bloc<NumberFormatEvent, NumberFormatState> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() async {
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
|
@ -49,11 +49,6 @@ class SelectOptionTypeOptionBloc
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() async {
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
import 'package:dartz/dartz.dart';
|
||||
|
||||
part 'setting_bloc.freezed.dart';
|
||||
@ -18,11 +17,6 @@ class DatabaseSettingBloc
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() async {
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
import 'package:dartz/dartz.dart';
|
||||
|
||||
part 'board_setting_bloc.freezed.dart';
|
||||
@ -17,11 +16,6 @@ class BoardSettingBloc extends Bloc<BoardSettingEvent, BoardSettingState> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() async {
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
|
@ -23,8 +23,6 @@ class CalendarSettingBloc
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() async => super.close();
|
||||
}
|
||||
|
||||
@freezed
|
||||
|
@ -1,5 +1,3 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:appflowy/plugins/database_view/grid/presentation/widgets/filter/choicechip/select_option/select_option_loader.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
@ -63,11 +61,6 @@ class SelectOptionFilterListBloc<T>
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() async {
|
||||
return super.close();
|
||||
}
|
||||
|
||||
void _updateSelectOptions({
|
||||
String? predicate,
|
||||
Set<String>? selectedOptionIds,
|
||||
|
@ -61,11 +61,6 @@ class GridHeaderBloc extends Bloc<GridHeaderEvent, GridHeaderState> {
|
||||
listenWhen: () => !isClosed,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() async {
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
|
@ -2,7 +2,6 @@ import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:async';
|
||||
import 'package:dartz/dartz.dart';
|
||||
|
||||
import '../../../application/row/row_cache.dart';
|
||||
@ -34,11 +33,6 @@ class RowActionSheetBloc
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() async {
|
||||
return super.close();
|
||||
}
|
||||
|
||||
void logResult(Either<Unit, FlowyError> result) {
|
||||
result.fold((l) => null, (err) => Log.error(err));
|
||||
}
|
||||
|
@ -38,7 +38,10 @@ class ChoiceChipButton extends StatelessWidget {
|
||||
child: FlowyButton(
|
||||
decoration: decoration,
|
||||
useIntrinsicWidth: true,
|
||||
text: FlowyText(filterInfo.fieldInfo.name),
|
||||
text: FlowyText(
|
||||
filterInfo.fieldInfo.name,
|
||||
color: AFThemeExtension.of(context).textColor,
|
||||
),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
radius: const BorderRadius.all(Radius.circular(14)),
|
||||
leftIcon: svgWidget(
|
||||
@ -62,7 +65,8 @@ class _ChoicechipFilterDesc extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final arrow = Transform.rotate(
|
||||
angle: -math.pi / 2,
|
||||
child: svgWidget("home/arrow_left"),
|
||||
child: svgWidget("home/arrow_left",
|
||||
color: AFThemeExtension.of(context).textColor),
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 2),
|
||||
|
@ -18,14 +18,19 @@ class ConditionButton extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final arrow = Transform.rotate(
|
||||
angle: -math.pi / 2,
|
||||
child: svgWidget("home/arrow_left"),
|
||||
child: svgWidget("home/arrow_left",
|
||||
color: AFThemeExtension.of(context).textColor),
|
||||
);
|
||||
|
||||
return SizedBox(
|
||||
height: 20,
|
||||
child: FlowyButton(
|
||||
useIntrinsicWidth: true,
|
||||
text: FlowyText(conditionName, fontSize: 10),
|
||||
text: FlowyText(
|
||||
conditionName,
|
||||
fontSize: 10,
|
||||
color: AFThemeExtension.of(context).textColor,
|
||||
),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||
radius: const BorderRadius.all(Radius.circular(2)),
|
||||
rightIcon: arrow,
|
||||
|
@ -3,6 +3,7 @@ import 'package:appflowy/plugins/database_view/grid/presentation/layout/sizes.da
|
||||
import 'package:appflowy/plugins/database_view/grid/presentation/widgets/header/field_type_extension.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra/theme_extension.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/text.dart';
|
||||
@ -117,19 +118,16 @@ class _FilterTextFieldDelegate extends SliverPersistentHeaderDelegate {
|
||||
@override
|
||||
Widget build(
|
||||
BuildContext context, double shrinkOffset, bool overlapsContent) {
|
||||
return Padding(
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Container(
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
height: fixHeight,
|
||||
child: FlowyTextField(
|
||||
hintText: LocaleKeys.grid_settings_filterBy.tr(),
|
||||
onChanged: (text) {
|
||||
context
|
||||
.read<GridCreateFilterBloc>()
|
||||
.add(GridCreateFilterEvent.didReceiveFilterText(text));
|
||||
},
|
||||
),
|
||||
height: fixHeight,
|
||||
child: FlowyTextField(
|
||||
hintText: LocaleKeys.grid_settings_filterBy.tr(),
|
||||
onChanged: (text) {
|
||||
context
|
||||
.read<GridCreateFilterBloc>()
|
||||
.add(GridCreateFilterEvent.didReceiveFilterText(text));
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -158,7 +156,11 @@ class _FilterPropertyCell extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FlowyButton(
|
||||
text: FlowyText.medium(fieldInfo.name),
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
text: FlowyText.medium(
|
||||
fieldInfo.name,
|
||||
color: AFThemeExtension.of(context).textColor,
|
||||
),
|
||||
onTap: () => onTap(fieldInfo),
|
||||
leftIcon: svgWidget(
|
||||
fieldInfo.fieldType.iconName(),
|
||||
|
@ -3,6 +3,7 @@ import 'package:appflowy/workspace/presentation/widgets/pop_up_action.dart';
|
||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra/theme_extension.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@ -31,6 +32,7 @@ class _DisclosureButtonState extends State<DisclosureButton> {
|
||||
.toList(),
|
||||
buildChild: (controller) {
|
||||
return FlowyIconButton(
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
width: 20,
|
||||
icon: svgWidget(
|
||||
"editor/details",
|
||||
|
@ -71,7 +71,10 @@ class _AddFilterButtonState extends State<AddFilterButton> {
|
||||
SizedBox(
|
||||
height: 28,
|
||||
child: FlowyButton(
|
||||
text: FlowyText(LocaleKeys.grid_settings_addFilter.tr()),
|
||||
text: FlowyText(
|
||||
LocaleKeys.grid_settings_addFilter.tr(),
|
||||
color: AFThemeExtension.of(context).textColor,
|
||||
),
|
||||
useIntrinsicWidth: true,
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
leftIcon: svgWidget(
|
||||
|
@ -14,12 +14,15 @@ class GridAddRowButton extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FlowyButton(
|
||||
text: FlowyText.medium(LocaleKeys.grid_row_newRow.tr()),
|
||||
text: FlowyText.medium(
|
||||
LocaleKeys.grid_row_newRow.tr(),
|
||||
color: Theme.of(context).colorScheme.tertiary,
|
||||
),
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
onTap: () => context.read<GridBloc>().add(const GridEvent.createRow()),
|
||||
leftIcon: svgWidget(
|
||||
"home/add",
|
||||
color: Theme.of(context).iconTheme.color,
|
||||
color: Theme.of(context).colorScheme.tertiary,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -164,11 +164,10 @@ class FieldCellButton extends StatelessWidget {
|
||||
.replaceAll(Characters(''), Characters('\u{200B}'))
|
||||
.toString();
|
||||
return FlowyButton(
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
hoverColor: AFThemeExtension.of(context).greyHover,
|
||||
onTap: onTap,
|
||||
leftIcon: svgWidget(
|
||||
field.fieldType.iconName(),
|
||||
color: Theme.of(context).iconTheme.color,
|
||||
leftIcon: FlowySvg(
|
||||
name: field.fieldType.iconName(),
|
||||
),
|
||||
radius: BorderRadius.zero,
|
||||
text: FlowyText.medium(
|
||||
|
@ -5,6 +5,7 @@ import 'package:appflowy/startup/startup.dart';
|
||||
import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
|
||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra/theme_extension.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/button.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||
@ -81,8 +82,10 @@ class _EditFieldButton extends StatelessWidget {
|
||||
return SizedBox(
|
||||
height: GridSize.popoverItemHeight,
|
||||
child: FlowyButton(
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
text: FlowyText.medium(
|
||||
LocaleKeys.grid_field_editProperty.tr(),
|
||||
color: AFThemeExtension.of(context).textColor,
|
||||
),
|
||||
onTap: onTap,
|
||||
),
|
||||
@ -148,9 +151,12 @@ class FieldActionCell extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FlowyButton(
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
text: FlowyText.medium(
|
||||
action.title(),
|
||||
color: enable ? null : Theme.of(context).disabledColor,
|
||||
color: enable
|
||||
? AFThemeExtension.of(context).textColor
|
||||
: Theme.of(context).disabledColor,
|
||||
),
|
||||
onTap: () {
|
||||
if (enable) {
|
||||
@ -160,7 +166,7 @@ class FieldActionCell extends StatelessWidget {
|
||||
leftIcon: svgWidget(
|
||||
action.iconName(),
|
||||
color: enable
|
||||
? Theme.of(context).colorScheme.onSurface
|
||||
? AFThemeExtension.of(context).textColor
|
||||
: Theme.of(context).disabledColor,
|
||||
),
|
||||
);
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra/theme_extension.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -57,7 +58,11 @@ class FieldTypeCell extends StatelessWidget {
|
||||
return SizedBox(
|
||||
height: GridSize.popoverItemHeight,
|
||||
child: FlowyButton(
|
||||
text: FlowyText.medium(fieldType.title()),
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
text: FlowyText.medium(
|
||||
fieldType.title(),
|
||||
color: AFThemeExtension.of(context).textColor,
|
||||
),
|
||||
onTap: () => onSelectField(fieldType),
|
||||
leftIcon: svgWidget(
|
||||
fieldType.iconName(),
|
||||
|
@ -4,6 +4,7 @@ import 'package:appflowy/plugins/database_view/application/field/type_option/typ
|
||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||
import 'package:dartz/dartz.dart' show Either;
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra/theme_extension.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/field_entities.pb.dart';
|
||||
@ -110,8 +111,10 @@ class _SwitchFieldButton extends StatelessWidget {
|
||||
Widget _buildMoreButton(BuildContext context) {
|
||||
final bloc = context.read<FieldTypeOptionEditBloc>();
|
||||
return FlowyButton(
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
text: FlowyText.medium(
|
||||
bloc.state.field.fieldType.title(),
|
||||
color: AFThemeExtension.of(context).textColor,
|
||||
),
|
||||
margin: GridSize.typeOptionContentInsets,
|
||||
leftIcon: svgWidget(
|
||||
|
@ -178,12 +178,9 @@ class CreateFieldButton extends StatelessWidget {
|
||||
child: FlowyButton(
|
||||
radius: BorderRadius.zero,
|
||||
text: FlowyText.medium(LocaleKeys.grid_field_newColumn.tr()),
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
hoverColor: AFThemeExtension.of(context).greyHover,
|
||||
onTap: () {},
|
||||
leftIcon: svgWidget(
|
||||
"home/add",
|
||||
color: Theme.of(context).iconTheme.color,
|
||||
),
|
||||
leftIcon: const FlowySvg(name: 'home/add'),
|
||||
),
|
||||
popupBuilder: (BuildContext popover) {
|
||||
return FieldEditor(
|
||||
|
@ -151,10 +151,7 @@ class DateFormatButton extends StatelessWidget {
|
||||
margin: buttonMargins,
|
||||
onTap: onTap,
|
||||
onHover: onHover,
|
||||
rightIcon: svgWidget(
|
||||
"grid/more",
|
||||
color: Theme.of(context).iconTheme.color,
|
||||
),
|
||||
rightIcon: const FlowySvg(name: 'grid/more'),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -182,10 +179,7 @@ class TimeFormatButton extends StatelessWidget {
|
||||
margin: buttonMargins,
|
||||
onTap: onTap,
|
||||
onHover: onHover,
|
||||
rightIcon: svgWidget(
|
||||
"grid/more",
|
||||
color: Theme.of(context).iconTheme.color,
|
||||
),
|
||||
rightIcon: const FlowySvg(name: 'grid/more'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'package:appflowy/plugins/database_view/application/field/type_option/select_option_type_option_bloc.dart';
|
||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra/theme_extension.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-database/select_type_option.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -243,7 +244,11 @@ class _AddOptionButton extends StatelessWidget {
|
||||
child: SizedBox(
|
||||
height: GridSize.popoverItemHeight,
|
||||
child: FlowyButton(
|
||||
text: FlowyText.medium(LocaleKeys.grid_field_addSelectOption.tr()),
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
text: FlowyText.medium(
|
||||
LocaleKeys.grid_field_addSelectOption.tr(),
|
||||
color: AFThemeExtension.of(context).textColor,
|
||||
),
|
||||
onTap: () {
|
||||
context
|
||||
.read<SelectOptionTypeOptionBloc>()
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'package:appflowy/plugins/database_view/application/field/type_option/edit_select_option_bloc.dart';
|
||||
import 'package:appflowy/plugins/database_view/widgets/row/cells/select_option_cell/extension.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra/theme_extension.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/text.dart';
|
||||
@ -103,7 +104,11 @@ class _DeleteTag extends StatelessWidget {
|
||||
return SizedBox(
|
||||
height: GridSize.popoverItemHeight,
|
||||
child: FlowyButton(
|
||||
text: FlowyText.medium(LocaleKeys.grid_selectOption_deleteTag.tr()),
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
text: FlowyText.medium(
|
||||
LocaleKeys.grid_selectOption_deleteTag.tr(),
|
||||
color: AFThemeExtension.of(context).textColor,
|
||||
),
|
||||
leftIcon: svgWidget(
|
||||
"grid/delete",
|
||||
color: Theme.of(context).iconTheme.color,
|
||||
|
@ -3,6 +3,7 @@ import 'package:appflowy/plugins/database_view/grid/application/row/row_action_s
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra/theme_extension.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/text.dart';
|
||||
@ -56,9 +57,12 @@ class _ActionCell extends StatelessWidget {
|
||||
return SizedBox(
|
||||
height: GridSize.popoverItemHeight,
|
||||
child: FlowyButton(
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
text: FlowyText.medium(
|
||||
action.title(),
|
||||
color: action.enable() ? null : Theme.of(context).disabledColor,
|
||||
color: action.enable()
|
||||
? AFThemeExtension.of(context).textColor
|
||||
: Theme.of(context).disabledColor,
|
||||
),
|
||||
onTap: () {
|
||||
if (action.enable()) {
|
||||
|
@ -5,6 +5,7 @@ import 'package:appflowy/plugins/database_view/grid/application/row/row_bloc.dar
|
||||
import 'package:appflowy/plugins/database_view/widgets/row/cell_builder.dart';
|
||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra/theme_extension.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -152,11 +153,15 @@ class _InsertButton extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return FlowyIconButton(
|
||||
tooltipText: LocaleKeys.tooltip_addNewRow.tr(),
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
width: 20,
|
||||
height: 30,
|
||||
onPressed: () => context.read<RowBloc>().add(const RowEvent.createRow()),
|
||||
iconPadding: const EdgeInsets.all(3),
|
||||
icon: svgWidget("home/add"),
|
||||
icon: svgWidget(
|
||||
'home/add',
|
||||
color: Theme.of(context).colorScheme.tertiary,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -182,11 +187,15 @@ class _MenuButtonState extends State<_MenuButton> {
|
||||
Widget build(BuildContext context) {
|
||||
return FlowyIconButton(
|
||||
tooltipText: LocaleKeys.tooltip_openMenu.tr(),
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
width: 20,
|
||||
height: 30,
|
||||
onPressed: () => widget.openMenu(),
|
||||
iconPadding: const EdgeInsets.all(3),
|
||||
icon: svgWidget("editor/details"),
|
||||
icon: svgWidget(
|
||||
'editor/details',
|
||||
color: Theme.of(context).colorScheme.tertiary,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import 'package:appflowy/plugins/database_view/grid/presentation/layout/sizes.da
|
||||
import 'package:appflowy/plugins/database_view/grid/presentation/widgets/header/field_type_extension.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra/theme_extension.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/text.dart';
|
||||
@ -116,19 +117,16 @@ class _FilterTextFieldDelegate extends SliverPersistentHeaderDelegate {
|
||||
@override
|
||||
Widget build(
|
||||
BuildContext context, double shrinkOffset, bool overlapsContent) {
|
||||
return Padding(
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Container(
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
height: fixHeight,
|
||||
child: FlowyTextField(
|
||||
hintText: LocaleKeys.grid_settings_sortBy.tr(),
|
||||
onChanged: (text) {
|
||||
context
|
||||
.read<CreateSortBloc>()
|
||||
.add(CreateSortEvent.didReceiveFilterText(text));
|
||||
},
|
||||
),
|
||||
height: fixHeight,
|
||||
child: FlowyTextField(
|
||||
hintText: LocaleKeys.grid_settings_sortBy.tr(),
|
||||
onChanged: (text) {
|
||||
context
|
||||
.read<CreateSortBloc>()
|
||||
.add(CreateSortEvent.didReceiveFilterText(text));
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -157,7 +155,11 @@ class _SortPropertyCell extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FlowyButton(
|
||||
text: FlowyText.medium(fieldInfo.name),
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
text: FlowyText.medium(
|
||||
fieldInfo.name,
|
||||
color: AFThemeExtension.of(context).textColor,
|
||||
),
|
||||
onTap: () => onTap(fieldInfo),
|
||||
leftIcon: svgWidget(
|
||||
fieldInfo.fieldType.iconName(),
|
||||
|
@ -37,7 +37,10 @@ class SortChoiceButton extends StatelessWidget {
|
||||
return FlowyButton(
|
||||
decoration: decoration,
|
||||
useIntrinsicWidth: true,
|
||||
text: FlowyText(text),
|
||||
text: FlowyText(
|
||||
text,
|
||||
color: AFThemeExtension.of(context).textColor,
|
||||
),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
radius: BorderRadius.all(radius),
|
||||
leftIcon: leftIcon,
|
||||
|
@ -182,13 +182,11 @@ class _AddSortButtonState extends State<_AddSortButton> {
|
||||
child: SizedBox(
|
||||
height: GridSize.popoverItemHeight,
|
||||
child: FlowyButton(
|
||||
hoverColor: AFThemeExtension.of(context).greyHover,
|
||||
disable: getCreatableSorts(widget.fieldController.fieldInfos).isEmpty,
|
||||
text: FlowyText.medium(LocaleKeys.grid_sort_addSort.tr()),
|
||||
onTap: () => _popoverController.show(),
|
||||
leftIcon: svgWidget(
|
||||
"home/add",
|
||||
color: Theme.of(context).iconTheme.color,
|
||||
),
|
||||
leftIcon: const FlowySvg(name: 'home/add'),
|
||||
),
|
||||
),
|
||||
popupBuilder: (BuildContext context) {
|
||||
@ -220,10 +218,7 @@ class _DeleteSortButton extends StatelessWidget {
|
||||
.read<SortEditorBloc>()
|
||||
.add(const SortEditorEvent.deleteAllSorts());
|
||||
},
|
||||
leftIcon: svgWidget(
|
||||
"editor/delete",
|
||||
color: Theme.of(context).iconTheme.color,
|
||||
),
|
||||
leftIcon: const FlowySvg(name: 'editor/delete'),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
@ -55,7 +55,10 @@ class SortChoiceChip extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final arrow = Transform.rotate(
|
||||
angle: -math.pi / 2,
|
||||
child: svgWidget("home/arrow_left"),
|
||||
child: svgWidget(
|
||||
"home/arrow_left",
|
||||
color: Theme.of(context).iconTheme.color,
|
||||
),
|
||||
);
|
||||
|
||||
final text = LocaleKeys.grid_settings_sort.tr();
|
||||
|
@ -25,7 +25,7 @@ class _FilterButtonState extends State<FilterButton> {
|
||||
return BlocBuilder<GridFilterMenuBloc, GridFilterMenuState>(
|
||||
builder: (context, state) {
|
||||
final textColor = state.filters.isEmpty
|
||||
? null
|
||||
? AFThemeExtension.of(context).textColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
|
||||
return _wrapPopover(
|
||||
|
@ -5,6 +5,7 @@ import 'package:appflowy/plugins/database_view/grid/presentation/widgets/header/
|
||||
import 'package:appflowy/startup/startup.dart';
|
||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra/theme_extension.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
@ -115,7 +116,11 @@ class _GridPropertyCellState extends State<_GridPropertyCell> {
|
||||
triggerActions: PopoverTriggerFlags.none,
|
||||
margin: EdgeInsets.zero,
|
||||
child: FlowyButton(
|
||||
text: FlowyText.medium(widget.fieldInfo.name),
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
text: FlowyText.medium(
|
||||
widget.fieldInfo.name,
|
||||
color: AFThemeExtension.of(context).textColor,
|
||||
),
|
||||
leftIcon: svgWidget(
|
||||
widget.fieldInfo.fieldType.iconName(),
|
||||
color: Theme.of(context).iconTheme.color,
|
||||
|
@ -2,6 +2,7 @@ import 'package:appflowy/plugins/database_view/application/field/field_controlle
|
||||
import 'package:appflowy/plugins/database_view/application/setting/setting_bloc.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra/theme_extension.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/text.dart';
|
||||
@ -71,9 +72,12 @@ class _SettingItem extends StatelessWidget {
|
||||
return SizedBox(
|
||||
height: GridSize.popoverItemHeight,
|
||||
child: FlowyButton(
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
text: FlowyText.medium(
|
||||
action.title(),
|
||||
color: action.enable() ? null : Theme.of(context).disabledColor,
|
||||
color: action.enable()
|
||||
? AFThemeExtension.of(context).textColor
|
||||
: Theme.of(context).disabledColor,
|
||||
),
|
||||
onTap: () => onAction(action),
|
||||
leftIcon: svgWidget(
|
||||
|
@ -52,6 +52,7 @@ class _SettingButtonState extends State<SettingButton> {
|
||||
triggerActions: PopoverTriggerFlags.none,
|
||||
child: FlowyTextButton(
|
||||
LocaleKeys.settings_title.tr(),
|
||||
fontColor: AFThemeExtension.of(context).textColor,
|
||||
fillColor: Colors.transparent,
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
padding: GridSize.typeOptionContentInsets,
|
||||
|
@ -24,7 +24,7 @@ class _SortButtonState extends State<SortButton> {
|
||||
return BlocBuilder<SortMenuBloc, SortMenuState>(
|
||||
builder: (context, state) {
|
||||
final textColor = state.sortInfos.isEmpty
|
||||
? null
|
||||
? AFThemeExtension.of(context).textColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
|
||||
return wrapPopover(
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra/theme_extension.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
@ -116,7 +117,11 @@ class _ChecklistOptionCellState extends State<_ChecklistOptionCell> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: FlowyButton(
|
||||
text: FlowyText(widget.option.data.name),
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
text: FlowyText(
|
||||
widget.option.data.name,
|
||||
color: AFThemeExtension.of(context).textColor,
|
||||
),
|
||||
leftIcon: icon,
|
||||
onTap: () => context
|
||||
.read<ChecklistCellEditorBloc>()
|
||||
@ -132,6 +137,7 @@ class _ChecklistOptionCellState extends State<_ChecklistOptionCell> {
|
||||
|
||||
Widget _disclosureButton() {
|
||||
return FlowyIconButton(
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
width: 20,
|
||||
onPressed: () => _popoverController.show(),
|
||||
iconPadding: const EdgeInsets.fromLTRB(2, 2, 2, 2),
|
||||
|
@ -20,7 +20,7 @@ class ChecklistProgressBar extends StatelessWidget {
|
||||
percent: percent,
|
||||
padding: EdgeInsets.zero,
|
||||
progressColor: Theme.of(context).colorScheme.primary,
|
||||
backgroundColor: AFThemeExtension.of(context).tint9,
|
||||
backgroundColor: AFThemeExtension.of(context).progressBarBGcolor,
|
||||
barRadius: const Radius.circular(5),
|
||||
);
|
||||
}
|
||||
|
@ -385,10 +385,7 @@ class _DateTypeOptionButton extends StatelessWidget {
|
||||
child: FlowyButton(
|
||||
text: FlowyText.medium(title),
|
||||
margin: GridSize.typeOptionContentInsets,
|
||||
rightIcon: svgWidget(
|
||||
"grid/more",
|
||||
color: Theme.of(context).iconTheme.color,
|
||||
),
|
||||
rightIcon: const FlowySvg(name: 'grid/more'),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -106,7 +106,11 @@ class SelectOptionTag extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Flexible(
|
||||
child: FlowyText.medium(name, overflow: TextOverflow.ellipsis),
|
||||
child: FlowyText.medium(
|
||||
name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
if (onRemove != null)
|
||||
FlowyIconButton(
|
||||
@ -116,7 +120,7 @@ class SelectOptionTag extends StatelessWidget {
|
||||
hoverColor: Colors.transparent,
|
||||
icon: svgWidget(
|
||||
'home/close',
|
||||
color: Theme.of(context).iconTheme.color,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -139,6 +143,9 @@ class SelectOptionTagCell extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FlowyHover(
|
||||
style: HoverStyle(
|
||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||
),
|
||||
child: InkWell(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
|
@ -210,7 +210,7 @@ class _CreateOptionCell extends StatelessWidget {
|
||||
alignment: Alignment.centerLeft,
|
||||
child: SelectOptionTag(
|
||||
name: name,
|
||||
color: AFThemeExtension.of(context).lightGreyHover,
|
||||
color: AFThemeExtension.of(context).greyHover,
|
||||
onSelected: () => context
|
||||
.read<SelectOptionCellEditorBloc>()
|
||||
.add(SelectOptionEditorEvent.newOption(name)),
|
||||
|
@ -5,6 +5,7 @@ import 'package:appflowy/workspace/presentation/home/toast.dart';
|
||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra/theme_extension.dart';
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@ -211,10 +212,8 @@ class _EditURLAccessoryState extends State<_EditURLAccessory>
|
||||
controller: _popoverController,
|
||||
direction: PopoverDirection.bottomWithLeftAligned,
|
||||
offset: const Offset(0, 8),
|
||||
child: svgWidget(
|
||||
"editor/edit",
|
||||
color: Theme.of(context).iconTheme.color,
|
||||
),
|
||||
child: svgWidget("editor/edit",
|
||||
color: AFThemeExtension.of(context).textColor),
|
||||
popupBuilder: (BuildContext popoverContext) {
|
||||
return URLEditorPopover(
|
||||
cellController:
|
||||
|
@ -1,19 +1,53 @@
|
||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||
import 'package:appflowy/plugins/database_view/application/database_view_service.dart';
|
||||
import 'package:appflowy/plugins/document/presentation/plugins/board/board_node_widget.dart';
|
||||
import 'package:appflowy/plugins/document/presentation/plugins/grid/grid_node_widget.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
|
||||
import 'package:appflowy/workspace/application/app/app_service.dart';
|
||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
|
||||
const String kAppID = 'app_id';
|
||||
const String kViewID = 'view_id';
|
||||
|
||||
extension InsertPage on EditorState {
|
||||
void insertPage(ViewPB appPB, ViewPB viewPB) {
|
||||
Future<void> insertPage(ViewPB appPB, ViewPB viewPB) async {
|
||||
final selection = service.selectionService.currentSelection.value;
|
||||
final textNodes =
|
||||
service.selectionService.currentSelectedNodes.whereType<TextNode>();
|
||||
if (selection == null || textNodes.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get the database that the view is associated with
|
||||
final database =
|
||||
await DatabaseViewBackendService(viewId: viewPB.id).openGrid().then(
|
||||
(value) => value.getLeftOrNull(),
|
||||
);
|
||||
|
||||
if (database == null) {
|
||||
throw StateError(
|
||||
'The database associated with ${viewPB.id} could not be found while attempting to create a referenced ${viewPB.layout.name}.');
|
||||
}
|
||||
|
||||
final prefix = referencedBoardPrefix(viewPB.layout);
|
||||
|
||||
final ref = await AppBackendService().createView(
|
||||
appId: appPB.id,
|
||||
name: "$prefix ${viewPB.name}",
|
||||
layoutType: viewPB.layout,
|
||||
ext: {
|
||||
'database_id': database.id,
|
||||
},
|
||||
).then(
|
||||
(value) => value.getLeftOrNull(),
|
||||
);
|
||||
|
||||
// TODO(a-wallen): Show error dialog here.
|
||||
if (ref == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final transaction = this.transaction;
|
||||
transaction.insertNode(
|
||||
selection.end.path,
|
||||
@ -21,13 +55,24 @@ extension InsertPage on EditorState {
|
||||
type: _convertPageType(viewPB),
|
||||
attributes: {
|
||||
kAppID: appPB.id,
|
||||
kViewID: viewPB.id,
|
||||
kViewID: ref.id,
|
||||
},
|
||||
),
|
||||
);
|
||||
apply(transaction);
|
||||
}
|
||||
|
||||
String referencedBoardPrefix(ViewLayoutPB layout) {
|
||||
switch (layout) {
|
||||
case ViewLayoutPB.Grid:
|
||||
return LocaleKeys.grid_referencedGridPrefix.tr();
|
||||
case ViewLayoutPB.Board:
|
||||
return LocaleKeys.board_referencedBoardPrefix.tr();
|
||||
default:
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
|
||||
String _convertPageType(ViewPB viewPB) {
|
||||
switch (viewPB.layout) {
|
||||
case ViewLayoutPB.Grid:
|
||||
|
@ -6,6 +6,7 @@ import 'package:flowy_infra/image.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/button.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'insert_page_command.dart';
|
||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
@ -57,7 +58,7 @@ void showLinkToPageMenu(
|
||||
);
|
||||
});
|
||||
|
||||
Overlay.of(context)?.insert(_linkToPageMenu!);
|
||||
Overlay.of(context).insert(_linkToPageMenu!);
|
||||
|
||||
editorState.service.selectionService.currentSelection
|
||||
.addListener(dismissLinkToPageMenu);
|
||||
@ -91,14 +92,50 @@ class LinkToPageMenu extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LinkToPageMenuState extends State<LinkToPageMenu> {
|
||||
final _focusNode = FocusNode(debugLabel: 'reference_list_widget');
|
||||
EditorStyle get style => widget.editorState.editorStyle;
|
||||
int _selectedIndex = 0;
|
||||
int _totalItems = 0;
|
||||
Future<List<dartz.Tuple2<ViewPB, List<ViewPB>>>>? _availableLayout;
|
||||
final Map<int, dartz.Tuple2<ViewPB, ViewPB>> _items = {};
|
||||
|
||||
Future<List<dartz.Tuple2<ViewPB, List<ViewPB>>>> fetchItems() async {
|
||||
final items = await AppBackendService().fetchViews(widget.layoutType);
|
||||
|
||||
int index = 0;
|
||||
for (final app in items) {
|
||||
for (final view in app.value2) {
|
||||
_items.putIfAbsent(index, () => dartz.Tuple2(app.value1, view));
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
|
||||
_totalItems = _items.length;
|
||||
return items;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_availableLayout = fetchItems();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_focusNode.requestFocus();
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_focusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: Colors.transparent,
|
||||
width: 300,
|
||||
return Focus(
|
||||
focusNode: _focusNode,
|
||||
onKey: _onKey,
|
||||
child: Container(
|
||||
width: 300,
|
||||
padding: const EdgeInsets.fromLTRB(10, 6, 10, 6),
|
||||
decoration: BoxDecoration(
|
||||
color: style.selectionMenuBackgroundColor,
|
||||
@ -111,12 +148,57 @@ class _LinkToPageMenuState extends State<LinkToPageMenu> {
|
||||
],
|
||||
borderRadius: BorderRadius.circular(6.0),
|
||||
),
|
||||
child: _buildListWidget(context),
|
||||
child: _buildListWidget(context, _selectedIndex, _availableLayout),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildListWidget(BuildContext context) {
|
||||
KeyEventResult _onKey(FocusNode node, RawKeyEvent event) {
|
||||
if (event is! RawKeyDownEvent ||
|
||||
_availableLayout == null ||
|
||||
_items.isEmpty) {
|
||||
return KeyEventResult.ignored;
|
||||
}
|
||||
|
||||
final acceptedKeys = [
|
||||
LogicalKeyboardKey.arrowUp,
|
||||
LogicalKeyboardKey.arrowDown,
|
||||
LogicalKeyboardKey.tab,
|
||||
LogicalKeyboardKey.enter
|
||||
];
|
||||
|
||||
if (!acceptedKeys.contains(event.logicalKey)) {
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
var newSelectedIndex = _selectedIndex;
|
||||
if (event.logicalKey == LogicalKeyboardKey.arrowDown &&
|
||||
newSelectedIndex != _totalItems - 1) {
|
||||
newSelectedIndex += 1;
|
||||
} else if (event.logicalKey == LogicalKeyboardKey.arrowUp &&
|
||||
newSelectedIndex != 0) {
|
||||
newSelectedIndex -= 1;
|
||||
} else if (event.logicalKey == LogicalKeyboardKey.tab) {
|
||||
newSelectedIndex += 1;
|
||||
newSelectedIndex %= _totalItems;
|
||||
} else if (event.logicalKey == LogicalKeyboardKey.enter) {
|
||||
widget.onSelected(
|
||||
_items[_selectedIndex]!.value1, _items[_selectedIndex]!.value2);
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_selectedIndex = newSelectedIndex;
|
||||
});
|
||||
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
Widget _buildListWidget(
|
||||
BuildContext context,
|
||||
int selectedIndex,
|
||||
Future<List<dartz.Tuple2<ViewPB, List<ViewPB>>>>? items,
|
||||
) {
|
||||
int index = 0;
|
||||
return FutureBuilder<List<dartz.Tuple2<ViewPB, List<ViewPB>>>>(
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData &&
|
||||
@ -146,6 +228,7 @@ class _LinkToPageMenuState extends State<LinkToPageMenu> {
|
||||
for (final value in view.value2) {
|
||||
children.add(
|
||||
FlowyButton(
|
||||
isSelected: index == _selectedIndex,
|
||||
leftIcon: svgWidget(
|
||||
_iconName(value),
|
||||
color: Theme.of(context).iconTheme.color,
|
||||
@ -154,6 +237,8 @@ class _LinkToPageMenuState extends State<LinkToPageMenu> {
|
||||
onTap: () => widget.onSelected(view.value1, value),
|
||||
),
|
||||
);
|
||||
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -168,7 +253,7 @@ class _LinkToPageMenuState extends State<LinkToPageMenu> {
|
||||
);
|
||||
}
|
||||
},
|
||||
future: AppBackendService().fetchViews(widget.layoutType),
|
||||
future: items,
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user