Skip to content

Commit

Permalink
Merge pull request #44 from jogboms/develop
Browse files Browse the repository at this point in the history
feat: 0.1.0
  • Loading branch information
jogboms authored Jul 13, 2018
2 parents 0c34d31 + c3ae56e commit 507f92f
Show file tree
Hide file tree
Showing 105 changed files with 832 additions and 934 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ doc/api/
.atom/
.dart_tool/
.idea
.vscode/
ios/.generated/
packages
.flutter-plugins
.log
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [{
"name": "Flutter",
"type": "dart",
"request": "launch",
"args": [
"--flavor=development"
],
"program": "lib/main.dart"
}]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
}
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
<img src="./assets/images/logo.png" style="margin: auto" width="90" />

# TailorMade

A Flutter experiment.
A Flutter experiment for managing a Fashion designer's daily routine. Logo, Design & Concept by Me.

> Android-only support
## Tools

## UI Shots (so far)
1. Firebase Auth
2. Firebase Cloud Firestore
3. Firebase Cloud Functions
4. Firebase Storage
5. RxDart
6. Redux
7. Redux Epics

For a full description of OSS used, see pubspec.yaml

## UI Shots

<div style="text-align: center">
<table>
Expand Down Expand Up @@ -64,6 +80,15 @@ A Flutter experiment.
<td style="text-align: center">
<img src="./screenshots/ss17.png" width="200" />
</td>
<td style="text-align: center">
<img src="./screenshots/ss18.png" width="200" />
</td>
<td style="text-align: center">
<img src="./screenshots/ss19.png" width="200" />
</td>
<td style="text-align: center">
<img src="./screenshots/ss20.png" width="200" />
</td>
</tr>
</table>
</div>
Expand Down
3 changes: 2 additions & 1 deletion TASKS.todo
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
PENDING:
☐ remodel w/ authID
☐ delete-able payment
☐ delete-able images
☐ implement share payment + image

☐ filter + search jobs & contacts

COMPLETED:
✔ update stats db on creation @high @done(18-07-10 16:39)
Expand Down
1 change: 1 addition & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/build
/captures
GeneratedPluginRegistrant.java
google-services.json
13 changes: 13 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ android {
signingConfig signingConfigs.debug
}
}

flavorDimensions "flavor-type"

productFlavors {
development {
dimension "flavor-type"
applicationIdSuffix ".dev"
versionNameSuffix "-dev"
}
production {
dimension "flavor-type"
}
}
}

