Swiftpack.co -  marinofelipe/CurrencyText as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
marinofelipe/CurrencyText
Currency text field formatter available for UIKit and SwiftUI 💶✏️
.package(url: "https://github.com/marinofelipe/CurrencyText.git", from: "2.2.0")

Build status Coverate status Swift Platform Swift Package Manager CocoaPods Compatible [Twitter](htt<img style="max-width:100%;" src="https://raw.github.com/marinofelipe/CurrencyText/main/er.com/_marinofelipe)

CurrencyText provides lightweight libraries for formating text field text as currency, available for both UIKit and SwiftUI.

Its main core, the CurrencyFormatter class, can also be used a part from text fields to format any value that can be monetary represented.

If you need to present currency formatted text or allow users to input currency data, CurrencyText is going to help you do it in a readable and configurable matter.

Documentation

For details on how to use CurrencyText libraries please refer to the docs.

Installation

Swift Package Manager

To install it using Swift Package Manager, just add this repository through Xcode built-in Swift Packages, or by manually adding it to your Package.swift Package's dependencies:

dependencies: [
    .package(
    	url: "https://github.com/marinofelipe/CurrencyText.git", 
    	.upToNextMinor(from: .init(2, 1, 0)
    )
]

.target(
    name: "MyTarget",
    dependencies: [
    	// Can be imported to consume the formatter in insolation
        .target(name: "CurrencyFormatter"),

        // UIKit library - Provide access to "CurrencyFormatter" and "CurrencyUITextFieldDelegate" targets
        .target(name: "CurrencyText"),

        // SwiftUI library - Provide access to "CurrencyFormatter" and "CurrencyTextField" targets
        .target(name: "CurrencyTextSwiftUI")
    ],
    ...
)

Install via CocoaPods

To integrate CurrencyText using CocoaPods, specify it, one or more of its sub-specs in your Podfile:

# Podfile
use_frameworks!

target 'YOUR_TARGET_NAME' do
     pod 'CurrencyText'

     # sub-specs

     # pod 'CurrencyText/CurrencyFormatter'
     # pod 'CurrencyText/CurrencyUITextField'
     # pod 'CurrencyText/CurrencyTextField'
end

Contributing

Contributions and feedbacks are always welcome. Please feel free to fork, follow, open issues and pull requests. The issues, milestones, and what we are currently working on can be seen in the main Project.

Special Thanks

To @malcommac for his awesome work with SwiftRichString and SwfitDate, that inspired me when creating this project. Also to myanalysis for contributing so much by finding issues and giving nice suggestions.

Copyright

CurrencyText is released under the MIT license. See LICENSE for details.

Felipe Marino: felipemarino91@gmail.com, @_marinofelipe

GitHub

link
Stars: 84
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Release libraries for SwiftUI
11 weeks 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

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API