|
|
|
|
|
|
|
|
final _scrollController = ScrollController(); |
|
|
final _scrollController = ScrollController(); |
|
|
final _scrollThreshold = 250.0; |
|
|
final _scrollThreshold = 250.0; |
|
|
var heightOfActionButton = Get.width * 0.625 + 24; |
|
|
var heightOfActionButton = Get.width * 0.625 + 24; |
|
|
|
|
|
var heightHeaderList = 44; |
|
|
|
|
|
var heightListWithoutHeader = Get.height - (Get.width * 0.625 + 24) - 44; |
|
|
|
|
|
var currentOffset = 0.0; |
|
|
|
|
|
|
|
|
@override |
|
|
@override |
|
|
void initState() { |
|
|
void initState() { |
|
|
|
|
|
|
|
|
.add(DataFetched(cropId: widget.cropId, cropCode: widget.cropCode)); |
|
|
.add(DataFetched(cropId: widget.cropId, cropCode: widget.cropCode)); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
widget.parentScroll.addListener(() { |
|
|
|
|
|
setState(() { |
|
|
|
|
|
currentOffset = widget.parentScroll.offset; |
|
|
|
|
|
heightListWithoutHeader = Get.height - |
|
|
|
|
|
heightOfActionButton - |
|
|
|
|
|
heightHeaderList + |
|
|
|
|
|
currentOffset; |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
super.initState(); |
|
|
super.initState(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
List<Activities> currentItems = List<Activities>.from(state.items); |
|
|
List<Activities> currentItems = List<Activities>.from(state.items); |
|
|
return Scaffold( |
|
|
return Scaffold( |
|
|
resizeToAvoidBottomInset: false, |
|
|
|
|
|
body: RefreshIndicator( |
|
|
body: RefreshIndicator( |
|
|
child: Column( |
|
|
child: Column( |
|
|
mainAxisSize: MainAxisSize.max, |
|
|
|
|
|
children: [ |
|
|
children: [ |
|
|
Container( |
|
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
|
color: COLOR_CONST.WHITE_50, |
|
|
|
|
|
border: Border( |
|
|
|
|
|
top: BorderSide( |
|
|
|
|
|
width: 0.5, color: COLOR_CONST.DEFAULT), |
|
|
|
|
|
bottom: BorderSide( |
|
|
|
|
|
width: 0.5, color: COLOR_CONST.DEFAULT)), |
|
|
|
|
|
), |
|
|
|
|
|
|
|
|
Expanded( |
|
|
|
|
|
flex: 1, |
|
|
child: Container( |
|
|
child: Container( |
|
|
height: 40, |
|
|
|
|
|
child: Row( |
|
|
|
|
|
children: [ |
|
|
|
|
|
Expanded( |
|
|
|
|
|
child: Text( |
|
|
|
|
|
plot_detail_title, |
|
|
|
|
|
textAlign: TextAlign.center, |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 20, fontWeight: FontWeight.normal), |
|
|
|
|
|
)), |
|
|
|
|
|
GestureDetector( |
|
|
|
|
|
child: (widget.parentScroll.position.pixels < |
|
|
|
|
|
heightOfActionButton) |
|
|
|
|
|
? Icon(Icons.arrow_upward) |
|
|
|
|
|
: Icon(Icons.arrow_downward_outlined), |
|
|
|
|
|
onTap: () { |
|
|
|
|
|
if (widget.parentScroll.position.pixels < |
|
|
|
|
|
heightOfActionButton) { |
|
|
|
|
|
widget.parentScroll.animateTo( |
|
|
|
|
|
heightOfActionButton, |
|
|
|
|
|
duration: Duration(milliseconds: 500), |
|
|
|
|
|
curve: Curves.easeOut); |
|
|
|
|
|
} else { |
|
|
|
|
|
widget.parentScroll.animateTo(0.0, |
|
|
|
|
|
duration: Duration(milliseconds: 500), |
|
|
|
|
|
curve: Curves.easeOut); |
|
|
|
|
|
} |
|
|
|
|
|
}), |
|
|
|
|
|
], |
|
|
|
|
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
|
color: COLOR_CONST.WHITE_50, |
|
|
|
|
|
border: Border( |
|
|
|
|
|
top: BorderSide( |
|
|
|
|
|
width: 0.5, color: COLOR_CONST.DEFAULT), |
|
|
|
|
|
bottom: BorderSide( |
|
|
|
|
|
width: 0.5, color: COLOR_CONST.DEFAULT)), |
|
|
|
|
|
), |
|
|
|
|
|
child: Container( |
|
|
|
|
|
child: Row( |
|
|
|
|
|
children: [ |
|
|
|
|
|
Expanded( |
|
|
|
|
|
child: Text( |
|
|
|
|
|
plot_detail_title, |
|
|
|
|
|
textAlign: TextAlign.center, |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 20, |
|
|
|
|
|
fontWeight: FontWeight.normal), |
|
|
|
|
|
)), |
|
|
|
|
|
GestureDetector( |
|
|
|
|
|
child: (0 == currentOffset) |
|
|
|
|
|
? Icon(Icons.arrow_upward) |
|
|
|
|
|
: Icon(Icons.arrow_downward_outlined), |
|
|
|
|
|
onTap: () { |
|
|
|
|
|
if (currentOffset == 0) { |
|
|
|
|
|
widget.parentScroll.animateTo( |
|
|
|
|
|
heightOfActionButton, |
|
|
|
|
|
duration: Duration(milliseconds: 500), |
|
|
|
|
|
curve: Curves.easeOut); |
|
|
|
|
|
} else { |
|
|
|
|
|
widget.parentScroll.animateTo(0.0, |
|
|
|
|
|
duration: Duration(milliseconds: 500), |
|
|
|
|
|
curve: Curves.easeOut); |
|
|
|
|
|
} |
|
|
|
|
|
}), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
Expanded( |
|
|
Expanded( |
|
|
|
|
|
flex: heightListWithoutHeader ~/ heightHeaderList, |
|
|
child: ListView.builder( |
|
|
child: ListView.builder( |
|
|
physics: AlwaysScrollableScrollPhysics(), |
|
|
|
|
|
itemBuilder: (BuildContext context, int index) { |
|
|
|
|
|
return index >= state.items.length |
|
|
|
|
|
? BottomLoader() |
|
|
|
|
|
: ItemInfinityWidget( |
|
|
|
|
|
currentItems: currentItems, |
|
|
|
|
|
item: state.items[index], |
|
|
|
|
|
currentPage: state.page, |
|
|
|
|
|
currentReachedMax: state.hasReachedMax); |
|
|
|
|
|
}, |
|
|
|
|
|
itemCount: state.hasReachedMax |
|
|
|
|
|
? state.items.length |
|
|
|
|
|
: state.items.length + 1, |
|
|
|
|
|
controller: _scrollController, |
|
|
|
|
|
)) |
|
|
|
|
|
|
|
|
physics: AlwaysScrollableScrollPhysics(), |
|
|
|
|
|
itemBuilder: (BuildContext context, int index) { |
|
|
|
|
|
return index >= state.items.length |
|
|
|
|
|
? BottomLoader() |
|
|
|
|
|
: ItemInfinityWidget( |
|
|
|
|
|
currentItems: currentItems, |
|
|
|
|
|
item: state.items[index], |
|
|
|
|
|
currentPage: state.page, |
|
|
|
|
|
currentReachedMax: state.hasReachedMax); |
|
|
|
|
|
}, |
|
|
|
|
|
itemCount: state.hasReachedMax |
|
|
|
|
|
? state.items.length |
|
|
|
|
|
: state.items.length + 1, |
|
|
|
|
|
controller: _scrollController, |
|
|
|
|
|
)) |
|
|
], |
|
|
], |
|
|
), |
|
|
), |
|
|
onRefresh: () async { |
|
|
onRefresh: () async { |