Commit 5ab6db6f authored by Shahzad Bhatti's avatar Shahzad Bhatti

changes to create build and generate apk

parent fce2c627
......@@ -118,6 +118,14 @@ android {
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
}
}
debug {
storeFile file('debug.keystore')
storePassword 'android'
......@@ -132,7 +140,8 @@ android {
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
signingConfig signingConfigs.release
// signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
......@@ -160,7 +169,7 @@ dependencies {
implementation("com.facebook.react:react-android")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
implementation ('com.facebook.android:facebook-login:latest.release')
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.squareup.okhttp3', module:'okhttp'
......
......@@ -9,6 +9,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
<meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
......
<resources>
<string name="app_name">MedStore</string>
<string name="facebook_app_id">921156519073351</string>
<string name="facebook_client_token">ffd6b763efcd496db0d7c981e8e71e8f</string>
</resources>
......@@ -42,3 +42,8 @@ newArchEnabled=false
# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true
MYAPP_UPLOAD_STORE_FILE=sbhatti_store.keystore
MYAPP_UPLOAD_KEY_ALIAS=sbhatti_store
MYAPP_UPLOAD_STORE_PASSWORD=tiptop123
MYAPP_UPLOAD_KEY_PASSWORD=tiptop123
\ No newline at end of file
#import <Firebase.h>
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <FBSDKCoreKit/FBSDKCoreKit-swift.h>
@implementation AppDelegate
......@@ -11,7 +12,8 @@
// You can add your custom initial props in the dictionary below.
// They will be passed down to the ViewController used by React Native.
self.initialProps = @{};
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
......
......@@ -81,5 +81,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>FaceBookAppID</key>
<string>921156519073351</string>
</dict>
</plist>
......@@ -11,6 +11,7 @@
},
"dependencies": {
"@react-native-firebase/app": "^17.3.0",
"@react-native-firebase/auth": "^17.3.1",
"@react-native-google-signin/google-signin": "^9.0.2",
"@react-navigation/native": "^6.1.3",
"@react-navigation/native-stack": "^6.9.9",
......@@ -19,6 +20,8 @@
"react-devtools": "^4.27.2",
"react-native": "0.71.1",
"react-native-axios": "^0.17.1",
"react-native-fbsdk-next": "^11.1.0",
"react-native-linear-gradient": "^2.6.2",
"react-native-safe-area-context": "^4.5.0",
"react-native-screens": "^3.19.0",
"react-native-vector-icons": "^9.2.0",
......
import React from 'react';
import {View, Button} from 'react-native';
import {connect} from 'react-redux';
import {addToCart} from './cartActions';
const AddToCartButton = ({product, addToCart}) => {
return (
<View>
<Button title="Add to Cart" onPress={() => addToCart(product)} />
</View>
);
};
export default connect(null, {addToCart})(AddToCartButton);
import React from 'react';
import {HeaderButtons, Item} from 'react-navigation-header-buttons';
export default function CartIcon() {
return (
<HeaderButtons>
<Item
title="cart"
iconName="cart"
onPress={() => {
// handle cart icon press
}}
/>
</HeaderButtons>
);
}
export const ADD_TO_CART = 'ADD_TO_CART';
export const addToCart = product => {
return {
type: ADD_TO_CART,
payload: product,
};
};
......@@ -6,7 +6,7 @@ import Btn from '../Button';
import {Colors} from '../../constants/Constants';
import Field from '../ui/Field';
import {useNavigation} from '@react-navigation/native';
import {googleLogin, login} from '../../util/auth';
import {onFacebookButtonPress, googleLogin, login} from '../../util/auth';
import {AuthContext} from '../../store/AuthContext';
import {GoogleSignin} from '@react-native-google-signin/google-signin';
......@@ -39,10 +39,10 @@ const Login = () => {
}
// navigation.navigate('MedicineList');
};
const facebookLoginHandler = () => {
console.log('i am in facebookLoginHandler');
const result = googleLogin();
const facebookLoginHandler = async () => {
const result = await onFacebookButtonPress();
console.log(result);
authCtx.authenticate(result.idToken);
};
return (
......@@ -81,7 +81,7 @@ const Login = () => {
<Icon.Button
name="facebook"
style={styles.facebook}
// onPress={() => {
onPress={facebookLoginHandler}
// // onFacebookButtonPress().then(() =>
// console.log('Signed in with Facebook!')
// // )
......
const initialState = {
items: [],
total: 0,
};
const cartReducer = (state = initialState, action) => {
switch (action.type) {
case 'ADD_TO_CART':
const itemToAdd = action.payload;
const existingItem = state.items.find(item => item.id === itemToAdd.id);
if (existingItem) {
existingItem.quantity += itemToAdd.quantity;
} else {
state.items.push(itemToAdd);
}
state.total += itemToAdd.price * itemToAdd.quantity;
return {...state};
case 'REMOVE_FROM_CART':
const itemIdToRemove = action.payload;
const itemToRemove = state.items.find(item => item.id === itemIdToRemove);
if (itemToRemove) {
state.total -= itemToRemove.price * itemToRemove.quantity;
state.items = state.items.filter(item => item.id !== itemIdToRemove);
}
return {...state};
case 'CLEAR_CART':
return {
...state,
items: [],
total: 0,
};
default:
return state;
}
};
export default cartReducer;
const initialState = {
products: [],
loading: false,
error: null,
};
const productsReducer = (state = initialState, action) => {
switch (action.type) {
case 'FETCH_PRODUCTS_REQUEST':
return {
...state,
loading: true,
error: null,
};
case 'FETCH_PRODUCTS_SUCCESS':
return {
...state,
products: action.payload,
loading: false,
error: null,
};
case 'FETCH_PRODUCTS_FAILURE':
return {
...state,
products: [],
loading: false,
error: action.payload,
};
default:
return state;
}
};
export default productsReducer;
import {combineReducers} from 'redux';
import cartReducer from './cartReducer';
import productsReducer from './productsReducer';
const rootReducer = combineReducers({
cart: cartReducer,
products: productsReducer,
});
export default rootReducer;
......@@ -3,8 +3,8 @@ import {
GoogleSignin,
statusCodes,
} from '@react-native-google-signin/google-signin';
// import auth from '@react-native-firebase/auth';
// import {LoginManager, AccessToken} from 'react-native-fbsdk-next';
import auth from '@react-native-firebase/auth';
import {LoginManager, AccessToken} from 'react-native-fbsdk-next';
// import axios from 'axios';
import {API_KEY} from '../constants/APIs';
......@@ -48,29 +48,29 @@ export const googleLogin = async () => {
}
};
// export const onFacebookButtonPress = async () => {
// // // Attempt login with permissions
// // const result = await LoginManager.logInWithPermissions([
// // 'public_profile',
// // 'email',
// // ]);
export const onFacebookButtonPress = async () => {
// // Attempt login with permissions
const result = await LoginManager.logInWithPermissions([
'public_profile',
'email',
]);
// // if (result.isCancelled) {
// // throw 'User cancelled the login process';
// // }
if (result.isCancelled) {
throw 'User cancelled the login process';
}
// // // Once signed in, get the users AccesToken
// // const data = await AccessToken.getCurrentAccessToken();
// Once signed in, get the users AccesToken
const data = await AccessToken.getCurrentAccessToken();
// // if (!data) {
// // throw 'Something went wrong obtaining access token';
// // }
if (!data) {
throw 'Something went wrong obtaining access token';
}
// // // Create a Firebase credential with the AccessToken
// // const facebookCredential = auth.FacebookAuthProvider.credential(
// // data.accessToken,
// // );
// Create a Firebase credential with the AccessToken
const facebookCredential = auth.FacebookAuthProvider.credential(
data.accessToken,
);
// // // Sign-in the user with the credential
// // return auth().signInWithCredential(facebookCredential);
// };
// Sign-in the user with the credential
return auth().signInWithCredential(facebookCredential);
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment