Skip to content

Releases: marinofelipe/CurrencyText

SwiftUI CurrencyFormater binding

09 Jun 19:26
32c6f68
Compare
Choose a tag to compare

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

02 Jun 22:59
f2302ee
Compare
Choose a tag to compare

Ensure state changes on CurrencyFormatter are propagated through CurrencyTextField.
This should fix the reported bug #87.

Improved SwiftUI focus API

26 Mar 13:16
d0b1413
Compare
Choose a tag to compare

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

09 May 23:49
Compare
Choose a tag to compare

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

05 Aug 20:49
Compare
Choose a tag to compare
  • 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

15 Mar 21:26
432676d
Compare
Choose a tag to compare
  • Add passthrough delegate
  • Bump two Gems to fix vulnerabilities
  • Organize git hub supporting files
  • Ignore DS_Store

Support SPM

03 Nov 02:09
1e51ed1
Compare
Choose a tag to compare
  • 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

03 Oct 12:51
842a0e3
Compare
Choose a tag to compare
  • 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

30 Sep 00:00
Compare
Choose a tag to compare

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.

Swift 5

05 Jul 18:48
abc190a
Compare
Choose a tag to compare

PATCH

  • Update to Swift 5.
  • Update fastlane and CI to Xcode 10.2.