Skip to content

Commit

Permalink
Update story view
Browse files Browse the repository at this point in the history
  • Loading branch information
henry11996 committed Jun 4, 2024
1 parent a2780cf commit 6dc3eaa
Showing 1 changed file with 39 additions and 20 deletions.
59 changes: 39 additions & 20 deletions lib/widgets/story_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
),
),
)
Expand Down Expand Up @@ -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,
),
),
Expand Down Expand Up @@ -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(),
),
),
)
Expand Down Expand Up @@ -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;

Expand All @@ -406,6 +411,7 @@ class StoryView extends StatefulWidget {

/// Indicator Color
final Color? indicatorColor;

/// Indicator Foreground Color
final Color? indicatorForegroundColor;

Expand All @@ -424,10 +430,14 @@ class StoryView extends StatefulWidget {
this.repeat = false,
this.inline = false,
this.onVerticalSwipeComplete,
this.onDoubleTap,
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
Expand Down Expand Up @@ -663,6 +673,8 @@ class StoryViewState extends State<StoryView> with TickerProviderStateMixin {
alignment: Alignment.centerRight,
heightFactor: 1,
child: GestureDetector(
behavior: HitTestBehavior.deferToChild,
onDoubleTap: widget.onDoubleTap,
onTapDown: (details) {
widget.controller.pause();
},
Expand Down Expand Up @@ -716,10 +728,14 @@ class StoryViewState extends State<StoryView> with TickerProviderStateMixin {
alignment: Alignment.centerLeft,
heightFactor: 1,
child: SizedBox(
child: GestureDetector(onTap: () {
child: GestureDetector(
behavior: HitTestBehavior.deferToChild,
onTap: () {
widget.controller.previous();
}),
width: 70),
},
),
width: 70,
),
),
],
),
Expand Down Expand Up @@ -796,8 +812,11 @@ class PageBarState extends State<PageBar> {
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,
),
Expand Down Expand Up @@ -831,11 +850,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,
),
);
Expand Down

0 comments on commit 6dc3eaa

Please sign in to comment.