Browse Source

fix scroll list action

master
daivph 5 years ago
parent
commit
22e0483874
3 changed files with 42 additions and 11 deletions
  1. +1
    -1
      ios/Flutter/.last_build_id
  2. +40
    -9
      lib/presentation/screens/plot_detail/sc_plot_action.dart
  3. +1
    -1
      pubspec.yaml

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

@@ -1 +1 @@
440505e9ea1eee7043d2cbfeb318f6bc
dab672e712362fdbbfa98386624f95d6

+ 40
- 9
lib/presentation/screens/plot_detail/sc_plot_action.dart View File

@@ -157,8 +157,6 @@ class _PlotActionScreenState extends State<PlotActionScreen> {

bool _showTitle(BuildContext context) {
var kExpandedHeight = MediaQuery.of(context).size.width * 0.625 + 24;
// print("height: $kExpandedHeight");
// print('offset ${_scrollController.offset}');
return _scrollController.hasClients &&
_scrollController.offset > kExpandedHeight - kToolbarHeight;
}
@@ -205,6 +203,7 @@ class _PlotActionScreenState extends State<PlotActionScreen> {
child: HoldInfinityWidget(
cropId: widget.cropId,
cropCode: widget.cropCode,
parentScroll: _scrollController,
),
),
);
@@ -214,18 +213,25 @@ class _PlotActionScreenState extends State<PlotActionScreen> {
class HoldInfinityWidget extends StatelessWidget {
int cropId;
String cropCode;
HoldInfinityWidget({this.cropId, this.cropCode});
ScrollController parentScroll;
HoldInfinityWidget({this.cropId, this.cropCode, @required this.parentScroll});
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
return Scaffold(key: _scaffoldKey, body: InfinityView(cropId: cropId));
return Scaffold(
key: _scaffoldKey,
body: InfinityView(
cropId: cropId,
parentScroll: parentScroll,
));
}
}

class InfinityView extends StatefulWidget {
int cropId;
String cropCode;
InfinityView({this.cropId, this.cropCode});
ScrollController parentScroll;
InfinityView({this.cropId, this.cropCode, @required this.parentScroll});
@override
_InfinityViewState createState() => _InfinityViewState();
}
@@ -235,6 +241,7 @@ class _InfinityViewState extends State<InfinityView> {
final _scrollThreshold = 250.0;
PlotDetailBloc _plotDetailBloc;
var a = Get.put(ChangeToRefreshLists());
var heightOfActionButton = Get.width * 0.625 + 24;

@override
void initState() {
@@ -278,10 +285,34 @@ class _InfinityViewState extends State<InfinityView> {
bottom: BorderSide(
width: 0.5, color: COLOR_CONST.DEFAULT)),
),
child: Text(
plot_detail_title,
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.normal),
child: Row(
children: [
Expanded(
child: Text(
plot_detail_title,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.normal),
)),
IconButton(
icon: (widget.parentScroll.position.pixels <
heightOfActionButton)
? Icon(Icons.arrow_upward)
: Icon(Icons.arrow_downward),
onPressed: () {
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);
}
})
],
)),
Expanded(
child: ListView.builder(

+ 1
- 1
pubspec.yaml View File

@@ -2,7 +2,7 @@ name: farm_tpf
description: A new Flutter project.

publish_to: 'none'
version: 0.3.0+1
version: 0.5.0+1

environment:
sdk: ">=2.7.0 <3.0.0"

Loading…
Cancel
Save