Skip to content

Commit

Permalink
Merge pull request #4 from Thesmader/development
Browse files Browse the repository at this point in the history
v0.1.0+1
  • Loading branch information
Chinmay-KB authored Apr 17, 2020
2 parents 98f9a1c + 3cc4e96 commit 82cd4a7
Show file tree
Hide file tree
Showing 87 changed files with 1,868 additions and 82 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ doc/api/
*.js_
*.js.deps
*.js.map

#keystore
gogrocy.jks
gogrocy.jks.old
1 change: 1 addition & 0 deletions gogrocy/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
.pub/
/build/
/android/app/google-services.json
/android/key.properties


# Web related
Expand Down
1 change: 1 addition & 0 deletions gogrocy/android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ gradle-wrapper.jar
/gradlew
/gradlew.bat
/local.properties
/key.properties
GeneratedPluginRegistrant.java
25 changes: 21 additions & 4 deletions gogrocy/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@ if (flutterVersionCode == null) {

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
flutterVersionName = '0.1.0'
}

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

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
compileSdkVersion 28

Expand All @@ -46,11 +53,21 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion gogrocy/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name="io.flutter.app.FlutterApplication"
android:label="gogrocy"
android:label="GoGrocy"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?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" />
<!--<item android:drawable="@android:color/white" />-->

<!-- You can insert your own image assets here -->
<!-- <item>
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
android:src="@mipmap/gogrocy" />
</item>
</layer-list>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gogrocy/android/app/src/main/res/mipmap-hdpi/ic_launcher.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 modified gogrocy/android/app/src/main/res/mipmap-mdpi/ic_launcher.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 modified gogrocy/android/app/src/main/res/mipmap-xhdpi/ic_launcher.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 modified gogrocy/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.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 modified gogrocy/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#005E20</color>
</resources>
1 change: 1 addition & 0 deletions gogrocy/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.0'
}
}

Expand Down
1 change: 1 addition & 0 deletions gogrocy/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
extra-gen-snapshot-options=--obfuscate
Binary file added gogrocy/assets/fonts/Gilroy-ExtraBold.ttf
Binary file not shown.
Binary file added gogrocy/assets/fonts/Gilroy-Light.ttf
Binary file not shown.
Binary file added gogrocy/assets/images/awesome_woman.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 gogrocy/assets/images/carousel_1.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 gogrocy/assets/images/carousel_2.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 gogrocy/assets/images/carousel_3.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 gogrocy/assets/images/grocery.png
Binary file added gogrocy/assets/images/packed.png
Binary file added gogrocy/assets/images/pulses.png
Binary file added gogrocy/assets/images/toiletries.png
Binary file added gogrocy/assets/images/woman.png
1 change: 1 addition & 0 deletions gogrocy/lib/core/enums/viewstate.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enum ViewState { Idle, Busy }
Empty file.
48 changes: 48 additions & 0 deletions gogrocy/lib/core/models/product.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
class Product {
String id;
String name;
String price;
String quantity;
String unit;
String description;
String timesSold;
String image;
String category;

Product(
{this.id,
this.name,
this.price,
this.quantity,
this.unit,
this.description,
this.timesSold,
this.image,
this.category});

Product.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
price = json['price'];
quantity = json['quantity'];
unit = json['unit'];
description = json['description'];
timesSold = json['times_sold'];
image = json['image'];
category = json['category'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
data['price'] = this.price;
data['quantity'] = this.quantity;
data['unit'] = this.unit;
data['description'] = this.description;
data['times_sold'] = this.timesSold;
data['image'] = this.image;
data['category'] = this.category;
return data;
}
}
1 change: 1 addition & 0 deletions gogrocy/lib/core/models/user.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class User {}
40 changes: 40 additions & 0 deletions gogrocy/lib/core/services/api.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'dart:convert';
import 'dart:io';
import 'package:gogrocy/core/models/product.dart';
import 'package:http/http.dart' as http;

const String baseUrl = "https://gogrocy.in/api/";

class Apis {
static String allProducts = baseUrl + "getProducts";
static String singleProduct = baseUrl + "getProduct";

Future<List<Product>> getAllProducts() async {
var client = new http.Client();
bool connectionState = await checkStatus();
if (connectionState) //TODO: Add a proper else return
{
var products = List<Product>();
var response = await client.post(allProducts);
var parsed = json.decode(response.body) as List<dynamic>;
for (var product in parsed) {
products.add(Product.fromJson(product));
}
return products;
} else
(print("Network failure"));
}

Future<bool> checkStatus() async {
try {
final result = await InternetAddress.lookup('google.com');
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
print('connected');
return true;
}
} on SocketException catch (_) {
print('not connected');
return false;
}
}
}
69 changes: 69 additions & 0 deletions gogrocy/lib/core/services/authentication_service.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';

