Skip to content

Commit

Permalink
Added License and README
Browse files Browse the repository at this point in the history
  • Loading branch information
smbrmoyo committed Oct 12, 2024
1 parent e2b26d7 commit d021ec4
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
22 changes: 22 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

MIT License

Copyright (c) 2024 Brian Moyou

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
94 changes: 94 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# InfiniteScrollView

![Swift Package](https://img.shields.io/badge/Swift-5.7-orange.svg)
![Platform](https://img.shields.io/badge/platform-iOS%2013%2C%20macOS%2010.15-lightgrey.svg)

`InfiniteScrollView` is a customizable SwiftUI component that provides an infinite scrolling interface, enabling users to load more items dynamically. This package is perfect for applications that require pagination or continuous data loading, with built-in support for loading states, empty views, and refresh actions.

## Features

- **Dynamic Loading**: Automatically loads more items as the user scrolls.
- **Loading States**: Displays a loading indicator when fetching data.
- **Empty View Support**: Shows a customizable view when no items are available.
- **Refresh Functionality**: Allows users to refresh the list by pulling down.
- **Lightweight & Easy to Use**: Simple API and flexible customization options.

## Installation

### Swift Package Manager

You can add `InfiniteScrollView` to your project using Swift Package Manager. Add the following dependency to your `Package.swift`:

```swift
dependencies: [
.package(url: "https://github.com/smbrmoyo/InfiniteScrollView.git", from: "1.0.0")
]```

## Xcode

- Open your project in Xcode.
- Navigate to File > Add Packages.
- Enter the URL of the repository: https://github.com/<username>/<repo>.
- Choose the version you want to install and click Add Package.

## Usage

Here's a simple example of how to use InfiniteScrollView in your SwiftUI project:

```swift
import SwiftUI
import InfiniteScrollViewPackage

struct ContentView: View {
@State private var items: [YourItemType] = []
@State private var canLoadMore: Bool = true
@State private var uiState: UIState = .idle

var body: some View {
InfiniteScrollView(
items: items,
canLoadMore: $canLoadMore,
uiState: uiState,
loadMoreItems: loadMore,
refresh: refresh,
emptyView: {
Text("No items available")
},
row: { item in
Text(item.title)
}
)
}

private func loadMore() async {
// Load more items logic
}

private func refresh() async {
// Refresh items logic
}
}
]```

### Parameters
- items: An array of items to display.
- canLoadMore: A binding that indicates whether more items can be loaded.
- uiState: The current UI state (idle, loading, etc.).
- loadMoreItems: A closure that loads more items asynchronously.
- refresh: A closure that refreshes the item list asynchronously.
- emptyView: A view displayed when there are no items.
- row: A closure to define how each item should be displayed.

## Contribution

Contributions are welcome! Please feel free to submit a pull request or open an issue.

Fork the repository.
Create your feature branch: git checkout -b feature/MyFeature.
Commit your changes: git commit -m 'Add some feature'.
Push to the branch: git push origin feature/MyFeature.
Open a pull request.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.

0 comments on commit d021ec4

Please sign in to comment.