Skip to content

Commit

Permalink
[Counter] Add the counter for TextFieldAddonsUIView
Browse files Browse the repository at this point in the history
  • Loading branch information
robergro committed Nov 8, 2024
1 parent a94a952 commit 2ddd960
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ let package = Package(
// path: "../spark-ios-common"
/*version*/ "0.0.1"..."999.999.999"
),
.package(
url: "https://github.com/adevinta/spark-ios-component-text-input.git",
// path: "../spark-ios-component-text-input"
/*version*/ "0.0.1"..."999.999.999"
),
.package(
url: "https://github.com/adevinta/spark-ios-theming.git",
// path: "../spark-ios-theming"
Expand All @@ -39,6 +44,10 @@ let package = Package(
name: "SparkCommon",
package: "spark-ios-common"
),
.product(
name: "SparkTextInput",
package: "spark-ios-component-text-input"
),
.product(
name: "SparkTheming",
package: "spark-ios-theming"
Expand Down
13 changes: 13 additions & 0 deletions Sources/Core/View/UIKit/FormFieldUIView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SwiftUI
import UIKit
@_spi(SI_SPI) import SparkCommon
import SparkTheming
import SparkTextInput

// TODO: compression resistance

Expand Down Expand Up @@ -412,3 +413,15 @@ public extension FormFieldUIView where Component: UITextInput {
self.viewModel.setCounter(text: text, limit: limit)
}
}

public extension FormFieldUIView where Component: TextFieldAddonsUIView {

// MARK: - Public Setter

/// Display a counter value (X/Y) in the secondary helper label with a text and the limit.
/// - parameter text: the text where the characters must be counted.
/// - parameter limit: the counter limit. If the value is nil, the counter is not displayed.
func setCounter(on text: String?, limit: Int?) {
self.viewModel.setCounter(text: text, limit: limit)
}
}

0 comments on commit 2ddd960

Please sign in to comment.