crowd_label.dart 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import 'package:fis_jsonrpc/rpc.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:get/get.dart';
  4. import 'package:vnoteapp/components/cell.dart';
  5. import 'package:vnoteapp/pages/controllers/crowd_labels.dart';
  6. class CrowdLabelView extends GetView<CrowdLabelsController> {
  7. const CrowdLabelView({super.key});
  8. @override
  9. Widget build(BuildContext context) {
  10. return Container(
  11. padding: const EdgeInsets.only(bottom: 80),
  12. child: buildCrowdLables(context));
  13. }
  14. Widget buildCrowdLables(BuildContext context) {
  15. return Obx(() {
  16. final state = controller.state;
  17. return SingleChildScrollView(
  18. child: Column(
  19. children: [
  20. VListFormCellGroup(
  21. children: [
  22. ...state.normalOptions
  23. .map((LabelDTO e) => buildItem(e, context))
  24. .toList(),
  25. ...state.diseaseOptions
  26. .map((LabelDTO e) => buildItem(e, context))
  27. .toList(),
  28. ...state.specialCareOptions
  29. .map((LabelDTO e) => buildItem(e, context))
  30. .toList(),
  31. ],
  32. ),
  33. ],
  34. ),
  35. );
  36. });
  37. }
  38. Widget buildItem(LabelDTO dto, BuildContext context) {
  39. return InkWell(
  40. onTap: () {
  41. controller.onItemCheckChanged(dto.code!);
  42. },
  43. child: Container(
  44. // margin: const EdgeInsets.symmetric(vertical: 8),
  45. child: Row(
  46. children: [
  47. Expanded(
  48. child: VListFormCell(
  49. label: dto.labelName ?? '',
  50. contentWidget: Obx(
  51. () => Switch(
  52. value: controller.state.selectedCodes.contains(dto.code),
  53. onChanged: (value) {
  54. controller.onItemCheckChanged(dto.code!);
  55. },
  56. activeColor: Theme.of(context).primaryColor,
  57. inactiveThumbColor: Colors.grey,
  58. // inactiveTrackColor:Colors.grey,
  59. ),
  60. ),
  61. ),
  62. ),
  63. ],
  64. ),
  65. ),
  66. );
  67. }
  68. }