Skip to content

Latest commit

 

History

History
154 lines (103 loc) · 5.68 KB

README.md

File metadata and controls

154 lines (103 loc) · 5.68 KB

Flutter iOS Calculator

A simple and intuitive Flutter application for foreign exchange calculations, featuring the latest iOS 18 calculator UI design.

This app allows users to convert between different currencies using real-time exchange rates fetched from Free Currency API.

Features

  • User-Friendly Interface: Mimics the iOS 18 calculator UI for a familiar experience.
  • Real-Time Conversion: Fetches the latest currency conversion rates via API.
  • Two Currency Display: Easily toggle between two currencies and input amounts.
  • Modal Currency Selection: Use a modal bottom sheet for selecting different currencies.
  • Error Handling: Proper error handling for API requests.

Screenshots

Calculator Screenshot

Getting Started

To run this application, you need to have Flutter installed on your machine. Follow the instructions below to set up your development environment.

Prerequisites

Installation

  1. Clone the repository:
git clone https://github.com/grandnexus/flutter-ios-calculator.git
cd flutter-ios-calculator
  1. Install the required dependencies:
flutter pub get
  1. Set up your API key for Free Currency API:
  • Create an secrets.json file in the root directory and add your API key:
{
    "CURRENCY_API_KEY": "your_api_key_here"
}
  1. Run the application:
flutter run
  1. Test the application:
flutter test

Code Structure

  • lib/: Contains the main application code.
    • models/: Contains model classes for handling currency data.
    • utils/: Utility functions and helpers for converting different currencies.
    • widgets/: Custom widgets for the calculator UI.
    • main.dart: Entry point of the application.

Key Classes

  • models

    • Currency: A model class representing a currency.
    • CurrenciesData: A model class representing a currencies data from the API.
  • pages

    • CalculatorPage: The main page that displays the currency calculator.
  • utils

    • Converter: A service class for fetching exchange rates and performing currency conversions.
  • widgets

    • CircularButton: A custom circular button widget.
    • CurrencyButton: A custom button widget for selecting a currency.
    • ModalListBottomSheet: A custom modal bottom sheet for selecting a currency.
    • ToggleButton: A custom toggle button widget for switching between currencies.
  • MyApp: The main application widget.

Usage

To use the calculator:

  1. Select the currencies you want to convert using the buttons next to the amount fields.
  2. Input the amount you wish to convert in either the top or bottom currency field.
  3. The converted amount will automatically display in the corresponding field.

API Reference

Fetching Currencies

static Future<Map<String, Currency>> fetchCurrencies({ http.Client? mockClient });

Fetching Latest Exchange Rates

static Future<Converter> fetchLatest(String baseCurrency, String targetCurrency, { http.Client? mockClient });

Currency Conversion

double convert(double amount);

Flutter Packages Used

Dependencies

  • flutter: The Flutter SDK. pub.dev
  • cupertino_icons: ^1.0.8 - Provides icons for iOS style applications. pub.dev
  • http: ^1.2.2 - A package for making HTTP requests. pub.dev
  • auto_size_text: ^3.0.0 - Automatically resizes text to fit within its bounds. pub.dev
  • font_awesome_flutter: ^10.7.0 - FontAwesome icons for Flutter. pub.dev
  • modal_bottom_sheet: ^3.0.0 - A package for displaying modal bottom sheets. pub.dev

Dev Dependencies

  • flutter_test: The Flutter testing framework. pub.dev
  • flutter_lints: ^4.0.0 - A set of recommended lints for Flutter projects. pub.dev
  • mockito: ^5.4.4 - A package for creating mock objects in tests. pub.dev
  • build_runner: ^2.4.13 - A tool for building Dart code. pub.dev

Contributing

Contributions are welcome! Please open an issue or submit a pull request if you'd like to contribute to this project.

License

This project is licensed under the BSD 2-Clause License. See the LICENSE file for more details.

Acknowledgements

  • Free Currency API for providing real-time exchange rates.
  • App Icon Generator for creating the application icon.
  • Flutter team for creating an amazing framework.
  • This project uses the SF Pro Display font, designed by Apple Inc. SF Pro Display is a versatile typeface that enhances the user experience with its clean and modern aesthetic. The font is available under the Apple Font License. For more information, visit Apple's official typography page.