diff --git a/CHANGELOG.md b/CHANGELOG.md index cedb4f8..004e8b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,11 @@ - fix: `NesRunningText` was not disposing its controller. - feat: add `NesRunningTextLines`. - feat: add `NesPulser`. + - feat: allow duration to be configured on selection list. # 0.12.1 - fix: theme lerp causing error on null access. - # 0.12.0 - feat: adding `NesBlinker`. - fix: `NesRunningText` would not update its text. diff --git a/example/lib/gallery/sections/selection_list.dart b/example/lib/gallery/sections/selection_list.dart index 05e8b3d..4ef7fbf 100644 --- a/example/lib/gallery/sections/selection_list.dart +++ b/example/lib/gallery/sections/selection_list.dart @@ -45,6 +45,7 @@ class _SelectionListSectionState extends State { child: NesSelectionList( initialIndex: _horizontal, axis: Axis.horizontal, + tickerDuration: const Duration(milliseconds: 100), children: const [ Text('Yes'), Text('No'), diff --git a/lib/src/widgets/nes_blinker.dart b/lib/src/widgets/nes_blinker.dart index ad4c4f1..f349e14 100644 --- a/lib/src/widgets/nes_blinker.dart +++ b/lib/src/widgets/nes_blinker.dart @@ -9,13 +9,17 @@ class NesBlinker extends Phased { NesBlinker({ super.key, required this.child, + this.tickerDuration = const Duration(seconds: 1), }) : super( state: PhasedState( values: [true, false], - ticker: const Duration(seconds: 1), + ticker: tickerDuration, ), ); + /// Duration of ticker, it changes the blink speed. + final Duration? tickerDuration; + /// The child widget to blink. final Widget child; diff --git a/lib/src/widgets/nes_selection_list.dart b/lib/src/widgets/nes_selection_list.dart index bf8b2fa..d356b3e 100644 --- a/lib/src/widgets/nes_selection_list.dart +++ b/lib/src/widgets/nes_selection_list.dart @@ -16,6 +16,7 @@ class NesSelectionList extends StatefulWidget { this.canAutoFocus = true, this.focusNode, this.onCancelSelection, + this.tickerDuration, this.canCancelSelection = true, }) : assert( initialIndex == null || initialIndex < children.length, @@ -58,6 +59,9 @@ class NesSelectionList extends StatefulWidget { /// This can be useful in lists that are the "root" of a page or section. final bool canCancelSelection; + /// Duration of ticker, it changes the blink speed. + final Duration? tickerDuration; + @override State createState() => _NesSelectionListState(); } @@ -171,6 +175,7 @@ class _NesSelectionListState extends State { for (var i = 0; i < widget.children.length; i++) _SelectionItem( markerKey: _markerKey, + tickerDuration: widget.tickerDuration, onTap: () { if (_focusNode.hasFocus) { setState(() { @@ -230,6 +235,7 @@ class _SelectionItem extends StatelessWidget { required this.markerSize, required this.itemMinHeight, required this.hasFocus, + this.tickerDuration, }); final Key markerKey; @@ -242,12 +248,14 @@ class _SelectionItem extends StatelessWidget { final Widget child; final double itemMinHeight; final bool hasFocus; + final Duration? tickerDuration; @override Widget build(BuildContext context) { final itemMarker = cursor && hasFocus ? NesBlinker( key: markerKey, + tickerDuration: tickerDuration, child: marker, ) : (selected ? marker : null);