Skip to content

Commit

Permalink
Merge pull request #2 from snkrdunk/feature/physics
Browse files Browse the repository at this point in the history
physicsを受け取れるようにする
  • Loading branch information
imajoriri authored Sep 20, 2023
2 parents 854e8b8 + de42030 commit aa7a894
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions lib/src/infinite_scroll_tab_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class InfiniteScrollTabView extends StatelessWidget {
this.size,
this.forceFixedTabWidth = false,
this.fixedTabWidthFraction = 0.5,
this.physics = const PageScrollPhysics(),
}) : super(key: key);

/// A length of tabs and pages.
Expand Down Expand Up @@ -131,6 +132,8 @@ class InfiniteScrollTabView extends StatelessWidget {
/// This will be ignored when [forceFixedTabWidth] is false.
final double fixedTabWidthFraction;

final ScrollPhysics physics;

@override
Widget build(BuildContext context) {
if (indicatorHeight != null) {
Expand All @@ -156,6 +159,7 @@ class InfiniteScrollTabView extends StatelessWidget {
tabPadding: tabPadding,
forceFixedTabWidth: forceFixedTabWidth,
fixedTabWidthFraction: fixedTabWidthFraction,
physics: physics,
);
}
}
16 changes: 9 additions & 7 deletions lib/src/inner_infinite_scroll_tab_view.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:math' as math;

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';

import '../infinite_scroll_tab_view.dart';
import 'cycled_list_view.dart';
Expand Down Expand Up @@ -30,6 +30,7 @@ class InnerInfiniteScrollTabView extends StatefulWidget {
required this.tabPadding,
required this.forceFixedTabWidth,
required this.fixedTabWidthFraction,
this.physics = const PageScrollPhysics(),
}) : super(key: key);

final Size size;
Expand All @@ -50,6 +51,7 @@ class InnerInfiniteScrollTabView extends StatefulWidget {
final double tabPadding;
final bool forceFixedTabWidth;
final double fixedTabWidthFraction;
final ScrollPhysics physics;

@override
InnerInfiniteScrollTabViewState createState() =>
Expand Down Expand Up @@ -189,11 +191,11 @@ class InnerInfiniteScrollTabViewState extends State<InnerInfiniteScrollTabView>
super.initState();

_indicatorAnimationController =
AnimationController(vsync: this, duration: _tabAnimationDuration)
..addListener(() {
if (_indicatorAnimation == null) return;
_indicatorSize.value = _indicatorAnimation!.value;
});
AnimationController(vsync: this, duration: _tabAnimationDuration)
..addListener(() {
if (_indicatorAnimation == null) return;
_indicatorSize.value = _indicatorAnimation!.value;
});

calculateTabBehaviorElements(widget.textScaleFactor);

Expand Down Expand Up @@ -324,7 +326,7 @@ class InnerInfiniteScrollTabViewState extends State<InnerInfiniteScrollTabView>
scrollDirection: Axis.horizontal,
contentCount: widget.contentLength,
controller: _pageController,
physics: const PageScrollPhysics(),
physics: widget.physics,
itemBuilder: (context, modIndex, rawIndex) => SizedBox(
width: widget.size.width,
child: ValueListenableBuilder<int>(
Expand Down

0 comments on commit aa7a894

Please sign in to comment.