Skip to content

Commit

Permalink
Merge pull request #13 from DSC-Flutter-PU/develop
Browse files Browse the repository at this point in the history
Migration to firebase
  • Loading branch information
MawiraIke authored Apr 11, 2020
2 parents 975f651 + b63ec74 commit c5108e3
Show file tree
Hide file tree
Showing 17 changed files with 335 additions and 337 deletions.
8 changes: 5 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ if (flutterVersionName == null) {

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services' // Google Services plugin

android {
compileSdkVersion 28
compileSdkVersion 29

lintOptions {
disable 'InvalidPackage'
Expand All @@ -34,8 +35,8 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.flutter.dscpu.employeeapp"
minSdkVersion 16
targetSdkVersion 28
minSdkVersion 21
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -58,4 +59,5 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'com.android.support:multidex:1.0.3'
}
48 changes: 48 additions & 0 deletions android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"project_info": {
"project_number": "421411144764",
"firebase_url": "https://dsc-employee-app.firebaseio.com",
"project_id": "dsc-employee-app",
"storage_bucket": "dsc-employee-app.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:421411144764:android:a9dcd8e7c77e047ee02f39",
"android_client_info": {
"package_name": "com.flutter.dscpu.employeeapp"
}
},
"oauth_client": [
{
"client_id": "421411144764-f08ss5vm5jeo8g5mgc8h2p6j447e4pro.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.flutter.dscpu.employeeapp",
"certificate_hash": "b4f40fabe2e98d03ddd9e7de545b48b9c4735ae4"
}
},
{
"client_id": "421411144764-l4rgc4u8c8p8b2qnl9an5v6h26r0ibji.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyD3UuEulk1ZzFHNNSYyvSaS6qTbWH1vbWw"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "421411144764-l4rgc4u8c8p8b2qnl9an5v6h26r0ibji.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
1 change: 1 addition & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ buildscript {

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.3' // Google Services plugin
}
}

Expand Down
2 changes: 0 additions & 2 deletions functions/firebase.dart

This file was deleted.

38 changes: 38 additions & 0 deletions ios/Runner/GoogleService-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>421411144764-oatv1dd4cga2nm0qj803i9iijvqv1c6g.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.421411144764-oatv1dd4cga2nm0qj803i9iijvqv1c6g</string>
<key>ANDROID_CLIENT_ID</key>
<string>421411144764-f08ss5vm5jeo8g5mgc8h2p6j447e4pro.apps.googleusercontent.com</string>
<key>API_KEY</key>
<string>AIzaSyAXOEYzkBYQv-_DOo9lsJqY3cgbg5splS4</string>
<key>GCM_SENDER_ID</key>
<string>421411144764</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.flutter.dscpu.employeeapp</string>
<key>PROJECT_ID</key>
<string>dsc-employee-app</string>
<key>STORAGE_BUCKET</key>
<string>dsc-employee-app.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:421411144764:ios:c03dfa9dcaec199ce02f39</string>
<key>DATABASE_URL</key>
<string>https://dsc-employee-app.firebaseio.com</string>
</dict>
</plist>
30 changes: 30 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:employeeapp/screens/rootPage.dart';
import 'package:employeeapp/services/authentication.dart';
import 'package:flutter/material.dart';

import 'utils/styles.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
appBarTheme: AppBarTheme(
textTheme: TextTheme(
title: appBarTextStyle,
),
),
textTheme: TextTheme(
title: titleTextStyle,
)),
home: RootPage(
auth: new Auth(),
),
);
}
}
133 changes: 0 additions & 133 deletions lib/models/Database.dart

This file was deleted.

13 changes: 2 additions & 11 deletions lib/models/Employee.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import 'package:employeeapp/services/auth.dart';
import 'package:flutter/cupertino.dart';

class Employee {
int id;
String name;
String username;
String password;
int age;
double rating;
int count; // Number of people who have rated the user
Expand All @@ -22,12 +20,10 @@ class Employee {
// toHash is whether to hash the password or not.
// When adding a user to the database, pass it as true,
// else, false. i.e When coercing a map from the db to an employee
Employee(
bool toHash, {
Employee({
int id,
@required String name,
@required String username,
@required String password,
@required int age,
double rating,
int count,
Expand All @@ -36,15 +32,12 @@ class Employee {
return;
} else if (username == null || username == null) {
return;
} else if (password == null || password == null) {
return;
} else if (age == null || age < 18) {
return;
}

this.name = name;
this.username = username;
this.password = toHash ? hashPassword(password) : password;
this.age = age;
this.rating = rating != null ? rating : 0;
this.count = count != null ? count : 0;
Expand All @@ -65,7 +58,6 @@ class Employee {
'id': id,
'name': name,
'username': username,
'password': password,
'age': age,
'rating': rating,
'count': count,
Expand All @@ -74,11 +66,10 @@ class Employee {
}

Employee.fromJson(Map data)
: this(false,
: this(
id: data['id'],
name: data['name'],
username: data['username'],
password: data['password'],
age: data['age'],
rating: data['rating'].toDouble());
}
2 changes: 0 additions & 2 deletions lib/screens/account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ class Account extends StatefulWidget {

class _AccountState extends State<Account> {
Employee fakeAccount = new Employee(
true,
name: "Dr Disrespect",
username: "drdr",
password: "5dwR422",
age: 22,
rating: 4.2,
count: 2,
Expand Down
Loading

0 comments on commit c5108e3

Please sign in to comment.