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