Skip to content

Commit

Permalink
Merge pull request #154 from 12fahed/main
Browse files Browse the repository at this point in the history
Railway Previous pass screen Done
  • Loading branch information
12fahed authored Jun 27, 2024
2 parents 4b53205 + cf18df1 commit c6b15bd
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 54 deletions.
133 changes: 108 additions & 25 deletions lib/new_ui/screens/railway_screen/railway_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:image_picker/image_picker.dart';
import 'package:intl/intl.dart';
import 'package:tsec_app/models/concession_details_model/concession_details_model.dart';
// import 'package:tsec_app/models/concession_request_model/concession_request_model.dart';
import 'package:tsec_app/models/student_model/student_model.dart';
import 'package:tsec_app/new_ui/screens/railway_screen/railwayform.dart';
import 'package:tsec_app/new_ui/screens/railway_screen/widgets/concession_status_modal.dart';
Expand Down Expand Up @@ -36,8 +37,8 @@ class _RailwayConcessionScreenState
String? statusMessage;
String? duration;
DateTime? lastPassIssued;

// String?
String? from;
String? to;

bool canIssuePass(ConcessionDetailsModel? concessionDetails,
DateTime? lastPassIssued, String? duration) {
Expand Down Expand Up @@ -66,13 +67,24 @@ class _RailwayConcessionScreenState
}
}

