Skip to content

Commit

Permalink
Merge pull request #181 from atharva-khewle/main
Browse files Browse the repository at this point in the history
many changes
  • Loading branch information
atharva-khewle authored Jul 8, 2024
2 parents c50b05b + 1bef4e8 commit ed10d24
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 121 deletions.
4 changes: 1 addition & 3 deletions lib/new_ui/screens/home_screen/widgets/home_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ class _HomeWidgetState extends ConsumerState<HomeWidget> {
_firebaseMessaging.getToken().then((String? token) {
assert(token != null);
print("FCM Token: $token");
// var recentFetchStudentData = FirebaseFirestore.instance
// .collection('Students ')
// .doc(userId);
// var recentFetchStudentData = FirebaseFirestore.instance.collection('Students ').doc(userId).get();
//
// print("////// ${recentFetchStudentData} //////");
// Save the token to Firestore
Expand Down
30 changes: 28 additions & 2 deletions lib/new_ui/screens/railway_screen/railwayform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@ class _RailwayForm extends ConsumerState<RailwayForm> {
initialDate: _selectedDate ?? DateTime.now(),
firstDate: DateTime(1990),
lastDate: DateTime.now(),
builder: (BuildContext context, Widget? child) {
return Theme(
data: ThemeData.dark().copyWith(
// Change background color of calendar here
colorScheme: ColorScheme.dark()
),
child: child!,
);
},
);

if (picked != null && picked != _selectedDate) {
Expand All @@ -179,7 +188,9 @@ class _RailwayForm extends ConsumerState<RailwayForm> {
List<String> genderList = ['Male', 'Female'];

File? idCardPhoto;
File? idCardPhoto2;
File? idCardPhotoTemp;
File? idCardPhotoTemp2;
File? previousPassPhoto;
File? previousPassPhotoTemp;

Expand All @@ -195,6 +206,8 @@ class _RailwayForm extends ConsumerState<RailwayForm> {
} else if (type == 'Previous Pass Photo') {
// previousPassPhoto = File(pickedFile.path);
previousPassPhotoTemp = File(pickedFile.path);
}else if(type == 'ID Card Back'){
idCardPhotoTemp2 = File(pickedFile.path);
}
});
}
Expand Down Expand Up @@ -236,6 +249,8 @@ class _RailwayForm extends ConsumerState<RailwayForm> {
idCardPhotoTemp = null;
} else if (type == 'Previous Pass Photo') {
previousPassPhotoTemp = null;
}else if(type == 'ID Card Back'){
idCardPhotoTemp2 = null;
}
});
}
Expand Down Expand Up @@ -340,14 +355,15 @@ class _RailwayForm extends ConsumerState<RailwayForm> {

if (_formKey.currentState!.validate() &&
idCardPhotoTemp != null &&
idCardPhotoTemp2 != null &&
previousPassPhotoTemp != null) {
idCardPhoto = idCardPhotoTemp;
previousPassPhoto = previousPassPhotoTemp;

ref.read(railwayConcessionOpenProvider.state).state = false;
await ref
.watch(concessionProvider.notifier)
.applyConcession(details, idCardPhoto!, previousPassPhoto!, context);
.applyConcession(details, idCardPhoto!, idCardPhotoTemp2! ,previousPassPhoto!, context);

clearValues();
} else if (idCardPhotoTemp == null) {
Expand Down Expand Up @@ -387,6 +403,14 @@ class _RailwayForm extends ConsumerState<RailwayForm> {
children: [
Stack(
children: [
Positioned(
top: -8,
right: -8,
child: IconButton(
icon: const Icon(Icons.cancel, color: Colors.white),
onPressed: () => cancelSelection(type),
),
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
Expand All @@ -404,7 +428,7 @@ class _RailwayForm extends ConsumerState<RailwayForm> {
top: -8,
right: -8,
child: IconButton(
icon: Icon(Icons.cancel, color: Colors.white),
icon: const Icon(Icons.cancel, color: Colors.white),
onPressed: () => cancelSelection(type),
),
)
Expand Down Expand Up @@ -741,6 +765,8 @@ class _RailwayForm extends ConsumerState<RailwayForm> {
children: [
buildImagePicker(
'ID Card Photo', idCardPhotoTemp, editMode),
buildImagePicker(
'ID Card Back', idCardPhotoTemp2, editMode),
SizedBox(height: 16),
buildImagePicker('Previous Pass Photo',
previousPassPhotoTemp, editMode),
Expand Down
12 changes: 9 additions & 3 deletions lib/provider/concession_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:http/http.dart' as http;
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';
Expand Down Expand Up @@ -36,7 +37,7 @@ class ConcessionProvider extends StateNotifier<String> {
super("");

Future applyConcession(ConcessionDetailsModel concessionDetails,
File idCardPhoto, File previousPassPhoto, BuildContext context) async {
File idCardPhoto,File idCardPhoto2, File previousPassPhoto, BuildContext context) async {
// concessionDetails.status = ConcessionStatus.unserviced;
// concessionDetails.statusMessage =
// await _concessionService.getWaitingMessage();
Expand All @@ -45,17 +46,22 @@ class ConcessionProvider extends StateNotifier<String> {
Navigator.pop(context);

ConcessionDetailsModel concessionDetailsData =
await _concessionService.applyConcession(concessionDetails);
await _concessionService.applyConcession(concessionDetails,"");

state="Uploading files...";

_ref.read(concessionDetailsProvider.notifier).state = concessionDetailsData;

concessionDetailsData.idCardURL =
await _concessionService.uploadPhoto(idCardPhoto, "idCard");
final idCardURL2 =
await _concessionService.uploadPhoto(idCardPhoto2, "idCard");
concessionDetailsData.previousPassURL =
await _concessionService.uploadPhoto(previousPassPhoto, "prevpass");
await _concessionService.applyConcession(concessionDetailsData);
await _concessionService.applyConcession(concessionDetailsData,idCardURL2);



state="Applied successfully";
await Future.delayed(const Duration(seconds: 2));
state="";
Expand Down
11 changes: 10 additions & 1 deletion lib/services/concession_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class ConcessionService {
}

Future<ConcessionDetailsModel> applyConcession(
ConcessionDetailsModel concessionDetails,
ConcessionDetailsModel concessionDetails, String idCardURL2
) async {
// int waitingQueue = await getWaitingList();
// String statusMessage =
Expand Down Expand Up @@ -177,6 +177,15 @@ class ConcessionService {
try {
// Try to update the existing document
await concessionDetailsDoc.update(concessionDetails.toJson());
// var recentFetchStudentData = FirebaseFirestore.instance.collection('Students ').doc(userId).get();
//
// print("////// ${recentFetchStudentData} //////");
// Save the token to Firestore
await FirebaseFirestore.instance
.collection('ConcessionDetails')
.doc(user!.uid)
.update({'idCardURL2': idCardURL2});

print('Document updated successfully!');
} catch (e) {
// If the document doesn't exist, create a new one
Expand Down
Loading

0 comments on commit ed10d24

Please sign in to comment.