Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate danlaw changes #156

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 6 additions & 10 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ jobs:
drive:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Write firebase_options.dart
run: echo '{{ secrets.FIREBASE_OPTIONS }}' > lib/firebase_options.dart
- name: Write GoogleService-info.plist
run: echo '{{ secrets.GOOGLE_SERVICE_INFO_PLIST }}' > ios/Runner/GoogleService-Info.plist
- name: Write google-services.json
run: echo '{{ secrets.GOOGLE_SERVICES_JSON }}' > android/app/google-services.json
- uses: subosito/[email protected]
- name: Run Flutter tests
run: flutter test
- uses: actions/checkout@v1
- uses: subosito/[email protected]
- run: flutter pub get
- run: flutter pub run build_runner build --delete-conflicting-outputs
- name: Run Flutter tests
run: flutter test
29 changes: 27 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
.buildlog/
.history
.svn/
*.jsk

# IntelliJ related
*.iml
Expand All @@ -17,7 +18,7 @@
.idea/

# Visual Studio Code related
#.vscode/
.vscode/

# Flutter repo-specific
/bin/cache/
Expand Down Expand Up @@ -46,6 +47,13 @@ unlinked.ds
unlinked_spec.ds
.flutter-plugins-dependencies

# Ignoring unsupported platforms
linux
macos
windows
web


# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
Expand All @@ -58,6 +66,10 @@ unlinked_spec.ds
*.jks

# iOS/XCode related
# commenting out the Podfile.lock because it is frequently changing and should be generated by the build
# want to avoid constant branch conflicts
/ios/Podfile.lock

**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
Expand Down Expand Up @@ -102,4 +114,17 @@ macos/firebase_app_id_file.json
android/app/google-services.json

# Firebase hosting
.firebase/
.firebase/

.env
.env/

# contains responses from Danlaw API
api-response.yml

**/*.g.dart
**/*.reflectable.dart

# bundle files
*.apk
*.aab
141 changes: 72 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,102 +1,105 @@
# Time Tracking app with Flutter & Firebase
<h1 id="top" align="center">Danlaw Smart Charger</h1>

A time tracking application built with Flutter & Firebase:
## Table of Contents

