Skip to content

Sharekhan Project Contribution (Implemented TO DOs - 1, 2, 3, 4, 5, 12, 13 & 14) #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions .metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: "a14f74ff3a1cbd521163c5f03d68113d50af93d3"
revision: "80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819"
channel: "stable"

project_type: app
Expand All @@ -13,11 +13,26 @@ project_type: app
migration:
platforms:
- platform: root
create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: android
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: ios
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: linux
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: macos
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: web
create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: windows
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819

# User provided section

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# get-flutter-fire

CONTRIBUTOR: Vaishvi Jigneshkumar Parikh
COLLEGE NAME: MIT World Peace University
CONTACT DETAILS: 1032211203@mitwpu.edu.in

This codebase provides a boilerplate code utilizing the following three technologies:

1. Flutter 3.0 - For UX and uses Dart languange. See [https://flutter.dev/]
Expand Down
29 changes: 29 additions & 0 deletions android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"project_info": {
"project_number": "projectnumber",
"project_id": "sharekhanproject",
"storage_bucket": "sharekhanproject.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "app_id",
"android_client_info": {
"package_name": "com.example.get_flutter_fire"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "MYKEY"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.example.get_flutter_fire

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity()
1 change: 1 addition & 0 deletions assets/lottie/tick.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"v":"5.4.2","fr":25,"ip":0,"op":50,"w":1080,"h":1080,"nm":"Tick","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 3","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[540,540,0],"ix":2},"a":{"a":0,"k":[-214,-44,0],"ix":1},"s":{"a":0,"k":[71.036,71.036,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[-392,-22],[-288,82],[-36,-170]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":60,"ix":5},"lc":2,"lj":2,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":0,"k":0,"ix":1},"e":{"a":1,"k":[{"i":{"x":[0],"y":[0.999]},"o":{"x":[0.112],"y":[0]},"n":["0_0p999_0p112_0"],"t":17,"s":[0],"e":[100]},{"t":35}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":50,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"Shape Layer 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[540,540,0],"ix":2},"a":{"a":0,"k":[46,70,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0,0,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"n":["0_1_0p333_0","0_1_0p333_0","0p667_1_0p333_0"],"t":9,"s":[0,0,100],"e":[84.593,84.593,100]},{"t":17}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[540,540],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[0.598895203833,0.149973072725,0.83137254902,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[46,70],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":50,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[540,540,0],"ix":2},"a":{"a":0,"k":[46,70,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.146,0.146,0.667],"y":[1,1,1]},"o":{"x":[0.21,0.21,0.333],"y":[0,0,0]},"n":["0p146_1_0p21_0","0p146_1_0p21_0","0p667_1_0p333_0"],"t":0,"s":[0,0,100],"e":[100,100,100]},{"t":8}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[540,540],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[0.830080817727,0.501960754395,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[46,70],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":50,"st":0,"bm":0}],"markers":[]}
14 changes: 14 additions & 0 deletions cors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"origin": [
"*"
],
"method": [
"GET",
"POST",
"PUT",
"DELETE"
],
"maxAgeSeconds": 3600
}
]
1 change: 1 addition & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Added my firebase.json file
30 changes: 30 additions & 0 deletions ios/Runner/GoogleService-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>API_KEY</key>
<string>API-KEY</string>
<key>GCM_SENDER_ID</key>
<string>SENDER-ID</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.example.getflutterfire</string>
<key>PROJECT_ID</key>
<string>sharekhanproject</string>
<key>STORAGE_BUCKET</key>
<string>sharekhanproject.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>GOOGLE-APP-ID</string>
</dict>
</plist>
7 changes: 7 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,12 @@
<string>Allow access to microphone for video recording</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Allow access to photo library</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Need access to photo library to select profile picture</string>
<key>NSCameraUsageDescription</key>
<string>Need access to camera to take a profile picture</string>
<key>NSMicrophoneUsageDescription</key>
<string>Need access to microphone for recording</string>

</dict>
</plist>
54 changes: 51 additions & 3 deletions lib/app/modules/cart/controllers/cart_controller.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:get/get.dart';
import 'package:get_flutter_fire/models/product.dart';
import '../../../../services/auth_service.dart';

