Skip to content

Latest commit

 

History

History
265 lines (205 loc) · 8 KB

README.md

File metadata and controls

265 lines (205 loc) · 8 KB

Transformx

coverage style: very good analysis License: MIT

Generated by the Very Good CLI 🤖

A habit tracking app based on the Atomic Habits


Set up project locally

  • Create a Fork

    • Visit the Transform X GitHub repository, and click 'Fork'.
    • Select the owner and repository name and click “Create Fork”
  • Clone the fork

  • Set up the upstream branch

    1. Open Terminal.
    2. List the current configured remote repository for your fork.
    $ git remote -v
    > origin  https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
    > origin  https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
    
    1. Specify a new remote upstream repository that will be synced with the fork.
    git remote add upstream https://github.com/MayurSMahajan/transformX.git
    
    1. Verify the new upstream repository you've specified for your fork.
    $ git remote -v
    > origin    https://github.com/YOUR_USERNAME/transformX.git
    > origin    https://github.com/YOUR_USERNAME/transformX.git
    > upstream  https://github.com/MayurSMahajan/transformX.git
    > upstream  https://github.com/MayurSMahajan/transformX.git
    
    
  • Running local project

    • Begin by ensuring that the script execution policy is enabled on your Windows system. For guidance, refer Enabling Script Execution Policy.
    • Install very_good_cli as a global package.
    dart pub global activate very_good_cli
    
    • After that from the root directory run
    very_good packages get --recursive
    
    • If the above command does not install all the dependencies in all your packages then you can try manually running flutter pub get within all your packages inside transformx/packages folder
  • Setting up Firebase

    • Visit “Firebase” and login with your Google Account.
    • Click on the "Console" button located in the top-right corner and create a new project.
    • Within the project overview, choose the Flutter option.
    • Install the Firebase CLI by executing the following command in your terminal:
    npm install -g firebase-tools
    
    • Install the FlutterFire CLI using the following command:
    dart pub global activate flutterfire_cli
    
    • Then login to Firebase using the following command:
    firebase login
    
    • A new Google Sign-In tab will open in your web browser.
    • Select your Google account and grant the necessary permissions.
    • Then, at the root of your Flutter project directory, run this command:
    flutterfire configure
    
  • Add SHA-1 certificate fingerprint

    1. Open your terminal/command prompt.
    2. Run the following command in your VS Code terminal to generate the SHA-1 fingerprint:
    ./gradlew signingReport
    
    1. Look for the SHA-1 fingerprint in the output. It will be displayed along with other signing information. For example:
    SHA1: 23:4E:xx:xx:xx:..
    
    1. In the project overview, select the recently created Flutter app and then go to settings.
    2. Scroll down to the "Your apps" section, where your Flutter app should be listed. Click on your app's platform (Android) to expand the settings.
    3. Under the "SHA certificate fingerprints" section, click on the "Add fingerprint" button. Enter the SHA-1 certificate fingerprint that you obtained earlier in the terminal. Click the “Save” button. (It is important to add SHA key for Google Sign In option)
  • Enable Google Sign-In and Firestore Database

    Your Firebase console should look like this:

    Firebase Console


Getting Started 🚀

This project contains 3 flavors:

  • development
  • staging
  • production

To run the desired flavor either use the launch configuration in VSCode/Android Studio or use the following commands:

# Development
$ flutter run --flavor development --target lib/main_development.dart

# Staging
$ flutter run --flavor staging --target lib/main_staging.dart

# Production
$ flutter run --flavor production --target lib/main_production.dart

*Transformx works on iOS, Android, Web, and Windows.


Running Tests 🧪

To run all unit and widget tests use the following command:

$ flutter test --coverage --test-randomize-ordering-seed random

To view the generated coverage report you can use lcov.

# Generate Coverage Report
$ genhtml coverage/lcov.info -o coverage/

# Open Coverage Report
$ open coverage/index.html

Working with Translations 🌐

This project relies on flutter_localizations and follows the official internationalization guide for Flutter.

Adding Strings

  1. To add a new localizable string, open the app_en.arb file at lib/l10n/arb/app_en.arb.
{
    "@@locale": "en",
    "counterAppBarTitle": "Counter",
    "@counterAppBarTitle": {
        "description": "Text shown in the AppBar of the Counter Page"
    }
}
  1. Then add a new key/value and description
{
    "@@locale": "en",
    "counterAppBarTitle": "Counter",
    "@counterAppBarTitle": {
        "description": "Text shown in the AppBar of the Counter Page"
    },
    "helloWorld": "Hello World",
    "@helloWorld": {
        "description": "Hello World Text"
    }
}
  1. Use the new string
import 'package:transformx/l10n/l10n.dart';

@override
Widget build(BuildContext context) {
  final l10n = context.l10n;
  return Text(l10n.helloWorld);
}

Adding Supported Locales

Update the CFBundleLocalizations array in the Info.plist at ios/Runner/Info.plist to include the new locale.

    ...

    <key>CFBundleLocalizations</key>
	<array>
		<string>en</string>
		<string>es</string>
	</array>

    ...

Adding Translations

  1. For each supported locale, add a new ARB file in lib/l10n/arb.
├── l10n
│   ├── arb
│   │   ├── app_en.arb
│   │   └── app_es.arb
  1. Add the translated strings to each .arb file:

app_en.arb

{
    "@@locale": "en",
    "counterAppBarTitle": "Counter",
    "@counterAppBarTitle": {
        "description": "Text shown in the AppBar of the Counter Page"
    }
}

app_es.arb

{
    "@@locale": "es",
    "counterAppBarTitle": "Contador",
    "@counterAppBarTitle": {
        "description": "Texto mostrado en la AppBar de la página del contador"
    }
}