D1APP-90 pageview scroll controlling
This commit is contained in:
parent
afc9c7bafe
commit
a2e0a9a29f
|
|
@ -43,6 +43,7 @@ class _NewsDetailsState extends State<NewsDetails> {
|
||||||
onPageChanged: _onPageChnaged,
|
onPageChanged: _onPageChnaged,
|
||||||
scrollController: _scrollController,
|
scrollController: _scrollController,
|
||||||
items: state.news,
|
items: state.news,
|
||||||
|
currentIndex: state.currentIndex,
|
||||||
),
|
),
|
||||||
if (state.news.isNotEmpty)
|
if (state.news.isNotEmpty)
|
||||||
Positioned(
|
Positioned(
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ class _RadarDetailsState extends State<RadarDetails> {
|
||||||
onPageChanged: _onPageChanged,
|
onPageChanged: _onPageChanged,
|
||||||
scrollController: _scrollController,
|
scrollController: _scrollController,
|
||||||
items: state.radars,
|
items: state.radars,
|
||||||
|
currentIndex: state.currentIndex,
|
||||||
),
|
),
|
||||||
if (state.radars.isNotEmpty)
|
if (state.radars.isNotEmpty)
|
||||||
Positioned(
|
Positioned(
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ class _FloatingNavigationBarState extends State<FloatingNavigationBar> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
_handleScroll();
|
||||||
_isScrolled = false;
|
_isScrolled = false;
|
||||||
_comments = widget.comments;
|
_comments = widget.comments;
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
@ -170,6 +171,23 @@ class _FloatingNavigationBarState extends State<FloatingNavigationBar> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _handleScroll() {
|
||||||
|
widget.scrollController.addListener(() {
|
||||||
|
final position = widget.scrollController.position.pixels;
|
||||||
|
final size = MediaQuery.of(context).size.height * 0.3;
|
||||||
|
if (position > size && _isScrolled == false) {
|
||||||
|
setState(() {
|
||||||
|
_isScrolled = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (position < size && _isScrolled == true) {
|
||||||
|
setState(() {
|
||||||
|
_isScrolled = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void _showMoreOptions() {
|
void _showMoreOptions() {
|
||||||
final categories = widget.categories!;
|
final categories = widget.categories!;
|
||||||
ActionSheetUtils.showBottomSheet(
|
ActionSheetUtils.showBottomSheet(
|
||||||
|
|
|
||||||
|
|
@ -11,17 +11,19 @@ import 'package:flutter_html/flutter_html.dart';
|
||||||
class DidvanPageView extends StatefulWidget {
|
class DidvanPageView extends StatefulWidget {
|
||||||
final List items;
|
final List items;
|
||||||
final int initialIndex;
|
final int initialIndex;
|
||||||
|
final int currentIndex;
|
||||||
final bool isRadar;
|
final bool isRadar;
|
||||||
final ScrollController? scrollController;
|
final ScrollController scrollController;
|
||||||
|
|
||||||
final void Function(int index) onPageChanged;
|
final void Function(int index) onPageChanged;
|
||||||
const DidvanPageView({
|
const DidvanPageView({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.initialIndex,
|
required this.initialIndex,
|
||||||
required this.items,
|
required this.items,
|
||||||
this.scrollController,
|
required this.scrollController,
|
||||||
required this.onPageChanged,
|
required this.onPageChanged,
|
||||||
required this.isRadar,
|
required this.isRadar,
|
||||||
|
required this.currentIndex,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -48,7 +50,8 @@ class _DidvanPageViewState extends State<DidvanPageView> {
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: MediaQuery.of(context).size.height,
|
height: MediaQuery.of(context).size.height,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
controller: index == 1 ? widget.scrollController : null,
|
controller:
|
||||||
|
index == widget.currentIndex ? widget.scrollController : null,
|
||||||
physics: const BouncingScrollPhysics(),
|
physics: const BouncingScrollPhysics(),
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
left: 4,
|
left: 4,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue