chore: Follow up create check list UX
This commit is contained in:
parent
52ba9468a4
commit
5fb882955c
3 changed files with 29 additions and 21 deletions
|
|
@ -1186,15 +1186,6 @@ 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- [ ] ';
|
|
||||||
}
|
|
||||||
onInputBarChanged(sendController.text);
|
|
||||||
inputFocus.requestFocus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unpinEvent(String eventId) async {
|
unpinEvent(String eventId) async {
|
||||||
|
|
|
||||||
|
|
@ -124,18 +124,6 @@ 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',
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,35 @@ Widget markdownContextBuilder(
|
||||||
ContextMenuController.removeAny();
|
ContextMenuController.removeAny();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
ContextMenuButtonItem(
|
||||||
|
label: l10n.checkList,
|
||||||
|
onPressed: () {
|
||||||
|
final text = controller.text;
|
||||||
|
final selection = controller.selection;
|
||||||
|
|
||||||
|
var start = selection.textBefore(text).lastIndexOf('\n');
|
||||||
|
if (start == -1) start = 0;
|
||||||
|
final end = selection.end;
|
||||||
|
|
||||||
|
final fullLineSelection =
|
||||||
|
TextSelection(baseOffset: start, extentOffset: end);
|
||||||
|
|
||||||
|
const checkBox = '- [ ]';
|
||||||
|
|
||||||
|
final replacedRange = fullLineSelection
|
||||||
|
.textInside(text)
|
||||||
|
.split('\n')
|
||||||
|
.map(
|
||||||
|
(line) => line.startsWith(checkBox) || line.isEmpty
|
||||||
|
? line
|
||||||
|
: '$checkBox $line',
|
||||||
|
)
|
||||||
|
.join('\n');
|
||||||
|
controller.text =
|
||||||
|
controller.text.replaceRange(start, end, replacedRange);
|
||||||
|
ContextMenuController.removeAny();
|
||||||
|
},
|
||||||
|
),
|
||||||
ContextMenuButtonItem(
|
ContextMenuButtonItem(
|
||||||
label: l10n.boldText,
|
label: l10n.boldText,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue