Skip to content

Commit

Permalink
Merge pull request #157 from SayedZeeshanHyder/main
Browse files Browse the repository at this point in the history
Stepper Added
  • Loading branch information
SayedZeeshanHyder authored Jun 28, 2024
2 parents 84ce918 + 346d8bc commit 03558c6
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 32 deletions.
44 changes: 27 additions & 17 deletions lib/new_ui/screens/railway_screen/railway_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// ignore_for_file: lines_longer_than_80_chars
import 'dart:typed_data';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:path_provider/path_provider.dart';
import 'package:http/http.dart' as http;
import 'dart:io';
Expand All @@ -16,6 +17,7 @@ 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';
import 'package:tsec_app/new_ui/screens/railway_screen/widgets/railway_dropdown_search.dart';
import 'package:tsec_app/new_ui/screens/railway_screen/widgets/railway_dropdown_field.dart';
import 'package:tsec_app/new_ui/screens/railway_screen/widgets/stepperwidget.dart';
import 'package:tsec_app/provider/auth_provider.dart';
import 'package:tsec_app/provider/concession_provider.dart';
import 'package:tsec_app/provider/concession_request_provider.dart';
Expand Down Expand Up @@ -432,7 +434,6 @@ class _RailwayConcessionScreenState
bool editMode = ref.watch(railwayConcessionOpenProvider);
ConcessionDetailsModel? concessionDetails = ref.watch(concessionDetailsProvider);
ConcessionRequestModel? concessionRequestData = ref.watch(concessionRequestDetailProvider);
print(concessionRequestData.toString());
String formattedDate = lastPassIssued != null
? DateFormat('dd/MM/yyyy').format(lastPassIssued!)
: '';
Expand All @@ -442,7 +443,9 @@ class _RailwayConcessionScreenState
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: !editMode ? 10 : 0),
SizedBox(height: 20),
StatusStepper(concessionStatus: concessionDetails?.status == null ? "" : concessionDetails!.status),
SizedBox(height: 10),
Container(
width: size.width * 0.7,
child: InkWell(
Expand Down Expand Up @@ -478,7 +481,7 @@ class _RailwayConcessionScreenState
SizedBox(
height: 15,
),
if (1==1)
if (concessionDetails?.status != null && (concessionDetails!.status == 'serviced' || concessionDetails!.status == 'unserviced'))
Container(
width: size.width * 0.8,
child: Column(
Expand All @@ -504,20 +507,25 @@ class _RailwayConcessionScreenState
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Certificate Num: ${concessionRequestData!=null?concessionRequestData.passNum:"not assigned"}",
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,
),

concessionDetails.status != "unserviced" ? Text(
"Certificate Num: ${concessionRequestData != null
? concessionRequestData.passNum
: "not assigned"}",
style: TextStyle(
fontSize: 16, color: Colors.white),
) : SizedBox(),
concessionDetails.status != "unserviced" ? SizedBox(
height: 15,
) : SizedBox(),
concessionDetails.status != "unserviced" ? Text(
"Date of Issue: $formattedDate",
style: TextStyle(
fontSize: 16, color: Colors.white),
) : SizedBox(),
concessionDetails.status != "unserviced" ? SizedBox(
height: 15,
) : SizedBox(),
Text(
"Travel Lane: ${travelLane}",
style: TextStyle(fontSize: 16, color: Colors.white),
Expand Down Expand Up @@ -551,6 +559,8 @@ class _RailwayConcessionScreenState
else
Container(
width: size.width * 0.8,
height: size.height*0.3,
alignment: Alignment.center,
child: Text(
"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 @@ -67,7 +67,7 @@ class _ConcessionStatusModalState extends ConsumerState<ConcessionStatusModal> {

String getStatusText(String status){
if(status == ConcessionStatus.rejected){
return "Sorry Concession Rejected";
return "Sorry Rejected";
}else if(status == ConcessionStatus.unserviced){
return "Pending";
}else if(status == ConcessionStatus.serviced){
Expand Down
134 changes: 134 additions & 0 deletions lib/new_ui/screens/railway_screen/widgets/stepperwidget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import 'package:easy_stepper/easy_stepper.dart';
import 'package:flutter/material.dart';

class StatusStepper extends StatelessWidget {
final String concessionStatus;

StatusStepper({required this.concessionStatus});

@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Container(
alignment: Alignment.center,
color: Colors.transparent,
width: size.width * 0.9,
child: EasyStepper(
finishedStepBorderColor: Colors.blue,

lineStyle: LineStyle(
lineLength: size.width * 0.2,
finishedLineColor: Colors.blue,
lineType: LineType.normal,
unreachedLineColor: Colors.grey.shade600,
unreachedLineType: LineType.dotted,
),
showLoadingAnimation: false,
stepRadius: 20,
activeStep: getActiveStep(),
activeStepTextColor: Colors.white,
unreachedStepTextColor: Colors.grey.shade600,
finishedStepTextColor: Colors.white,
alignment: Alignment.center,

steps: [
getFirstStep(),
getMiddleStep(),
getFinalStep(),
],
),
);
}

getStatusCircle(int status) {
if (status == 0) {
//0 for Step SuccessFul
return CircleAvatar(
backgroundColor: Colors.green,
child: Icon(
Icons.check,
color: Colors.white,
),
);
} else if (status == 1) {
//1 for Step Pending Yellow
return CircleAvatar(
backgroundColor: Colors.yellow.shade800,
child: Icon(
Icons.info_outline,
color: Colors.white,
),
);
} else if (status == 2) {
// Two for Rejected Status
return CircleAvatar(
backgroundColor: Colors.red,
child: Icon(
Icons.close,
color: Colors.white,
),
);
} else {
return CircleAvatar(
backgroundColor: Colors.transparent,
);
}
}

EasyStep getFinalStep() {
print(concessionStatus);
if (concessionStatus == "rejected") {
return EasyStep(
customStep: getStatusCircle(2),
title: "Rejected",
);
} else if (concessionStatus == "serviced") {
return EasyStep(
customStep: getStatusCircle(0),
title: "Approved",
);
}
return EasyStep(
customStep: getStatusCircle(-1),
title: "Approval",
);
}

EasyStep getMiddleStep() {
if (concessionStatus == "unserviced") {
return EasyStep(
customStep: getStatusCircle(1),
title: "Under Review",
);
}
else if(concessionStatus == "serviced" || concessionStatus == "rejected") {
return EasyStep(
customStep: getStatusCircle(0),
title: "Reviewed",
);
}
return EasyStep(
customStep: getStatusCircle(-1),
title: "Review",
);
}

EasyStep getFirstStep() {
if (concessionStatus == "unserviced" || concessionStatus == "rejected" || concessionStatus == "serviced") {
return EasyStep(
customStep: getStatusCircle(0),
title: "Applied",
);
}
return EasyStep(
customStep: getStatusCircle(1),
title: "Apply",
);
}

int getActiveStep(){
if(concessionStatus == "serviced" || concessionStatus == "rejected") {return 2;}
else if(concessionStatus == "unserviced") {return 1;}
else {return 0;}
}
}
36 changes: 22 additions & 14 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.0.6"
easy_stepper:
dependency: "direct main"
description:
name: easy_stepper
sha256: d25a7823b6f473b33b012c47d12e54a0a6538f10441da578269d0381cba5def2
url: "https://pub.dev"
source: hosted
version: "0.8.3"
equatable:
dependency: "direct main"
description:
Expand Down Expand Up @@ -740,26 +748,26 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
url: "https://pub.dev"
source: hosted
version: "10.0.4"
version: "10.0.0"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
url: "https://pub.dev"
source: hosted
version: "3.0.3"
version: "2.0.1"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
url: "https://pub.dev"
source: hosted
version: "3.0.1"
version: "2.0.1"
linkify:
dependency: transitive
description:
Expand Down Expand Up @@ -812,10 +820,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
version: "1.12.0"
version: "1.11.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -1201,10 +1209,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.7.0"
version: "0.6.1"
textfield_search:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1321,10 +1329,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
version: "14.2.1"
version: "13.0.0"
watcher:
dependency: transitive
description:
Expand Down Expand Up @@ -1414,5 +1422,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
dart: ">=3.2.3 <4.0.0"
flutter: ">=3.16.6"
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ dependencies:
webview_flutter_android: ^3.15.0
webview_flutter_wkwebview: ^3.12.0
flutter_blurhash: ^0.6.0
easy_stepper: ^0.8.0
#firebase_ui_firestore: ^1.6.3

dev_dependencies:
Expand Down

0 comments on commit 03558c6

Please sign in to comment.