Browse Source

fix scroll screen action list

master
daivph 5 years ago
parent
commit
7ae0a19744
3 changed files with 74 additions and 62 deletions
  1. +1
    -1
      ios/Flutter/.last_build_id
  2. +5
    -5
      lib/data/api/dio_provider.dart
  3. +68
    -56
      lib/presentation/screens/plot_detail/sc_plot_action.dart

+ 1
- 1
ios/Flutter/.last_build_id View File

@@ -1 +1 @@
48197743e3d78b3769f70bac9a76e7e0
5729eb498eaeb9c64784fcfc80bbb33b

+ 5
- 5
lib/data/api/dio_provider.dart View File

@@ -26,11 +26,11 @@ class HttpLogInterceptor extends InterceptorsWrapper {
var token = await pref.getString(DATA_CONST.TOKEN_KEY);
options.headers["Authorization"] = "Bearer $token";
options.receiveTimeout = 20000;
log("onRequest: ${options.uri}\n"
"data=${options.data}\n"
"method=${options.method}\n"
"headers=${options.headers}\n"
"queryParameters=${options.queryParameters}");
// log("onRequest: ${options.uri}\n"
// "data=${options.data}\n"
// "method=${options.method}\n"
// "headers=${options.headers}\n"
// "queryParameters=${options.queryParameters}");
return options;
}


+ 68
- 56
lib/presentation/screens/plot_detail/sc_plot_action.dart View File

@@ -237,6 +237,9 @@ class _InfinityViewState extends State<InfinityView> {
final _scrollController = ScrollController();
final _scrollThreshold = 250.0;
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
void initState() {
@@ -250,6 +253,15 @@ class _InfinityViewState extends State<InfinityView> {
.add(DataFetched(cropId: widget.cropId, cropCode: widget.cropCode));
}
});
widget.parentScroll.addListener(() {
setState(() {
currentOffset = widget.parentScroll.offset;
heightListWithoutHeader = Get.height -
heightOfActionButton -
heightHeaderList +
currentOffset;
});
});
super.initState();
}

@@ -267,71 +279,71 @@ class _InfinityViewState extends State<InfinityView> {
}
List<Activities> currentItems = List<Activities>.from(state.items);
return Scaffold(
resizeToAvoidBottomInset: false,
body: RefreshIndicator(
child: Column(
mainAxisSize: MainAxisSize.max,
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(
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(
flex: heightListWithoutHeader ~/ heightHeaderList,
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 {

Loading…
Cancel
Save