Skip to content

JamesSedlacek/CurrencyProviding

Repository files navigation

CurrencyProviding

Swift Package Manager GitHub stars GitHub forks GitHub contributors Pull Requests Badge Issues Badge

Description

CurrencyProviding is a SwiftUI library that allows users to select a currency for an application.
The selected currency will be used for icons, strings, and text fields throughout the application.


Requirements

  • iOS: 17.0 or later.

Installation

You can install CurrencyProviding using the Swift Package Manager.

  1. In Xcode, select "File" > "Add Package Dependencies".
  2. Copy & paste the following into the "Search or Enter Package URL" search bar.
https://github.com/JamesSedlacek/CurrencyProviding.git
  1. Xcode will fetch the repository & the "CurrencyProviding" library will be added to your project.

Getting Started

  1. Add CurrencyProviding to your project.
import CurrencyProviding
import SwiftUI

struct ContentView: View {
    @State private var currencyProvider: CurrencyProvider = .init()

    var body: some View {
        VStack {
            Text("Hello, world!")
        }
        .environment(currencyProvider)
    }
}

  1. Add CurrencyPicker to the settings screen in your project.
import CurrencyProviding
import SwiftUI

struct SettingsView {
    var body: some View {
        VStack {
            CurrencyPicker()
        }
    }
}

  1. Use CurrencyProvider for Icons, Strings, and TextFields.
import CurrencyProviding
import SwiftUI

struct ExampleView: View {
    @Environment(CurrencyProvider.self)
    private var currencyProvider

    @State private var someNumber: Decimal = 0

    private var decimalToCurrencyString: String {
        currencyProvider.text(for: someNumber)
    }

    var body: some View {
        VStack {
            CurrencyTextField(value: $someNumber)

            currencyProvider.icon(withCircle: true)
        }
    }
}

Author

James Sedlacek, find me on X/Twitter or LinkedIn

About

SwiftUI library for handling currency selection

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages