chore: code cleanup according to unintroduced lints (#4488)

* chore: remove redundant arguments

* chore: remove unused constructor params

* chore: reorganize constructors

* chore: remove unnecessary awaits in returns

* chore: remove unnecessary paranthesis

* chore: add lints

* chore: clean up after merge

* chore: add sort constructors first

* chore: organize constructors in blocs

* chore: use sizedbox.shrink over empty container
This commit is contained in:
Mathias Mogensen
2024-01-25 16:37:36 +01:00
committed by GitHub
parent 747abba87f
commit acc03b8cc4
447 changed files with 3333 additions and 3412 deletions

View File

@ -21,6 +21,22 @@ import 'container/card_container.dart';
/// Edit a database row with card style widget
class RowCard extends StatefulWidget {
const RowCard({
super.key,
required this.fieldController,
required this.rowMeta,
required this.viewId,
required this.isEditing,
required this.rowCache,
required this.cellBuilder,
required this.openCard,
required this.onStartEditing,
required this.onEndEditing,
required this.styleConfiguration,
this.groupingFieldId,
this.groupId,
});
final FieldController fieldController;
final RowMetaPB rowMeta;
final String viewId;
@ -44,22 +60,6 @@ class RowCard extends StatefulWidget {
final RowCardStyleConfiguration styleConfiguration;
const RowCard({
super.key,
required this.fieldController,
required this.rowMeta,
required this.viewId,
required this.isEditing,
required this.rowCache,
required this.cellBuilder,
required this.openCard,
required this.onStartEditing,
required this.onEndEditing,
required this.styleConfiguration,
this.groupingFieldId,
this.groupId,
});
@override
State<RowCard> createState() => _RowCardState();
}
@ -250,11 +250,9 @@ class MoreCardOptionsAccessory extends StatelessWidget with CardAccessory {
}
class EditCardAccessory extends StatelessWidget with CardAccessory {
const EditCardAccessory({super.key, required this.rowNotifier});
final EditableRowNotifier rowNotifier;
const EditCardAccessory({
super.key,
required this.rowNotifier,
});
@override
Widget build(BuildContext context) {
@ -275,15 +273,15 @@ class EditCardAccessory extends StatelessWidget with CardAccessory {
}
class RowCardStyleConfiguration {
final CardCellStyleMap cellStyleMap;
final bool showAccessory;
final EdgeInsets cardPadding;
final HoverStyle? hoverStyle;
const RowCardStyleConfiguration({
required this.cellStyleMap,
this.showAccessory = true,
this.cardPadding = const EdgeInsets.all(8),
this.hoverStyle,
});
final CardCellStyleMap cellStyleMap;
final bool showAccessory;
final EdgeInsets cardPadding;
final HoverStyle? hoverStyle;
}

View File

@ -1,27 +1,19 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:appflowy/plugins/database/application/cell/cell_controller.dart';
import 'package:appflowy/plugins/database/application/field/field_controller.dart';
import 'package:appflowy/plugins/database/application/row/row_cache.dart';
import 'package:appflowy/plugins/database/application/row/row_listener.dart';
import 'package:appflowy/plugins/database/widgets/setting/field_visibility_extension.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/row_entities.pb.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'card_bloc.freezed.dart';
class CardBloc extends Bloc<CardEvent, CardState> {
final FieldController fieldController;
final String rowId;
final String? groupFieldId;
final RowCache _rowCache;
final String viewId;
final RowListener _rowListener;
VoidCallback? _rowCallback;
CardBloc({
required this.fieldController,
required this.groupFieldId,
@ -43,6 +35,19 @@ class CardBloc extends Bloc<CardEvent, CardState> {
isEditing,
),
) {
_dispatch();
}
final FieldController fieldController;
final String rowId;
final String? groupFieldId;
final RowCache _rowCache;
final String viewId;
final RowListener _rowListener;
VoidCallback? _rowCallback;
void _dispatch() {
on<CardEvent>(
(event, emit) async {
await event.when(

View File

@ -16,14 +16,15 @@ typedef CardAccessoryBuilder = List<CardAccessory> Function(
);
class CardAccessoryContainer extends StatelessWidget {
final void Function(AccessoryType) onTapAccessory;
final List<CardAccessory> accessories;
const CardAccessoryContainer({
super.key,
required this.accessories,
required this.onTapAccessory,
super.key,
});
final List<CardAccessory> accessories;
final void Function(AccessoryType) onTapAccessory;
@override
Widget build(BuildContext context) {
final children = accessories.map<Widget>((accessory) {
@ -77,13 +78,11 @@ class CardAccessoryContainer extends StatelessWidget {
color: Theme.of(context).brightness == Brightness.light
? const Color(0xFF1F2329).withOpacity(0.12)
: const Color(0xff59647a),
width: 1.0,
),
),
boxShadow: [
BoxShadow(
blurRadius: 4,
spreadRadius: 0,
color: const Color(0xFF1F2329).withOpacity(0.02),
),
BoxShadow(

View File

@ -105,10 +105,10 @@ class _CardEnterRegion extends StatelessWidget {
}
class _CardContainerNotifier extends ChangeNotifier {
bool _onEnter = false;
_CardContainerNotifier();
bool _onEnter = false;
set onEnter(bool value) {
if (_onEnter != value) {
_onEnter = value;

View File

@ -16,10 +16,10 @@ import 'card_cell_skeleton/url_card_cell.dart';
typedef CardCellStyleMap = Map<FieldType, CardCellStyle>;
class CardCellBuilder {
final DatabaseController databaseController;
CardCellBuilder({required this.databaseController});
final DatabaseController databaseController;
Widget build({
required CellContext cellContext,
required CardCellStyleMap styleMap,

View File

@ -2,15 +2,15 @@ import 'package:appflowy/plugins/database/application/cell/cell_controller.dart'
import 'package:flutter/material.dart';
abstract class CardCell<T extends CardCellStyle> extends StatefulWidget {
final T style;
const CardCell({super.key, required this.style});
final T style;
}
abstract class CardCellStyle {
final EdgeInsetsGeometry padding;
const CardCellStyle({required this.padding});
final EdgeInsetsGeometry padding;
}
S? isStyleOrNull<S>(CardCellStyle? style) {
@ -22,23 +22,23 @@ S? isStyleOrNull<S>(CardCellStyle? style) {
}
class EditableCardNotifier {
final ValueNotifier<bool> isCellEditing;
EditableCardNotifier({bool isEditing = false})
: isCellEditing = ValueNotifier(isEditing);
final ValueNotifier<bool> isCellEditing;
void dispose() {
isCellEditing.dispose();
}
}
class EditableRowNotifier {
final Map<CellContext, EditableCardNotifier> _cells = {};
final ValueNotifier<bool> isEditing;
EditableRowNotifier({required bool isEditing})
: isEditing = ValueNotifier(isEditing);
final Map<CellContext, EditableCardNotifier> _cells = {};
final ValueNotifier<bool> isEditing;
void bindCell(
CellContext cellIdentifier,
EditableCardNotifier notifier,

View File

@ -11,22 +11,19 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'card_cell.dart';
class CheckboxCardCellStyle extends CardCellStyle {
final Size iconSize;
final bool showFieldName;
final TextStyle? textStyle;
CheckboxCardCellStyle({
required super.padding,
required this.iconSize,
required this.showFieldName,
this.textStyle,
}) : assert(!showFieldName || showFieldName && textStyle != null);
final Size iconSize;
final bool showFieldName;
final TextStyle? textStyle;
}
class CheckboxCardCell extends CardCell<CheckboxCardCellStyle> {
final DatabaseController databaseController;
final CellContext cellContext;
const CheckboxCardCell({
super.key,
required super.style,
@ -34,6 +31,9 @@ class CheckboxCardCell extends CardCell<CheckboxCardCellStyle> {
required this.cellContext,
});
final DatabaseController databaseController;
final CellContext cellContext;
@override
State<CheckboxCardCell> createState() => _CheckboxCellState();
}
@ -58,7 +58,6 @@ class _CheckboxCellState extends State<CheckboxCardCell> {
child: Row(
children: [
FlowyIconButton(
iconPadding: EdgeInsets.zero,
icon: FlowySvg(
state.isSelected
? FlowySvgs.check_filled_s

View File

@ -9,18 +9,15 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'card_cell.dart';
class ChecklistCardCellStyle extends CardCellStyle {
final TextStyle textStyle;
ChecklistCardCellStyle({
required super.padding,
required this.textStyle,
});
final TextStyle textStyle;
}
class ChecklistCardCell extends CardCell<ChecklistCardCellStyle> {
final DatabaseController databaseController;
final CellContext cellContext;
const ChecklistCardCell({
super.key,
required super.style,
@ -28,6 +25,9 @@ class ChecklistCardCell extends CardCell<ChecklistCardCellStyle> {
required this.cellContext,
});
final DatabaseController databaseController;
final CellContext cellContext;
@override
State<ChecklistCardCell> createState() => _ChecklistCellState();
}

View File

@ -8,18 +8,15 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'card_cell.dart';
class DateCardCellStyle extends CardCellStyle {
final TextStyle textStyle;
DateCardCellStyle({
required super.padding,
required this.textStyle,
});
final TextStyle textStyle;
}
class DateCardCell extends CardCell<DateCardCellStyle> {
final DatabaseController databaseController;
final CellContext cellContext;
const DateCardCell({
super.key,
required super.style,
@ -27,6 +24,9 @@ class DateCardCell extends CardCell<DateCardCellStyle> {
required this.cellContext,
});
final DatabaseController databaseController;
final CellContext cellContext;
@override
State<DateCardCell> createState() => _DateCellState();
}

View File

@ -8,18 +8,15 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'card_cell.dart';
class NumberCardCellStyle extends CardCellStyle {
final TextStyle textStyle;
const NumberCardCellStyle({
required super.padding,
required this.textStyle,
});
final TextStyle textStyle;
}
class NumberCardCell extends CardCell<NumberCardCellStyle> {
final DatabaseController databaseController;
final CellContext cellContext;
const NumberCardCell({
super.key,
required super.style,
@ -27,6 +24,9 @@ class NumberCardCell extends CardCell<NumberCardCellStyle> {
required this.cellContext,
});
final DatabaseController databaseController;
final CellContext cellContext;
@override
State<NumberCardCell> createState() => _NumberCellState();
}

View File

@ -9,22 +9,19 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'card_cell.dart';
class SelectOptionCardCellStyle extends CardCellStyle {
final double tagFontSize;
final bool wrap;
final EdgeInsets tagPadding;
SelectOptionCardCellStyle({
required super.padding,
required this.tagFontSize,
required this.wrap,
required this.tagPadding,
});
final double tagFontSize;
final bool wrap;
final EdgeInsets tagPadding;
}
class SelectOptionCardCell extends CardCell<SelectOptionCardCellStyle> {
final DatabaseController databaseController;
final CellContext cellContext;
const SelectOptionCardCell({
super.key,
required super.style,
@ -32,6 +29,9 @@ class SelectOptionCardCell extends CardCell<SelectOptionCardCellStyle> {
required this.cellContext,
});
final DatabaseController databaseController;
final CellContext cellContext;
@override
State<SelectOptionCardCell> createState() => _SelectOptionCellState();
}

View File

@ -13,33 +13,32 @@ import '../editable_cell_builder.dart';
import 'card_cell.dart';
class TextCardCellStyle extends CardCellStyle {
final TextStyle textStyle;
final TextStyle titleTextStyle;
final int? maxLines;
TextCardCellStyle({
required super.padding,
required this.textStyle,
required this.titleTextStyle,
this.maxLines = 1,
});
final TextStyle textStyle;
final TextStyle titleTextStyle;
final int? maxLines;
}
class TextCardCell extends CardCell<TextCardCellStyle> with EditableCell {
final DatabaseController databaseController;
final CellContext cellContext;
final bool showNotes;
const TextCardCell({
super.key,
required super.style,
required this.databaseController,
required this.cellContext,
this.editableNotifier,
this.showNotes = false,
this.editableNotifier,
});
final DatabaseController databaseController;
final CellContext cellContext;
final bool showNotes;
@override
final EditableCardNotifier? editableNotifier;
@ -134,7 +133,6 @@ class _TextCellState extends State<TextCardCell> {
: _buildText(state, isTitle);
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if (isTitle && widget.showNotes)
FlowyTooltip(

View File

@ -8,18 +8,15 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'card_cell.dart';
class TimestampCardCellStyle extends CardCellStyle {
final TextStyle textStyle;
TimestampCardCellStyle({
required super.padding,
required this.textStyle,
});
final TextStyle textStyle;
}
class TimestampCardCell extends CardCell<TimestampCardCellStyle> {
final DatabaseController databaseController;
final CellContext cellContext;
const TimestampCardCell({
super.key,
required super.style,
@ -27,6 +24,9 @@ class TimestampCardCell extends CardCell<TimestampCardCellStyle> {
required this.cellContext,
});
final DatabaseController databaseController;
final CellContext cellContext;
@override
State<TimestampCardCell> createState() => _TimestampCellState();
}

View File

@ -8,18 +8,15 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'card_cell.dart';
class URLCardCellStyle extends CardCellStyle {
final TextStyle textStyle;
URLCardCellStyle({
required super.padding,
required this.textStyle,
});
final TextStyle textStyle;
}
class URLCardCell extends CardCell<URLCardCellStyle> {
final DatabaseController databaseController;
final CellContext cellContext;
const URLCardCell({
super.key,
required super.style,
@ -27,6 +24,9 @@ class URLCardCell extends CardCell<URLCardCellStyle> {
required this.cellContext,
});
final DatabaseController databaseController;
final CellContext cellContext;
@override
State<URLCardCell> createState() => _URLCellState();
}

View File

@ -32,7 +32,6 @@ class DesktopGridURLSkin extends IEditableURLCellSkin {
color: Theme.of(context).colorScheme.primary,
decoration: TextDecoration.underline,
),
autofocus: false,
decoration: InputDecoration(
contentPadding: GridSize.cellContentInsets,
border: InputBorder.none,

View File

@ -25,7 +25,6 @@ class DesktopRowDetailURLSkin extends IEditableURLCellSkin {
color: Theme.of(context).colorScheme.primary,
decoration: TextDecoration.underline,
),
autofocus: false,
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(horizontal: 8, vertical: 9),
border: InputBorder.none,

View File

@ -26,11 +26,9 @@ enum EditableCellStyle {
/// Build an editable cell widget
class EditableCellBuilder {
final DatabaseController databaseController;
EditableCellBuilder({required this.databaseController});
EditableCellBuilder({
required this.databaseController,
});
final DatabaseController databaseController;
EditableCellWidget buildStyled(
CellContext cellContext,

View File

@ -15,13 +15,6 @@ import '../mobile_row_detail/mobile_row_detail_checkbox_cell.dart';
abstract class IEditableCheckboxCellSkin {
const IEditableCheckboxCellSkin();
Widget build(
BuildContext context,
CellContainerNotifier cellContainerNotifier,
CheckboxCellBloc bloc,
CheckboxCellState state,
);
factory IEditableCheckboxCellSkin.fromStyle(EditableCellStyle style) {
return switch (style) {
EditableCellStyle.desktopGrid => DesktopGridCheckboxCellSkin(),
@ -30,13 +23,16 @@ abstract class IEditableCheckboxCellSkin {
EditableCellStyle.mobileRowDetail => MobileRowDetailCheckboxCellSkin(),
};
}
Widget build(
BuildContext context,
CellContainerNotifier cellContainerNotifier,
CheckboxCellBloc bloc,
CheckboxCellState state,
);
}
class EditableCheckboxCell extends EditableCellWidget {
final DatabaseController databaseController;
final CellContext cellContext;
final IEditableCheckboxCellSkin skin;
EditableCheckboxCell({
super.key,
required this.databaseController,
@ -44,6 +40,10 @@ class EditableCheckboxCell extends EditableCellWidget {
required this.skin,
});
final DatabaseController databaseController;
final CellContext cellContext;
final IEditableCheckboxCellSkin skin;
@override
GridCellState<EditableCheckboxCell> createState() => _CheckboxCellState();
}

View File

@ -16,14 +16,6 @@ import '../mobile_row_detail/mobile_row_detail_checklist_cell.dart';
abstract class IEditableChecklistCellSkin {
const IEditableChecklistCellSkin();
Widget build(
BuildContext context,
CellContainerNotifier cellContainerNotifier,
ChecklistCellBloc bloc,
ChecklistCellState state,
PopoverController popoverController,
);
factory IEditableChecklistCellSkin.fromStyle(EditableCellStyle style) {
return switch (style) {
EditableCellStyle.desktopGrid => DesktopGridChecklistCellSkin(),
@ -32,13 +24,17 @@ abstract class IEditableChecklistCellSkin {
EditableCellStyle.mobileRowDetail => MobileRowDetailChecklistCellSkin(),
};
}
Widget build(
BuildContext context,
CellContainerNotifier cellContainerNotifier,
ChecklistCellBloc bloc,
ChecklistCellState state,
PopoverController popoverController,
);
}
class EditableChecklistCell extends EditableCellWidget {
final DatabaseController databaseController;
final CellContext cellContext;
final IEditableChecklistCellSkin skin;
EditableChecklistCell({
super.key,
required this.databaseController,
@ -46,6 +42,10 @@ class EditableChecklistCell extends EditableCellWidget {
required this.skin,
});
final DatabaseController databaseController;
final CellContext cellContext;
final IEditableChecklistCellSkin skin;
@override
GridCellState<EditableChecklistCell> createState() =>
GridChecklistCellState();

View File

@ -16,14 +16,6 @@ import '../mobile_row_detail/mobile_row_detail_date_cell.dart';
abstract class IEditableDateCellSkin {
const IEditableDateCellSkin();
Widget build(
BuildContext context,
CellContainerNotifier cellContainerNotifier,
DateCellBloc bloc,
DateCellState state,
PopoverController popoverController,
);
factory IEditableDateCellSkin.fromStyle(EditableCellStyle style) {
return switch (style) {
EditableCellStyle.desktopGrid => DesktopGridDateCellSkin(),
@ -32,13 +24,17 @@ abstract class IEditableDateCellSkin {
EditableCellStyle.mobileRowDetail => MobileRowDetailDateCellSkin(),
};
}
Widget build(
BuildContext context,
CellContainerNotifier cellContainerNotifier,
DateCellBloc bloc,
DateCellState state,
PopoverController popoverController,
);
}
class EditableDateCell extends EditableCellWidget {
final DatabaseController databaseController;
final CellContext cellContext;
final IEditableDateCellSkin skin;
EditableDateCell({
super.key,
required this.databaseController,
@ -46,6 +42,10 @@ class EditableDateCell extends EditableCellWidget {
required this.skin,
});
final DatabaseController databaseController;
final CellContext cellContext;
final IEditableDateCellSkin skin;
@override
GridCellState<EditableDateCell> createState() => _DateCellState();
}

View File

@ -17,14 +17,6 @@ import '../mobile_row_detail/mobile_row_detail_number_cell.dart';
abstract class IEditableNumberCellSkin {
const IEditableNumberCellSkin();
Widget build(
BuildContext context,
CellContainerNotifier cellContainerNotifier,
NumberCellBloc bloc,
FocusNode focusNode,
TextEditingController textEditingController,
);
factory IEditableNumberCellSkin.fromStyle(EditableCellStyle style) {
return switch (style) {
EditableCellStyle.desktopGrid => DesktopGridNumberCellSkin(),
@ -33,13 +25,17 @@ abstract class IEditableNumberCellSkin {
EditableCellStyle.mobileRowDetail => MobileRowDetailNumberCellSkin(),
};
}
Widget build(
BuildContext context,
CellContainerNotifier cellContainerNotifier,
NumberCellBloc bloc,
FocusNode focusNode,
TextEditingController textEditingController,
);
}
class EditableNumberCell extends EditableCellWidget {
final DatabaseController databaseController;
final CellContext cellContext;
final IEditableNumberCellSkin skin;
EditableNumberCell({
super.key,
required this.databaseController,
@ -47,6 +43,10 @@ class EditableNumberCell extends EditableCellWidget {
required this.skin,
});
final DatabaseController databaseController;
final CellContext cellContext;
final IEditableNumberCellSkin skin;
@override
GridEditableTextCell<EditableNumberCell> createState() => _NumberCellState();
}

View File

@ -17,14 +17,6 @@ import '../mobile_row_detail/mobile_row_detail_select_cell_option.dart';
abstract class IEditableSelectOptionCellSkin {
const IEditableSelectOptionCellSkin();
Widget build(
BuildContext context,
CellContainerNotifier cellContainerNotifier,
SelectOptionCellBloc bloc,
SelectOptionCellState state,
PopoverController popoverController,
);
factory IEditableSelectOptionCellSkin.fromStyle(EditableCellStyle style) {
return switch (style) {
EditableCellStyle.desktopGrid => DesktopGridSelectOptionCellSkin(),
@ -35,15 +27,17 @@ abstract class IEditableSelectOptionCellSkin {
MobileRowDetailSelectOptionCellSkin(),
};
}
Widget build(
BuildContext context,
CellContainerNotifier cellContainerNotifier,
SelectOptionCellBloc bloc,
SelectOptionCellState state,
PopoverController popoverController,
);
}
class EditableSelectOptionCell extends EditableCellWidget {
final DatabaseController databaseController;
final CellContext cellContext;
final IEditableSelectOptionCellSkin skin;
final FieldType fieldType;
EditableSelectOptionCell({
super.key,
required this.databaseController,
@ -52,6 +46,12 @@ class EditableSelectOptionCell extends EditableCellWidget {
required this.fieldType,
});
final DatabaseController databaseController;
final CellContext cellContext;
final IEditableSelectOptionCellSkin skin;
final FieldType fieldType;
@override
GridCellState<EditableSelectOptionCell> createState() =>
_SelectOptionCellState();

View File

@ -15,14 +15,6 @@ import '../mobile_row_detail/mobile_row_detail_text_cell.dart';
abstract class IEditableTextCellSkin {
const IEditableTextCellSkin();
Widget build(
BuildContext context,
CellContainerNotifier cellContainerNotifier,
TextCellBloc bloc,
FocusNode focusNode,
TextEditingController textEditingController,
);
factory IEditableTextCellSkin.fromStyle(EditableCellStyle style) {
return switch (style) {
EditableCellStyle.desktopGrid => DesktopGridTextCellSkin(),
@ -31,13 +23,17 @@ abstract class IEditableTextCellSkin {
EditableCellStyle.mobileRowDetail => MobileRowDetailTextCellSkin(),
};
}
Widget build(
BuildContext context,
CellContainerNotifier cellContainerNotifier,
TextCellBloc bloc,
FocusNode focusNode,
TextEditingController textEditingController,
);
}
class EditableTextCell extends EditableCellWidget {
final DatabaseController databaseController;
final CellContext cellContext;
final IEditableTextCellSkin skin;
EditableTextCell({
super.key,
required this.databaseController,
@ -45,6 +41,10 @@ class EditableTextCell extends EditableCellWidget {
required this.skin,
});
final DatabaseController databaseController;
final CellContext cellContext;
final IEditableTextCellSkin skin;
@override
GridEditableTextCell<EditableTextCell> createState() => _TextCellState();
}

View File

@ -16,13 +16,6 @@ import '../mobile_row_detail/mobile_row_detail_timestamp_cell.dart';
abstract class IEditableTimestampCellSkin {
const IEditableTimestampCellSkin();
Widget build(
BuildContext context,
CellContainerNotifier cellContainerNotifier,
TimestampCellBloc bloc,
TimestampCellState state,
);
factory IEditableTimestampCellSkin.fromStyle(EditableCellStyle style) {
return switch (style) {
EditableCellStyle.desktopGrid => DesktopGridTimestampCellSkin(),
@ -31,15 +24,16 @@ abstract class IEditableTimestampCellSkin {
EditableCellStyle.mobileRowDetail => MobileRowDetailTimestampCellSkin(),
};
}
Widget build(
BuildContext context,
CellContainerNotifier cellContainerNotifier,
TimestampCellBloc bloc,
TimestampCellState state,
);
}
class EditableTimestampCell extends EditableCellWidget {
final DatabaseController databaseController;
final CellContext cellContext;
final IEditableTimestampCellSkin skin;
final FieldType fieldType;
EditableTimestampCell({
super.key,
required this.databaseController,
@ -48,6 +42,11 @@ class EditableTimestampCell extends EditableCellWidget {
required this.fieldType,
});
final DatabaseController databaseController;
final CellContext cellContext;
final IEditableTimestampCellSkin skin;
final FieldType fieldType;
@override
GridCellState<EditableTimestampCell> createState() => _TimestampCellState();
}

View File

@ -18,6 +18,15 @@ import '../mobile_row_detail/mobile_row_detail_url_cell.dart';
abstract class IEditableURLCellSkin {
const IEditableURLCellSkin();
factory IEditableURLCellSkin.fromStyle(EditableCellStyle style) {
return switch (style) {
EditableCellStyle.desktopGrid => DesktopGridURLSkin(),
EditableCellStyle.desktopRowDetail => DesktopRowDetailURLSkin(),
EditableCellStyle.mobileGrid => MobileGridURLCellSkin(),
EditableCellStyle.mobileRowDetail => MobileRowDetailURLCellSkin(),
};
}
Widget build(
BuildContext context,
CellContainerNotifier cellContainerNotifier,
@ -31,25 +40,11 @@ abstract class IEditableURLCellSkin {
GridCellAccessoryBuildContext context,
URLCellDataNotifier cellDataNotifier,
);
factory IEditableURLCellSkin.fromStyle(EditableCellStyle style) {
return switch (style) {
EditableCellStyle.desktopGrid => DesktopGridURLSkin(),
EditableCellStyle.desktopRowDetail => DesktopRowDetailURLSkin(),
EditableCellStyle.mobileGrid => MobileGridURLCellSkin(),
EditableCellStyle.mobileRowDetail => MobileRowDetailURLCellSkin(),
};
}
}
typedef URLCellDataNotifier = CellDataNotifier<String>;
class EditableURLCell extends EditableCellWidget {
final DatabaseController databaseController;
final CellContext cellContext;
final IEditableURLCellSkin skin;
final URLCellDataNotifier _cellDataNotifier;
EditableURLCell({
super.key,
required this.databaseController,
@ -57,6 +52,11 @@ class EditableURLCell extends EditableCellWidget {
required this.skin,
}) : _cellDataNotifier = CellDataNotifier(value: '');
final DatabaseController databaseController;
final CellContext cellContext;
final IEditableURLCellSkin skin;
final URLCellDataNotifier _cellDataNotifier;
@override
List<GridCellAccessoryBuilder> Function(
GridCellAccessoryBuildContext buildContext,

View File

@ -17,7 +17,6 @@ class MobileGridNumberCellSkin extends IEditableNumberCellSkin {
controller: textEditingController,
focusNode: focusNode,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(fontSize: 15),
maxLines: 1,
decoration: const InputDecoration(
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,

View File

@ -33,7 +33,6 @@ class MobileGridTextCellSkin extends IEditableTextCellSkin {
focusNode: focusNode,
style:
Theme.of(context).textTheme.bodyMedium?.copyWith(fontSize: 15),
maxLines: 1,
decoration: const InputDecoration(
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,

View File

@ -20,7 +20,6 @@ class MobileGridTimestampCellSkin extends IEditableTimestampCellSkin {
child: FlowyText(
state.dateStr,
fontSize: 15,
maxLines: 1,
),
),
);

View File

@ -28,7 +28,6 @@ class MobileGridURLCellSkin extends IEditableURLCellSkin {
return TextField(
focusNode: focusNode,
keyboardType: TextInputType.url,
maxLines: 1,
decoration: const InputDecoration(
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,

View File

@ -4,15 +4,15 @@ import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:flutter/material.dart';
class DatabaseViewWidget extends StatefulWidget {
final ViewPB view;
final bool shrinkWrap;
const DatabaseViewWidget({
super.key,
required this.view,
this.shrinkWrap = true,
});
final ViewPB view;
final bool shrinkWrap;
@override
State<DatabaseViewWidget> createState() => _DatabaseViewWidgetState();
}

View File

@ -124,14 +124,15 @@ class DatabaseGroupList extends StatelessWidget {
}
class _GridGroupCell extends StatelessWidget {
final VoidCallback onSelected;
final FieldInfo fieldInfo;
const _GridGroupCell({
super.key,
required this.fieldInfo,
required this.onSelected,
super.key,
});
final FieldInfo fieldInfo;
final VoidCallback onSelected;
@override
Widget build(BuildContext context) {
Widget? rightIcon;

View File

@ -13,23 +13,23 @@ import 'package:styled_widget/styled_widget.dart';
import '../../cell/editable_cell_builder.dart';
class GridCellAccessoryBuildContext {
final BuildContext anchorContext;
final bool isCellEditing;
GridCellAccessoryBuildContext({
required this.anchorContext,
required this.isCellEditing,
});
final BuildContext anchorContext;
final bool isCellEditing;
}
class GridCellAccessoryBuilder<T extends State<StatefulWidget>> {
GridCellAccessoryBuilder({required Widget Function(Key key) builder})
: _builder = builder;
final GlobalKey<T> _key = GlobalKey();
final Widget Function(Key key) _builder;
GridCellAccessoryBuilder({required Widget Function(Key key) builder})
: _builder = builder;
Widget build() => _builder(_key);
void onTap() {
@ -93,14 +93,15 @@ class _PrimaryCellAccessoryState extends State<PrimaryCellAccessory>
}
class AccessoryHover extends StatefulWidget {
final CellAccessory child;
final FieldType fieldType;
const AccessoryHover({
super.key,
required this.child,
required this.fieldType,
});
final CellAccessory child;
final FieldType fieldType;
@override
State<AccessoryHover> createState() => _AccessoryHoverState();
}
@ -125,10 +126,10 @@ class _AccessoryHoverState extends State<AccessoryHover> {
final accessoryBuilder = widget.child.accessoryBuilder;
if (accessoryBuilder != null && _isHover) {
final accessories = accessoryBuilder(
(GridCellAccessoryBuildContext(
GridCellAccessoryBuildContext(
anchorContext: context,
isCellEditing: false,
)),
),
);
children.add(
Padding(
@ -144,7 +145,6 @@ class _AccessoryHoverState extends State<AccessoryHover> {
onEnter: (p) => setState(() => _isHover = true),
onExit: (p) => setState(() => _isHover = false),
child: Stack(
fit: StackFit.loose,
alignment: AlignmentDirectional.center,
children: children,
),
@ -153,9 +153,10 @@ class _AccessoryHoverState extends State<AccessoryHover> {
}
class CellAccessoryContainer extends StatelessWidget {
final List<GridCellAccessoryBuilder> accessories;
const CellAccessoryContainer({required this.accessories, super.key});
final List<GridCellAccessoryBuilder> accessories;
@override
Widget build(BuildContext context) {
final children =

View File

@ -18,9 +18,10 @@ abstract class CellShortcuts extends Widget {
}
class GridCellShortcuts extends StatelessWidget {
final CellShortcuts child;
const GridCellShortcuts({required this.child, super.key});
final CellShortcuts child;
@override
Widget build(BuildContext context) {
return Shortcuts(
@ -60,9 +61,10 @@ class GridCellEnterIdent extends Intent {
}
class GridCellEnterAction extends Action<GridCellEnterIdent> {
final CellShortcuts child;
GridCellEnterAction({required this.child});
final CellShortcuts child;
@override
void invoke(covariant GridCellEnterIdent intent) {
final callback = child.shortcutHandlers[CellKeyboardKey.onEnter];
@ -77,9 +79,10 @@ class GridCellCopyIntent extends Intent {
}
class GridCellCopyAction extends Action<GridCellCopyIntent> {
final CellShortcuts child;
GridCellCopyAction({required this.child});
final CellShortcuts child;
@override
void invoke(covariant GridCellCopyIntent intent) {
final callback = child.shortcutHandlers[CellKeyboardKey.onCopy];
@ -99,9 +102,10 @@ class GridCellPasteIntent extends Intent {
}
class GridCellPasteAction extends Action<GridCellPasteIntent> {
final CellShortcuts child;
GridCellPasteAction({required this.child});
final CellShortcuts child;
@override
void invoke(covariant GridCellPasteIntent intent) {
final callback = child.shortcutHandlers[CellKeyboardKey.onInsert];

View File

@ -9,11 +9,6 @@ import '../accessory/cell_shortcuts.dart';
import '../../cell/editable_cell_builder.dart';
class CellContainer extends StatelessWidget {
final EditableCellWidget child;
final AccessoryBuilder? accessoryBuilder;
final double width;
final bool isPrimary;
const CellContainer({
super.key,
required this.child,
@ -22,6 +17,11 @@ class CellContainer extends StatelessWidget {
this.accessoryBuilder,
});
final EditableCellWidget child;
final AccessoryBuilder? accessoryBuilder;
final double width;
final bool isPrimary;
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider.value(

View File

@ -7,12 +7,16 @@ import 'package:freezed_annotation/freezed_annotation.dart';
part 'checkbox_cell_bloc.freezed.dart';
class CheckboxCellBloc extends Bloc<CheckboxCellEvent, CheckboxCellState> {
final CheckboxCellController cellController;
void Function()? _onCellChangedFn;
CheckboxCellBloc({
required this.cellController,
}) : super(CheckboxCellState.initial(cellController)) {
_dispatch();
}
final CheckboxCellController cellController;
void Function()? _onCellChangedFn;
void _dispatch() {
on<CheckboxCellEvent>(
(event, emit) {
event.when(

View File

@ -1,3 +1,5 @@
import 'dart:async';
import 'package:appflowy/plugins/database/application/cell/cell_controller_builder.dart';
import 'package:appflowy/plugins/database/application/cell/checklist_cell_service.dart';
import 'package:appflowy_backend/log.dart';
@ -5,28 +7,31 @@ import 'package:appflowy_backend/protobuf/flowy-database2/checklist_entities.pb.
import 'package:appflowy_backend/protobuf/flowy-database2/select_option_entities.pb.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'dart:async';
part 'checklist_cell_bloc.freezed.dart';
class ChecklistSelectOption {
ChecklistSelectOption(this.isSelected, this.data);
final bool isSelected;
final SelectOptionPB data;
ChecklistSelectOption(this.isSelected, this.data);
}
class ChecklistCellBloc extends Bloc<ChecklistCellEvent, ChecklistCellState> {
final ChecklistCellController cellController;
final ChecklistCellBackendService _checklistCellService;
void Function()? _onCellChangedFn;
ChecklistCellBloc({
required this.cellController,
}) : _checklistCellService = ChecklistCellBackendService(
ChecklistCellBloc({required this.cellController})
: _checklistCellService = ChecklistCellBackendService(
viewId: cellController.viewId,
fieldId: cellController.fieldId,
rowId: cellController.rowId,
),
super(ChecklistCellState.initial(cellController)) {
_dispatch();
}
final ChecklistCellController cellController;
final ChecklistCellBackendService _checklistCellService;
void Function()? _onCellChangedFn;
void _dispatch() {
on<ChecklistCellEvent>(
(event, emit) async {
await event.when(

View File

@ -18,9 +18,10 @@ import 'checklist_cell_bloc.dart';
import 'checklist_progress_bar.dart';
class ChecklistCellEditor extends StatefulWidget {
final ChecklistCellController cellController;
const ChecklistCellEditor({required this.cellController, super.key});
final ChecklistCellController cellController;
@override
State<ChecklistCellEditor> createState() => _GridChecklistCellState();
}
@ -93,15 +94,15 @@ class _GridChecklistCellState extends State<ChecklistCellEditor> {
/// Displays the a list of all the exisiting tasks and an input field to create
/// a new task if `isAddingNewTask` is true
class ChecklistItemList extends StatefulWidget {
final List<ChecklistSelectOption> options;
final VoidCallback onUpdateTask;
const ChecklistItemList({
super.key,
required this.options,
required this.onUpdateTask,
});
final List<ChecklistSelectOption> options;
final VoidCallback onUpdateTask;
@override
State<ChecklistItemList> createState() => _ChecklistItemListState();
}
@ -143,9 +144,6 @@ class _ChecklistItemListState extends State<ChecklistItemList> {
/// Represents an existing task
@visibleForTesting
class ChecklistItem extends StatefulWidget {
final ChecklistSelectOption task;
final VoidCallback? onSubmitted;
final bool autofocus;
const ChecklistItem({
super.key,
required this.task,
@ -153,6 +151,10 @@ class ChecklistItem extends StatefulWidget {
this.autofocus = false,
});
final ChecklistSelectOption task;
final VoidCallback? onSubmitted;
final bool autofocus;
@override
State<ChecklistItem> createState() => _ChecklistItemState();
}
@ -209,7 +211,6 @@ class _ChecklistItemState extends State<ChecklistItem> {
borderRadius: Corners.s6Border,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
FlowyIconButton(
width: 32,
@ -224,7 +225,6 @@ class _ChecklistItemState extends State<ChecklistItem> {
controller: _textController,
focusNode: _focusNode,
style: Theme.of(context).textTheme.bodyMedium,
maxLines: 1,
decoration: InputDecoration(
border: InputBorder.none,
isCollapsed: true,
@ -280,9 +280,10 @@ class _ChecklistItemState extends State<ChecklistItem> {
/// This can be cancelled by pressing escape
@visibleForTesting
class NewTaskItem extends StatefulWidget {
final FocusNode focusNode;
const NewTaskItem({super.key, required this.focusNode});
final FocusNode focusNode;
@override
State<NewTaskItem> createState() => _NewTaskItemState();
}
@ -305,7 +306,6 @@ class _NewTaskItemState extends State<NewTaskItem> {
padding: const EdgeInsets.symmetric(horizontal: 8),
constraints: BoxConstraints(minHeight: GridSize.popoverItemHeight),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const HSpace(8),
Expanded(
@ -313,7 +313,6 @@ class _NewTaskItemState extends State<NewTaskItem> {
focusNode: widget.focusNode,
controller: _textEditingController,
style: Theme.of(context).textTheme.bodyMedium,
maxLines: 1,
decoration: InputDecoration(
border: InputBorder.none,
isCollapsed: true,

View File

@ -5,11 +5,6 @@ import 'package:percent_indicator/percent_indicator.dart';
import 'checklist_cell_bloc.dart';
class ChecklistProgressBar extends StatefulWidget {
final List<ChecklistSelectOption> tasks;
final double percent;
final int segmentLimit = 5;
final TextStyle? textStyle;
const ChecklistProgressBar({
super.key,
required this.tasks,
@ -17,6 +12,11 @@ class ChecklistProgressBar extends StatefulWidget {
this.textStyle,
});
final List<ChecklistSelectOption> tasks;
final double percent;
final TextStyle? textStyle;
final int segmentLimit = 5;
@override
State<ChecklistProgressBar> createState() => _ChecklistProgressBarState();
}

View File

@ -60,14 +60,12 @@ class _MobileChecklistCellEditScreenState
size: Size.square(iconWidth),
),
width: iconWidth,
iconPadding: EdgeInsets.zero,
onPressed: () => context.pop(),
),
),
SizedBox(
height: 44.0,
child: Align(
alignment: Alignment.center,
child: FlowyText.medium(
LocaleKeys.grid_field_checklistFieldName.tr(),
fontSize: 18,
@ -156,7 +154,6 @@ class _ChecklistItemState extends State<_ChecklistItem> {
padding: const EdgeInsets.symmetric(horizontal: 5),
height: 44,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
InkWell(
borderRadius: BorderRadius.circular(22),
@ -181,7 +178,6 @@ class _ChecklistItemState extends State<_ChecklistItem> {
controller: _textController,
focusNode: _focusNode,
style: Theme.of(context).textTheme.bodyMedium,
maxLines: 1,
decoration: InputDecoration(
border: InputBorder.none,
enabledBorder: InputBorder.none,

View File

@ -9,11 +9,15 @@ import 'package:freezed_annotation/freezed_annotation.dart';
part 'date_cell_bloc.freezed.dart';
class DateCellBloc extends Bloc<DateCellEvent, DateCellState> {
DateCellBloc({required this.cellController})
: super(DateCellState.initial(cellController)) {
_dispatch();
}
final DateCellController cellController;
void Function()? _onCellChangedFn;
DateCellBloc({required this.cellController})
: super(DateCellState.initial(cellController)) {
void _dispatch() {
on<DateCellEvent>(
(event, emit) async {
event.when(
@ -42,11 +46,11 @@ class DateCellBloc extends Bloc<DateCellEvent, DateCellState> {
void _startListening() {
_onCellChangedFn = cellController.addListener(
onCellChanged: ((data) {
onCellChanged: (data) {
if (!isClosed) {
add(DateCellEvent.didReceiveCellUpdate(data));
}
}),
},
);
}
}

View File

@ -27,11 +27,6 @@ part 'date_cell_editor_bloc.freezed.dart';
class DateCellEditorBloc
extends Bloc<DateCellEditorEvent, DateCellEditorState> {
final DateCellBackendService _dateCellBackendService;
final DateCellController cellController;
final ReminderBloc _reminderBloc;
void Function()? _onCellChangedFn;
DateCellEditorBloc({
required this.cellController,
required ReminderBloc reminderBloc,
@ -42,6 +37,15 @@ class DateCellEditorBloc
rowId: cellController.rowId,
),
super(DateCellEditorState.initial(cellController, reminderBloc)) {
_dispatch();
}
final DateCellBackendService _dateCellBackendService;
final DateCellController cellController;
final ReminderBloc _reminderBloc;
void Function()? _onCellChangedFn;
void _dispatch() {
on<DateCellEditorEvent>(
(event, emit) async {
await event.when(
@ -120,9 +124,8 @@ class DateCellEditorBloc
}
},
setIncludeTime: (includeTime) async =>
await _updateDateData(includeTime: includeTime),
setIsRange: (isRange) async =>
await _updateDateData(isRange: isRange),
_updateDateData(includeTime: includeTime),
setIsRange: (isRange) async => _updateDateData(isRange: isRange),
setTime: (timeStr) async {
emit(state.copyWith(timeStr: timeStr));
await _updateDateData(timeStr: timeStr);
@ -213,7 +216,7 @@ class DateCellEditorBloc
}
},
// Empty String signifies no reminder
removeReminder: () async => await _updateDateData(reminderId: ""),
removeReminder: () async => _updateDateData(reminderId: ""),
);
},
);
@ -578,16 +581,6 @@ _DateCellData _dateDataFromCellData(
}
class _DateCellData {
final DateTime? dateTime;
final DateTime? endDateTime;
final String? timeStr;
final String? endTimeStr;
final bool includeTime;
final bool isRange;
final String? dateStr;
final String? endDateStr;
final String? reminderId;
_DateCellData({
required this.dateTime,
required this.endDateTime,
@ -599,4 +592,14 @@ class _DateCellData {
required this.endDateStr,
required this.reminderId,
});
final DateTime? dateTime;
final DateTime? endDateTime;
final String? timeStr;
final String? endTimeStr;
final bool includeTime;
final bool isRange;
final String? dateStr;
final String? endDateStr;
final String? reminderId;
}

View File

@ -6,10 +6,6 @@ import '../../cell/editable_cell_builder.dart';
import 'cell_container.dart';
class MobileCellContainer extends StatelessWidget {
final EditableCellWidget child;
final bool isPrimary;
final VoidCallback? onPrimaryFieldCellTap;
const MobileCellContainer({
super.key,
required this.child,
@ -17,6 +13,10 @@ class MobileCellContainer extends StatelessWidget {
this.onPrimaryFieldCellTap,
});
final EditableCellWidget child;
final bool isPrimary;
final VoidCallback? onPrimaryFieldCellTap;
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider.value(

View File

@ -1,17 +1,21 @@
import 'dart:async';
import 'package:appflowy/plugins/database/application/cell/cell_controller_builder.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'dart:async';
part 'number_cell_bloc.freezed.dart';
class NumberCellBloc extends Bloc<NumberCellEvent, NumberCellState> {
NumberCellBloc({required this.cellController})
: super(NumberCellState.initial(cellController)) {
_dispatch();
}
final NumberCellController cellController;
void Function()? _onCellChangedFn;
NumberCellBloc({
required this.cellController,
}) : super(NumberCellState.initial(cellController)) {
void _dispatch() {
on<NumberCellEvent>(
(event, emit) async {
event.when(
@ -53,11 +57,11 @@ class NumberCellBloc extends Bloc<NumberCellEvent, NumberCellState> {
void _startListening() {
_onCellChangedFn = cellController.addListener(
onCellChanged: ((cellContent) {
onCellChanged: (cellContent) {
if (!isClosed) {
add(NumberCellEvent.didReceiveCellUpdate(cellContent));
}
}),
},
);
}
}

View File

@ -60,14 +60,6 @@ extension SelectOptionColorExtension on SelectOptionColorPB {
}
class SelectOptionTag extends StatelessWidget {
final SelectOptionPB? option;
final String? name;
final double? fontSize;
final Color? color;
final TextStyle? textStyle;
final EdgeInsets padding;
final void Function(String)? onRemove;
const SelectOptionTag({
super.key,
this.option,
@ -79,6 +71,14 @@ class SelectOptionTag extends StatelessWidget {
required this.padding,
}) : assert(option != null || name != null && color != null);
final SelectOptionPB? option;
final String? name;
final double? fontSize;
final Color? color;
final TextStyle? textStyle;
final void Function(String)? onRemove;
final EdgeInsets padding;
@override
Widget build(BuildContext context) {
final optionName = option?.name ?? name!;

View File

@ -94,14 +94,12 @@ class _MobileSelectOptionEditorState extends State<MobileSelectOptionEditor> {
size: const Size.square(iconWidth),
),
width: iconWidth,
iconPadding: EdgeInsets.zero,
onPressed: () => _popOrBack(),
),
),
SizedBox(
height: 44.0,
child: Align(
alignment: Alignment.center,
child: FlowyText.medium(
_headerTitle(),
fontSize: 18,
@ -335,7 +333,6 @@ class _SelectOption extends StatelessWidget {
behavior: HitTestBehavior.translucent,
onTap: () => onCheck(!checked),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// check icon
FlowySvg(
@ -450,8 +447,6 @@ class _MoreOptionsState extends State<_MoreOptions> {
),
const VSpace(4.0),
FlowyOptionDecorateBox(
showTopBorder: true,
showBottomBorder: true,
child: Padding(
padding: const EdgeInsets.only(
top: 12.0,

View File

@ -9,12 +9,15 @@ part 'select_option_cell_bloc.freezed.dart';
class SelectOptionCellBloc
extends Bloc<SelectOptionCellEvent, SelectOptionCellState> {
SelectOptionCellBloc({required this.cellController})
: super(SelectOptionCellState.initial(cellController)) {
_dispatch();
}
final SelectOptionCellController cellController;
void Function()? _onCellChangedFn;
SelectOptionCellBloc({
required this.cellController,
}) : super(SelectOptionCellState.initial(cellController)) {
void _dispatch() {
on<SelectOptionCellEvent>(
(event, emit) async {
await event.when(

View File

@ -22,10 +22,10 @@ import 'text_field.dart';
const double _editorPanelWidth = 300;
class SelectOptionCellEditor extends StatefulWidget {
final SelectOptionCellController cellController;
const SelectOptionCellEditor({super.key, required this.cellController});
final SelectOptionCellController cellController;
@override
State<SelectOptionCellEditor> createState() => _SelectOptionCellEditorState();
}
@ -71,14 +71,14 @@ class _SelectOptionCellEditorState extends State<SelectOptionCellEditor> {
}
class _OptionList extends StatelessWidget {
final TextEditingController textEditingController;
final PopoverMutex popoverMutex;
const _OptionList({
required this.textEditingController,
required this.popoverMutex,
});
final TextEditingController textEditingController;
final PopoverMutex popoverMutex;
@override
Widget build(BuildContext context) {
return BlocBuilder<SelectOptionCellEditorBloc, SelectOptionEditorState>(
@ -126,14 +126,14 @@ class _OptionList extends StatelessWidget {
}
class _TextField extends StatelessWidget {
final TextEditingController textEditingController;
final PopoverMutex popoverMutex;
const _TextField({
required this.textEditingController,
required this.popoverMutex,
});
final TextEditingController textEditingController;
final PopoverMutex popoverMutex;
@override
Widget build(BuildContext context) {
return BlocBuilder<SelectOptionCellEditorBloc, SelectOptionEditorState>(
@ -199,7 +199,6 @@ class _Title extends StatelessWidget {
child: SizedBox(
height: GridSize.popoverItemHeight,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Flexible(
child: FlowyText.medium(
@ -275,16 +274,16 @@ class _CreateOptionCell extends StatelessWidget {
}
class _SelectOptionCell extends StatefulWidget {
final SelectOptionPB option;
final PopoverMutex popoverMutex;
final bool isSelected;
const _SelectOptionCell({
required this.option,
required this.isSelected,
required this.popoverMutex,
});
final SelectOptionPB option;
final bool isSelected;
final PopoverMutex popoverMutex;
@override
State<_SelectOptionCell> createState() => _SelectOptionCellState();
}
@ -317,7 +316,6 @@ class _SelectOptionCellState extends State<_SelectOptionCell> {
),
),
FlowyIconButton(
width: 30,
onPressed: () => _popoverController.show(),
iconPadding: const EdgeInsets.symmetric(horizontal: 6.0),
hoverColor: Colors.transparent,

View File

@ -1,11 +1,12 @@
import 'dart:async';
import 'package:flutter/widgets.dart';
import 'package:appflowy/plugins/database/application/cell/cell_controller_builder.dart';
import 'package:appflowy/plugins/database/application/cell/select_option_cell_service.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/select_option_entities.pb.dart';
import 'package:dartz/dartz.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
@ -13,19 +14,22 @@ part 'select_option_editor_bloc.freezed.dart';
class SelectOptionCellEditorBloc
extends Bloc<SelectOptionEditorEvent, SelectOptionEditorState> {
final SelectOptionCellBackendService _selectOptionService;
final SelectOptionCellController cellController;
VoidCallback? _onCellChangedFn;
SelectOptionCellEditorBloc({
required this.cellController,
}) : _selectOptionService = SelectOptionCellBackendService(
SelectOptionCellEditorBloc({required this.cellController})
: _selectOptionService = SelectOptionCellBackendService(
viewId: cellController.viewId,
fieldId: cellController.fieldId,
rowId: cellController.rowId,
),
super(SelectOptionEditorState.initial(cellController)) {
_dispatch();
}
final SelectOptionCellBackendService _selectOptionService;
final SelectOptionCellController cellController;
VoidCallback? _onCellChangedFn;
void _dispatch() {
on<SelectOptionEditorEvent>(
(event, emit) async {
await event.when(
@ -247,9 +251,9 @@ class SelectOptionCellEditorBloc
void _startListening() {
_onCellChangedFn = cellController.addListener(
onCellChanged: ((selectOptionContext) {
onCellChanged: (selectOptionContext) {
_loadOptions();
}),
},
onCellFieldChanged: (field) {
_loadOptions();
},
@ -308,11 +312,11 @@ class SelectOptionEditorState with _$SelectOptionEditorState {
}
class _MakeOptionResult {
List<SelectOptionPB> options;
Option<String> createOption;
_MakeOptionResult({
required this.options,
required this.createOption,
});
List<SelectOptionPB> options;
Option<String> createOption;
}

View File

@ -11,6 +11,20 @@ import 'package:flutter/services.dart';
import 'extension.dart';
class SelectOptionTextField extends StatefulWidget {
const SelectOptionTextField({
super.key,
required this.options,
required this.selectedOptionMap,
required this.distanceToText,
required this.textSeparators,
required this.textController,
required this.onSubmitted,
required this.newText,
required this.onPaste,
required this.onRemove,
this.onClick,
});
final List<SelectOptionPB> options;
final LinkedHashMap<String, SelectOptionPB> selectedOptionMap;
final double distanceToText;
@ -23,20 +37,6 @@ class SelectOptionTextField extends StatefulWidget {
final Function(String) onRemove;
final VoidCallback? onClick;
const SelectOptionTextField({
super.key,
required this.options,
required this.selectedOptionMap,
required this.distanceToText,
required this.onSubmitted,
required this.onPaste,
required this.onRemove,
required this.newText,
required this.textSeparators,
required this.textController,
this.onClick,
});
@override
State<SelectOptionTextField> createState() => _SelectOptionTextFieldState();
}
@ -59,7 +59,6 @@ class _SelectOptionTextFieldState extends State<SelectOptionTextField> {
widget.textController.value = TextEditingValue(
text: "${text.substring(0, start)}${text.substring(end)}",
selection: TextSelection(baseOffset: start, extentOffset: start),
composing: const TextRange(start: -1, end: -1),
);
return KeyEventResult.handled;
}
@ -92,14 +91,10 @@ class _SelectOptionTextFieldState extends State<SelectOptionTextField> {
widget.textController.clear();
}
},
maxLines: 1,
style: Theme.of(context).textTheme.bodyMedium,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).colorScheme.outline,
width: 1.0,
),
borderSide: BorderSide(color: Theme.of(context).colorScheme.outline),
borderRadius: Corners.s10Border,
),
isDense: true,
@ -111,10 +106,7 @@ class _SelectOptionTextFieldState extends State<SelectOptionTextField> {
.copyWith(color: Theme.of(context).hintColor),
prefixIconConstraints: BoxConstraints(maxWidth: widget.distanceToText),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).colorScheme.primary,
width: 1.0,
),
borderSide: BorderSide(color: Theme.of(context).colorScheme.primary),
borderRadius: Corners.s10Border,
),
),
@ -154,6 +146,7 @@ class _SelectOptionTextFieldState extends State<SelectOptionTextField> {
),
)
.toList();
return MouseRegion(
cursor: SystemMouseCursors.basic,
child: Padding(

View File

@ -7,12 +7,15 @@ import 'package:freezed_annotation/freezed_annotation.dart';
part 'text_cell_bloc.freezed.dart';
class TextCellBloc extends Bloc<TextCellEvent, TextCellState> {
TextCellBloc({required this.cellController})
: super(TextCellState.initial(cellController)) {
_dispatch();
}
final TextCellController cellController;
void Function()? _onCellChangedFn;
TextCellBloc({
required this.cellController,
}) : super(TextCellState.initial(cellController)) {
void _dispatch() {
on<TextCellEvent>(
(event, emit) {
event.when(
@ -50,11 +53,11 @@ class TextCellBloc extends Bloc<TextCellEvent, TextCellState> {
void _startListening() {
_onCellChangedFn = cellController.addListener(
onCellChanged: ((cellContent) {
onCellChanged: (cellContent) {
if (!isClosed) {
add(TextCellEvent.didReceiveCellUpdate(cellContent ?? ""));
}
}),
},
onRowMetaChanged: () {
if (!isClosed && cellController.fieldInfo.isPrimary) {
add(TextCellEvent.didUpdateEmoji(cellController.icon ?? ""));

View File

@ -9,11 +9,15 @@ import 'package:freezed_annotation/freezed_annotation.dart';
part 'timestamp_cell_bloc.freezed.dart';
class TimestampCellBloc extends Bloc<TimestampCellEvent, TimestampCellState> {
TimestampCellBloc({required this.cellController})
: super(TimestampCellState.initial(cellController)) {
_dispatch();
}
final TimestampCellController cellController;
void Function()? _onCellChangedFn;
TimestampCellBloc({required this.cellController})
: super(TimestampCellState.initial(cellController)) {
void _dispatch() {
on<TimestampCellEvent>(
(event, emit) async {
event.when(
@ -43,11 +47,11 @@ class TimestampCellBloc extends Bloc<TimestampCellEvent, TimestampCellState> {
void _startListening() {
_onCellChangedFn = cellController.addListener(
onCellChanged: ((data) {
onCellChanged: (data) {
if (!isClosed) {
add(TimestampCellEvent.didReceiveCellUpdate(data));
}
}),
},
);
}
}

View File

@ -6,14 +6,15 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'url_cell_editor_bloc.dart';
class URLCellEditor extends StatefulWidget {
final VoidCallback onExit;
final URLCellController cellController;
const URLCellEditor({
super.key,
required this.cellController,
required this.onExit,
super.key,
});
final URLCellController cellController;
final VoidCallback onExit;
@override
State<URLCellEditor> createState() => _URLCellEditorState();
}
@ -50,7 +51,6 @@ class _URLCellEditorState extends State<URLCellEditor> {
controller: _controller,
onSubmitted: (value) => focusChanged(),
onEditingComplete: () => focusChanged(),
maxLines: 1,
style: Theme.of(context).textTheme.bodyMedium,
decoration: const InputDecoration(
contentPadding: EdgeInsets.zero,
@ -80,14 +80,15 @@ class _URLCellEditorState extends State<URLCellEditor> {
}
class URLEditorPopover extends StatelessWidget {
final VoidCallback onExit;
final URLCellController cellController;
const URLEditorPopover({
super.key,
required this.cellController,
required this.onExit,
super.key,
});
final URLCellController cellController;
final VoidCallback onExit;
@override
Widget build(BuildContext context) {
return Container(

View File

@ -1,17 +1,22 @@
import 'dart:async';
import 'package:appflowy/plugins/database/application/cell/cell_controller_builder.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/url_entities.pb.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'dart:async';
part 'url_cell_bloc.freezed.dart';
class URLCellBloc extends Bloc<URLCellEvent, URLCellState> {
URLCellBloc({required this.cellController})
: super(URLCellState.initial(cellController)) {
_dispatch();
}
final URLCellController cellController;
void Function()? _onCellChangedFn;
URLCellBloc({
required this.cellController,
}) : super(URLCellState.initial(cellController)) {
void _dispatch() {
on<URLCellEvent>(
(event, emit) async {
event.when(
@ -46,11 +51,11 @@ class URLCellBloc extends Bloc<URLCellEvent, URLCellState> {
void _startListening() {
_onCellChangedFn = cellController.addListener(
onCellChanged: ((cellData) {
onCellChanged: (cellData) {
if (!isClosed) {
add(URLCellEvent.didReceiveCellUpdate(cellData));
}
}),
},
);
}
}

View File

@ -1,17 +1,22 @@
import 'dart:async';
import 'package:appflowy/plugins/database/application/cell/cell_controller_builder.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/url_entities.pb.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'dart:async';
part 'url_cell_editor_bloc.freezed.dart';
class URLCellEditorBloc extends Bloc<URLCellEditorEvent, URLCellEditorState> {
URLCellEditorBloc({required this.cellController})
: super(URLCellEditorState.initial(cellController)) {
_dispatch();
}
final URLCellController cellController;
void Function()? _onCellChangedFn;
URLCellEditorBloc({
required this.cellController,
}) : super(URLCellEditorState.initial(cellController)) {
void _dispatch() {
on<URLCellEditorEvent>(
(event, emit) async {
await event.when(
@ -47,11 +52,11 @@ class URLCellEditorBloc extends Bloc<URLCellEditorEvent, URLCellEditorState> {
void _startListening() {
_onCellChangedFn = cellController.addListener(
onCellChanged: ((cellData) {
onCellChanged: (cellData) {
if (!isClosed) {
add(URLCellEditorEvent.didReceiveCellUpdate(cellData));
}
}),
},
);
}
}

View File

@ -9,11 +9,9 @@ import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
class RowActionList extends StatelessWidget {
const RowActionList({super.key, required this.rowController});
final RowController rowController;
const RowActionList({
required this.rowController,
super.key,
});
@override
Widget build(BuildContext context) {

View File

@ -19,15 +19,15 @@ typedef OnSubmittedEmoji = void Function(String emoji);
const _kBannerActionHeight = 40.0;
class RowBanner extends StatefulWidget {
final RowController rowController;
final EditableCellBuilder cellBuilder;
const RowBanner({
super.key,
required this.rowController,
required this.cellBuilder,
super.key,
});
final RowController rowController;
final EditableCellBuilder cellBuilder;
@override
State<RowBanner> createState() => _RowBannerState();
}
@ -88,14 +88,14 @@ class _RowBannerState extends State<RowBanner> {
}
class _BannerAction extends StatelessWidget {
final ValueNotifier<bool> isHovering;
final PopoverController popoverController;
const _BannerAction({
required this.isHovering,
required this.popoverController,
});
final ValueNotifier<bool> isHovering;
final PopoverController popoverController;
@override
Widget build(BuildContext context) {
return SizedBox(
@ -111,7 +111,6 @@ class _BannerAction extends StatelessWidget {
builder: (context, state) {
return Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if (state.rowMeta.icon.isEmpty)
AddEmojiButton(
@ -134,16 +133,16 @@ class _BannerAction extends StatelessWidget {
}
class _BannerTitle extends StatelessWidget {
final EditableCellBuilder cellBuilder;
final PopoverController popoverController;
final RowController rowController;
const _BannerTitle({
required this.cellBuilder,
required this.popoverController,
required this.rowController,
});
final EditableCellBuilder cellBuilder;
final PopoverController popoverController;
final RowController rowController;
@override
Widget build(BuildContext context) {
return BlocBuilder<RowBannerBloc, RowBannerState>(
@ -187,15 +186,15 @@ class _BannerTitle extends StatelessWidget {
}
class EmojiButton extends StatelessWidget {
final String emoji;
final VoidCallback showEmojiPicker;
const EmojiButton({
super.key,
required this.emoji,
required this.showEmojiPicker,
super.key,
});
final String emoji;
final VoidCallback showEmojiPicker;
@override
Widget build(BuildContext context) {
return SizedBox(
@ -214,11 +213,9 @@ class EmojiButton extends StatelessWidget {
}
class AddEmojiButton extends StatelessWidget {
const AddEmojiButton({super.key, required this.onTap});
final VoidCallback onTap;
const AddEmojiButton({
super.key,
required this.onTap,
});
@override
Widget build(BuildContext context) {
@ -238,11 +235,9 @@ class AddEmojiButton extends StatelessWidget {
}
class RemoveEmojiButton extends StatelessWidget {
const RemoveEmojiButton({super.key, required this.onTap});
final VoidCallback onTap;
const RemoveEmojiButton({
super.key,
required this.onTap,
});
@override
Widget build(BuildContext context) {
@ -262,9 +257,10 @@ class RemoveEmojiButton extends StatelessWidget {
}
class RowActionButton extends StatelessWidget {
final RowController rowController;
const RowActionButton({super.key, required this.rowController});
final RowController rowController;
@override
Widget build(BuildContext context) {
return AppFlowyPopover(

View File

@ -13,15 +13,15 @@ import 'row_banner.dart';
import 'row_property.dart';
class RowDetailPage extends StatefulWidget with FlowyOverlayDelegate {
final DatabaseController databaseController;
final RowController rowController;
const RowDetailPage({
super.key,
required this.rowController,
required this.databaseController,
});
final RowController rowController;
final DatabaseController databaseController;
@override
State<RowDetailPage> createState() => _RowDetailPageState();
}

View File

@ -27,10 +27,6 @@ import '../cell/editable_cell_builder.dart';
/// Display the row properties in a list. Only used in [RowDetailPage].
class RowPropertyList extends StatelessWidget {
final String viewId;
final FieldController fieldController;
final EditableCellBuilder cellBuilder;
const RowPropertyList({
super.key,
required this.viewId,
@ -38,6 +34,10 @@ class RowPropertyList extends StatelessWidget {
required this.cellBuilder,
});
final String viewId;
final FieldController fieldController;
final EditableCellBuilder cellBuilder;
@override
Widget build(BuildContext context) {
return BlocBuilder<RowDetailBloc, RowDetailState>(
@ -109,11 +109,6 @@ class RowPropertyList extends StatelessWidget {
}
class _PropertyCell extends StatefulWidget {
final CellContext cellContext;
final EditableCellBuilder cellBuilder;
final FieldController fieldController;
final int index;
const _PropertyCell({
super.key,
required this.cellContext,
@ -122,6 +117,11 @@ class _PropertyCell extends StatefulWidget {
required this.index,
});
final CellContext cellContext;
final EditableCellBuilder cellBuilder;
final FieldController fieldController;
final int index;
@override
State<StatefulWidget> createState() => _PropertyCellState();
}
@ -193,7 +193,6 @@ class _PropertyCellState extends State<_PropertyCell> {
onExit: (event) => _isFieldHover.value = false,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
ValueListenableBuilder(
valueListenable: _isFieldHover,
@ -312,7 +311,6 @@ class ToggleHiddenFieldsVisibilityButton extends StatelessWidget {
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
side: BorderSide.none,
),
),
overlayColor: MaterialStateProperty.all<Color>(
@ -345,15 +343,15 @@ class ToggleHiddenFieldsVisibilityButton extends StatelessWidget {
}
class CreateRowFieldButton extends StatefulWidget {
final String viewId;
final FieldController fieldController;
const CreateRowFieldButton({
super.key,
required this.viewId,
required this.fieldController,
});
final String viewId;
final FieldController fieldController;
@override
State<CreateRowFieldButton> createState() => _CreateRowFieldButtonState();
}

View File

@ -79,7 +79,6 @@ extension DatabaseSettingActionExtension on DatabaseSettingAction {
child: SizedBox(
height: GridSize.popoverItemHeight,
child: FlowyButton(
onTap: null,
hoverColor: AFThemeExtension.of(context).lightGreyHover,
text: FlowyText.medium(
title(),

View File

@ -18,15 +18,15 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:styled_widget/styled_widget.dart';
class DatabasePropertyList extends StatefulWidget {
final String viewId;
final FieldController fieldController;
const DatabasePropertyList({
super.key,
required this.viewId,
required this.fieldController,
});
final String viewId;
final FieldController fieldController;
@override
State<StatefulWidget> createState() => _DatabasePropertyListState();
}

View File

@ -140,10 +140,10 @@ enum ShareAction {
}
class ShareActionWrapper extends ActionCell {
final ShareAction inner;
ShareActionWrapper(this.inner);
final ShareAction inner;
Widget? icon(Color iconColor) => null;
@override