flutter {
Expand Down
42 changes: 0 additions & 42 deletions android/app/google-services.json

This file was deleted.

14 changes: 6 additions & 8 deletions android/app/src/main/res/drawable/launch_background.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="fill">
<!-- You can insert your own image assets here -->
<item android:drawable="@mipmap/pattern" />

<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
<item>
<bitmap android:gravity="center" android:src="@mipmap/logo" />
</item>
</layer-list>
Binary file added android/app/src/main/res/mipmap-hdpi/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/mipmap-hdpi/pattern.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/mipmap-mdpi/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/mipmap-mdpi/pattern.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/mipmap-xhdpi/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/mipmap-xxxhdpi/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/2.0x/google_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/2.0x/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/2.0x/pattern.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/3.0x/google_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/3.0x/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/3.0x/pattern.png
Binary file added assets/images/google_logo.png
Binary file added assets/images/logo.png
Binary file added assets/images/pattern.png
52 changes: 52 additions & 0 deletions functions/functions/src/fn/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { firestore as Firestore } from "firebase-admin";
import { auth, EventContext } from "firebase-functions";
import { ChangeState } from "../utils";

export function _onAuth(onCreate: ChangeState) {
return async (user: auth.UserRecord, context: EventContext) => {
const db = Firestore();
const batch = db.batch();

const account = db.collection("accounts").doc(user.uid);
batch.set(account, {
storeName: user.displayName,
uid: user.uid,
email: user.email,
displayName: user.displayName,
phoneNumber: user.phoneNumber,
photoURL: user.photoURL
});

const stats = db.collection("stats").doc(user.uid);
batch.set(stats, {
contacts: {
total: 0
},
gallery: {
total: 0
},
jobs: {
total: 0,
pending: 0,
completed: 0
},
payments: {
total: 0,
pending: 0,
completed: 0
}
});

// Commit the batch
return batch.commit();
};
}

export function onAuthCreate(onCreate: ChangeState) {
const store = auth.user();

// return onCreate == ChangeState.Create
// ? store.onCreate(_onAuth(onCreate))
// : store.onDelete(_onAuth(onCreate));
return store.onCreate(_onAuth(onCreate));
}
9 changes: 5 additions & 4 deletions functions/functions/src/fn/stats_contacts.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { firestore as Firestore } from "firebase-admin";
import { EventContext, firestore } from "firebase-functions";
import { isArray } from "util";
import { ChangeState } from "../utils";

export function _onStatsContacts(onCreate: boolean) {
export function _onStatsContacts(onCreate: ChangeState) {
return async (
snapshot: firestore.DocumentSnapshot,
context: EventContext
) => {
const db = Firestore();
const stats = db.doc("stats/current");
const contact = snapshot.data();
const stats = db.doc(`stats/${contact.userID}`);

const statsSnap = await stats.get();

Expand All @@ -25,10 +26,10 @@ export function _onStatsContacts(onCreate: boolean) {
};
}

export function onStatsContacts(onCreate = true) {
export function onStatsContacts(onCreate: ChangeState) {
const store = firestore.document("contacts/{contactId}");

return onCreate
return onCreate === ChangeState.Created
? store.onCreate(_onStatsContacts(onCreate))
: store.onDelete(_onStatsContacts(onCreate));
}
41 changes: 35 additions & 6 deletions functions/functions/src/fn/stats_jobs.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
import * as admin from "firebase-admin";
import { Change, EventContext, firestore } from "firebase-functions";
import { isArray } from "util";
import { ChangeState } from "../utils";

async function _onStatsJob(
// TODO
// Maybe not the best way to go about this
async function _onStatsJobUpdate(
change: Change<firestore.DocumentSnapshot>,
context: EventContext
) {
const jobs = change.before.exists ? change.before : change.after;

return _onStatsJob(jobs, context);
}

async function _onStatsJob(
snapshot: firestore.DocumentSnapshot,
context: EventContext
) {
const db = admin.firestore();
const stats = db.doc("stats/current");
const _data = snapshot.data();

// Get user ID from Job
const userID = isArray(_data) ? _data[0].userID : _data.userID;

const stats = db.doc(`stats/${userID}`);

const jobsSnap = await db.collection("jobs").get();
const jobsSnap = await db
.collection("jobs")
.where("userID", "==", userID)
.get();

let completedJob = 0,
pendingJob = 0,
Expand Down Expand Up @@ -46,6 +67,14 @@ async function _onStatsJob(
});
}

export const onStatsJob = firestore
.document("jobs/{jobId}")
.onWrite(_onStatsJob);
export function onStatsJob(change: ChangeState) {
const store = firestore.document("jobs/{jobId}");

if (change === ChangeState.Created) {
return store.onCreate(_onStatsJob);
} else if (change === ChangeState.Updated) {
return store.onUpdate(_onStatsJobUpdate);
} else {
return store.onDelete(_onStatsJob);
}
}
14 changes: 11 additions & 3 deletions functions/functions/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
import { initializeApp } from "firebase-admin";
import { config } from "firebase-functions";
import { onAuthCreate } from "./fn/auth";
import { onContactStats } from "./fn/contact_stats";
import { onJobPayments } from "./fn/job_payments";
import { onPaymentGallery } from "./fn/payment_gallery";
import { onStatsContacts } from "./fn/stats_contacts";
import { onStatsJob } from "./fn/stats_jobs";
import { ChangeState } from "./utils";

initializeApp(config().firebase);

export const AuthCreate = onAuthCreate(ChangeState.Created);

export const PaymentGallery = onPaymentGallery;

export const JobPayments = onJobPayments;

export const StatsJobs = onStatsJob;
export const StatsJobsCreate = onStatsJob(ChangeState.Created);

export const StatsJobsUpdate = onStatsJob(ChangeState.Updated);

export const StatsJobsDelete = onStatsJob(ChangeState.Deleted);

export const StatsContactsCreate = onStatsContacts();
export const StatsContactsCreate = onStatsContacts(ChangeState.Created);

export const StatsContactsDelete = onStatsContacts(false);
export const StatsContactsDelete = onStatsContacts(ChangeState.Deleted);

export const ContactStats = onContactStats;
5 changes: 5 additions & 0 deletions functions/functions/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum ChangeState {
Created,
Updated,
Deleted
}
Loading

0 comments on commit 507f92f

Please sign in to comment.