The markdown parsing is broken/disabled for release notes. Sorry about that, I'm chasing the source of a crash that's been bringing this website down for the last couple of days.
SwiftUI CurrencyFormater binding
1 year ago
## Breaking
Change `CurrencyTextFieldConfiguration.formatter` to be a `@Binding` property, which aims to propagate state changes when the formatter is updated, like on `formatter.currency` changes.
When bumping to this release, users will have to update their `CurrencyTextField` usages passing a projected value for their formatters, prefixed with `$`.
```swift
CurrencyTextField(
configuration: .init(
// ...
formatter: $currencyFormatter
```
In order to update the bound formatter, it must be re-initialized with the desired properties, since the view update is only triggered when the Binding changes, in that case the formatter instance itself:
```swift
CurrencyTextField(
Picker(
"Change currency",
selection: $currency
) {
ForEach(
[
Currency.euro,
Currency.dollar,
Currency.brazilianReal,
Currency.yen
],
id: \.self
) {
Text($0.rawValue).tag($0)
}
}
.pickerStyle(.segmented)
.onChange(of: currency) { newValue in
currencyFormatter = .init {
$0.currency = newValue
// other props
}
}
```
For a full example, one case check the `SwiftUIExampleView.swift` on the `Example` app target, available in the `CurrencyText.xcworkspace`.
Fix formatter state to update on SwiftUI
1 year ago
Ensure state changes on `CurrencyFormatter` are propagated through `CurrencyTextField`.
This should fix the reported bug #87.
Improved SwiftUI focus API
2 years ago
Added a new property to `CurrencyTextFieldConfiguration` called `hasFocus`, a `Binding<Bool?>` that can be used to control and observe focus/isFirstResponder changes for a `CurrencyTextField` wrapped `UITextField`. By default `hasFocus` is `nil`.
The usage is as follows:
```swift
struct MyView: View {
@State private var hasFocus: Bool? // or this initially as true
var body: some View {
CurrencyTextField(
configuration: .init(
text: $text,
hasFocus: $hasFocus,
// ...
)
)
.onAppear {
hasFocus = true
}
}
}
```
Release libraries for SwiftUI
2 years ago
This release added new libraries and API for formatting currency text in SwiftUI.
For more detail please check the docs and the Example app.
**Obs**: For now the SwiftUI libraries are only available for iOS given that the bridging between `UIKit` to `SwiftUI` required configuring an underlying `UITextField`.
A future major version may provide `SwiftUI` support for all Apple platforms, in vanilla `SwiftUI` without the need to bridge from `UIKit`, whenever Apple provides us with API for fully controlling a `SwiftUI.TextField` selectedTextRange.
## Changes
- Fixed CurrencyFormatter.unformatted(string:) when hasDecimals is true
- Updated the ExampleApp with both UIKit and SwiftUI examples, and made it Storyboard-less
- Increased min supported iOS version from `9.0` to `11.0`
- Updated from Swift 5.0 to Swift 5.3 toolchain
- Added a SwiftPackage library `CurrencyTextSwiftUI` and CocoaPods sub-spec `CurrencyTextField` that provides access to `SwiftUI.CurrencyTextField` and `CurrencyTextFieldConfiguration`
Improve experience when formatter has min/max set
3 years ago
- Fix #66 , by adjusting user inputed value to match formatter's defined range (min and/or max) only when the text field resign as first responder. This improves the experience by allowing users to freely type their currency text, without the value being e.g. initially adjusted from `$ 0.01` to `$ 2.00` - when `currencyFormatter's min is 2`.
- Small improvements on the release lanes.
Add passthrough delegate
4 years ago
- Add passthrough delegate
- Bump two Gems to fix vulnerabilities
- Organize git hub supporting files
- Ignore DS_Store
- Add support to use Currency Text via **Swift Package Manager**.
- Fix security vulnerability by bumping _rubyzip_ from 1.2.4 to 1.3.0.
Improve initial selected text range
4 years ago
- Update example layout.
- Improve initial selected text range to be always after the last number, and to always at the end of the string.
- Update CI to Xcode 11.
Improve selected text range
4 years ago
## PATCH
- Update bundle dependencies;
- Improve and adjust selected text range when the currency symbol is at the end of the text.
- Update Example's layout.
## PATCH
- Update to Swift 5.
- Update fastlane and CI to Xcode 10.2.