Skip to content

Create stories with just single-line code written in SwiftUI

License

Notifications You must be signed in to change notification settings

tiskender2/StoryUI

Repository files navigation

StoryUI

Create stories with just single-line code

build status

Installation

Use Swift Package Manager

dependencies: [
    .package(url: "https://github.com/tiskender2/StoryUI.git", exact: "1.5.7")
]

Example

example

Usage

import SwiftUI
import StoryUI

struct ContentView: View {
    @State var isPresented: Bool = false
    @State var stories: [StoryUIModel] = [
        .init(
            user: .init(
                name: "Tolga İskender",
                image: "https://image.tmdb.org/t/p/original/pB8BM7pdSp6B6Ih7QZ4DrQ3PmJK.jpg"
            ),
            stories: [
                .init(
                    mediaURL: "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4",
                    date: "30 min ago",
                    config: .init(
                        storyType: .message(
                            config: .init(showLikeButton: true),
                            emojis: [
                                ["😂","😮","😍"],
                                ["😢","👏","🔥"]
                            ],
                            placeholder: "Send Message"
                        ),
                        mediaType: .video
                    )
                ),
                .init(
                    mediaURL: "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4",
                    date: "30 min ago",
                    config: .init(mediaType: .video)
                )
            ]
        )
    ]
    var body: some View {
        NavigationView {
            Button {
                isPresented = true
            } label: {
                Text("Show")
            }
            .fullScreenCover(isPresented: $isPresented) {
                StoryView(
                    stories: stories,
                    isPresented: $isPresented
                )
            }
        }

    }
}

Requirements

  • iOS 14+
  • Swift 5.6+

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

StoryUI is available under the MIT license. See the LICENSE file for more info.