SSStoryStatus

SSStoryStatus

Swift Compatibility-badge Platform Compatibility-badge Release-badge License Badge-badge Pod Version-badge SPM Compatible-badge

SSStoryStatus 是一个多功能且直观的 SwiftUI 库,旨在轻松显示用户列表并无缝展示他们引人入胜的故事。 该库使开发人员能够轻松集成用户列表和故事查看功能。 该库提供对 UI 自定义视图组件的完全控制。

个人资料列表 故事视图 消息 & 反馈

特性

要求

安装

Swift Package Manager

您可以使用 Swift Package Manager 安装 SSStoryStaus,方法是:

  1. 转到 Xcode -> File -> Add Package Dependencies...
  2. 添加包 URL https://github.com/SimformSolutionsPvtLtd/SSStoryStatus

CocoaPods

CocoaPods 是 Cocoa 项目的依赖管理工具。 您可以使用以下命令安装它:

$ gem install cocoapods

导航到项目根文件夹以集成 pod。

$ pod init

这将为您的项目生成 Podfile。 要将 SSStoryStatus 集成到您的项目中,请在您的 Podfile 中指定它:

platform :ios, '17.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'SSStoryStatus'
end

然后,运行以下命令:

$ pod install

这将生成 <Project>.xcworkspace 文件。 从现在开始,您应该使用此文件打开项目。

脚本沙箱错误

如果您遇到构建错误 Command PhaseScriptExecution failed with a nonzero exit code,请按照以下步骤操作:

转到项目 Build Settings -> 搜索 User Script Sandboxing -> 设置为 No

参考 - User Script Sandboxing

用法

首先导入所需的包:

import SSStoryStatus

SSStoryStatus 接受用户列表作为 UserModel

let users: [UserModel] = [
    UserModel(
        id: UUID().uuidString, // Unique identifier for user (optional, uses UUID by default)
        name: "Krunal",        // Name of user
        image: "",             // URL of profile image
        stories: stories,      // List of story for this user
    )
]

UserModel 接受每个用户的 StoryModel 故事列表。

let stories: [StoryModel] = [
    StoryModel(
        id: UUID().uuidString,  // Unique identifier for story (optional, uses UUID by default)
        mediaURL: "",           // Media url of image or video
        date: .now,             // Story creation date
        caption: "",            // Caption for the story (optional)
        mediaType: .image,      // Media type: image or video
        storyState: .seen       // Story is seen or unseen
    )
]

现在,您可以将此用户列表传递给 SSStoryStatus

SSStoryStatus(
    users: users,            // List of users
    sorted: true,            // Whether the users should be sorted based on their seen status (default is false)
    cacheExpire: expireDate  // Date indicating cache expiration time (default is 24 hours)
)

您可以监听用户查看任何故事时的回调。

SSStoryStatus(users: users)
    .onStorySeen { user, storyIndex in
        print("Seen - ", user.stories[storyIndex].mediaURL) // You can retrieve story instance using user and storyIndex
    }

当用户按下任何表情符号或回复故事时,您可以观察它。

SSStoryStatus(users: users)
    .emoji { emoji, user, storyIndex in
        print("Selected \(emoji) for story \(user.stories[storyIndex].id)") // Emoji pressed by user
    }
    .messageField { message, user, storyIndex in
        print("Sent \(message) to \(user.name)") // Message sent
    }   

自定义

要自定义 SSStoryStatus,请参阅 自定义指南

文档

文档 - 查找完整的 API 参考以获取更详细的文档。

觉得这些示例有用吗? ❤️

通过加入此存储库的 star ⭐ 来支持它。

如何贡献 🤝

无论您是帮助我们修复错误、改进文档还是提出功能请求,我们都非常欢迎您! 💪
查看我们的 贡献指南,获取贡献的想法。

错误和反馈

对于错误、功能请求和讨论,请使用 GitHub Issues

其他移动库

查看我们的其他库 Awesome-Mobile-Libraries

许可证

在 MIT 许可证下分发。 有关详细信息,请参阅 LICENSE