tag can submit after space
This commit is contained in:
parent
9eb72a60ac
commit
41112a3eea
@ -91,6 +91,7 @@ class _AddServiceProjectJobBottomSheetState
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Widget _branchSelector() => Obx(() {
|
||||
if (controller.isBranchLoading.value) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
@ -197,6 +198,8 @@ class _AddServiceProjectJobBottomSheetState
|
||||
],
|
||||
);
|
||||
|
||||
// ----------------- UPDATED TAG INPUT -----------------
|
||||
|
||||
Widget _tagInput() => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@ -205,6 +208,27 @@ class _AddServiceProjectJobBottomSheetState
|
||||
child: TextFormField(
|
||||
controller: controller.tagCtrl,
|
||||
textInputAction: TextInputAction.done,
|
||||
|
||||
// 🚀 Auto-create tag when space pressed
|
||||
onChanged: (value) {
|
||||
if (value.endsWith(' ')) {
|
||||
final raw = value.trim();
|
||||
if (raw.isNotEmpty) {
|
||||
final parts = raw
|
||||
.split(RegExp(r'[, ]+'))
|
||||
.map((s) => s.trim())
|
||||
.where((s) => s.isNotEmpty);
|
||||
|
||||
for (final p in parts) {
|
||||
if (!controller.enteredTags.contains(p)) {
|
||||
controller.enteredTags.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
controller.tagCtrl.clear();
|
||||
}
|
||||
},
|
||||
|
||||
onEditingComplete: () {
|
||||
final raw = controller.tagCtrl.text.trim();
|
||||
if (raw.isEmpty) return;
|
||||
@ -221,13 +245,13 @@ class _AddServiceProjectJobBottomSheetState
|
||||
}
|
||||
controller.tagCtrl.clear();
|
||||
},
|
||||
|
||||
onFieldSubmitted: (v) {
|
||||
// also handle normal submit
|
||||
final raw = v.trim();
|
||||
if (raw.isEmpty) return;
|
||||
|
||||
final parts = raw
|
||||
.split(',')
|
||||
.split(RegExp(r'[, ]+'))
|
||||
.map((s) => s.trim())
|
||||
.where((s) => s.isNotEmpty);
|
||||
|
||||
@ -238,6 +262,7 @@ class _AddServiceProjectJobBottomSheetState
|
||||
}
|
||||
controller.tagCtrl.clear();
|
||||
},
|
||||
|
||||
decoration: _inputDecoration("Start typing to add tags"),
|
||||
validator: (v) => controller.enteredTags.isEmpty
|
||||
? "Please add at least one tag"
|
||||
@ -257,6 +282,8 @@ class _AddServiceProjectJobBottomSheetState
|
||||
],
|
||||
);
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
||||
void _handleSubmit() {
|
||||
if (!(formKey.currentState?.validate() ?? false)) return;
|
||||
controller.titleCtrl.text = controller.titleCtrl.text.trim();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user