Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/youjinp/SwiftUIKit
A collection of missing SwiftUI components
https://github.com/youjinp/SwiftUIKit
ios spm swift swiftui
Last synced: about 2 months ago
JSON representation
A collection of missing SwiftUI components
- Host: GitHub
- URL: https://github.com/youjinp/SwiftUIKit
- Owner: youjinp
- License: mit
- Created: 2020-05-05T04:19:24.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-09-22T04:47:33.000Z (over 2 years ago)
- Last Synced: 2024-08-02T09:27:06.294Z (5 months ago)
- Topics: ios, spm, swift, swiftui
- Language: Swift
- Homepage:
- Size: 1 MB
- Stars: 271
- Watchers: 5
- Forks: 32
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-swiftui - SwiftUIKit - A collection of missing SwiftUI components (Samples)
README
# SwiftUIKit
A collection of components that will simplify and accelerate your iOS development.
## Components
1. [CurrencyTextField](#1-currencytextfield)
1. [AdaptToKeyboard](#2-adapttokeyboard) (not needed for iOS 14 beta 6+)
1. [ContactPicker](#3-contactpicker)## Demo
There is an example app at `SwiftUIKitExampleApp` which can be built and run. Just clone this repo and run it.
# 1. CurrencyTextField
## Demo
## Description
Real time formatting of users input into currency format.
## Usage
```swift
import SwiftUIKitstruct ContentView: View {
@State private var value = 0.0var body: some View {
//Minimal configuration
CurrencyTextField("Amount", value: self.$value)
//All configurations
CurrencyTextField("Amount", value: self.$value, alwaysShowFractions: false, numberOfDecimalPlaces: 2, currencySymbol: "US$")
.font(.largeTitle)
.multilineTextAlignment(TextAlignment.center)
}
}
```# 2. AdaptToKeyboard
## Demo
## Description
Animate view's position when keyboard is shown / hidden
## Usage
```swift
import SwiftUIKitstruct ContentView: View {
var body: some View {
VStack {
Spacer()
Button(action: {}) {
Text("Hi")
.adaptToKeyboard()
}
}
}
}
```# 3. ContactPicker
## Demo
## Description
SwiftUI doesn't work well with `CNContactPickerViewController` if you just put it inside a `UIViewControllerRepresentable`. See this [stackoverflow post](https://stackoverflow.com/questions/57246685/uiviewcontrollerrepresentable-and-cncontactpickerviewcontroller/57621666#57621666). With `ContactPicker` here its just a one liner.
To enable multiple selection use `onSelectContacts` instead.
## Usage
```swift
import SwiftUIKitstruct ContentView: View {
@State var showPicker = falsevar body: some View {
ZStack {
// This is just a dummy view to present the contact picker,
// it won't display anything, so place this anywhere.
// Here I have created a ZStack and placed it beneath the main view.
ContactPicker(
showPicker: $showPicker,
onSelectContact: {c in
self.contact = c
}
)
VStack {
Button(action: {
self.showPicker.toggle()
}) {
Text("Pick a contact")
}
}
}
}
}
```