class AuthenticationService {
final firebaseInstance = FirebaseAuth.instance;
String verificationId;

Future verifyPhoneNumber(BuildContext context, String phoneNumber) async {
final PhoneVerificationCompleted verificationCompleted =
(AuthCredential credential) {
print('Verification Complete');
signInWithNumber(context, credential);
};

final PhoneVerificationFailed verificationFailed =
(AuthException exception) {
print(exception.message);
};

final PhoneCodeSent phoneCodeSent =
(String verificationId, [int forceResendingToken]) async {
this.verificationId = verificationId;
print('Code sent: $verificationId');
};

final PhoneCodeAutoRetrievalTimeout retrievalTimeout =
(String verificationId) {
print('Retrieval Timeout: $verificationId');
};

try {
await firebaseInstance.verifyPhoneNumber(
phoneNumber: phoneNumber,
timeout: Duration(seconds: 60),
verificationCompleted: verificationCompleted,
verificationFailed: verificationFailed,
codeSent: phoneCodeSent,
codeAutoRetrievalTimeout: retrievalTimeout);
FirebaseUser currentUser = await firebaseInstance.currentUser();
return currentUser != null;
} catch (e) {
return e.message;
}
}

signInWithNumber(BuildContext context, AuthCredential credential) async {
FirebaseUser user =
(await firebaseInstance.signInWithCredential(credential)).user;
FirebaseUser currentUser = await firebaseInstance.currentUser();
assert(user.uid == currentUser.uid);
}

Future signInWithOtp(String verificationId, String otp) async {
try {
AuthCredential credential = PhoneAuthProvider.getCredential(
verificationId: verificationId, smsCode: otp);
FirebaseUser currentUser =
(await firebaseInstance.signInWithCredential(credential)).user;
return currentUser != null;
} catch (e) {
return e.message;
}
}

Future<bool> isUserLoggedIn() async {
var user = await firebaseInstance.currentUser();
return user != null;
}
}
14 changes: 14 additions & 0 deletions gogrocy/lib/core/services/bottom_appbar_provider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:flutter/material.dart';

class BottomNavBarProvider with ChangeNotifier{
int _currentIndex=0;

get currentIndex=> _currentIndex;

set currentIndex(int index){
print("Changed index to $index");
_currentIndex=index;
notifyListeners();
}

}
Empty file.
14 changes: 14 additions & 0 deletions gogrocy/lib/core/services/navigation_service.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:flutter/material.dart';

class NavigationService {
static final GlobalKey<NavigatorState> navigatorKey =
GlobalKey<NavigatorState>();

Future<dynamic> navigateTo(String routeName, {dynamic arguments}) async {
return navigatorKey.currentState.pushNamed(routeName, arguments: arguments);
}

bool goBack() {
return navigatorKey.currentState.pop();
}
}
23 changes: 23 additions & 0 deletions gogrocy/lib/core/services/shared_prefs.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:shared_preferences/shared_preferences.dart';

class SharedPrefs {
SharedPreferences _sharedPrefs;

SharedPrefs() {
initSharedPrefs();
}

initSharedPrefs() async{
_sharedPrefs=await SharedPreferences.getInstance();
}

setJWT(String s) async{
_sharedPrefs.setString("jwt",s);
}

Future<String> getJWT() async{
String jwt = _sharedPrefs.getString("jwt");
return jwt;
}

}
19 changes: 19 additions & 0 deletions gogrocy/lib/core/viewModels/allProducts_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:gogrocy/core/enums/viewstate.dart';
import 'package:gogrocy/core/models/product.dart';
import 'package:gogrocy/core/services/api.dart';
import 'package:gogrocy/core/viewModels/base_model.dart';
import 'package:gogrocy/service_locator.dart';

class AllProductsModel extends BaseModel{
Apis _apis=locator<Apis>();

List<Product> allProducts;

Future getAllProducts() async{
setState(ViewState.Busy);
allProducts=await _apis.getAllProducts();
setState(ViewState.Idle);
}


}
Loading

0 comments on commit 82cd4a7

Please sign in to comment.