An open API service indexing awesome lists of open source software.

https://github.com/eunchan2815/flexiblekit

Lightweight, reusable SwiftUI components for flexible layouts and adaptive UI.
https://github.com/eunchan2815/flexiblekit

alginment autopadding backbutton cornershape flexible ios stack swift swiftui trigger webview

Last synced: 19 days ago
JSON representation

Lightweight, reusable SwiftUI components for flexible layouts and adaptive UI.

Awesome Lists containing this project

README

          






> SwiftUI is great. But layout isn't.

**FlexibleKit** is a SwiftUI utility library that offers flexible layouts, custom back buttons, adaptive corners, triggers, and lightweight webviews. Easily drop into any SwiftUI project to speed up development.

---

## ๐Ÿ–ผ Preview

---

## ๐Ÿ“ฆ Installation

### Swift Package Manager

**Xcode:**

Paste:

**Or use `Package.swift`:**

```swift
.package(url: "https://github.com/YourUsername/FlexibleKit.git", .upToNextMajor(from: "1.0.1"))
```

## โœ… Features

### ๐Ÿ“ Alignment

๊ฐ„๋‹จํ•œ ์ •๋ ฌ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ขŒ์ธก, ์šฐ์ธก, ์ค‘์•™ ์ •๋ ฌ์„ HStack ๊ธฐ๋ฐ˜์œผ๋กœ ๊ตฌํ˜„๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

```swift
Text("์™ผ์ชฝ ์ •๋ ฌ")
.alignLeft()

Text("์˜ค๋ฅธ์ชฝ ์ •๋ ฌ")
.alignRight()

Text("์ค‘์•™ ์ •๋ ฌ")
.alignCenter()
```

### ๐Ÿ”™ Back Button

์œ ์—ฐํ•œ SwiftUI BackButton์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ƒ‰์ƒ๊ณผ ์„ค๋ช…, ์•ก์…˜์„ ์‰ฝ๊ฒŒ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
๋˜ํ•œ swipe๋ฅผ ํ†ตํ•œ ๋’ค๋กœ๊ฐ€๊ธฐ๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

```swift
struct TestView: View {
@Environment(\.dismiss) var dismiss
var body: some View {
NavigationStack {
Text("hello")
}
.backButton(description: "๋’ค๋กœ๊ฐ€๊ธฐ", color: .black) {
dismiss()
}
}
}
```

### ๐ŸŽฏ Rounded Corners

ํŠน์ • ์ฝ”๋„ˆ๋งŒ ๋ผ์šด๋”ฉํ•  ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ฃผ๋Š” ์œ ํ‹ธ์ž…๋‹ˆ๋‹ค. .topLeft, .bottomRight ๋“ฑ ์„ ํƒ์ ์œผ๋กœ ์ ์šฉ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

```swift
struct TestView: View {
var body: some View {
VStack {
Text("hello")
.frame(width: 300, height: 300)
.background(.red)
.roundedCorners(30, corners: [.topLeft, .bottomLeft, .bottomRight])
}
}
}
```

### ๐Ÿ“ฆ Flexible Stacks

FlexibleHStack, FlexibleVStack์„ ํ†ตํ•ด ํŒจ๋”ฉ๊ณผ ์ •๋ ฌ์ด ํฌํ•จ๋œ ์Šคํƒ์„ ์‰ฝ๊ฒŒ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
```swift
FlexibleHStack(spacing: 12, paddingEdges: [.leading, .trailing]) {
Text("์•„์ดํ…œ 1")
Text("์•„์ดํ…œ 2")
}

FlexibleVStack(alignment: .center, paddingLength: 8) {
Text("์œ„")
Text("์•„๋ž˜")
}

```

### โฑ Trigger Delay

์ผ์ • ์‹œ๊ฐ„ ํ›„ ์ƒํƒœ๋ฅผ ๋ฐ”๊พธ๋Š” ํŠธ๋ฆฌ๊ฑฐ ์œ ํ‹ธ์ž…๋‹ˆ๋‹ค. Binding์„ ์ผ์ • ์‹œ๊ฐ„ ์ดํ›„ true๋กœ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.
```swift
struct LaunchView: View {
@State private var isActive = false

var body: some View {
Group {
if isActive {
TestView2()
} else {
VStack {
Text("๐Ÿš€ FlexibleKit")
.font(.largeTitle.bold())
Text("Launching...")
.foregroundColor(.gray)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.white)
.delayedTrigger(to: $isActive, after: 2)
}
}
}
}
```

### ๐ŸŒ WebView

SwiftUI์—์„œ ๊ฐ„๋‹จํ•˜๊ฒŒ WKWebView๋ฅผ ๋„์šฐ๊ณ  ์‹ถ์„ ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. URL๋งŒ ๋„˜๊ธฐ๋ฉด ๋ฉ๋‹ˆ๋‹ค.
```swift
FlexibleWebView(url: "https://apple.com")
```