class CartController extends GetxController {
//TODO: Implement CartController
final RxList<Product> cartItems = <Product>[].obs;
final RxDouble totalPrice = 0.0.obs;

final count = 0.obs;
@override
void onInit() {
super.onInit();
Expand All @@ -19,5 +21,51 @@ class CartController extends GetxController {
super.onClose();
}

void increment() => count.value++;
void increment() => totalPrice.value++;

Future<void> signInAnonymously() async {
await AuthService.to.signInAnonymously();
update();
}

Future<void> convertAnonymousAccount(String email, String password) async {
await AuthService.to.convertAnonymousAccount(email, password);
}

Future<void> addItemToCart(Product product) async {
if (AuthService.to.user == null) {
// If the user is not signed in, sign them in anonymously
await signInAnonymously();
}
cartItems.add(product);
totalPrice.value += product.price;
print("Product added to cart: ${product.name}");
update();
}

Future<void> removeItemFromCart(Product product) async {
cartItems.remove(product);
totalPrice.value -= product.price;
print("Product removed from cart: ${product.name}");
update();
}

Future<void> checkout() async {
if (AuthService.to.user == null) {
// If the user is not signed in, sign them in anonymously
await signInAnonymously();
}
// Proceed with the checkout process
print("Checkout process initiated");
update();
}

void calculateTotalPrice() {
totalPrice.value = cartItems.fold(0, (sum, item) => sum + item.price);
}

void clearCart() {
cartItems.clear();
calculateTotalPrice();
}
}
101 changes: 88 additions & 13 deletions lib/app/modules/cart/views/cart_view.dart
Original file line number Diff line number Diff line change
@@ -1,27 +1,102 @@
import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:get_flutter_fire/app/routes/app_pages.dart';
import '../../../widgets/screen_widget.dart';
import '../../../../services/auth_service.dart';
import '../controllers/cart_controller.dart';
import 'package:get_flutter_fire/models/product.dart'; // Ensure correct path

class CartView extends GetView<CartController> {
const CartView({super.key});

@override
Widget build(BuildContext context) {
return ScreenWidget(
return Scaffold(
appBar: AppBar(
title: Text('${AuthService.to.userName} Cart'),
title: const Text('Cart'),
centerTitle: true,
),
body: const Center(
child: Text(
'CartView is working',
style: TextStyle(fontSize: 20),
),
),
screen: screen!,
body: Obx(() {
if (controller.cartItems.isEmpty) {
return const Center(
child: Text(
'Your cart is empty',
style: TextStyle(fontSize: 20),
),
);
}

return Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: ListView.builder(
itemCount: controller.cartItems.length,
itemBuilder: (context, index) {
final item = controller.cartItems[index];
return Card(
child: ListTile(
title: Text(item.name),
subtitle:
Text('Price: \$${item.price.toStringAsFixed(2)}'),
trailing: IconButton(
icon: const Icon(Icons.remove_circle),
onPressed: () {
_confirmRemoveItem(context, item);
},
),
),
);
},
),
),
const SizedBox(height: 20),
Text(
'Total: \$${controller.totalPrice.toStringAsFixed(2)}',
style:
const TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
if (controller.cartItems.isNotEmpty) {
Get.toNamed('/checkout');
} else {
Get.snackbar('Cart is empty',
'Add items before proceeding to checkout');
}
},
child: const Text('Proceed to Checkout'),
),
],
),
);
}),
);
}

void _confirmRemoveItem(BuildContext context, Product item) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('Remove Item'),
content: const Text(
'Are you sure you want to remove this item from the cart?'),
actions: [
TextButton(
onPressed: () => Get.back(),
child: const Text('Cancel'),
),
TextButton(
onPressed: () {
controller.removeItemFromCart(item);
Get.back();
},
child: const Text('Remove'),
),
],
);
},
);
}
}
1 change: 0 additions & 1 deletion lib/app/modules/checkout/bindings/checkout_binding.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:get/get.dart';

import '../controllers/checkout_controller.dart';

class CheckoutBinding extends Bindings {
Expand Down
20 changes: 18 additions & 2 deletions lib/app/modules/checkout/controllers/checkout_controller.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'package:get/get.dart';
import '../../cart/controllers/cart_controller.dart';

class CheckoutController extends GetxController {
//TODO: Implement CheckoutController

final cartController = Get.find<CartController>();
final count = 0.obs;

@override
void onInit() {
super.onInit();
Expand All @@ -20,4 +21,19 @@ class CheckoutController extends GetxController {
}

void increment() => count.value++;

double get totalPrice => cartController.totalPrice.value;

void checkout() {
if (cartController.cartItems.isEmpty) {
print("Cart is empty. Add items before checking out.");
return;
}
// Placeholder for the payment process logic
print(
"Checkout initiated with total price: \$${totalPrice.toStringAsFixed(2)}");

// Clear the cart after successful checkout
cartController.clearCart();
}
}
Loading