mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: auto focus checklist editing (#2720)
This commit is contained in:
parent
bf121623ae
commit
e96bea0de5
@ -41,6 +41,7 @@ class ChecklistCellEditorBloc
|
||||
_createOption(optionName);
|
||||
emit(
|
||||
state.copyWith(
|
||||
createOption: Some(optionName),
|
||||
predicate: '',
|
||||
),
|
||||
);
|
||||
|
@ -54,13 +54,52 @@ class _SliverChecklistProgressBarDelegate
|
||||
double shrinkOffset,
|
||||
bool overlapsContent,
|
||||
) {
|
||||
return const _AutoFocusTextField();
|
||||
}
|
||||
|
||||
@override
|
||||
double get maxExtent => fixHeight;
|
||||
|
||||
@override
|
||||
double get minExtent => fixHeight;
|
||||
|
||||
@override
|
||||
bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class _AutoFocusTextField extends StatefulWidget {
|
||||
const _AutoFocusTextField();
|
||||
|
||||
@override
|
||||
State<_AutoFocusTextField> createState() => _AutoFocusTextFieldState();
|
||||
}
|
||||
|
||||
class _AutoFocusTextFieldState extends State<_AutoFocusTextField> {
|
||||
final _focusNode = FocusNode();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<ChecklistCellEditorBloc, ChecklistCellEditorState>(
|
||||
builder: (context, state) {
|
||||
return Padding(
|
||||
return BlocListener<ChecklistCellEditorBloc, ChecklistCellEditorState>(
|
||||
listenWhen: (previous, current) =>
|
||||
previous.createOption != current.createOption,
|
||||
listener: (context, state) {
|
||||
if (_focusNode.canRequestFocus) {
|
||||
_focusNode.requestFocus();
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
color: Theme.of(context).cardColor,
|
||||
child: Padding(
|
||||
padding: GridSize.typeOptionContentInsets,
|
||||
child: Column(
|
||||
children: [
|
||||
FlowyTextField(
|
||||
autoFocus: true,
|
||||
focusNode: _focusNode,
|
||||
autoClearWhenDone: true,
|
||||
submitOnLeave: true,
|
||||
hintText: LocaleKeys.grid_checklist_panelTitle.tr(),
|
||||
@ -81,19 +120,10 @@ class _SliverChecklistProgressBarDelegate
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
double get maxExtent => fixHeight;
|
||||
|
||||
@override
|
||||
double get minExtent => fixHeight;
|
||||
|
||||
@override
|
||||
bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user