Docs
Media

Story Strip

A Stories-style segment strip with its own clock, hold to pause, and tap zones for back and forward.

$npx swiftpieces add StoryStrip
Free · MIT + Commons ClauseiOS 17.0+Liquid Glassstoriesprogresssegmentstimerholdmedia
Type
StoryStrip
Files
StoryStrip.swift
Depends on
Nothing (Apple frameworks only)
Version
2.3.0

Segment strip plus the gesture surface of a story player. Pass duration to let it run itself, or leave it nil and drive progress.

Notes

  • With duration set the strip runs itself: a TimelineView(.animation) draws the fill and a task sleeps for the rest of the segment, then advances current. Pausing (a hold, or isPaused) records the pause time and shifts the segment start on resume, so the fill continues exactly where it stopped.
  • Without duration the strip is stateless like before: you own current and progress, and steps animate with a short linear curve so 30 Hz updates read as continuous.
  • Holding anywhere on the surface for 200 ms pins the strip: the clock freezes on its frame and the bars dim at once with a soft tick. Releasing lifts the dim and resumes. A touch the system interrupts, such as an incoming call or Control Center, also lets go of the hold, so a story never stays paused. A shorter touch is a tap: the left 30% goes back (restarting the first segment when duration is set) and the rest advances, the moment the finger lifts.
  • Segment steps fill or empty the bars on a short spring that never overshoots, since the bars say where the story is. The running fill is a clock: it is drawn from the time every frame and never animated, so it stays exact and never bounces.
  • Haptics: a soft impact when a hold engages, and one .selection tick for each move you ask for with a tap or a VoiceOver swipe that changes something, including restarting the first segment when duration is set. A move with nothing to change stays silent: forward after the story has finished, or back on the first segment when you drive progress, since there is no clock to restart. The clock's own advances and changes you make to current stay silent too, since a story can run for minutes.
  • fillsContainer stretches the invisible surface over the whole story with the bars pinned to the top; set it to false to use only the bar row.
  • onFinish fires once when the last segment completes. VoiceOver reads "3 of 5", swipes up or down move between segments, and a custom action pauses or resumes.
  • Holding buds a liquid glass "Paused" badge, tinted with the strip's tint, down out of the trailing end of the bars once the strip is pinned: it is born under the bars, springs out to its place, and its label sharpens just after. Let go and it rises back into the bars on a spring with no bounce, its label gone at once and its tint draining; the bars are not glass, so it thins away on the way and is gone by the time it gets there. A tap that moves back or forward flashes a glass chevron bubble in that zone, tinted the same way, which springs in with a little give, nudging in the direction of the move, and drifts on as it fades. Bars are 3 pt by default.
  • With Reduce Motion the badge and the chevron fade in place instead of moving, and segment steps settle without overshoot. Under Reduce Transparency the glass draws solid. The dim, the haptics and the running fill are unchanged, so the strip still says when it is paused and where it is.
  • style: (StoryStrip.Style) sets barHeight, spacing, trackOpacity, inset, showsPausedBadge, showsTapHints, and ink (the glyph and text color on the glass, which is tinted with tint). .minimal restores the version 1 look. All text is one weight, semibold.
  • The example runs the strip in dark ink over solid color slides with one big idea each.

Usage

StoryStripExample()
    .preferredColorScheme(.light)

Parameters

ParameterDescription
countNumber of segments.
currentIndex of the segment currently filling. The strip advances it when it drives the clock.
progressFill of the current segment from 0 to 1, used only when duration is nil.
durationSeconds per segment. When set, a TimelineView clock fills the segment and advances at the end.
isPausedOptional external pause, for example while a reply sheet is up. Holding the strip pauses on its own.
tintSegment color; the track is the same color at low opacity, and the paused badge and tap hints are liquid glass tinted with it.
styleBar geometry, track strength, and the paused badge and tap hints. .standard draws 3 pt bars and shows both.
fillsContainerExpand the gesture surface to the whole container so holds and taps work over the story, with the bars pinned to the top.
onFinishCalled when the last segment completes.

Install

Pick one. Run it from the folder that contains your .xcodeproj and the files land inside your app.

Terminal

$npx swiftpieces add StoryStrip

Or ask your coding agent · Claude Code, Cursor or Xcode, once the MCP server is connected

>Add the SwiftPieces "Story Strip" piece to my app

Or copy the source above into your app.

New to SwiftUI?If you know React, CSS or Tailwind, SwiftUI is easier to pick up than it looks.Try real app patterns first

Building a whole app? See SwiftPieces Pro →

All media →

Build it yourself: SwiftUI animations guide

On this page

SwiftPiecesPro

Build the whole app with one library.

Production-ready screens, whole flows, complete app templates, a Build Kit your agent follows and Pro remixing.

54 screens · 46 patterns · 48 flows · 12 templates · 31 Build Kit skills

Explore Pro