Skip to content

Commit

Permalink
feat(GiniHealthSDK): Introduces TextFieldConfiguration
Browse files Browse the repository at this point in the history
IPC-153
  • Loading branch information
zladzeyka committed Feb 26, 2024
1 parent a58f91c commit 58fdc5c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// TextFieldConfiguration.swift
//
// Copyright © 2024 Gini GmbH. All rights reserved.
//


import UIKit
public struct TextFieldConfiguration {
let backgroundColor: UIColor
let borderColor: UIColor
let textColor: UIColor
let cornerRadius: CGFloat
let borderWidth: CGFloat
let placeholderForegroundColor: UIColor


/// Text Field configuration initalizer
/// - Parameters:
/// - backgroundColor: the textField's background color
/// - borderColor: the textField's border color
/// - textColor: the textField's text color
/// - cornerRadius: the textField's corner radius
/// - borderWidth: the textField's border width
/// - placeholderForegroundColor:the textField's placeholder foreground color

public init(backgroundColor: UIColor,
borderColor: UIColor,
textColor: UIColor,
cornerRadius: CGFloat,
borderWidth: CGFloat,
placeholderForegroundColor: UIColor) {
self.backgroundColor = backgroundColor
self.borderColor = borderColor
self.textColor = textColor
self.cornerRadius = cornerRadius
self.borderWidth = borderWidth
self.placeholderForegroundColor = placeholderForegroundColor
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,15 @@ public extension UITextField {
}
}
}

extension UITextField {
func configureWith(configuration: TextFieldConfiguration){
self.layer.cornerRadius = configuration.cornerRadius
self.layer.borderWidth = configuration.borderWidth
self.layer.borderColor = configuration.borderColor.cgColor
self.backgroundColor = configuration.backgroundColor
self.textColor = configuration.textColor
self.attributedPlaceholder = NSAttributedString(string: "",
attributes: [NSAttributedString.Key.foregroundColor: configuration.placeholderForegroundColor])
}
}

0 comments on commit 58fdc5c

Please sign in to comment.