https://github.com/aakarsh-verma/swiftuilayouts
Swift Package providing a collection of reusable SwiftUI layouts
https://github.com/aakarsh-verma/swiftuilayouts
ios layout-engine spm swiftui xcode
Last synced: 4 months ago
JSON representation
Swift Package providing a collection of reusable SwiftUI layouts
- Host: GitHub
- URL: https://github.com/aakarsh-verma/swiftuilayouts
- Owner: Aakarsh-verma
- Created: 2025-08-13T09:38:58.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2025-10-19T18:54:57.000Z (8 months ago)
- Last Synced: 2025-10-19T23:25:34.953Z (8 months ago)
- Topics: ios, layout-engine, spm, swiftui, xcode
- Language: Swift
- Homepage:
- Size: 511 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SwiftUILayouts
SwiftUILayouts is a Swift Package providing a collection of reusable SwiftUI layouts and UI components. It is designed for iOS developers who want to quickly build modern and customizable interfaces with minimal boilerplate. The package leverages **SwiftUI** and integrates with **[Kingfisher](https://github.com/onevcat/Kingfisher)** for efficient image loading and caching.
---
## Highlights
- π **Reusable Layouts** β Predefined SwiftUI layouts for carousels, grids, and cards.
- π¨ **Customizable Components** β Highly flexible with configuration models.
- πΌοΈ **Image Handling** β Supports remote and local images via Kingfisher.
- π **Swift Package Manager (SPM)** β Easy integration into your project.
- β
**Unit Tests Included** β Ensures reliability and easy extension. (TBAπ₯²)
---
## Requirements
- **iOS**: 17.0+
- **Swift**: 6.0+
- **Xcode**: 15.0+
---
## Installation
### Swift Package Manager
In Xcode:
1. Go to **File β Add Packages...**
2. Enter the repository URL:
```bash
https://github.com/your-username/SwiftUILayouts.git
```
3. Select the latest version and add the package to your project.
---
## Usage
### Import the Package
```swift
import SwiftUILayouts
```
### Example: Carousel View
```swift
struct DemoView: View {
let images: [CustomImageModel] = [
CustomImageModel(for: "https://picsum.photos/200"),
CustomImageModel(for: "https://picsum.photos/300"),
CustomImageModel(for: "mylocalImage")
]
var body: some View {
StackCarouselView(items: images, currentIndex: .constant(0)) { item in
CustomImageView(imageModel: item)
.clipShape(RoundedRectangle(cornerRadius: 12))
.shadow(radius: 5)
}
.frame(height: 300)
}
}
```
### Example: Custom Configurations
```swift
struct ConfiguredCarousel: View {
@State private var index = 0
var body: some View {
StackCarouselView(
items: Array(1...5),
config: SLStackCarouselModel(
cardWidthRatio: 0.8,
cardSizeDifferenceRatio: 0.05,
cardOffsetDifference: 20,
visibleCardIndexDifference: 3,
showSelected: true
),
currentIndex: $index
) { number in
Text("Item \(number)")
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.blue.opacity(0.7))
.cornerRadius(12)
}
.frame(height: 250)
}
}
```
---
## Project Structure
```code
SwiftUILayouts/
βββ Package.swift
βββ Sources/
β βββInteractions/
β βββ Models/
β βββ SwiftUILayouts/
β βββ Views/
| βββComponents/
βββ Tests/
βββ SwiftUILayoutsTests/
```
- **Sources/** β Core components and layouts.
- **Tests/SwiftUILayoutsTests** β Unit tests for reliability.
---
## Dependencies
- [Kingfisher](https://github.com/onevcat/Kingfisher) β A powerful Swift library for downloading and caching images from the web.
---
## Features Index [Screen shots TBA]
### Layouts
1. Ambient Carousel Layout
2. Cover Carousel Layout
3. Grid Layout
4. Parallax Carousel Layout
5. Stack Carousel Layout
### Interactions
1. Pinch Pan Zoom
### Components
1. Image View
## Contributing
Contributions are welcome! π
If youβd like to fix bugs or add new features:
1. Fork the repo
2. Create a feature branch: `git checkout -b feature/my-feature`
3. Commit your changes: `git commit -m "Add my feature"`
4. Push and open a PR
---
## License
This project is licensed under the **MIT License**.
See [LICENSE](https://choosealicense.com/licenses/mit/) for details.