Skip to content

Commit

Permalink
Main Screen UI bug resolved, notes tile admin UI updated
Browse files Browse the repository at this point in the history
  • Loading branch information
syedwajid01 committed Mar 21, 2022
1 parent 1654f8e commit 6c4a9a0
Show file tree
Hide file tree
Showing 42 changed files with 2,454 additions and 1,171 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ app.*.map.json
# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages


.env
/android
/android/app/key.jks
Expand All @@ -59,3 +58,5 @@ app.*.map.json
functions/
.firebaserc
firebase.json
/Web
/Web/config.js
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "disabled"
}
13 changes: 13 additions & 0 deletions ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
1 change: 1 addition & 0 deletions ios/Runner/Runner-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#import "GeneratedPluginRegistrant.h"
37 changes: 18 additions & 19 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,25 +175,24 @@ class MyApp extends StatelessWidget {
// _remoteConfigService.remoteConfig.getString("WIREDASH_SECRET"),
navigatorKey: StackedService.navigatorKey,
child: ThemeProvider(
initTheme: AppStateNotifier.isDarkModeOn
? AppTheme.darkTheme
: AppTheme.lightTheme,
child: Builder(builder: (context) {
return MaterialApp(
navigatorObservers: <NavigatorObserver>[observer],
title: 'OU Notes',
debugShowCheckedModeBanner: false,
theme: ThemeProvider.of(context),
// theme: AppTheme.lightTheme,
// darkTheme: ThemeProvider.of(context),
// themeMode: AppStateNotifier.isDarkModeOn
// ? ThemeMode.dark
// : ThemeMode.light,
onGenerateRoute: StackedRouter().onGenerateRoute,
navigatorKey: StackedService.navigatorKey,
);
}),
),
initTheme: AppStateNotifier.isDarkModeOn
? AppTheme.darkTheme
: AppTheme.lightTheme,
builder: (context, myTheme) {
return MaterialApp(
navigatorObservers: <NavigatorObserver>[observer],
title: 'OU Notes',
debugShowCheckedModeBanner: false,
theme: myTheme,
// theme: AppTheme.lightTheme,
// darkTheme: ThemeProvider.of(context),
// themeMode: AppStateNotifier.isDarkModeOn
// ? ThemeMode.dark
// : ThemeMode.light,
onGenerateRoute: StackedRouter().onGenerateRoute,
navigatorKey: StackedService.navigatorKey,
);
}),
),
),
viewModelBuilder: () => locator<AppStateNotifier>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'package:FSOUNotes/enums/constants.dart';
import 'package:FSOUNotes/enums/enums.dart';
import 'package:FSOUNotes/services/state_services/syllabus_service.dart';
import 'package:FSOUNotes/utils/file_picker_service.dart';
import 'package:ext_storage/ext_storage.dart';
// import 'package:ext_storage/ext_storage.dart';
import 'package:mime/mime.dart';
import 'package:pdf_compressor/pdf_compressor.dart';
import 'package:permission_handler/permission_handler.dart';
Expand Down Expand Up @@ -85,9 +85,9 @@ class GoogleDriveService {
/// Merge the verified document upload to gdrive with the normal wala function
/// Merge Download and DownloadPurchased functions
/// Difference betweeen downloadFile and downloadPuchasedPdf seems to be that
/// in download file we are making sure it hasnt been downloaded before and
/// for purchased pdfs we are ensuring that its downloaded in the external directory
/// Difference betweeen downloadFile and downloadPuchasedPdf seems to be that
/// in download file we are making sure it hasnt been downloaded before and
/// for purchased pdfs we are ensuring that its downloaded in the external directory
/// where its visible. Both should be clubbed into one.
downloadFile(
Expand Down Expand Up @@ -133,8 +133,7 @@ class GoogleDriveService {
//>> Start the download
file.stream.listen((data) {
downloadedLength += data.length;
downloadProgress.value =
((downloadedLength / contentLength) * 100);
downloadProgress.value = ((downloadedLength / contentLength) * 100);
loading.value = downloadProgress.value;
print(downloadProgress.value);
dataStore.insertAll(dataStore.length, data);
Expand Down Expand Up @@ -190,8 +189,9 @@ class GoogleDriveService {
String fileID = note.GDriveID;
ga.Media file = await drive.files
.get(fileID, downloadOptions: ga.DownloadOptions.fullMedia);
var dir = await ExtStorage.getExternalStoragePublicDirectory(
ExtStorage.DIRECTORY_DOWNLOADS);
// var dir = await ExtStorage.getExternalStoragePublicDirectory(
// ExtStorage.DIRECTORY_DOWNLOADS);
var dir;

String fileName = "${note.subjectName}_${note.title}.pdf";
String filePath = dir + fileName;
Expand All @@ -203,7 +203,6 @@ class GoogleDriveService {
? contentLength * 1000
: contentLength * 1000000;
log.e("Size in numbers : " + contentLength.toString());


//*Start the download
file.stream.listen((data) {
Expand All @@ -227,8 +226,9 @@ class GoogleDriveService {
}

//This function is used to upload verified documents that are in Firebase, to Google Drive
uploadFileToGoogleDriveAfterVerification(File fileToUpload, Document docEnum, doc) async {
try {
uploadFileToGoogleDriveAfterVerification(
File fileToUpload, Document docEnum, doc) async {
try {
ga.File gDriveFileToUpload;
ga.File response;
String subjectSubFolderID;
Expand All @@ -237,44 +237,43 @@ uploadFileToGoogleDriveAfterVerification(File fileToUpload, Document docEnum, do
//>> 1.4 Compress PDF
fileToUpload = await _compressPDF(fileToCompress: fileToUpload);

//>> 1.5 Upload to Google Drive
//>> 1.5 Upload to Google Drive
log.i("Uploading File to Google Drive");

try {

//>> 1.5.1 initialize http client and GDrive API
var drive = _initializeHttpClientAndGDriveAPI();
subjectSubFolderID = _getSubjectFolderID(subjectName:doc.subjectName,docEnum:docEnum);
gDriveFileToUpload = _setMetadataToGDriveFile(gDriveFileToUpload,subjectSubFolderID,doc);

subjectSubFolderID =
_getSubjectFolderID(subjectName: doc.subjectName, docEnum: docEnum);
gDriveFileToUpload = _setMetadataToGDriveFile(
gDriveFileToUpload, subjectSubFolderID, doc);

//>> 1.5.3 Commence Upload
log.e(fileToUpload);
response = await drive.files.create(
gDriveFileToUpload,
uploadMedia: ga.Media(fileToUpload.openRead(), fileToUpload.lengthSync()),
uploadMedia:
ga.Media(fileToUpload.openRead(), fileToUpload.lengthSync()),
);

///>> 1.5.4 Create and Set Data to access the uploaded file
_setDataForUploadedFile(response,subjectSubFolderID,docEnum,doc,note,fileToUpload);

_setDataForUploadedFile(
response, subjectSubFolderID, docEnum, doc, note, fileToUpload);
} catch (e) {

return _errorHandling(e,
"While UPLOADING Notes to Google Drive , Error occurred");
return _errorHandling(
e, "While UPLOADING Notes to Google Drive , Error occurred");
}

//>> Post-Upload Sanitization and finishing touches
// pdf.dispose();
fileToUpload.delete();
return "Upload Successful";

} catch (e) {
log.e(e);
} catch (e) {
log.e(e);
}
}
}

}

class GoogleHttpClient extends IOClient {
Map<String, String> _headers;

Expand Down
68 changes: 35 additions & 33 deletions lib/services/funtional_services/google_in_app_payment_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class GoogleInAppPaymentService{
Note note;

/// The In App Purchase plugin
InAppPurchaseConnection _iap ;
/// TODO deprecated
//InAppPurchaseConnection _iap ;

/// Products for sale
ValueNotifier<List<ProductDetails>> _products = new ValueNotifier(new List<ProductDetails>());
Expand All @@ -55,9 +56,9 @@ class GoogleInAppPaymentService{

initialize() async {
log.e("started");
_iap = InAppPurchaseConnection.instance;
// Check availability of In App Purchases
_available = await _iap.isAvailable();
// _iap = InAppPurchaseConnection.instance;
// // Check availability of In App Purchases
// _available = await _iap.isAvailable();

if (_available) {

Expand All @@ -72,37 +73,38 @@ class GoogleInAppPaymentService{
}

// Listen to new purchases
subscription = _iap.purchaseUpdatedStream.listen((data) async {
log.e("purchaseUpdatedStream UPDATED");
_purchases.value.addAll(data);
await verifyPurchase();
});
// subscription = _iap.purchaseUpdatedStream.listen((data) async {
// log.e("purchaseUpdatedStream UPDATED");
// _purchases.value.addAll(data);
// await verifyPurchase();
// });

}

/// Get all products available for sale
Future<void> getProducts() async {
Set<String> ids = Set.from([pdfProductID,premiumProductID]);
ProductDetailsResponse response = await _iap.queryProductDetails(ids);
// Set<String> ids = Set.from([pdfProductID,premiumProductID]);
// ProductDetailsResponse response = await _iap.queryProductDetails(ids);

_products.value = response.productDetails;
// _products.value = response.productDetails;

}

/// Gets past purchases
//TODO deprecated classes
Future<void> getPastPurchases() async {
QueryPurchaseDetailsResponse response =
await _iap.queryPastPurchases();
// QueryPurchaseDetailsResponse response =
// await _iap.queryPastPurchases();

for (PurchaseDetails purchaseDetails in response.pastPurchases) {
final pending = !purchaseDetails.billingClientPurchase.isAcknowledged;
// for (PurchaseDetails purchaseDetails in response.pastPurchases) {
// final pending = !purchaseDetails.billingClientPurchase.isAcknowledged;

if (pending) {
InAppPurchaseConnection.instance.completePurchase(purchaseDetails);
}
}
// if (pending) {
// InAppPurchaseConnection.instance.completePurchase(purchaseDetails);
// }
// }

_purchases.value = response.pastPurchases;
// _purchases.value = response.pastPurchases;
}

// Returns purchase of specific product ID
Expand Down Expand Up @@ -132,25 +134,25 @@ class GoogleInAppPaymentService{
void buyProduct({ProductDetails prod,Note note}) async {
final PurchaseParam purchaseParam = PurchaseParam(productDetails: prod);
// _iap.buyNonConsumable(purchaseParam: purchaseParam);
bool success = await _iap.buyConsumable(purchaseParam: purchaseParam, autoConsume: false);
if(success && prod.id == pdfProductID)
OnboardingService.box.put(GoogleInAppPaymentService.pdfProductID, "${note.subjectId}_${note.id}");
else if(success && prod.id == premiumProductID)
OnboardingService.box.put(GoogleInAppPaymentService.premiumProductID, premiumProductID);
// bool success = await _iap.buyConsumable(purchaseParam: purchaseParam, autoConsume: false);
// if(success && prod.id == pdfProductID)
// OnboardingService.box.put(GoogleInAppPaymentService.pdfProductID, "${note.subjectId}_${note.id}");
// else if(success && prod.id == premiumProductID)
// OnboardingService.box.put(GoogleInAppPaymentService.premiumProductID, premiumProductID);
}

/// Complete purchase and download PDF
completePurchase(PurchaseDetails purchase) async {

if(hasPurchased(purchase.productID) != null){
var res = await _iap.consumePurchase(purchase);
// if(hasPurchased(purchase.productID) != null){
// var res = await _iap.consumePurchase(purchase);

if(purchase.productID == pdfProductID)
await _handlePurchasedPdfDownload();
else if(purchase.productID == premiumProductID)
await _handlePremiumPurchase();
// if(purchase.productID == pdfProductID)
// await _handlePurchasedPdfDownload();
// else if(purchase.productID == premiumProductID)
// await _handlePremiumPurchase();

}
// }

}

Expand Down
Loading

0 comments on commit 6c4a9a0

Please sign in to comment.