|
@@ -1,9 +1,9 @@
|
|
|
import 'package:appflowy/plugins/database_view/application/cell/cell_controller_builder.dart';
|
|
|
+import 'package:appflowy/plugins/database_view/widgets/row/cells/text_cell/text_cell_bloc.dart';
|
|
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
import '../../row/cell_builder.dart';
|
|
|
-import '../bloc/text_card_cell_bloc.dart';
|
|
|
import '../define.dart';
|
|
|
import 'card_cell.dart';
|
|
|
|
|
@@ -30,11 +30,11 @@ class TextCardCell<CustomCardData>
|
|
|
}) : super(key: key, style: style, cardData: cardData);
|
|
|
|
|
|
@override
|
|
|
- State<TextCardCell> createState() => _TextCardCellState();
|
|
|
+ State<TextCardCell> createState() => _TextCellState();
|
|
|
}
|
|
|
|
|
|
-class _TextCardCellState extends State<TextCardCell> {
|
|
|
- late TextCardCellBloc _cellBloc;
|
|
|
+class _TextCellState extends State<TextCardCell> {
|
|
|
+ late TextCellBloc _cellBloc;
|
|
|
late TextEditingController _controller;
|
|
|
bool focusWhenInit = false;
|
|
|
final focusNode = SingleListenerFocusNode();
|
|
@@ -43,8 +43,8 @@ class _TextCardCellState extends State<TextCardCell> {
|
|
|
void initState() {
|
|
|
final cellController =
|
|
|
widget.cellControllerBuilder.build() as TextCellController;
|
|
|
- _cellBloc = TextCardCellBloc(cellController: cellController)
|
|
|
- ..add(const TextCardCellEvent.initial());
|
|
|
+ _cellBloc = TextCellBloc(cellController: cellController)
|
|
|
+ ..add(const TextCellEvent.initial());
|
|
|
_controller = TextEditingController(text: _cellBloc.state.content);
|
|
|
focusWhenInit = widget.editableNotifier?.isCellEditing.value ?? false;
|
|
|
if (focusWhenInit) {
|
|
@@ -58,7 +58,7 @@ class _TextCardCellState extends State<TextCardCell> {
|
|
|
if (!focusNode.hasFocus) {
|
|
|
focusWhenInit = false;
|
|
|
widget.editableNotifier?.isCellEditing.value = false;
|
|
|
- _cellBloc.add(const TextCardCellEvent.enableEdit(false));
|
|
|
+ _cellBloc.add(const TextCellEvent.enableEdit(false));
|
|
|
}
|
|
|
});
|
|
|
_bindEditableNotifier();
|
|
@@ -75,7 +75,7 @@ class _TextCardCellState extends State<TextCardCell> {
|
|
|
focusNode.requestFocus();
|
|
|
});
|
|
|
}
|
|
|
- _cellBloc.add(TextCardCellEvent.enableEdit(isEditing));
|
|
|
+ _cellBloc.add(TextCellEvent.enableEdit(isEditing));
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -89,13 +89,13 @@ class _TextCardCellState extends State<TextCardCell> {
|
|
|
Widget build(BuildContext context) {
|
|
|
return BlocProvider.value(
|
|
|
value: _cellBloc,
|
|
|
- child: BlocListener<TextCardCellBloc, TextCardCellState>(
|
|
|
+ child: BlocListener<TextCellBloc, TextCellState>(
|
|
|
listener: (context, state) {
|
|
|
if (_controller.text != state.content) {
|
|
|
_controller.text = state.content;
|
|
|
}
|
|
|
},
|
|
|
- child: BlocBuilder<TextCardCellBloc, TextCardCellState>(
|
|
|
+ child: BlocBuilder<TextCellBloc, TextCellState>(
|
|
|
buildWhen: (previous, current) {
|
|
|
if (previous.content != current.content &&
|
|
|
_controller.text == current.content &&
|
|
@@ -137,7 +137,7 @@ class _TextCardCellState extends State<TextCardCell> {
|
|
|
}
|
|
|
|
|
|
Future<void> focusChanged() async {
|
|
|
- _cellBloc.add(TextCardCellEvent.updateText(_controller.text));
|
|
|
+ _cellBloc.add(TextCellEvent.updateText(_controller.text));
|
|
|
}
|
|
|
|
|
|
@override
|
|
@@ -156,7 +156,7 @@ class _TextCardCellState extends State<TextCardCell> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Widget _buildText(TextCardCellState state) {
|
|
|
+ Widget _buildText(TextCellState state) {
|
|
|
return Padding(
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
vertical: CardSizes.cardCellVPadding,
|