Commit 590a37e78061f2708255c929f5968df19e40b7b1

Authored by wdn127929
1 parent 72b88052

min and max

@@ -63,14 +63,26 @@ class _MyContactListPageState extends State<MyContactListPage> { @@ -63,14 +63,26 @@ class _MyContactListPageState extends State<MyContactListPage> {
63 // ItemPosition itemPosition = positon.itemPositions.value.first; 63 // ItemPosition itemPosition = positon.itemPositions.value.first;
64 print('${positon.itemPositions.value.last.index}'); 64 print('${positon.itemPositions.value.last.index}');
65 // positon.itemPositions.value 65 // positon.itemPositions.value
66 - if (positon.itemPositions.value.last.index == 1 &&  
67 - widget.contacts.length >= 10) { 66 +
  67 + int max = positon.itemPositions.value
  68 + .where((ItemPosition position) => position.itemLeadingEdge < 1)
  69 + .reduce((ItemPosition max, ItemPosition position) =>
  70 + position.itemLeadingEdge > max.itemLeadingEdge ? position : max)
  71 + .index;
  72 + int min = positon.itemPositions.value
  73 + .where((ItemPosition position) => position.itemTrailingEdge > 0)
  74 + .reduce((ItemPosition min, ItemPosition position) =>
  75 + position.itemTrailingEdge < min.itemTrailingEdge ? position : min)
  76 + .index;
  77 + print(min);
  78 + print(max);
  79 + if (min == 0 && widget.contacts.length > 10) {
68 bus.emit( 80 bus.emit(
69 'onrefresh_guest_list_my', 81 'onrefresh_guest_list_my',
70 ); 82 );
71 } 83 }
72 - if (positon.itemPositions.value.last.index == widget.contacts.length - 1 &&  
73 - widget.contacts.length >= 10) { 84 +
  85 + if (max == widget.contacts.length - 1 && widget.contacts.length >= 10) {
74 //上拉加载方法,最底部 86 //上拉加载方法,最底部
75 87
76 bus.emit( 88 bus.emit(
@@ -79,6 +91,22 @@ class _MyContactListPageState extends State<MyContactListPage> { @@ -79,6 +91,22 @@ class _MyContactListPageState extends State<MyContactListPage> {
79 ? 1 91 ? 1
80 : (widget.contacts.length / 10).toInt()); 92 : (widget.contacts.length / 10).toInt());
81 } 93 }
  94 + // if (positon.itemPositions.value.last.index == 1 &&
  95 + // widget.contacts.length >= 10) {
  96 + // bus.emit(
  97 + // 'onrefresh_guest_list_my',
  98 + // );
  99 + // }
  100 + // if (positon.itemPositions.value.last.index == widget.contacts.length - 1 &&
  101 + // widget.contacts.length >= 10) {
  102 + // //上拉加载方法,最底部
  103 +
  104 + // bus.emit(
  105 + // 'onload_guest_list_my',
  106 + // (widget.contacts.length / 10) < 1
  107 + // ? 1
  108 + // : (widget.contacts.length / 10).toInt());
  109 + // }
82 } 110 }
83 111
84 // void loadData() async { 112 // void loadData() async {
@@ -164,7 +164,7 @@ class _MyCustomerListPageState extends State<MyCustomerListPage> @@ -164,7 +164,7 @@ class _MyCustomerListPageState extends State<MyCustomerListPage>
164 _onrefresh() { 164 _onrefresh() {
165 page = 1; 165 page = 1;
166 customerProvider.pageDataMy = [0]; 166 customerProvider.pageDataMy = [0];
167 - _getContantData(showLoading: false); 167 + _getContantData(showLoading: false, load: true);
168 } 168 }
169 169
170 _filterLabelList() async { 170 _filterLabelList() async {
@@ -43,6 +43,7 @@ class _ContactListPageState extends State<ContactListPage> { @@ -43,6 +43,7 @@ class _ContactListPageState extends State<ContactListPage> {
43 void initState() { 43 void initState() {
44 super.initState(); 44 super.initState();
45 widget.provider.handleList(widget.contacts); 45 widget.provider.handleList(widget.contacts);
  46 +
46 positon.itemPositions.addListener(_itemPositonChanaged 47 positon.itemPositions.addListener(_itemPositonChanaged
47 // print('${positon.itemPositions.value.last.index}'); 48 // print('${positon.itemPositions.value.last.index}');
48 // // positon.itemPositions.value 49 // // positon.itemPositions.value
@@ -64,15 +65,26 @@ class _ContactListPageState extends State<ContactListPage> { @@ -64,15 +65,26 @@ class _ContactListPageState extends State<ContactListPage> {
64 _itemPositonChanaged() { 65 _itemPositonChanaged() {
65 // ItemPosition itemPosition = positon.itemPositions.value.first; 66 // ItemPosition itemPosition = positon.itemPositions.value.first;
66 print('${positon.itemPositions.value.last.index}'); 67 print('${positon.itemPositions.value.last.index}');
67 - // positon.itemPositions.value  
68 - if (positon.itemPositions.value.last.index == 1 &&  
69 - widget.contacts.length >= 10) { 68 +
  69 + int max = positon.itemPositions.value
  70 + .where((ItemPosition position) => position.itemLeadingEdge < 1)
  71 + .reduce((ItemPosition max, ItemPosition position) =>
  72 + position.itemLeadingEdge > max.itemLeadingEdge ? position : max)
  73 + .index;
  74 + int min = positon.itemPositions.value
  75 + .where((ItemPosition position) => position.itemTrailingEdge > 0)
  76 + .reduce((ItemPosition min, ItemPosition position) =>
  77 + position.itemTrailingEdge < min.itemTrailingEdge ? position : min)
  78 + .index;
  79 + print(min);
  80 + print(max);
  81 + if (min == 0 && widget.contacts.length > 10) {
70 bus.emit( 82 bus.emit(
71 'onrefresh_guest_list', 83 'onrefresh_guest_list',
72 ); 84 );
73 } 85 }
74 - if (positon.itemPositions.value.last.index == widget.contacts.length - 1 &&  
75 - widget.contacts.length >= 10) { 86 +
  87 + if (max == widget.contacts.length - 1 && widget.contacts.length >= 10) {
76 //上拉加载方法,最底部 88 //上拉加载方法,最底部
77 89
78 bus.emit( 90 bus.emit(
@@ -81,6 +93,24 @@ class _ContactListPageState extends State<ContactListPage> { @@ -81,6 +93,24 @@ class _ContactListPageState extends State<ContactListPage> {
81 ? 1 93 ? 1
82 : (widget.contacts.length / 10).toInt()); 94 : (widget.contacts.length / 10).toInt());
83 } 95 }
  96 + // positon.itemPositions.value
  97 + // if (positon.itemPositions.value.last.index == 1 &&
  98 + // widget.contacts.length >= 10) {
  99 + // bus.emit(
  100 + // 'onrefresh_guest_list',
  101 + // );
  102 + // }
  103 +
  104 + // if (positon.itemPositions.value.last.index == widget.contacts.length - 1 &&
  105 + // widget.contacts.length >= 10) {
  106 + // //上拉加载方法,最底部
  107 +
  108 + // bus.emit(
  109 + // 'onload_guest_list',
  110 + // (widget.contacts.length / 10) < 1
  111 + // ? 1
  112 + // : (widget.contacts.length / 10).toInt());
  113 + // }
84 } 114 }
85 115
86 // void loadData() async { 116 // void loadData() async {
@@ -186,7 +186,7 @@ class _CustomerListPageState extends State<CustomerListPage> @@ -186,7 +186,7 @@ class _CustomerListPageState extends State<CustomerListPage>
186 _onrefresh() { 186 _onrefresh() {
187 page = 1; 187 page = 1;
188 customerProvider.pageData = [0]; 188 customerProvider.pageData = [0];
189 - _getContantData(showLoading: false); 189 + _getContantData(showLoading: false, load: true);
190 } 190 }
191 191
192 // _getAuthUserLists() async { 192 // _getAuthUserLists() async {