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

Track details card and track card UI improvements #19

Open
wants to merge 22 commits into
base: bluetooth_flutter_reactive_ble
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6bb2e8d
Created settings screen
D-Ajay-Kumar Jun 24, 2021
f82d240
Created logbook screen and screen to add new fueling logs
D-Ajay-Kumar Jun 26, 2021
9344ade
minor fixes and add track details card
KhyatiSaini Jun 26, 2021
b336d1c
handle exceptions in write and subscribe characteristics function and…
KhyatiSaini Jun 27, 2021
f8d8c73
Created Report Issue Screen
D-Ajay-Kumar Jun 28, 2021
27d2168
Created Help Screen
D-Ajay-Kumar Jun 28, 2021
fcb228e
Created Rate Us feature
D-Ajay-Kumar Jun 28, 2021
91e3d32
Added feature to close app programatically
D-Ajay-Kumar Jun 28, 2021
cfabd8b
add bluetooth provider and popup menu for track card
KhyatiSaini Jun 29, 2021
e6f6ee0
Added liniting to the whole project and local db for car
D-Ajay-Kumar Jul 5, 2021
a15011b
Merge pull request #13 from D-Ajay-Kumar/settings-screen-creation
D-Ajay-Kumar Jul 5, 2021
7f049f2
Merge pull request #14 from D-Ajay-Kumar/logbook-creation
D-Ajay-Kumar Jul 5, 2021
15ac3be
Merge pull request #15 from D-Ajay-Kumar/report-issue-screen
D-Ajay-Kumar Jul 5, 2021
cc812d5
Merge pull request #16 from D-Ajay-Kumar/help-screen
D-Ajay-Kumar Jul 5, 2021
446cd8b
Merge pull request #17 from D-Ajay-Kumar/rate-Us-feature
D-Ajay-Kumar Jul 5, 2021
0acb262
Merge pull request #18 from D-Ajay-Kumar/close-enviroCar-feature
D-Ajay-Kumar Jul 5, 2021
1ac69eb
Adding CI using Github Actions
D-Ajay-Kumar Jul 6, 2021
f176e6b
Merge pull request #22 from D-Ajay-Kumar/adding-CI
D-Ajay-Kumar Jul 6, 2021
f5cc9ee
update branch, minor fixes and add linting
KhyatiSaini Jul 9, 2021
834a7a0
Update ci.yml
D-Ajay-Kumar Jul 12, 2021
fdf5a30
Merge branch 'master' of https://github.com/enviroCar/enviroCar-Cross…
KhyatiSaini Jul 20, 2021
0f8c298
fix the handleError function and convert BluetoothProvider to singlet…
KhyatiSaini Jul 20, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: CI
on:
# Run the workflow when code is pushed to master branch
pull_request:
branches:
- master

jobs:
flutter_test:
name: Run flutter test and analyze
runs-on: ubuntu-latest
steps:
# Setup Java environment in order to build the Android app
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: "12.x"

# Setup the flutter environment
- uses: subosito/flutter-action@v1
with:
channel: "stable"

# Get flutter dependencies
- run: flutter pub get

build_ios:
name: Build Flutter (iOS)
needs: [flutter_test]
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: "12.x"
- uses: subosito/flutter-action@v1
with:
channel: "stable"
- run: flutter pub get
- run: flutter clean

# Build iOS app
- run: flutter build ios --release --no-codesign

# Upload the iOS build to GitHub as artifact
- uses: actions/upload-artifact@v1
with:
name: ios-app
path: /Users/runner/work/enviroCar-Cross-Platform-App/enviroCar-Cross-Platform-App/build/ios/iphoneos

build_appbundle:
name: Build Flutter (Android)

