Swiftpack.co - brennobemoura/InputField as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by brennobemoura.
brennobemoura/InputField v0.0.1
Reimplements TextField for iOS 13 will all additions made by Apple over the years
⭐️ 0
🕓 2 weeks ago
iOS
.package(url: "https://github.com/brennobemoura/InputField.git", from: "v0.0.1")

InputField

The InputField implements all behaviors available that SwiftUI code plus some methods to better configurate the TextField.

Usage

Since it uses UITextField as base of all implementation, you can define any layout to it in your component.

import SwiftUI
import InputField

struct NewTextField: View {
    
    @EditingState var isEditing: Bool
    @Binding var text: String
    
    let prompt: String
    
    init(
        _ text: Binding<String>,
        prompt: String
    ) {
        self._text = text
        self.prompt = prompt
    }
    
    var body: some View {
        ZStack(alignment: .leading) {
            if text.isEmpty {
                Text(prompt)
                    .foregroundColor(.gray)
            }
            
            InputField(
                text: $text,
                foregroundColor: .black,
                accentColor: .blue,
                font: .systemFont(ofSize: 16)
            )
            .frame(maxWidth: .infinity)
            .frame(height: 40)
            .editing($isEditing)
        }
        .padding()
        .cornerRadius(8)
        .overlay(
            RoundedRectangle(cornerRadius: 8)
                .strokeBorder(
                    isEditing ? .blue : .gray,
                    lineWidth: 1
                )
        )
    }
}

GitHub

link
Stars: 0
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics