Skip to content

Commit

Permalink
Add Poll Modal UI template
Browse files Browse the repository at this point in the history
  • Loading branch information
ChesterSim committed Jul 8, 2019
1 parent 5fd6f08 commit a4f53e0
Show file tree
Hide file tree
Showing 23 changed files with 3,444 additions and 29 deletions.
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "clique2-777a0"
}
}
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

[version]
^0.92.0
^0.101.0
63 changes: 58 additions & 5 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,16 @@ import {
sortGroups
} from "./src/store/actions/groups";
import { connect } from "react-redux";
import _ from "lodash";

import GroupScreenStack from "./src/screens/Main/GroupScreenStack";
import NotificationsScreen from "./src/screens/Main/NotificationsScreen";
import SettingsScreen from "./src/screens/Main/SettingsScreen";
// import PersonalCalendar from "./src/screens/Main/PersonalCalendar";
import CalendarStack from "./src/screens/Main/CalendarStack";
import AuthLoading from "./src/screens/Auth/AuthLoading";
import Auth from "./src/screens/Auth/Auth";
import UserDetails from "./src/screens/Auth/UserDetails";

import MyIcon from "./src/components/MyIcon";
import { cliqueBlue } from "./src/assets/constants";
import firebase from "react-native-firebase";

const AppNavigator = createBottomTabNavigator(
{
Expand All @@ -45,7 +42,7 @@ const AppNavigator = createBottomTabNavigator(
iconType = "material-community";
iconName = `calendar${
focused || Platform.OS === "ios" ? "" : "-blank-outline"
}`;
}`;
} else if (routeName === "Notifications") {
iconName = `notifications${focused ? "-active" : "-none"}`;
} else if (routeName === "Profile") {
Expand Down Expand Up @@ -97,6 +94,62 @@ const InitialNavigator = createSwitchNavigator(
const AppContainer = createAppContainer(InitialNavigator);

class App extends React.Component {
async componentDidMount() {
const notificationOpen = await firebase.notifications().getInitialNotification();
if (notificationOpen) {
const action = notificationOpen.action;
const notification = notificationOpen.notification;
var seen = [];
alert(JSON.stringify(notification.data, function (key, val) {
if (val != null && typeof val == "object") {
if (seen.indexOf(val) >= 0) {
return;
}
seen.push(val);
}
return val;
}));
}
const channel = new firebase.notifications.Android.Channel('test-channel', 'Test Channel', firebase.notifications.Android.Importance.Max)
.setDescription('My apps test channel');
// Create the channel
firebase.notifications().android.createChannel(channel);
this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification) => {
// Process your notification as required
// ANDROID: Remote notifications do not contain the channel ID. You will have to specify this manually if you'd like to re-display the notification.
});
this.notificationListener = firebase.notifications().onNotification((notification) => {
// Process your notification as required
notification
.android.setChannelId('test-channel')
firebase.notifications()
.displayNotification(notification);

});
this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen) => {
// Get the action triggered by the notification being opened
const action = notificationOpen.action;
// Get information about the notification that was opened
const notification = notificationOpen.notification;
var seen = [];
alert(JSON.stringify(notification.data, function (key, val) {
if (val != null && typeof val == "object") {
if (seen.indexOf(val) >= 0) {
return;
}
seen.push(val);
}
return val;
}));
firebase.notifications().removeDeliveredNotification(notification.notificationId);

});
}
componentWillUnmount() {
this.notificationDisplayedListener();
this.notificationListener();
this.notificationOpenedListener();
}
render() {
if (Platform.OS === "android") StatusBar.setBackgroundColor(cliqueBlue);
return <AppContainer />;
Expand Down
6 changes: 5 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def enableProguardInReleaseBuilds = false

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -154,9 +155,12 @@ dependencies {
implementation project(':react-native-splash-screen')
implementation project(':react-native-gesture-handler')
implementation project(':react-native-firebase')
implementation project(':react-native-contacts')
implementation project(':react-native-contacts')
implementation "com.google.firebase:firebase-messaging:18.0.0"
implementation 'me.leolin:ShortcutBadger:1.1.21@aar'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"

/* ----------------------------
* REACT NATIVE FIREBASE
Expand Down
16 changes: 14 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<uses-permission-sdk-23 android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.apps.photos.permission.GOOGLE_PHOTOS"/>
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />


<application
Expand All @@ -27,7 +29,8 @@
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand All @@ -44,11 +47,20 @@
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />
<service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<receiver android:name="io.invertase.firebase.notifications.RNFirebaseNotificationReceiver"/>
<receiver android:enabled="true" android:exported="true" android:name="io.invertase.firebase.notifications.RNFirebaseNotificationsRebootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>

</manifest>
7 changes: 7 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
}
}
88 changes: 88 additions & 0 deletions functions/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"parserOptions": {
// Required for certain syntax usages
"ecmaVersion": 2017,
"sourceType": "module"
},
"plugins": [
"promise"
],
"extends": "eslint:recommended",
"rules": {
// Removed rule "disallow the use of console" from recommended eslint rules
"no-console": "off",
// Removed rule "disallow multiple spaces in regular expressions" from recommended eslint rules
"no-regex-spaces": "off",
// Removed rule "disallow the use of debugger" from recommended eslint rules
"no-debugger": "off",
// Removed rule "disallow unused variables" from recommended eslint rules
"no-unused-vars": "off",
// Removed rule "disallow mixed spaces and tabs for indentation" from recommended eslint rules
"no-mixed-spaces-and-tabs": "off",
// Removed rule "disallow the use of undeclared variables unless mentioned in /*global */ comments" from recommended eslint rules
"no-undef": "off",
// Warn against template literal placeholder syntax in regular strings
"no-template-curly-in-string": 1,
// Warn if return statements do not either always or never specify values
"consistent-return": 1,
// Warn if no return statements in callbacks of array methods
"array-callback-return": 1,
// Require the use of === and !==
"eqeqeq": 2,
// Disallow the use of alert, confirm, and prompt
"no-alert": 2,
// Disallow the use of arguments.caller or arguments.callee
"no-caller": 2,
// Disallow null comparisons without type-checking operators
"no-eq-null": 2,
// Disallow the use of eval()
"no-eval": 2,
// Warn against extending native types
"no-extend-native": 1,
// Warn against unnecessary calls to .bind()
"no-extra-bind": 1,
// Warn against unnecessary labels
"no-extra-label": 1,
// Disallow leading or trailing decimal points in numeric literals
"no-floating-decimal": 2,
// Warn against shorthand type conversions
"no-implicit-coercion": 1,
// Warn against function declarations and expressions inside loop statements
"no-loop-func": 1,
// Disallow new operators with the Function object
"no-new-func": 2,
// Warn against new operators with the String, Number, and Boolean objects
"no-new-wrappers": 1,
// Disallow throwing literals as exceptions
"no-throw-literal": 2,
// Require using Error objects as Promise rejection reasons
"prefer-promise-reject-errors": 2,
// Enforce “for” loop update clause moving the counter in the right direction
"for-direction": 2,
// Enforce return statements in getters
"getter-return": 2,
// Disallow await inside of loops
"no-await-in-loop": 2,
// Disallow comparing against -0
"no-compare-neg-zero": 2,
// Warn against catch clause parameters from shadowing variables in the outer scope
"no-catch-shadow": 1,
// Disallow identifiers from shadowing restricted names
"no-shadow-restricted-names": 2,
// Enforce return statements in callbacks of array methods
"callback-return": 2,
// Require error handling in callbacks
"handle-callback-err": 2,
// Warn against string concatenation with __dirname and __filename
"no-path-concat": 1,
// Prefer using arrow functions for callbacks
"prefer-arrow-callback": 1,
// Return inside each then() to create readable and reusable Promise chains.
// Forces developers to return console logs and http calls in promises.
"promise/always-return": 2,
//Enforces the use of catch() on un-returned promises
"promise/catch-or-return": 2,
// Warn against nested then() or catch() statements
"promise/no-nesting": 1
}
}
1 change: 1 addition & 0 deletions functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
62 changes: 62 additions & 0 deletions functions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// const functions = require("firebase-functions");
// const admin = require("firebase-admin");

// // initializes your application
// admin.initializeApp(functions.config().firebase);

// exports.sendPushNotificationMessage = functions.database
// .ref(`/messages/f4bdd0c1-cd29-431a-b7e9-1d4e0fe4baee`)
// .onWrite(event => {
// const messages = event.val();
// console.log(messages);
// const pushToken = "dctuzVhN6Nw:APA91bHAI4_TGAG_ptwzswAGfe5zx_6w79mrYx_RUcMsLEGI8TNkSHqc0P5fLr89uB4brLlS7bAP2HiFxHm_Ss4SaYWEf8Cn5MNTQQh8XdPMv74fSEUv6G7cQlyDynjRGNw1_DGkULzm";
// let payload = {
// notification: {
// title: "Testing Clique Message Notification",
// body: "Hello World!"
// }
// }

// return admin.messaging().sendToDevice([pushToken], payload);
// });

// exports.sendPushNotification = functions.database()
// .ref("messages")
// .on("child_added", event => {
// // gets standard JavaScript object from the new write
// const writeData = event.data.data();
// // access data necessary for push notification
// const sender = writeData.uid;
// const senderName = writeData.name;
// const recipient = writeData.recipient;
// // the payload is what will be delivered to the device(s)
// let payload = {
// notification: {
// title:
// body:
// sound:
// badge:
// }
// }
// // either store the recepient tokens in the document write
// const tokens = writeData.tokens;

// // or collect them by accessing your database
// var pushToken = "";
// return functions
// .firestore
// .collection("user_data_collection/recipient")
// .get()
// .then(doc => {
// pushToken = doc.data().token;
// // sendToDevice can also accept an array of push tokens
// return admin.messaging().sendToDevice(pushToken, payload);
// });
// });

// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
// exports.helloWorld = functions.https.onRequest((request, response) => {
// response.send("Hello from Firebase!");
// });
Loading

0 comments on commit a4f53e0

Please sign in to comment.