feat: Create lists with checkboxes via + menu
This commit is contained in:
parent
a2e5a940bd
commit
9da7a5704e
3 changed files with 55 additions and 7 deletions
|
|
@ -696,6 +696,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"checkList": "Check list",
|
||||||
"countParticipants": "{count} participants",
|
"countParticipants": "{count} participants",
|
||||||
"@countParticipants": {
|
"@countParticipants": {
|
||||||
"type": "String",
|
"type": "String",
|
||||||
|
|
|
||||||
|
|
@ -275,13 +275,44 @@ class ChatController extends State<ChatPageWithRoom>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEventResult _shiftEnterKeyHandling(FocusNode node, KeyEvent evt) {
|
KeyEventResult _customEnterKeyHandling(FocusNode node, KeyEvent evt) {
|
||||||
if (!HardwareKeyboard.instance.isShiftPressed &&
|
if (!HardwareKeyboard.instance.isShiftPressed &&
|
||||||
evt.logicalKey.keyLabel == 'Enter') {
|
evt.logicalKey.keyLabel == 'Enter' &&
|
||||||
|
(AppConfig.sendOnEnter ?? !PlatformInfos.isMobile)) {
|
||||||
if (evt is KeyDownEvent) {
|
if (evt is KeyDownEvent) {
|
||||||
send();
|
send();
|
||||||
}
|
}
|
||||||
return KeyEventResult.handled;
|
return KeyEventResult.handled;
|
||||||
|
} else if (evt.logicalKey.keyLabel == 'Enter' && evt is KeyDownEvent) {
|
||||||
|
final currentLineNum = sendController.text
|
||||||
|
.substring(
|
||||||
|
0,
|
||||||
|
sendController.selection.baseOffset,
|
||||||
|
)
|
||||||
|
.split('\n')
|
||||||
|
.length -
|
||||||
|
1;
|
||||||
|
final currentLine = sendController.text.split('\n')[currentLineNum];
|
||||||
|
|
||||||
|
for (final pattern in [
|
||||||
|
'- [ ] ',
|
||||||
|
'- [x] ',
|
||||||
|
'* [ ] ',
|
||||||
|
'* [x] ',
|
||||||
|
'- ',
|
||||||
|
'* ',
|
||||||
|
'+ ',
|
||||||
|
]) {
|
||||||
|
if (currentLine.startsWith(pattern)) {
|
||||||
|
if (currentLine == pattern) {
|
||||||
|
return KeyEventResult.ignored;
|
||||||
|
}
|
||||||
|
sendController.text += '\n$pattern';
|
||||||
|
return KeyEventResult.handled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return KeyEventResult.ignored;
|
||||||
} else {
|
} else {
|
||||||
return KeyEventResult.ignored;
|
return KeyEventResult.ignored;
|
||||||
}
|
}
|
||||||
|
|
@ -289,11 +320,7 @@ class ChatController extends State<ChatPageWithRoom>
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
inputFocus = FocusNode(
|
inputFocus = FocusNode(onKeyEvent: _customEnterKeyHandling);
|
||||||
onKeyEvent: (AppConfig.sendOnEnter ?? !PlatformInfos.isMobile)
|
|
||||||
? _shiftEnterKeyHandling
|
|
||||||
: null,
|
|
||||||
);
|
|
||||||
|
|
||||||
scrollController.addListener(_updateScrollController);
|
scrollController.addListener(_updateScrollController);
|
||||||
inputFocus.addListener(_inputFocusListener);
|
inputFocus.addListener(_inputFocusListener);
|
||||||
|
|
@ -1154,6 +1181,14 @@ class ChatController extends State<ChatPageWithRoom>
|
||||||
if (choice == 'location') {
|
if (choice == 'location') {
|
||||||
sendLocationAction();
|
sendLocationAction();
|
||||||
}
|
}
|
||||||
|
if (choice == 'checklist') {
|
||||||
|
if (sendController.text.isEmpty) {
|
||||||
|
sendController.text = '- [ ] ';
|
||||||
|
} else {
|
||||||
|
sendController.text += '\n- [ ] ';
|
||||||
|
}
|
||||||
|
inputFocus.requestFocus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unpinEvent(String eventId) async {
|
unpinEvent(String eventId) async {
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,18 @@ class ChatInputRow extends StatelessWidget {
|
||||||
onSelected: controller.onAddPopupMenuButtonSelected,
|
onSelected: controller.onAddPopupMenuButtonSelected,
|
||||||
itemBuilder: (BuildContext context) =>
|
itemBuilder: (BuildContext context) =>
|
||||||
<PopupMenuEntry<String>>[
|
<PopupMenuEntry<String>>[
|
||||||
|
PopupMenuItem<String>(
|
||||||
|
value: 'checklist',
|
||||||
|
child: ListTile(
|
||||||
|
leading: CircleAvatar(
|
||||||
|
backgroundColor: theme.colorScheme.onPrimaryContainer,
|
||||||
|
foregroundColor: theme.colorScheme.primaryContainer,
|
||||||
|
child: const Icon(Icons.check_circle_outlined),
|
||||||
|
),
|
||||||
|
title: Text(L10n.of(context).checkList),
|
||||||
|
contentPadding: const EdgeInsets.all(0),
|
||||||
|
),
|
||||||
|
),
|
||||||
if (PlatformInfos.isMobile)
|
if (PlatformInfos.isMobile)
|
||||||
PopupMenuItem<String>(
|
PopupMenuItem<String>(
|
||||||
value: 'location',
|
value: 'location',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue