mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Merge pull request #958 from AppFlowy-IO/feat/click_to_edit_card
This commit is contained in:
commit
942e966a25
@ -34,6 +34,14 @@ class EditableRowNotifier {
|
|||||||
notifier.resignFirstResponder.notify();
|
notifier.resignFirstResponder.notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dispose() {
|
||||||
|
for (final notifier in cells.values) {
|
||||||
|
notifier.resignFirstResponder.notify();
|
||||||
|
}
|
||||||
|
|
||||||
|
cells.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class EditableCell {
|
abstract class EditableCell {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:app_flowy/plugins/board/application/card/board_text_cell_bloc.dart';
|
import 'package:app_flowy/plugins/board/application/card/board_text_cell_bloc.dart';
|
||||||
import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart';
|
import 'package:app_flowy/plugins/grid/application/cell/cell_service/cell_service.dart';
|
||||||
import 'package:app_flowy/plugins/grid/presentation/widgets/cell/cell_builder.dart';
|
import 'package:app_flowy/plugins/grid/presentation/widgets/cell/cell_builder.dart';
|
||||||
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
@ -42,9 +43,17 @@ class _BoardTextCellState extends State<BoardTextCell> {
|
|||||||
focusNode.requestFocus();
|
focusNode.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
focusNode.addListener(() {
|
||||||
|
if (!focusNode.hasFocus) {
|
||||||
|
_cellBloc.add(const BoardTextCellEvent.enableEdit(false));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
widget.editableNotifier?.becomeFirstResponder.addListener(() {
|
widget.editableNotifier?.becomeFirstResponder.addListener(() {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
focusNode.requestFocus();
|
focusNode.requestFocus();
|
||||||
|
});
|
||||||
_cellBloc.add(const BoardTextCellEvent.enableEdit(true));
|
_cellBloc.add(const BoardTextCellEvent.enableEdit(true));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -67,24 +76,38 @@ class _BoardTextCellState extends State<BoardTextCell> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: BlocBuilder<BoardTextCellBloc, BoardTextCellState>(
|
child: BlocBuilder<BoardTextCellBloc, BoardTextCellState>(
|
||||||
buildWhen: (previous, current) =>
|
|
||||||
previous.enableEdit != current.enableEdit,
|
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return TextField(
|
Widget child;
|
||||||
// autofocus: true,
|
if (state.enableEdit) {
|
||||||
// enabled: state.enableEdit,
|
child = TextField(
|
||||||
controller: _controller,
|
controller: _controller,
|
||||||
focusNode: focusNode,
|
focusNode: focusNode,
|
||||||
onChanged: (value) => focusChanged(),
|
onChanged: (value) => focusChanged(),
|
||||||
onEditingComplete: () => focusNode.unfocus(),
|
onEditingComplete: () => focusNode.unfocus(),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
|
style: const TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
fontFamily: 'Mulish',
|
||||||
|
),
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
contentPadding: EdgeInsets.symmetric(vertical: 6),
|
// Magic number 4 makes the textField take up the same space as FlowyText
|
||||||
|
contentPadding: EdgeInsets.symmetric(vertical: 4),
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
isDense: true,
|
isDense: true,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
child = FlowyText.medium(state.content, fontSize: 14);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Align(
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -122,6 +122,7 @@ class _BoardCardState extends State<BoardCard> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> dispose() async {
|
Future<void> dispose() async {
|
||||||
|
rowNotifier.dispose();
|
||||||
_cardBloc.close();
|
_cardBloc.close();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,6 @@ class _AFBoardContentState extends State<AFBoardContent> {
|
|||||||
builder: (context, value, child) {
|
builder: (context, value, child) {
|
||||||
final boardColumn = AFBoardColumnWidget(
|
final boardColumn = AFBoardColumnWidget(
|
||||||
// key: PageStorageKey<String>(columnData.id),
|
// key: PageStorageKey<String>(columnData.id),
|
||||||
// key: GlobalObjectKey(columnData.id),
|
|
||||||
margin: _marginFromIndex(columnIndex),
|
margin: _marginFromIndex(columnIndex),
|
||||||
itemMargin: widget.config.columnItemPadding,
|
itemMargin: widget.config.columnItemPadding,
|
||||||
headerBuilder: _buildHeader,
|
headerBuilder: _buildHeader,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user