Releases: marinofelipe/CurrencyText
3.0.1 - Fix SwiftUI warnings
Shipped by @Andrewangeta .
Production
- Fix multiple SwiftUI warnings and make sure view changes are published outside of the view updates loop
Development
- Update CI to Xcode 16
- Update fastlane and used GitHub actions to the latest
SwiftUI CurrencyFormater binding
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 $
.
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:
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
Ensure state changes on CurrencyFormatter
are propagated through CurrencyTextField
.
This should fix the reported bug #87.
Improved SwiftUI focus API
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:
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
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
to11.0
- Updated from Swift 5.0 to Swift 5.3 toolchain
- Added a SwiftPackage library
CurrencyTextSwiftUI
and CocoaPods sub-specCurrencyTextField
that provides access toSwiftUI.CurrencyTextField
andCurrencyTextFieldConfiguration
Improve experience when formatter has min/max set
- 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
- whencurrencyFormatter's min is 2
. - Small improvements on the release lanes.
Add passthrough delegate
- Add passthrough delegate
- Bump two Gems to fix vulnerabilities
- Organize git hub supporting files
- Ignore DS_Store
Support SPM
- 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
- 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
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.