Showing
1 changed file
with
38 additions
and
14 deletions
| @@ -53,6 +53,7 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | @@ -53,6 +53,7 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | ||
| 53 | NotebookDetailModel detailModel = NotebookDetailModel(); | 53 | NotebookDetailModel detailModel = NotebookDetailModel(); |
| 54 | EasyContactPicker _contactPicker = EasyContactPicker(); | 54 | EasyContactPicker _contactPicker = EasyContactPicker(); |
| 55 | RemarkManagerModel remarkManagerModel; | 55 | RemarkManagerModel remarkManagerModel; |
| 56 | + String currentRemark = ''; | ||
| 56 | 57 | ||
| 57 | @override | 58 | @override |
| 58 | void initState() { | 59 | void initState() { |
| @@ -663,7 +664,11 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | @@ -663,7 +664,11 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | ||
| 663 | // EdgeInsets.only(bottom: ScreenUtil().setWidth(17)), | 664 | // EdgeInsets.only(bottom: ScreenUtil().setWidth(17)), |
| 664 | border: InputBorder.none, | 665 | border: InputBorder.none, |
| 665 | ), | 666 | ), |
| 666 | - onChanged: (value) {}, | 667 | + onChanged: (value) { |
| 668 | + print(value); | ||
| 669 | + currentRemark = value; | ||
| 670 | + // print(); | ||
| 671 | + }, | ||
| 667 | onEditingComplete: () { | 672 | onEditingComplete: () { |
| 668 | print('fff'); | 673 | print('fff'); |
| 669 | _needNode.unfocus(); | 674 | _needNode.unfocus(); |
| @@ -731,24 +736,43 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | @@ -731,24 +736,43 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> { | ||
| 731 | } | 736 | } |
| 732 | 737 | ||
| 733 | _refreshRemark(List<Remark> remark, int index) { | 738 | _refreshRemark(List<Remark> remark, int index) { |
| 734 | - String currentRemark = ''; | ||
| 735 | - for (int i = 0; i < remark.length; i++) { | ||
| 736 | - if (remark[i].selected) { | ||
| 737 | - if (currentRemark.length == 0) { | ||
| 738 | - currentRemark += '${remark[i].custom}'; | ||
| 739 | - } else { | ||
| 740 | - currentRemark += '、${remark[i].custom}'; | 739 | + if (remark[index].selected) { |
| 740 | + if (currentRemark.length == 0) { | ||
| 741 | + currentRemark += '${remark[index].custom}'; | ||
| 742 | + } else { | ||
| 743 | + if (!currentRemark.contains(remark[index].custom)) { | ||
| 744 | + if (currentRemark.endsWith('、')) { | ||
| 745 | + currentRemark += '${remark[index].custom}'; | ||
| 746 | + } else { | ||
| 747 | + currentRemark += '、${remark[index].custom}'; | ||
| 748 | + } | ||
| 749 | + } | ||
| 750 | + } | ||
| 751 | + } else { | ||
| 752 | + if (currentRemark.contains(remark[index].custom)) { | ||
| 753 | + int start = currentRemark.indexOf(remark[index].custom); | ||
| 754 | + int end = start + remark[index].custom.length; | ||
| 755 | + currentRemark = currentRemark.replaceRange(start, end, ''); | ||
| 756 | + if (currentRemark.endsWith('、')) { | ||
| 757 | + currentRemark = currentRemark.substring(0, currentRemark.length - 1); | ||
| 758 | + } | ||
| 759 | + if (currentRemark.startsWith('、')) { | ||
| 760 | + currentRemark = currentRemark.substring(1, currentRemark.length); | ||
| 761 | + } | ||
| 762 | + if (currentRemark.contains('、、')) { | ||
| 763 | + currentRemark = currentRemark.replaceRange( | ||
| 764 | + currentRemark.indexOf('、、'), | ||
| 765 | + currentRemark.indexOf('、、') + 2, | ||
| 766 | + '、'); | ||
| 741 | } | 767 | } |
| 742 | } | 768 | } |
| 743 | } | 769 | } |
| 744 | if (currentRemark.length > 25) { | 770 | if (currentRemark.length > 25) { |
| 745 | - Utils.showToast('备注字数超过25个字!'); | ||
| 746 | - remark[index].selected = !remark[index].selected; | ||
| 747 | - } else { | ||
| 748 | - setState(() { | ||
| 749 | - _notebookDetailChangeModel.customController.text = currentRemark; | ||
| 750 | - }); | 771 | + currentRemark = currentRemark.substring(0, 25); |
| 751 | } | 772 | } |
| 773 | + setState(() { | ||
| 774 | + _notebookDetailChangeModel.customController.text = currentRemark; | ||
| 775 | + }); | ||
| 752 | } | 776 | } |
| 753 | 777 | ||
| 754 | ///底部弹框,设置时间30分钟间隔布局 | 778 | ///底部弹框,设置时间30分钟间隔布局 |
-
Please register or login to post a comment