String futurePassMessage() {
String futurePassMessage(concessionDetails) {
if (canIssuePass(concessionDetails, lastPassIssued, duration)) {
return "⚠️ You can tap above to apply for the Pass";
}

if (lastPassIssued == null) {
return "⚠️ You need to wait until your request is granted";
}

DateTime today = DateTime.now();
DateTime lastPass = lastPassIssued ?? DateTime.now();
DateTime futurePass = lastPass.add(duration == "Monthly" ? const Duration(days: 27) : Duration(days: 87));
DateTime futurePass = lastPass.add(duration == "Monthly" ? const Duration(days: 27) : const Duration(days: 87));
int diff = futurePass.difference(today).inDays;
return "You will be able to apply for a new pass after $diff days";

return "⚠️ You will be able to apply for a new pass only after $diff days";
}


@override
void didChangeDependencies() {
super.didChangeDependencies();
Expand Down Expand Up @@ -416,24 +428,25 @@ class _RailwayConcessionScreenState
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
bool editMode = ref.watch(railwayConcessionOpenProvider);
// StudentModel student = ref.watch(userModelProvider)!.studentModel!;
ConcessionDetailsModel? concessionDetails =
ref.watch(concessionDetailsProvider);
ConcessionDetailsModel? concessionDetails = ref.watch(concessionDetailsProvider);

String formattedDate = lastPassIssued != null
? DateFormat('dd/MM/yyyy').format(lastPassIssued!)
: '';

return SingleChildScrollView(
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: !editMode ? 10 : 0),
Container(
width: size.width*0.7,
// color: Colors.red,
width: size.width * 0.7,
child: InkWell(
splashFactory: NoSplash.splashFactory,
splashColor: Colors.transparent,
onTap: (){
if (canIssuePass(concessionDetails,
lastPassIssued, duration)) {
onTap: () {
if (canIssuePass(concessionDetails, lastPassIssued, duration)) {
Navigator.push(
context,
MaterialPageRoute(
Expand All @@ -443,33 +456,103 @@ class _RailwayConcessionScreenState
}
},
child: ConcessionStatusModal(
// concessionDetails: concessionDetails,
canIssuePass: canIssuePass,
// lastPassIssued: lastPassIssued,
// duration: duration,
futurePassMessage: futurePassMessage,
),
),
),
SizedBox(
height: 15,
),

Container(
width: size.width * 0.68,
child: Text(
"${futurePassMessage()}",
style: TextStyle(fontSize: 18, color: Colors.white),
)),
width: size.width * 0.9,
alignment: Alignment.center,
child: Text(
"${futurePassMessage(concessionDetails)}",
style: TextStyle(fontSize: 15, color: Colors.white),
),
),
SizedBox(
height: 15,
),
Container(
if (lastPassIssued != null)
Container(
width: size.width * 0.8,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 20),
Text(
"Ongoing Pass",
style: TextStyle(fontSize: 18, color: Colors.white),
),
SizedBox(height: 10),
Container(
padding: EdgeInsets.all(10),
width: MediaQuery.of(context).size.width * 0.9,
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Colors.blue,
width: 1,
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Certificate Num: Z####",
style: TextStyle(fontSize: 16, color: Colors.white),
),
SizedBox(
height: 15,
),
Text(
"Date of Issue: $formattedDate",
style: TextStyle(fontSize: 16, color: Colors.white),
),
SizedBox(
height: 15,
),
Text(
"Travel Lane: ${travelLane}",
style: TextStyle(fontSize: 16, color: Colors.white),
),
SizedBox(height: 10),
Text(
"From: ${homeStation}",
style: TextStyle(fontSize: 16, color: Colors.white),
),
Text(
"To: ${toStation}",
style: TextStyle(fontSize: 16, color: Colors.white),
),
SizedBox(
height: 15,
),
Text(
"Duration: ${duration}",
style: TextStyle(fontSize: 16, color: Colors.white),
),
Text(
"Class: ${travelClass}",
style: TextStyle(fontSize: 16, color: Colors.white),
),
],
),
),
],
),
)
else
Container(
width: size.width * 0.8,
child: Text(
"Previous Passes",
"You Dont have any ongoing pass",
style: TextStyle(fontSize: 18, color: Colors.white),
)),
),
),
],
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,20 @@ class _ConcessionStatusModalState extends ConsumerState<ConcessionStatusModal> {
padding: const EdgeInsets.all(8.0),
child: Container(
alignment: Alignment.center,
// height: 70,
height: 50,
height: 45,
width: size.width*0.7,
decoration: BoxDecoration(
color: concessionDetails?.status == ConcessionStatus.rejected
? Theme.of(context).colorScheme.error
: widget.canIssuePass(concessionDetails, lastPassIssued, duration)
? Theme.of(context).colorScheme.tertiaryContainer
: Theme.of(context).colorScheme.primary,
borderRadius: BorderRadius.circular(5),
// boxShadow: isItDarkMode
// ? shadowLightModeTextFields
// : shadowDarkModeTextFields,
borderRadius: BorderRadius.circular(20),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
concessionDetails?.status != null ? "Status : ${getStatusText(concessionDetails!.status)}" : "Can Apply for Pass",
/*"Status : ${concessionDetails?.status == ConcessionStatus.rejected
? "Rejected"
: concessionDetails?.status ==
ConcessionStatus.unserviced
? "Pending"
: widget.canIssuePass(
concessionDetails, lastPassIssued, duration)
? "Can apply"
: ""}",*/
style: Theme.of(context).textTheme.headlineSmall!.copyWith(
color: Colors.white,
fontWeight: FontWeight.w600,
Expand All @@ -80,7 +67,7 @@ class _ConcessionStatusModalState extends ConsumerState<ConcessionStatusModal> {

String getStatusText(String status){
if(status == ConcessionStatus.rejected){
return "Sorry Cnncession Rejected";
return "Sorry Concession Rejected";
}else if(status == ConcessionStatus.unserviced){
return "Pending";
}else if(status == ConcessionStatus.serviced){
Expand Down
1 change: 0 additions & 1 deletion lib/utils/station_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ List<String> mumbaiRailwayStations = [
'Atgaon',
'Badlapur',
'Bamandongri',
'Bandra',
'Bhandup',
'Bhayandar',
'Bhivpuri Road',
Expand Down
56 changes: 44 additions & 12 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.8.0"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
url: "https://pub.dev"
source: hosted
version: "10.0.4"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
linkify:
dependency: transitive
description:
Expand Down Expand Up @@ -772,26 +796,26 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.16"
version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "0.8.0"
meta:
dependency: transitive
description:
name: meta
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "1.12.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -828,10 +852,10 @@ packages:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
version: "1.9.0"
path_provider:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1177,10 +1201,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
version: "0.7.0"
textfield_search:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1293,6 +1317,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
url: "https://pub.dev"
source: hosted
version: "14.2.1"
watcher:
dependency: transitive
description:
Expand Down Expand Up @@ -1382,5 +1414,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.2.3 <4.0.0"
flutter: ">=3.16.6"
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"

0 comments on commit c6b15bd

Please sign in to comment.