# Runs only when Flutter test executes successfully
needs: [flutter_test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: "12.x"
- uses: subosito/flutter-action@v1
with:
channel: "stable"
- run: flutter pub get

# Clean any previous builds
- run: flutter clean

# Build apk
- run: flutter build apk

# Upload the build as artifact
- uses: actions/upload-artifact@v1
with:
name: release-apk
path: build/app/outputs/apk/release/app-release.apk
26 changes: 26 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
include: package:lint/analysis_options.yaml

# Linting rules for the project

linter:
rules:
# Blindly follow the Flutter code style, which prefers types everywhere
prefer_relative_imports: true

# Ignoring naming convention of using underscores instead of camelCase
file_names: false

# Ignoring having to make getters for setters
avoid_setters_without_getters: false

# Ignoring avoiding using true and false in conditions
avoid_bool_literals_in_conditional_expressions: false

# Ignoring ordering directives in alphabetical order
directives_ordering: false

# Ignoring converting outter single to doube quotes
avoid_escaping_inner_quotes: false

# ignoring naming convention for constant identifiers
constant_identifier_names: false
Binary file added assets/images/img_logbook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 15 additions & 10 deletions lib/constants.dart
Original file line number Diff line number Diff line change
@@ -3,27 +3,27 @@ import 'package:flutter/material.dart';
const InputDecoration inputDecoration = InputDecoration(
alignLabelWithHint: true,
labelStyle: TextStyle(
color: const Color(0xff7e7e7e),
color: Color(0xff7e7e7e),
),
contentPadding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
contentPadding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
border: OutlineInputBorder(
borderRadius: const BorderRadius.all(
const Radius.circular(5.0),
borderRadius: BorderRadius.all(
Radius.circular(5.0),
),
),
enabledBorder: OutlineInputBorder(
borderSide: const BorderSide(color: kSecondaryColor, width: 1.5),
borderRadius: const BorderRadius.all(
const Radius.circular(5.0),
borderSide: BorderSide(color: kSecondaryColor, width: 1.5),
borderRadius: BorderRadius.all(
Radius.circular(5.0),
),
),
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
borderSide: BorderSide(
color: kGreyColor,
width: 1.5,
),
borderRadius: const BorderRadius.all(
const Radius.circular(5.0),
borderRadius: BorderRadius.all(
Radius.circular(5.0),
),
),
);
@@ -34,3 +34,8 @@ const Color kPrimaryColor = Color(0xff000000);
const Color kSecondaryColor = Color(0xffD8D8D8);
const Color kErrorColor = Color.fromARGB(250, 255, 50, 64);
const Color kWhiteColor = Color(0xffffffff);
const Color kTertiaryColor = Color.fromARGB(200, 0, 0, 0);

// PlayStore URL for 'Rate Us' feature
const String playstoreUrl =
'https://play.google.com/store/apps/details?id=org.envirocar.app';
24 changes: 24 additions & 0 deletions lib/database/carsTable.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class CarsTable {
// name of the table
static const String tableName = 'cars';

// columns of the table
static const String idColumn = 'id';
static const String manufacturerColumn = 'manufacturer';
static const String modelColumn = 'model';
static const String constructionYearColumn = 'constructionYear';
static const String fuelTypeColumn = 'fuelType';
static const String engineDisplacementColumn = 'engineDisplacement';

// query to create the table
static const String carsTableQuery = '''
CREATE TABLE ${CarsTable.tableName} (
${CarsTable.idColumn} INTEGER PRIMARY KEY AUTOINCREMENT,
${CarsTable.manufacturerColumn} TEXT NOT NULL,
${CarsTable.modelColumn} TEXT NOT NULL,
${CarsTable.constructionYearColumn} INTEGER NOT NULL,
${CarsTable.fuelTypeColumn} TEXT NOT NULL,
${CarsTable.engineDisplacementColumn} INTEGER NOT NULL
)
''';
}
75 changes: 75 additions & 0 deletions lib/database/databaseHelper.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import 'package:flutter/foundation.dart';

import 'package:sqflite/sqflite.dart';
import 'package:path/path.dart';

import './carsTable.dart';

class DatabaseHelper {
static Database _database;

// name and version of the database, to be changed later
static const _dbName = 'testDB1.db';
static const _dbVersion = 1;

// private construction to create a singleton of the database instance
DatabaseHelper._privateConstructor();
static final DatabaseHelper instance = DatabaseHelper._privateConstructor();

// fetching the database
Future<Database> get getDatabase async {
// return database if it is already open
if (_database != null) {
return _database;
} else {
return _database = await initDatabase();
}
}

// openining the database
Future<Database> initDatabase() async {
final String dbPath = await getDatabasesPath();
return openDatabase(
join(dbPath, _dbName),
version: _dbVersion,
onCreate: createDatabase,
);
}

// creating the database and the tables if it is the first time
Future<void> createDatabase(Database db, int version) async {
await db.execute(CarsTable.carsTableQuery);
}

// method to insert values in the database
// return the primary key of the inserted value
Future<int> insertValue(
{@required String tableName, @required Map<String, dynamic> data}) async {
final Database db = await instance.getDatabase;
final int primaryKey = await db.insert(
tableName,
data,
);

return primaryKey;
}

// reads all values in the table
Future<List<Map<String, dynamic>>> readAllValues(
{@required String tableName}) async {
final Database db = await instance.getDatabase;

return db.query(tableName);
}

// deletes the value
Future<void> deleteValue(
{@required String tableName, @required Map<String, dynamic> data}) async {
final Database db = await instance.getDatabase;
db.delete(
tableName,
where: 'id = ?',
whereArgs: [data['id']],
);
}
}
30 changes: 27 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import 'package:shared_preferences/shared_preferences.dart';

import './providers/authProvider.dart';
import './providers/tracksProvider.dart';
import 'models/track.dart';
import './screens/splashScreen.dart';
import './screens/bluetoothDevicesScreen.dart';
import './screens/index.dart';
@@ -22,10 +23,18 @@ import './screens/createCarScreen.dart';
import './screens/trackDetailsScreen.dart';
import './providers/bluetoothStatusProvider.dart';
import './providers/locationStatusProvider.dart';
import './providers/bluetoothProvider.dart';
import './providers/fuelingsProvider.dart';
import './screens/createFuelingScreen.dart';
import './screens/logBookScreen.dart';
import './screens/reportIssueScreen.dart';
import './screens/helpScreen.dart';

void main() async {
Future<void> main() async {
// Ensures all the future functions of main() finish before launching the app
WidgetsFlutterBinding.ensureInitialized();

// Instance of shared prefs
preferences = await SharedPreferences.getInstance();

// Restricts rotation of screen
@@ -42,6 +51,7 @@ void main() async {
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
@@ -73,7 +83,16 @@ class MyApp extends StatelessWidget {
// Provides location status update to the different widgets on the tree
ChangeNotifierProvider(
create: (context) => LocationStatusProvider(),
)
),

// Provides bluetooth functions to the different widgets on the tree
ChangeNotifierProvider(
create: (context) => BluetoothProvider(),
),
// Provides Fueling data to different widgets
ChangeNotifierProvider(
create: (context) => FuelingsProvider(),
),
],
child: MaterialApp(
locale: DevicePreview.locale(context),
@@ -90,7 +109,8 @@ class MyApp extends StatelessWidget {
case TrackDetailsScreen.routeName:
return MaterialPageRoute(
builder: (_) {
return TrackDetailsScreen(track: settings.arguments);
final Track track = settings.arguments as Track;
return TrackDetailsScreen(track: track);
},
);

@@ -110,6 +130,10 @@ class MyApp extends StatelessWidget {
MapScreen.routeName: (context) => MapScreen(),
CarScreen.routeName: (context) => CarScreen(),
CreateCarScreen.routeName: (context) => CreateCarScreen(),
CreateFuelingScreen.routeName: (context) => CreateFuelingScreen(),
LogBookScreen.routeName: (context) => LogBookScreen(),
ReportIssueScreen.routeName: (context) => ReportIssueScreen(),
HelpScreen.routeName: (context) => HelpScreen(),
},
),
);
23 changes: 22 additions & 1 deletion lib/models/car.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Car {
String id;
int id;
String manufacturer;
String model;
int constructionYear;
@@ -14,4 +14,25 @@ class Car {
this.fuelType,
this.engineDisplacement,
});

Car.fromJson(Map<String, dynamic> json) {
id = json['id'] as int;
manufacturer = json['manufacturer'] as String;
model = json['model'] as String;
constructionYear = json['constructionYear'] as int;
fuelType = json['fuelType'] as String;
engineDisplacement = json['engineDisplacement'] as int;
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['manufacturer'] = manufacturer;
data['model'] = model;
data['constructionYear'] = constructionYear;
data['fuelType'] = fuelType;
data['engineDisplacement'] = engineDisplacement;

return data;
}
}
30 changes: 30 additions & 0 deletions lib/models/fueling.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:flutter/foundation.dart';

import './car.dart';

// Model for Fueling data in Log Book
class Fueling {
String id;
Car car;
String mileage;
String fueledVolume;
String pricePerLitre;
String totalPrice;
bool partialFueling;
bool missedPreviousFueling;
String comment;

// TODO: Add datetime attribute

Fueling({
@required this.id,
@required this.car,
@required this.mileage,
@required this.fueledVolume,
@required this.totalPrice,
@required this.pricePerLitre,
@required this.partialFueling,
@required this.missedPreviousFueling,
@required this.comment,
});
}
Loading