![](/.github/images/time-tracker-screenshots.png)
- [Description](#description)
- [Features](#features)
- [Roadmap](#roadmap)
- [Packages](#packages)
- [Support](#support)
- [Design](#design)
- [Screenshots](#screenshots)
- [License](#license)

This is intended as a **reference app** based on my [Riverpod Architecture](https://codewithandrea.com/articles/flutter-app-architecture-riverpod-introduction/).

> **Note**: this project used to be called "Started Architecture for Flutter & Firebase" (based on this [old article](https://codewithandrea.com/videos/starter-architecture-flutter-firebase/)). As of January 2023, it follows my updated [Riverpod Architecture](https://codewithandrea.com/articles/flutter-app-architecture-riverpod-introduction/), using the latest packages.

## Flutter web preview

A Flutter web preview of the app is available here:

- [Time Tracker | Flutter web demo](https://starter-architecture-flutter.web.app)
## Description

Danlaw Smart Charger provides a simple interface for users to monitor the charging status of their EVs, plan custom charging schedules and setup various alerts.

## Features

- **Simple onboarding page**
- **Full authentication flow** (using email & password)
- **Jobs**: users can view, create, edit, and delete their own private jobs (each job has a name and hourly rate)
- **Entries**: for each job, user can view, create, edit, and delete the corresponding entries (an entry is a task with a start and end time, with an optional comment)
- **A report page** that shows a daily breakdown of all jobs, hours worked and pay, along with the totals.

All the data is persisted with Firestore and is kept in sync across multiple devices.
- **Account**: New users need to create an account to access the features of the app.
- **Authentication**: After account creation, users can login with email & password.
- **Household**:
- Users can add up to 3 households per account.
- Household details can be changed.
- **Charger**:
- Users can add up to 3 chargers per household.
- Chargers can be added with scanning a QR code or Bluetooth flow.
- **Vehicle**:
- Users can add up to 6 vehicles per household.
- Vehicles can be added with scanning a QR code or Bluetooth flow.
- Diagnostic Trouble Codes can be accessed from details page.
- **Alert**:
- Alerts are grouped by Vehicles and Chargers.
- Users can be alerted by Push Notifications, Email and SMS.
- Alerts can be set based on remaining miles, charge status, etc..
- **Schedule**: Users can see and set charging schedules for the week.
- **Reports**: Energy reports are available for all the vehicles and chargers. Table can be grouped by chargers.

## Roadmap

- [ ] Add missing tests
- [x] Stateful Nested Navigation (available since GoRouter 7.1)
- [ ] Use controllers / notifiers consistently across the app (some code still needs to be updated)
- [ ] Add localization
- [ ] Use the new Firebase UI packages where useful
- [ ] Responsive UI

> This is a tentative roadmap. There is no ETA for any of the points above. This is a low priority project and I don't have much time to maintain it.

## Relevant Articles
- [ ] Update Add Charger Flow
- [ ] Update Add Vehicle Flow
- [ ] Add more tests
- [ ] Add language selection

The app is based on my Flutter Riverpod architecture, which is explained in detail here:
>**Note:** Some of the items on the roadmap might be tackled at the next phase of development.

- [Flutter App Architecture with Riverpod: An Introduction](https://codewithandrea.com/articles/flutter-app-architecture-riverpod-introduction/)
- [Flutter Project Structure: Feature-first or Layer-first?](https://codewithandrea.com/articles/flutter-project-structure/)
- [Flutter App Architecture: The Repository Pattern](https://codewithandrea.com/articles/flutter-repository-pattern/)

More more info on Riverpod, read this:

- [Flutter Riverpod 2.0: The Ultimate Guide](https://codewithandrea.com/articles/flutter-state-management-riverpod/)

## Packages in use
## Packages

These are the main packages used in the app:

- [Flutter Riverpod](https://pub.dev/packages/flutter_riverpod) for data caching, dependency injection, and more
- [Riverpod Generator](https://pub.dev/packages/riverpod_generator) and [Riverpod Lint](https://pub.dev/packages/riverpod_lint) for the latest Riverpod APIs
- [GoRouter](https://pub.dev/packages/go_router) for navigation
- [Firebase Auth](https://pub.dev/packages/firebase_auth) and [Firebase UI Auth](https://pub.dev/packages/firebase_ui_auth) for authentication
- [Cloud Firestore](https://pub.dev/packages/cloud_firestore) as a realtime database
- [Firebase UI for Firestore](https://pub.dev/packages/firebase_ui_firestore) for the `FirestoreListView` widget with pagination support
- [RxDart](https://pub.dev/packages/rxdart) for combining multiple Firestore collections as needed
- [Intl](https://pub.dev/packages/intl) for currency, date, time formatting
- [Intl](https://pub.dev/packages/intl) for date, time formatting
- [Mocktail](https://pub.dev/packages/mocktail) for testing
- [Equatable](https://pub.dev/packages/equatable) to reduce boilerplate code in model classes
- [flutter_blue_plus](https://pub.dev/packages/flutter_blue_plus) to communicate with Charger and Vehicle via Bluetooth
- [Reflectable](https://pub.dev/packages/reflectable) to automate widget generation from bespoke objects

See the [pubspec.yaml](pubspec.yaml) file for the complete list.

## Running the project with Firebase

To use this project with Firebase, follow these steps:

- Create a new project with the Firebase console
- Enable Firebase Authentication, along with the Email/Password Authentication Sign-in provider in the Firebase Console (Authentication > Sign-in method > Email/Password > Edit > Enable > Save)
- Enable Cloud Firestore

Then, follow one of the two approaches below. 👇
## Support
Application support by [Danlaw](https://danlawtechnologies.com/contactus).

### 1. Using the CLI
Platform support:
- Android: SDK 34+
- iOS: iOS 17.0+

Make sure you have the Firebase CLI and [FlutterFire CLI](https://pub.dev/packages/flutterfire_cli) installed.
Localization support:
- United States English
- Canadian French
- Mexican Spanish

Then run this on the terminal from the root of this project:
Currently application uses default language of the device. If device language is not supported defaults to Engligh.

- Run `firebase login` so you have access to the Firebase project you have created
- Run `flutterfire configure` and follow all the steps
## Design

For more info, follow this guide:
Current designs for this application can be found at [Figma](https://www.figma.com/design/Ji08JojX9t4N5U4uhjgH55/DAN003---EV-Charger-App?node-id=315-20822&t=r8H62xjxlTNpKI6r-0).

- [How to add Firebase to a Flutter app with FlutterFire CLI](https://codewithandrea.com/articles/flutter-firebase-flutterfire-cli/)
## Screenshots

### 2. Manual way (not recommended)
<p >
<img src="assets/readme_assets/start.png" height="400">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<img src="assets/readme_assets/landing_empty.png" height="400">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<img src="assets/readme_assets/landing_full.png" height="400">
</p>
<p >
<img src="assets/readme_assets/alert_main.png" height="400"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<img src="assets/readme_assets/alert_config.png" height="400"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<img src="assets/readme_assets/report_table.png" height="400">
</p>
<p >
<img src="assets/readme_assets/add_charger.png" height="400">
<img src="assets/readme_assets/add_dongle.png" height="400">
<img src="assets/readme_assets/report_main.png" height="400">
</p>

If you don't want to use FlutterFire CLI, follow these steps instead:

- Register separate iOS, Android, and web apps in the Firebase project settings.
- On Android, use `com.example.starter_architecture_flutter_firebase` as the package name.
- then, [download and copy](https://firebase.google.com/docs/flutter/setup#configure_an_android_app) `google-services.json` into `android/app`.
- On iOS, use `com.example.starterArchitectureFlutterFirebase` as the bundle ID.
- then, [download and copy](https://firebase.google.com/docs/flutter/setup#configure_an_ios_app) `GoogleService-Info.plist` into `iOS/Runner`, and add it to the Runner target in Xcode.
## License
Copyright © 2024. All rights reserved by [Danlaw](https://danlawtechnologies.com/terms-conditions).

That's it. Have fun!
<br><br>

## [License: MIT](LICENSE.md)
[Back to Top](#top)
13 changes: 0 additions & 13 deletions android/.gitignore

This file was deleted.

67 changes: 0 additions & 67 deletions android/app/build.gradle

This file was deleted.

7 changes: 0 additions & 7 deletions android/app/src/debug/AndroidManifest.xml

This file was deleted.

33 changes: 0 additions & 33 deletions android/app/src/main/AndroidManifest.xml

This file was deleted.

This file was deleted.

Loading