From a2780cf44e66d90da2bff15be3a93a0aefaef97c Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 3 Jun 2024 09:04:50 +0800 Subject: [PATCH 1/3] Fix image loader request header type --- lib/widgets/story_image.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/widgets/story_image.dart b/lib/widgets/story_image.dart index 6f3d333e..44a60dae 100644 --- a/lib/widgets/story_image.dart +++ b/lib/widgets/story_image.dart @@ -29,7 +29,8 @@ class ImageLoader { } final fileStream = DefaultCacheManager().getFileStream(this.url, - headers: this.requestHeaders as Map?); + headers: requestHeaders + ?.map((key, value) => MapEntry(key, value.toString()))); fileStream.listen( (fileResponse) { From 3e16e4f18900ff7efbe9fdd49f0ee4453c1c591c Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 4 Jun 2024 10:39:05 +0800 Subject: [PATCH 2/3] Update story view --- lib/widgets/story_view.dart | 62 +++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/lib/widgets/story_view.dart b/lib/widgets/story_view.dart index 3a6e8db1..d006613a 100644 --- a/lib/widgets/story_view.dart +++ b/lib/widgets/story_view.dart @@ -79,10 +79,11 @@ class StoryItem { bottom: Radius.circular(roundedBottom ? 8 : 0), ), ), - padding: textOuterPadding?? EdgeInsets.symmetric( - horizontal: 24, - vertical: 16, - ), + padding: textOuterPadding ?? + EdgeInsets.symmetric( + horizontal: 24, + vertical: 16, + ), child: Center( child: Text( title, @@ -140,12 +141,13 @@ class StoryItem { margin: EdgeInsets.only( bottom: 24, ), - padding: captionOuterPadding?? EdgeInsets.symmetric( - horizontal: 24, - vertical: 8, - ), + padding: captionOuterPadding ?? + EdgeInsets.symmetric( + horizontal: 24, + vertical: 8, + ), color: caption != null ? Colors.black54 : Colors.transparent, - child: caption?? const SizedBox.shrink(), + child: caption ?? const SizedBox.shrink(), ), ), ) @@ -193,11 +195,12 @@ class StoryItem { ), Container( margin: EdgeInsets.only(bottom: 16), - padding: captionOuterPadding?? EdgeInsets.symmetric(horizontal: 24, vertical: 8), + padding: captionOuterPadding ?? + EdgeInsets.symmetric(horizontal: 24, vertical: 8), child: Align( alignment: Alignment.bottomLeft, child: Container( - child: caption?? const SizedBox.shrink(), + child: caption ?? const SizedBox.shrink(), width: double.infinity, ), ), @@ -252,7 +255,7 @@ class StoryItem { padding: EdgeInsets.symmetric(horizontal: 24, vertical: 8), color: caption != null ? Colors.black54 : Colors.transparent, - child: caption?? const SizedBox.shrink(), + child: caption ?? const SizedBox.shrink(), ), ), ) @@ -387,6 +390,8 @@ class StoryView extends StatefulWidget { /// provide this callback so as to enable scroll events on the list view. final Function(Direction?)? onVerticalSwipeComplete; + final void Function()? onDoubleTap; + /// Callback for when a story and it index is currently being shown. final void Function(StoryItem storyItem, int index)? onStoryShow; @@ -406,6 +411,7 @@ class StoryView extends StatefulWidget { /// Indicator Color final Color? indicatorColor; + /// Indicator Foreground Color final Color? indicatorForegroundColor; @@ -415,6 +421,8 @@ class StoryView extends StatefulWidget { /// Use this if you want to give outer padding to the indicator final EdgeInsetsGeometry indicatorOuterPadding; + final HitTestBehavior? gestureBehavior; + StoryView({ required this.storyItems, required this.controller, @@ -424,10 +432,15 @@ class StoryView extends StatefulWidget { this.repeat = false, this.inline = false, this.onVerticalSwipeComplete, + this.onDoubleTap, + this.gestureBehavior, this.indicatorColor, this.indicatorForegroundColor, this.indicatorHeight = IndicatorHeight.large, - this.indicatorOuterPadding = const EdgeInsets.symmetric(horizontal: 16, vertical: 8,), + this.indicatorOuterPadding = const EdgeInsets.symmetric( + horizontal: 16, + vertical: 8, + ), }); @override @@ -663,6 +676,8 @@ class StoryViewState extends State with TickerProviderStateMixin { alignment: Alignment.centerRight, heightFactor: 1, child: GestureDetector( + behavior: widget.gestureBehavior, + onDoubleTap: widget.onDoubleTap, onTapDown: (details) { widget.controller.pause(); }, @@ -716,10 +731,14 @@ class StoryViewState extends State with TickerProviderStateMixin { alignment: Alignment.centerLeft, heightFactor: 1, child: SizedBox( - child: GestureDetector(onTap: () { + child: GestureDetector( + behavior: widget.gestureBehavior, + onTap: () { widget.controller.previous(); - }), - width: 70), + }, + ), + width: 70, + ), ), ], ), @@ -796,8 +815,11 @@ class PageBarState extends State { right: widget.pages.last == it ? 0 : this.spacing), child: StoryProgressIndicator( isPlaying(it) ? widget.animation!.value : (it.shown ? 1 : 0), - indicatorHeight: - widget.indicatorHeight == IndicatorHeight.large ? 5 : widget.indicatorHeight == IndicatorHeight.medium ? 3 : 2, + indicatorHeight: widget.indicatorHeight == IndicatorHeight.large + ? 5 + : widget.indicatorHeight == IndicatorHeight.medium + ? 3 + : 2, indicatorColor: widget.indicatorColor, indicatorForegroundColor: widget.indicatorForegroundColor, ), @@ -831,11 +853,11 @@ class StoryProgressIndicator extends StatelessWidget { this.indicatorHeight, ), foregroundPainter: IndicatorOval( - this.indicatorForegroundColor?? Colors.white.withOpacity(0.8), + this.indicatorForegroundColor ?? Colors.white.withOpacity(0.8), this.value, ), painter: IndicatorOval( - this.indicatorColor?? Colors.white.withOpacity(0.4), + this.indicatorColor ?? Colors.white.withOpacity(0.4), 1.0, ), ); From a3802a95b2cfbc6896201a312be3159dd638491a Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 4 Jun 2024 10:49:28 +0800 Subject: [PATCH 3/3] Update story view --- lib/widgets/story_view.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/widgets/story_view.dart b/lib/widgets/story_view.dart index d006613a..257f2507 100644 --- a/lib/widgets/story_view.dart +++ b/lib/widgets/story_view.dart @@ -646,7 +646,9 @@ class StoryViewState extends State with TickerProviderStateMixin { color: Colors.white, child: Stack( children: [ - _currentView, + IgnorePointer( + child: _currentView, + ), Visibility( visible: widget.progressPosition != ProgressPosition.none, child: Align(