SwiftUI component - Stories instagram, slideshow
SwiftUI and Combine – Stories instagram widget
Features
- Long tap – pause stories showcase
- Tap – next story
- Leeway – pause before start stories
- Customize component with you own stories and every story with it’s own view
- Customize time longivity for every story
- iOS and macOS support
- Customizable dark and light scheme support for every story
1. Stories
Define enum with your stories conforming to IStory ** There must be defined at least one story**
public enum Stories: IStory {
case first
case second
case third
@ViewBuilder
public func builder(progress : Binding<CGFloat>) -> some View {
switch(self) {
case .first: StoryTpl(self, .green, "1", progress)
case .second: StoryTpl(self, .brown, "2", progress)
case .third: StoryTpl(self, .purple, "3", progress)
}
}
public var duration: TimeInterval {
switch self{
case .first, .third : return 4
default : return 3
}
}
public var colorScheme: ColorScheme? {
switch(self) {
case .first: return .light
default: return .dark
}
}
}
2. Create stories widget
manager– package standard manager StoriesManager.self for managing stories life circle. Define your own manager conforming to IStoriesManager if you need some specific managing processestories– stories conforming to IStory
StoriesWidget(
manager: StoriesManager.self,
stories: Stories.allCases
)
Optional
strategy– default strategy for the item menu width allocation is auto
| Size strategy | Description |
|---|---|
| circle | Repeat stories |
| once | Show just once |
-
current– start story if not defined start with first -
leeway– delay before start stories
SwiftUI example of using package
Documentation(API)
- You need to have Xcode 13 installed in order to have access to Documentation Compiler (DocC)
- Go to Product > Build Documentation or ⌃⇧⌘ D