Commit f693e7f1 authored by Sai Srinivas's avatar Sai Srinivas
Browse files

12-11-2025 generator Details Screen and sub screens

parent dd6e2bd2
class scheduleListResponse {
String? error;
List<AllScheduleServices>? allScheduleServices;
String? message;
scheduleListResponse({this.error, this.allScheduleServices, this.message});
scheduleListResponse.fromJson(Map<String, dynamic> json) {
error = json['error'];
if (json['all_schedule_services'] != null) {
allScheduleServices = <AllScheduleServices>[];
json['all_schedule_services'].forEach((v) {
allScheduleServices!.add(new AllScheduleServices.fromJson(v));
});
}
message = json['message'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['error'] = this.error;
if (this.allScheduleServices != null) {
data['all_schedule_services'] =
this.allScheduleServices!.map((v) => v.toJson()).toList();
}
data['message'] = this.message;
return data;
}
}
class AllScheduleServices {
String? id;
String? dueDate;
String? complaintType;
String? comType;
String? status;
AllScheduleServices(
{this.id, this.dueDate, this.complaintType, this.comType, this.status});
AllScheduleServices.fromJson(Map<String, dynamic> json) {
id = json['id'];
dueDate = json['due_date'];
complaintType = json['complaint_type'];
comType = json['com_type'];
status = json['status'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['due_date'] = this.dueDate;
data['complaint_type'] = this.complaintType;
data['com_type'] = this.comType;
data['status'] = this.status;
return data;
}
}
import 'package:flutter/foundation.dart';
import 'package:gen_service/Models/amcQuotationListResponse.dart';
import 'package:gen_service/Models/complaintListResponse.dart';
import 'package:gen_service/Models/generatorDetailsResponse.dart';
import 'package:gen_service/Models/quotationListResponse.dart';
import 'package:gen_service/Models/scheduleListResponse.dart';
import '../Services/api_calling.dart';
class Generatordetailsprovider extends ChangeNotifier{
generatorDetailsResponse? _detailsResponse;
scheduleListResponse? _scheduleResponse;
quotationListResponse? _quotationResponse;
complaintListResponse? _complaintResponse;
amcQuotationListResponse? _amcQuotationResponse;
bool _isLoading = false;
String? _errorMessage;
bool _showMoreDetails = false;
generatorDetailsResponse? get detailsResponse => _detailsResponse;
scheduleListResponse? get scheduleResponse => _scheduleResponse;
quotationListResponse? get quotationResponse => _quotationResponse;
complaintListResponse? get complaintResponse => _complaintResponse;
amcQuotationListResponse? get amcQuotationResponse => _amcQuotationResponse;
bool get isLoading => _isLoading;
String? get errorMessage => _errorMessage;
bool get showMoreDetails => _showMoreDetails;
set showMoreDetails(bool value) {
_showMoreDetails = value;
notifyListeners();
}
Future<void> fetchGeneratorDetails(String accId, String sessionId,genId) async {
_isLoading = true;
_errorMessage = null;
notifyListeners();
try {
final response = await ApiCalling.generatorDetailsAPI(accId, sessionId,genId);
if (response != null) {
if (response.error == "0") {
_detailsResponse = response;
} else {
_errorMessage = response.message ?? "Something went wrong!";
}
} else {
_errorMessage = "No response from server.";
}
} catch (e) {
_errorMessage = "Failed to fetch dashboard: $e";
} finally {
_isLoading = false;
notifyListeners();
}
}
Future<void> fetchScheduleList(String accId, String sessionId,gen_id) async {
_isLoading = true;
_errorMessage = null;
notifyListeners();
try {
final response = await ApiCalling.scheduleListAPI(accId, sessionId,gen_id);
if (response != null) {
if (response.error == "0") {
_scheduleResponse = response;
notifyListeners();
} else {
_errorMessage = response.message ?? "Something went wrong!";
}
} else {
_errorMessage = "No response from server.";
}
} catch (e) {
_errorMessage = "Failed to fetch dashboard: $e";
} finally {
_isLoading = false;
notifyListeners();
}
}
Future<void> fetchQuotationList(String accId, String sessionId,genID) async {
_isLoading = true;
_errorMessage = null;
notifyListeners();
try {
final response = await ApiCalling.quotationListAPI(accId, sessionId,genID);
if (response != null) {
if (response.error == "0") {
_quotationResponse = response;
notifyListeners();
} else {
_errorMessage = response.message ?? "Something went wrong!";
}
} else {
_errorMessage = "No response from server.";
}
} catch (e) {
_errorMessage = "Failed to fetch dashboard: $e";
} finally {
_isLoading = false;
notifyListeners();
}
}
Future<void> fetchComplaintList(String accId, String sessionId) async {
_isLoading = true;
_errorMessage = null;
notifyListeners();
try {
final response = await ApiCalling.complaintListAPI(accId, sessionId);
if (response != null) {
if (response.error == "0") {
_complaintResponse = response;
notifyListeners();
} else {
_errorMessage = response.message ?? "Something went wrong!";
}
} else {
_errorMessage = "No response from server.";
}
} catch (e) {
_errorMessage = "Failed to fetch dashboard: $e";
} finally {
_isLoading = false;
notifyListeners();
}
}
Future<void> fetchAmcQuotationList(String accId, String sessionId,genId) async {
_isLoading = true;
_errorMessage = null;
notifyListeners();
try {
final response = await ApiCalling.amcQuoteListAPI(accId, sessionId,genId);
if (response != null) {
if (response.error == "0") {
_amcQuotationResponse = response;
notifyListeners();
} else {
_errorMessage = response.message ?? "Something went wrong!";
}
} else {
_errorMessage = "No response from server.";
}
} catch (e) {
_errorMessage = "Failed to fetch dashboard: $e";
} finally {
_isLoading = false;
notifyListeners();
}
}
}
\ No newline at end of file
......@@ -26,7 +26,10 @@ class _SelectOrderHelpScreenState extends State<SelectOrderHelpScreen> {
void initState() {
super.initState();
Future.microtask(() {
final provider = Provider.of<HelpAndComplaintProvider>(context, listen: false);
final provider = Provider.of<HelpAndComplaintProvider>(
context,
listen: false,
);
provider.fetchGeneratorList(
accId: widget.accId,
sessionId: widget.sessionId,
......@@ -63,12 +66,12 @@ class _SelectOrderHelpScreenState extends State<SelectOrderHelpScreen> {
);
}
if (generatorData == null || generatorData.orders == null || generatorData.orders!.isEmpty) {
if (generatorData == null ||
generatorData.orders == null ||
generatorData.orders!.isEmpty) {
return const Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: Center(
child: Text("No Generators Found."),
),
body: Center(child: Text("No Generators Found.")),
);
}
......@@ -107,7 +110,10 @@ class _SelectOrderHelpScreenState extends State<SelectOrderHelpScreen> {
background: Container(
decoration: const BoxDecoration(color: AppColors.primary),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 16,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
......@@ -141,7 +147,10 @@ class _SelectOrderHelpScreenState extends State<SelectOrderHelpScreen> {
child: Container(
color: AppColors.primary,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 20,
),
decoration: const BoxDecoration(
color: AppColors.backgroundRegular,
borderRadius: BorderRadius.only(
......@@ -174,13 +183,16 @@ class _SelectOrderHelpScreenState extends State<SelectOrderHelpScreen> {
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => AddComplaintScreen(
MaterialPageRoute(
builder:
(context) => AddComplaintScreen(
accId: widget.accId,
sessionId: widget.sessionId,
product: order.prodName.toString(),
hashId: order.hashId.toString(),
modolNo: order.engine.toString())
)
modolNo: order.engine.toString(),
),
),
).then((_) async {
await provider.fetchGeneratorList(
accId: widget.accId,
......@@ -189,15 +201,18 @@ class _SelectOrderHelpScreenState extends State<SelectOrderHelpScreen> {
});
},
child: _buildOrderItem(
assetId: "#${order.hashId ?? ''} | Engine : ${order.engine ?? ''}",
assetId:
"#${order.hashId ?? ''} | Engine : ${order.engine ?? ''}",
description: order.prodName ?? '',
amc: order.amc ?? '',
warranty: order.warranty ?? '',
pImage: order.productImage ?? '',
date: order.schedule?.isNotEmpty == true
date:
order.schedule?.isNotEmpty == true
? order.schedule!.first
: null,
serviceText: order.schedule?.isNotEmpty == true
serviceText:
order.schedule?.isNotEmpty == true
? 'Upcoming Service Scheduled'
: null,
),
......@@ -270,9 +285,13 @@ class _SelectOrderHelpScreenState extends State<SelectOrderHelpScreen> {
children: [
if (amc == "1" || amc == "2")
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
decoration: BoxDecoration(
gradient: amc == "1"
gradient:
amc == "1"
? AppColors.greenStripGradient
: AppColors.fadeGradient,
borderRadius: BorderRadius.circular(12),
......@@ -283,7 +302,8 @@ class _SelectOrderHelpScreenState extends State<SelectOrderHelpScreen> {
SvgPicture.asset(
"assets/svg/tick_ic.svg",
height: 14,
color: amc == "1"
color:
amc == "1"
? AppColors.greenICBg
: AppColors.subtitleText,
),
......@@ -295,7 +315,8 @@ class _SelectOrderHelpScreenState extends State<SelectOrderHelpScreen> {
fontFamily: "PoppinsBold",
fontStyle: FontStyle.italic,
fontWeight: FontWeight.w700,
color: amc == "1"
color:
amc == "1"
? AppColors.greenICBg
: AppColors.subtitleText,
),
......@@ -305,9 +326,13 @@ class _SelectOrderHelpScreenState extends State<SelectOrderHelpScreen> {
),
if (warranty == "1" || warranty == "2")
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
decoration: BoxDecoration(
gradient: warranty == "1"
gradient:
warranty == "1"
? AppColors.yellowStripGradient
: AppColors.fadeGradient,
borderRadius: BorderRadius.circular(12),
......@@ -318,7 +343,8 @@ class _SelectOrderHelpScreenState extends State<SelectOrderHelpScreen> {
SvgPicture.asset(
"assets/svg/tick2_ic.svg",
height: 14,
color: warranty == "1"
color:
warranty == "1"
? AppColors.warning
: AppColors.subtitleText,
),
......@@ -330,7 +356,8 @@ class _SelectOrderHelpScreenState extends State<SelectOrderHelpScreen> {
fontFamily: "PoppinsBold",
fontStyle: FontStyle.italic,
fontWeight: FontWeight.w700,
color: warranty == "1"
color:
warranty == "1"
? AppColors.normalText
: AppColors.subtitleText,
),
......@@ -359,7 +386,8 @@ class _SelectOrderHelpScreenState extends State<SelectOrderHelpScreen> {
height: 50,
width: 50,
fit: BoxFit.contain,
errorBuilder: (context, error, stack) => Image.asset(
errorBuilder:
(context, error, stack) => Image.asset(
'assets/images/dashboard_gen.png',
height: 40,
width: 40,
......
......@@ -3,10 +3,12 @@ import 'package:flutter_svg/svg.dart';
import 'package:gen_service/Screens/HelpAndComplaintScreens/SelectOrderHelpScreen.dart';
import 'package:gen_service/Screens/ProfileScreen.dart';
import 'package:gen_service/Screens/TransactionListScreen.dart';
import 'package:gen_service/Screens/ComplaintListScreen.dart';
import 'package:provider/provider.dart';
import '../Notifiers/DashboardProvider.dart';
import '../Utility/AppColors.dart';
import 'generatorDetailsScreen.dart';
class HomeScreen extends StatefulWidget {
final String accId;
......@@ -343,7 +345,8 @@ class _HomeScreenState extends State<HomeScreen> {
);
}
return Padding(
return InkResponse(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 14),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
......@@ -352,7 +355,20 @@ class _HomeScreenState extends State<HomeScreen> {
...orders.map<Widget>((order) {
return Column(
children: [
_buildOrderItem(
InkResponse(
onTap: () async {
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Generatordetailsscreen(
accId: widget.accId,
sessionId: widget.sessionId,
genId: order.id,
),
),
);
},
child: _buildOrderItem(
assetId: "#${order.hashId ?? ''} | Engine : ${order.engine ?? ''}",
description: order.prodName ?? '',
amc: (order.amc?.toString() ?? ''),
......@@ -365,6 +381,7 @@ class _HomeScreenState extends State<HomeScreen> {
? 'Upcoming Service Scheduled'
: null,
),
),
const SizedBox(height: 12),
],
);
......@@ -373,6 +390,7 @@ class _HomeScreenState extends State<HomeScreen> {
],
),
),
);
}
......
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/svg.dart';
import 'package:provider/provider.dart';
import '../Notifiers/generatorDetailsProvider.dart';
import '../Utility/AppColors.dart';
class AmcQuotationListScreen extends StatefulWidget {
final accId;
final sessionId;
final genid;
const AmcQuotationListScreen({super.key,required this.accId,required this.sessionId,required this.genid});
@override
State<AmcQuotationListScreen> createState() => _AmcQuotationListScreenState();
}
class _AmcQuotationListScreenState extends State<AmcQuotationListScreen> {
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
final provider = Provider.of<Generatordetailsprovider>(
context,
listen: false,
);
provider.fetchAmcQuotationList(widget.accId, widget.sessionId,widget.genid);
});
}
@override
Widget build(BuildContext context) {
return Consumer<Generatordetailsprovider>(
builder: (context, provider, child) {
final isLoading = provider.isLoading;
final error = provider.errorMessage;
final response = provider.amcQuotationResponse;
final data = response?.amcQuotations??[];
if (isLoading) {
return const Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: Center(
child: CircularProgressIndicator(color: AppColors.buttonColor),
),
);
}
if (error != null) {
return Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: Center(
child: Text(
error,
style: const TextStyle(color: Colors.red, fontSize: 16),
),
),
);
}
if (data == null) {
return const Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: Center(child: Text("No data found.")),
);
}
return RefreshIndicator.adaptive(
color: AppColors.amountText,
onRefresh: () async {
await Future.delayed(const Duration(milliseconds: 600));
},
child: Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: CustomScrollView(
physics: const BouncingScrollPhysics(),
slivers: [
SliverAppBar(
stretch: true,
pinned: true,
expandedHeight: 75,
backgroundColor: AppColors.backgroundRegular,
elevation: 0,
// Remove shadow
automaticallyImplyLeading: false,
toolbarHeight: 0,
// Remove toolbar space
collapsedHeight: 0,
// Completely collapse to 0 height
flexibleSpace: FlexibleSpaceBar(
stretchModes: const [StretchMode.fadeTitle],
background: Container(
decoration: BoxDecoration(
gradient: AppColors.balanceBarGradientA,
),
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 20,
),
child: SizedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
InkResponse(
onTap: () {
HapticFeedback.selectionClick();
Navigator.pop(context, true);
},
child: SvgPicture.asset(
"assets/svg/appbar_back.svg",
height: 25,
),
),
SizedBox(width: 10),
Expanded(
flex: 4,
child: InkResponse(
onTap: () {
HapticFeedback.selectionClick();
Navigator.pop(context, true);
},
child: Text(
"AMC Quotation List",
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
fontSize: 16,
color: Colors.white,
height: 1.1,
),
),
),
),
],
),
),
),
),
),
),
),
SliverToBoxAdapter(
child: Container(
color: Color(0xFF4076FF),
child: Container(
decoration: const BoxDecoration(
color: AppColors.backgroundRegular,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 4),
ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: data!.length,
itemBuilder: (context, j) {
return Container(
margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
decoration: BoxDecoration(
color: data[j].amcStatus == "1" ? Color(0xFFD7F0FF) : Color(0xFFE0E0E0),
borderRadius: BorderRadius.circular(14),
),
child: Column(
children: [
Container(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
border: Border.all(
color:
data[j].amcStatus == "1"
? AppColors.buttonColor
: Colors.white,
),
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisSize: MainAxisSize.min,
children: [
SvgPicture.asset(
"assets/svg/tick_ic.svg",
height: 14,
color:
data[j].amcStatus == "1"
? AppColors.greenICBg
: AppColors.subtitleText,
),
const SizedBox(width: 4),
Text(
"AMC ",
style: TextStyle(
fontSize: 15,
fontFamily: "PoppinsBold",
fontStyle: FontStyle.italic,
fontWeight: FontWeight.w700,
color:
data[j].amcStatus == "1"
? AppColors.greenICBg
: AppColors.subtitleText,
),
),
Text(
"Protected",
style: TextStyle(
fontSize: 15,
fontFamily: "PoppinsBold",
fontStyle: FontStyle.italic,
fontWeight: FontWeight.w700,
color:
data[j].amcStatus == "1"
? AppColors.normalText
: AppColors.subtitleText,
),
),
const SizedBox(width: 4),
if (data[j].amcStatus == "2")
const Icon(
Icons.info_outline,
color: Colors.red,
size: 12,
),
],
),
Container(
padding: EdgeInsets.symmetric(vertical: 3, horizontal: 5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color:
data[j].amcStatus == "1"
? AppColors.successBG
: Color(0xFFFFF8D2),
),
child: Center(
child: Text(
data[j].expNote ?? "-",
style: TextStyle(
fontSize: 14,
color:
data[j].amcStatus == "1"
? AppColors.success
: AppColors.error,
),
),
),
),
],
),
Divider(color: Color(0xFF777777), thickness: 0.3),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Purchased On",
style: TextStyle(
color: AppColors.subtitleText,
fontSize: 12,
),
),
Text(data[j].purchaseDate!),
],
),
Text(
"₹${data[j].price}" ?? "-",
style: TextStyle(
color:
data[j].amcStatus == "1"
? AppColors.buttonColor
: AppColors.nearDarkText,
fontSize: 14,
),
),
],
),
],
),
),
Container(
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
rowText(data[j].noOfVisits, "No. of Visits"),
rowText(data[j].noOfOilServices, "No. of Oil Services"),
],
),
),
],
),
);
},
),
],
),
),
),
),
],
),
),
);
},
);
}
Widget rowText(text1, text2) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
height: 20,
width: 20,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
child: Center(
child: Text(
text1,
style: TextStyle(color: AppColors.nearDarkText, fontSize: 12),
),
),
),
SizedBox(width: 5),
Text(
text2,
style: TextStyle(color: AppColors.nearDarkText, fontSize: 12),
),
],
);
}
}
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/svg.dart';
import 'package:provider/provider.dart';
import '../Notifiers/generatorDetailsProvider.dart';
import '../Utility/AppColors.dart';
class ComplaintListScreen extends StatefulWidget {
final accId;
final sessionId;
const ComplaintListScreen({super.key,required this.accId,required this.sessionId});
@override
State<ComplaintListScreen> createState() => _ComplaintListScreenState();
}
class _ComplaintListScreenState extends State<ComplaintListScreen> {
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
final provider = Provider.of<Generatordetailsprovider>(
context,
listen: false,
);
provider.fetchComplaintList(widget.accId, widget.sessionId);
});
}
@override
Widget build(BuildContext context) {
return Consumer<Generatordetailsprovider>(
builder: (context, provider, child) {
final isLoading = provider.isLoading;
final error = provider.errorMessage;
final response = provider.complaintResponse;
final data = response?.complaintList??[];
if (isLoading) {
return const Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: Center(
child: CircularProgressIndicator(color: AppColors.buttonColor),
),
);
}
if (error != null) {
return Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: Center(
child: Text(
error,
style: const TextStyle(color: Colors.red, fontSize: 16),
),
),
);
}
if (data == null) {
return const Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: Center(child: Text("No data found.")),
);
}
return RefreshIndicator.adaptive(
color: AppColors.amountText,
onRefresh: () async {
await Future.delayed(const Duration(milliseconds: 600));
},
child: Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: CustomScrollView(
physics: const BouncingScrollPhysics(),
slivers: [
SliverAppBar(
stretch: true,
pinned: true,
expandedHeight: 75,
backgroundColor: AppColors.backgroundRegular,
elevation: 0,
// Remove shadow
automaticallyImplyLeading: false,
toolbarHeight: 0,
// Remove toolbar space
collapsedHeight: 0,
// Completely collapse to 0 height
flexibleSpace: FlexibleSpaceBar(
stretchModes: const [StretchMode.fadeTitle],
background: Container(
decoration: BoxDecoration(
gradient: AppColors.balanceBarGradientA,
),
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 20,
),
child: SizedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
InkResponse(
onTap: () {
HapticFeedback.selectionClick();
Navigator.pop(context, true);
},
child: SvgPicture.asset(
"assets/svg/appbar_back.svg",
height: 25,
),
),
SizedBox(width: 10),
Expanded(
flex: 4,
child: InkResponse(
onTap: () {
HapticFeedback.selectionClick();
Navigator.pop(context, true);
},
child: Text(
"Complaint List",
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
fontSize: 16,
color: Colors.white,
height: 1.1,
),
),
),
),
],
),
),
),
),
),
),
),
SliverToBoxAdapter(
child: Container(
color: Color(0xFF4076FF),
child: Container(
decoration: const BoxDecoration(
color: AppColors.backgroundRegular,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 4),
ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: data!.length,
itemBuilder: (context, j) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
flex: 7,
child: SizedBox(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RichText(
text: TextSpan(
style: const TextStyle(
fontFamily: 'Poppins',
color: Color(0xFF008CDE),
fontSize: 14,
),
children: [
TextSpan(text: "#${data[j].id}"),
TextSpan(text: " | ${data[j].complaintName}"),
],
),
),
Text(
"${data[j].registredDate}",
style: TextStyle(
color: AppColors.subtitleText,
fontSize: 12,
),
),
],
),
),
),
Expanded(
flex: 3,
child: Container(
padding: EdgeInsets.symmetric(vertical: 6, horizontal: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: AppColors.successBG,
),
child: Center(
child: Text(
"${data[j].openStatus}",
style: TextStyle(fontSize: 14, color: AppColors.success),
),
),
),
),
],
),
Divider(color: Color(0xFF777777), thickness: 0.3),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 5,
child: Text(
"${data[j].productName}",
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: const TextStyle(
color: AppColors.nearDarkText,
fontSize: 12,
),
),
),
Expanded(
flex: 5,
child: RichText(
maxLines: 1,
textAlign: TextAlign.right,
text: TextSpan(
style: TextStyle(
fontFamily: 'Poppins',
color: AppColors.subtitleText,
fontSize: 12,
),
children: [
TextSpan(text: "#${data[j].hashId}"),
TextSpan(text: " | Engine: ${data[j].modelName}"),
],
),
),
),
],
),
],
),
);
},
),
],
),
),
),
),
],
),
),
);
},
);
}
}
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/svg.dart';
import 'package:gen_service/Notifiers/generatorDetailsProvider.dart';
import 'package:gen_service/Screens/HelpAndComplaintScreens/SelectOrderHelpScreen.dart';
import 'package:gen_service/Screens/amcQuotationListScreen.dart';
import 'package:gen_service/Screens/complaintListScreen.dart';
import 'package:gen_service/Screens/quotationListScreen.dart';
import 'package:gen_service/Screens/scheduleListScreen.dart';
import 'package:provider/provider.dart';
import '../Models/generatorDetailsResponse.dart';
import '../Utility/AppColors.dart';
class Generatordetailsscreen extends StatefulWidget {
final accId;
final sessionId;
final genId;
const Generatordetailsscreen({
super.key,
required this.accId,
required this.sessionId,
required this.genId,
});
@override
State<Generatordetailsscreen> createState() => _GeneratordetailsscreenState();
}
class _GeneratordetailsscreenState extends State<Generatordetailsscreen> {
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
final detailsProvider = Provider.of<Generatordetailsprovider>(
context,
listen: false,
);
detailsProvider.fetchGeneratorDetails(
widget.accId,
widget.sessionId,
widget.genId,
);
});
}
@override
Widget build(BuildContext context) {
return Consumer<Generatordetailsprovider>(
builder: (context, detailsProvider, child) {
final isLoading = detailsProvider.isLoading;
final error = detailsProvider.errorMessage;
final data = detailsProvider.detailsResponse;
final genDetails = data!.genDetails??GenDetails();
final locDetails = data!.locationDetails??LocationDetails();
final quotationsList = data.quotations??[];
final scheduleList = data.schedule ?? [];
final amcQuotationsList = data.amcQuotations??[];
final complaintList = data.complaints??[];
List<String> sectionTitles = ["Generator Details", "Location Details"];
List<String> headings1 = [
"Date of Engine Purchase",
"Alternator No.",
"Engine Model",
"Battery No.",
"Commissioning Date",
"Dispatch Date",
];
List<String> subHeadings1 = [
genDetails!.purchaseDate ?? "-",
genDetails!.altNo ?? "-",
genDetails!.modelName ?? "-",
genDetails!.batterNo ?? "-",
genDetails!.commisDate ?? "-",
genDetails!.dispDate ?? "-",
];
List<String> headings2 = ["District", "State", "Address"];
List<String> subHeadings2 = [
locDetails!.districtName ?? "-",
locDetails!.stateName ?? "-",
locDetails!.address ?? "-",
];
List<List<String>> headings = [headings1, headings2];
List<List<String>> subHeadings = [subHeadings1, subHeadings2];
if (isLoading) {
return const Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: Center(
child: CircularProgressIndicator(color: AppColors.buttonColor),
),
);
}
if (error != null) {
return Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: Center(
child: Text(
error,
style: const TextStyle(color: Colors.red, fontSize: 16),
),
),
);
}
if (data == null) {
return const Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: Center(child: Text("No data found.")),
);
}
return SafeArea(
maintainBottomViewPadding: true,
top: false,
bottom: Platform.isIOS ? false : true,
child: Scaffold(
backgroundColor: Color(0xFF4076FF),
appBar: AppBar(
backgroundColor: Color(0xFF4076FF),
automaticallyImplyLeading: false,
// elevation: 2.0,
title: SizedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
InkResponse(
onTap: () {
HapticFeedback.selectionClick();
Navigator.pop(context, true);
},
child: SvgPicture.asset(
"assets/svg/appbar_back.svg",
height: 25,
),
),
SizedBox(width: 10),
Expanded(
flex: 4,
child: InkResponse(
onTap: () {
HapticFeedback.selectionClick();
Navigator.pop(context, true);
},
child: Text(
"Generator Details",
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
fontSize: 16,
color: Colors.white,
height: 1.1,
),
),
),
),
],
),
),
),
body: CustomScrollView(
slivers: [
SliverToBoxAdapter(
child: Container(
color: const Color(0xFF4076FF),
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 12,
),
child: Column(
children: [
// Product Info Row
Row(
children: [
Expanded(
flex: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RichText(
text: TextSpan(
style: const TextStyle(
fontFamily: 'Poppins',
color: Color(0xFF48F3FF),
fontSize: 12,
),
children: [
TextSpan(text: "#${data.hashId!}"),
TextSpan(
text: " | Engine: ${data.engine!}",
),
],
),
),
Text(
data.prodName!,
maxLines: 2,
style: const TextStyle(
color: Colors.white,
fontSize: 14,
),
),
if (data.amc != "0") ...[
Row(
mainAxisSize: MainAxisSize.min,
children: [
SvgPicture.asset(
"assets/svg/tick_ic.svg",
height: 15,
color:
data.amc == "1"
? AppColors.greenICBg
: AppColors.subtitleText,
),
const SizedBox(width: 4),
Text(
"AMC ",
style: TextStyle(
fontSize: 15,
fontFamily: "PoppinsBold",
fontStyle: FontStyle.italic,
fontWeight: FontWeight.w700,
color:
data.amc == "1"
? AppColors.greenICBg
: AppColors.subtitleText,
),
),
Text(
"Protected",
style: TextStyle(
fontSize: 15,
fontFamily: "PoppinsBold",
fontStyle: FontStyle.italic,
fontWeight: FontWeight.w700,
color:
data.amc == "1"
? AppColors.normalText
: AppColors.subtitleText,
),
),
const SizedBox(width: 4),
if (data.amc == "2")
const Icon(
Icons.info_outline,
color: Colors.red,
size: 15,
),
],
),
],
if (data.warranty != "0") ...[
Row(
mainAxisSize: MainAxisSize.min,
children: [
Row(
children: [
SvgPicture.asset(
"assets/svg/tick2_ic.svg",
height: 15,
color:
data.warranty == "1"
? AppColors.warning
: AppColors
.subtitleText,
),
const SizedBox(width: 6),
Text(
"Warranty",
style: TextStyle(
fontSize: 15,
fontFamily: "PoppinsBold",
fontStyle: FontStyle.italic,
fontWeight: FontWeight.w700,
color:
data.warranty == "1"
? AppColors.normalText
: AppColors
.subtitleText,
),
),
SizedBox(width: 6),
if (data.warranty == "2")
const Icon(
Icons.info_outline,
color: Colors.red,
size: 15,
),
],
),
],
),
],
],
),
),
Expanded(
flex: 2,
child: Image.network(
data.prodImg!,
fit: BoxFit.scaleDown,
),
),
],
),
// Show More Details
if (detailsProvider.showMoreDetails) ...[
const Divider(color: Colors.white),
...List.generate(headings.length, (index) {
final sectionTitle = sectionTitles[index];
final sectionItems = headings[index];
final sectionSubItems = subHeadings[index];
return Padding(
padding: const EdgeInsets.only(top: 12),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 25,
width: 25,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
),
child: Center(
child: Text(
index == 0 ? "🔧" : "📍",
style: const TextStyle(fontSize: 14),
),
),
),
const SizedBox(width: 8),
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
sectionTitle,
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 16,
),
),
const SizedBox(height: 8),
...List.generate(sectionItems.length, (
i,
) {
return Padding(
padding: const EdgeInsets.symmetric(
vertical: 3,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
sectionItems[i]??"-",
style: const TextStyle(
fontSize: 14,
color: Color(0xFF48F3FF),
),
),
),
Expanded(
child: Text(
sectionSubItems[i]??"-",
maxLines: 3,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.end,
style: const TextStyle(
fontSize: 14,
color: Colors.white,
),
),
),
],
),
);
}),
],
),
),
],
),
);
}),
],
Center(
child: InkResponse(
onTap:
() =>
detailsProvider.showMoreDetails =
!detailsProvider.showMoreDetails,
child: Container(
width: 125,
margin: const EdgeInsets.only(top: 5),
padding: const EdgeInsets.symmetric(vertical: 6),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: Colors.white,
width: 0.7,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
detailsProvider.showMoreDetails
? "Hide Details"
: "View Details",
style: const TextStyle(
fontFamily: "JakartaMedium",
fontSize: 14,
color: Colors.white,
),
),
const SizedBox(width: 4),
Transform.flip(
flipY: detailsProvider.showMoreDetails,
child: SvgPicture.asset(
"assets/svg/arrow_dropdown.svg",
height: 12,
width: 12,
colorFilter: const ColorFilter.mode(
Colors.white,
BlendMode.srcIn,
),
),
),
],
),
),
),
),
const SizedBox(height: 10),
],
),
),
),
SliverFillRemaining(
hasScrollBody: false,
child: Container(
decoration: const BoxDecoration(
color: AppColors.backgroundRegular,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30),
),
),
padding: const EdgeInsets.fromLTRB(5, 20, 5, 30),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (scheduleList.isNotEmpty) ...[
sectionHeading("Scheduled Services"),
...List.generate(
scheduleList.length,
(i) => _buildListItem(scheduleList[i]),
),
],
if (quotationsList.isNotEmpty) ...[
sectionHeading("Quotations"),
...List.generate(
quotationsList.length,
(i) => _buildListItem1(
quotationsList[i]!.title ?? "-",
quotationsList[i]!.date ?? "-",
),
),
],
if (complaintList.isNotEmpty) ...[
sectionHeading("Complaint Details"),
...List.generate(
1,
(i) => _buildListItem2(complaintList[i]),
),
],
SizedBox(height: 10),
InkResponse(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SelectOrderHelpScreen(accId: widget.accId, sessionId: widget.sessionId))
);
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 14),
child: Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: const Color(0xFFD7F0FF),
borderRadius: BorderRadius.circular(16),
border: Border.all(
width: 1.5,
color: AppColors.buttonColor,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Text(
'Facing Issues?',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: AppColors.amountText,
),
),
Text(
'Raise a ticket to resolve your issues.',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w400,
color: AppColors.subtitleText,
),
),
],
),
SvgPicture.asset(
"assets/svg/requirements.svg",
height: 32,
width: 32,
),
],
),
),
),
),
if (amcQuotationsList.isNotEmpty) ...[
sectionHeading("AMC Quotation Details"),
...List.generate(
amcQuotationsList.length,
(i) => _buildListItem3(amcQuotationsList[i]!),
),
],
],
),
),
),
],
),
),
);
},
);
}
Widget sectionHeading(text) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
text,
style: TextStyle(color: AppColors.nearDarkText, fontSize: 14),
),
InkResponse(
onTap: () async {
var redirectScreen;
switch (text) {
case "Scheduled Services":
redirectScreen = ScheduleListScreen(
accId: widget.accId,
sessionId: widget.sessionId,
genId: widget.genId,
);
break;
case "Quotations":
redirectScreen = QuotationListScreen(
accId: widget.accId,
sessionId: widget.sessionId,
genId: widget.genId,
);
break;
case "Complaint Details":
redirectScreen = ComplaintListScreen(
accId: widget.accId,
sessionId: widget.sessionId,
);
break;
case "AMC Quotation Details":
redirectScreen = AmcQuotationListScreen(
accId: widget.accId,
sessionId: widget.sessionId,
genid: widget.genId,
);
break;
default:
break;
}
await Navigator.push(
context,
MaterialPageRoute(builder: (context) => redirectScreen),
);
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Text(
"See All",
style: TextStyle(color: AppColors.buttonColor, fontSize: 14),
),
),
),
],
),
);
}
Widget _buildListItem(Schedule data) {
return Container(
margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
decoration: BoxDecoration(
color:
data.status == "Scheduled" ? Color(0xFFD7F0FF) : Color(0xFFE0E0E0),
borderRadius: BorderRadius.circular(14),
),
child: Column(
children: [
Container(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
border: Border.all(
color:
data.status == "Scheduled"
? AppColors.buttonColor
: Colors.white,
),
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
if (data.status == "Scheduled") ...[
SvgPicture.asset("assets/svg/calendar_ic.svg"),
SizedBox(width: 8),
],
SizedBox(
child: Column(
children: [
if (data.status == "Completed") ...[
Text(
data.complaintType ?? "-",
style: TextStyle(
fontSize: 14,
color: AppColors.nearDarkText,
),
),
],
Text(
data.date ?? "-",
style: TextStyle(
fontSize: data.status == "Scheduled" ? 14 : 12,
color:
data.status == "Scheduled"
? AppColors.nearDarkText
: Color(0xFF777777),
),
),
],
),
),
Spacer(),
Container(
padding: EdgeInsets.symmetric(vertical: 3, horizontal: 5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color:
data.status == "Scheduled"
? AppColors.successBG
: Color(0xFFFFF8D2),
),
child: Center(
child: Text(
data.status ?? "-",
style: TextStyle(
fontSize: 14,
color:
data.status == "Scheduled"
? AppColors.success
: AppColors.error,
),
),
),
),
],
),
],
),
),
if (data.status == "Scheduled") ...[
Container(
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Upcoming Service Scheduled",
style: TextStyle(
fontSize: 12,
color: AppColors.buttonColor,
),
),
],
),
),
],
],
),
);
}
Widget _buildListItem1(String left, String right) {
return Container(
height: 50,
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [Text(left), Text(right)],
),
);
}
Widget _buildListItem2(Complaints data) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
flex: 7,
child: SizedBox(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RichText(
text: TextSpan(
style: const TextStyle(
fontFamily: 'Poppins',
color: Color(0xFF008CDE),
fontSize: 14,
),
children: [
TextSpan(text: "#${data.id}"),
TextSpan(text: " | ${data.complaintName}"),
],
),
),
Text(
"${data.registredDate}",
style: TextStyle(
color: AppColors.subtitleText,
fontSize: 12,
),
),
],
),
),
),
Expanded(
flex: 3,
child: Container(
padding: EdgeInsets.symmetric(vertical: 6, horizontal: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: AppColors.successBG,
),
child: Center(
child: Text(
"${data.openStatus}",
style: TextStyle(fontSize: 14, color: AppColors.success),
),
),
),
),
],
),
Divider(color: Color(0xFF777777), thickness: 0.3),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 5,
child: Text(
"${data.productName}",
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: const TextStyle(
color: AppColors.nearDarkText,
fontSize: 12,
),
),
),
Expanded(
flex: 5,
child: RichText(
maxLines: 1,
textAlign: TextAlign.right,
text: TextSpan(
style: TextStyle(
fontFamily: 'Poppins',
color: AppColors.subtitleText,
fontSize: 12,
),
children: [
TextSpan(text: "#${data.hashId}"),
TextSpan(text: " | Engine: ${data.modelName}"),
],
),
),
),
],
),
],
),
);
}
Widget _buildListItem3(AmcQuotations data) {
return Container(
margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
decoration: BoxDecoration(
color: data.amcStatus == "1" ? Color(0xFFD7F0FF) : Color(0xFFE0E0E0),
borderRadius: BorderRadius.circular(14),
),
child: Column(
children: [
Container(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
border: Border.all(
color:
data.amcStatus == "1"
? AppColors.buttonColor
: Colors.white,
),
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisSize: MainAxisSize.min,
children: [
SvgPicture.asset(
"assets/svg/tick_ic.svg",
height: 14,
color:
data.amcStatus == "1"
? AppColors.greenICBg
: AppColors.subtitleText,
),
const SizedBox(width: 4),
Text(
"AMC ",
style: TextStyle(
fontSize: 15,
fontFamily: "PoppinsBold",
fontStyle: FontStyle.italic,
fontWeight: FontWeight.w700,
color:
data.amcStatus == "1"
? AppColors.greenICBg
: AppColors.subtitleText,
),
),
Text(
"Protected",
style: TextStyle(
fontSize: 15,
fontFamily: "PoppinsBold",
fontStyle: FontStyle.italic,
fontWeight: FontWeight.w700,
color:
data.amcStatus == "1"
? AppColors.normalText
: AppColors.subtitleText,
),
),
const SizedBox(width: 4),
if (data.amcStatus == "2")
const Icon(
Icons.info_outline,
color: Colors.red,
size: 12,
),
],
),
Container(
padding: EdgeInsets.symmetric(vertical: 3, horizontal: 5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color:
data.amcStatus == "1"
? AppColors.successBG
: Color(0xFFFFF8D2),
),
child: Center(
child: Text(
data.expNote ?? "-",
style: TextStyle(
fontSize: 14,
color:
data.amcStatus == "1"
? AppColors.success
: AppColors.error,
),
),
),
),
],
),
Divider(color: Color(0xFF777777), thickness: 0.3),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Purchased On",
style: TextStyle(
color: AppColors.subtitleText,
fontSize: 12,
),
),
Text(data.purchaseDate!),
],
),
Text(
"₹${data.price}" ?? "-",
style: TextStyle(
color:
data.amcStatus == "1"
? AppColors.buttonColor
: AppColors.nearDarkText,
fontSize: 14,
),
),
],
),
],
),
),
Container(
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
rowText(data.noOfVisits, "No. of Visits"),
rowText(data.noOfOilServices, "No. of Oil Services"),
],
),
),
],
),
);
}
Widget rowText(text1, text2) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
height: 20,
width: 20,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
child: Center(
child: Text(
text1,
style: TextStyle(color: AppColors.nearDarkText, fontSize: 12),
),
),
),
SizedBox(width: 5),
Text(
text2,
style: TextStyle(color: AppColors.nearDarkText, fontSize: 12),
),
],
);
}
}
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/svg.dart';
import 'package:provider/provider.dart';
import '../Notifiers/generatorDetailsProvider.dart';
import '../Utility/AppColors.dart';
class QuotationListScreen extends StatefulWidget {
final accId;
final sessionId;
final genId;
const QuotationListScreen({
super.key,
required this.accId,
required this.sessionId,
required this.genId,
});
@override
State<QuotationListScreen> createState() => _QuotationListScreenState();
}
class _QuotationListScreenState extends State<QuotationListScreen> {
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
final provider = Provider.of<Generatordetailsprovider>(
context,
listen: false,
);
provider.fetchQuotationList(widget.accId, widget.sessionId, widget.genId);
});
}
@override
Widget build(BuildContext context) {
return Consumer<Generatordetailsprovider>(
builder: (context, provider, child) {
final isLoading = provider.isLoading;
final error = provider.errorMessage;
final response = provider.quotationResponse;
final data = response?.serviceQuotation ?? [];
if (isLoading) {
return const Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: Center(
child: CircularProgressIndicator(color: AppColors.buttonColor),
),
);
}
if (error != null) {
return Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: Center(
child: Text(
error,
style: const TextStyle(color: Colors.red, fontSize: 16),
),
),
);
}
if (data == null) {
return const Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: Center(child: Text("No data found.")),
);
}
return RefreshIndicator.adaptive(
color: AppColors.amountText,
onRefresh: () async {
await Future.delayed(const Duration(milliseconds: 600));
},
child: Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: CustomScrollView(
physics: const BouncingScrollPhysics(),
slivers: [
SliverAppBar(
stretch: true,
pinned: true,
expandedHeight: 75,
backgroundColor: AppColors.backgroundRegular,
elevation: 0,
// Remove shadow
automaticallyImplyLeading: false,
toolbarHeight: 0,
// Remove toolbar space
collapsedHeight: 0,
// Completely collapse to 0 height
flexibleSpace: FlexibleSpaceBar(
stretchModes: const [StretchMode.fadeTitle],
background: Container(
decoration: BoxDecoration(
gradient: AppColors.balanceBarGradientA,
),
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 20,
),
child: SizedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
InkResponse(
onTap: () {
HapticFeedback.selectionClick();
Navigator.pop(context, true);
},
child: SvgPicture.asset(
"assets/svg/appbar_back.svg",
height: 25,
),
),
SizedBox(width: 10),
Expanded(
flex: 4,
child: InkResponse(
onTap: () {
HapticFeedback.selectionClick();
Navigator.pop(context, true);
},
child: Text(
"Quotations List",
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
fontSize: 16,
color: Colors.white,
height: 1.1,
),
),
),
),
],
),
),
),
),
),
),
),
SliverToBoxAdapter(
child: Container(
color: Color(0xFF4076FF),
child: Container(
decoration: const BoxDecoration(
color: AppColors.backgroundRegular,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 4),
ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: data!.length,
itemBuilder: (context, j) {
return Container(
padding: const EdgeInsets.symmetric(
vertical: 10,
horizontal: 10,
),
margin: const EdgeInsets.symmetric(
vertical: 5,
horizontal: 10,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Expanded(
flex: 2,
child: Text(
data[j].title ?? "-",
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
Spacer(),
Expanded(
flex: 1,
child: Text(
data[j].date ?? "-",
textAlign: TextAlign.right,
style: TextStyle(),
),
),
],
),
);
},
),
],
),
),
),
),
],
),
),
);
},
);
}
}
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/svg.dart';
import 'package:gen_service/Notifiers/generatorDetailsProvider.dart';
import 'package:provider/provider.dart';
import '../Utility/AppColors.dart';
class ScheduleListScreen extends StatefulWidget {
final accId;
final sessionId;
final genId;
const ScheduleListScreen({
super.key,
required this.accId,
required this.sessionId,
required this.genId,
});
@override
State<ScheduleListScreen> createState() => _ScheduleListScreenState();
}
class _ScheduleListScreenState extends State<ScheduleListScreen> {
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
final provider = Provider.of<Generatordetailsprovider>(
context,
listen: false,
);
provider.fetchScheduleList(widget.accId, widget.sessionId,widget.genId);
});
}
@override
Widget build(BuildContext context) {
return Consumer<Generatordetailsprovider>(
builder: (context, provider, child) {
final isLoading = provider.isLoading;
final error = provider.errorMessage;
final response = provider.scheduleResponse;
final data = response?.allScheduleServices??[];
if (isLoading) {
return const Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: Center(
child: CircularProgressIndicator(color: AppColors.buttonColor),
),
);
}
if (error != null) {
return Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: Center(
child: Text(
error,
style: const TextStyle(color: Colors.red, fontSize: 16),
),
),
);
}
if (data == null) {
return const Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: Center(child: Text("No data found.")),
);
}
return RefreshIndicator.adaptive(
color: AppColors.amountText,
onRefresh: () async {
await Future.delayed(const Duration(milliseconds: 600));
},
child: Scaffold(
backgroundColor: AppColors.backgroundRegular,
body: CustomScrollView(
physics: const BouncingScrollPhysics(),
slivers: [
SliverAppBar(
stretch: true,
pinned: true,
expandedHeight: 75,
backgroundColor: AppColors.backgroundRegular,
elevation: 0,
// Remove shadow
automaticallyImplyLeading: false,
toolbarHeight: 0,
// Remove toolbar space
collapsedHeight: 0,
// Completely collapse to 0 height
flexibleSpace: FlexibleSpaceBar(
stretchModes: const [StretchMode.fadeTitle],
background: Container(
decoration: BoxDecoration(
gradient: AppColors.balanceBarGradientA,
),
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 20,
),
child: SizedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
InkResponse(
onTap: () {
HapticFeedback.selectionClick();
Navigator.pop(context, true);
},
child: SvgPicture.asset(
"assets/svg/appbar_back.svg",
height: 25,
),
),
SizedBox(width: 10),
Expanded(
flex: 4,
child: InkResponse(
onTap: () {
HapticFeedback.selectionClick();
Navigator.pop(context, true);
},
child: Text(
"Schedule List",
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
fontSize: 16,
color: Colors.white,
height: 1.1,
),
),
),
),
],
),
),
),
),
),
),
),
SliverToBoxAdapter(
child: Container(
color: Color(0xFF4076FF),
child: Container(
decoration: const BoxDecoration(
color: AppColors.backgroundRegular,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 4),
ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: data!.length,
itemBuilder: (context, j) {
return Container(
margin: const EdgeInsets.symmetric(
vertical: 5,
horizontal: 10,
),
decoration: BoxDecoration(
color:
data[j].status == "Scheduled"
? Color(0xFFD7F0FF)
: Color(0xFFE0E0E0),
borderRadius: BorderRadius.circular(14),
),
child: Column(
children: [
Container(
padding: const EdgeInsets.symmetric(
vertical: 10,
horizontal: 10,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
border: Border.all(
color:
data[j].status == "Scheduled"
? AppColors.buttonColor
: Colors.white,
),
),
child: Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
if (data[j].status ==
"Scheduled") ...[
SvgPicture.asset(
"assets/svg/calendar_ic.svg",
),
SizedBox(width: 8),
],
SizedBox(
child: Column(
children: [
if (data[j].status ==
"Completed") ...[
Text(
data[j].complaintType ??
"-",
style: TextStyle(
fontSize: 14,
color:
AppColors
.nearDarkText,
),
),
],
Text(
data[j].dueDate ?? "-",
style: TextStyle(
fontSize:
data[j].status ==
"Scheduled"
? 14
: 12,
color:
data[j].status ==
"Scheduled"
? AppColors
.nearDarkText
: Color(
0xFF777777,
),
),
),
],
),
),
Spacer(),
Container(
padding: EdgeInsets.symmetric(
vertical: 3,
horizontal: 5,
),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(8),
color:
data[j].status == "Scheduled"
? AppColors.successBG
: Color(0xFFFFF8D2),
),
child: Center(
child: Text(
data[j].status ?? "-",
style: TextStyle(
fontSize: 14,
color:
data[j].status ==
"Scheduled"
? AppColors
.success
: AppColors.error,
),
),
),
),
],
),
],
),
),
if (data[j].status == "Scheduled") ...[
Container(
padding: EdgeInsets.symmetric(
vertical: 10,
horizontal: 10,
),
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Text(
"Upcoming Service Scheduled",
style: TextStyle(
fontSize: 12,
color: AppColors.buttonColor,
),
),
],
),
),
],
],
),
);
},
),
],
),
),
),
),
],
),
),
);
},
);
}
}
......@@ -17,9 +17,13 @@ const profileDetailsUrl = "${baseUrl2}Rental_Home/profile_details";
const transactionsUrl = "${baseUrl}all_transactions";
const paymentDetailUrl = "${baseUrl}payment_details";
const billDetailUrl = "${baseUrl}bill_details";
const generatorDetailsUrl = "${baseUrl}generator_details";
const scheduleListUrl = "${baseUrl}all_schedule_services";
const quotationListUrl = "${baseUrl}all_quoatations";
const amcQuoteListUrl = "${baseUrl}all_amc_quotations";
const complaintListUrl = "${baseUrl}all_complaint_list";
/// Help and complaints
const complaintListUrl = "${baseUrl}all_complaint_list";
const addComplaintUrl = "${baseUrl}add_complaint";
const generatorListUrl = "${baseUrl}generator_list";
const complaintDropdownsUrl = "${baseUrl}complaint_dropdowns";
\ No newline at end of file
......@@ -4,6 +4,11 @@ import 'package:flutter/material.dart';
import 'package:gen_service/Models/HelpAndComplaintModels/ComplaintListResponse.dart';
import 'package:gen_service/Models/TransactionModels/BillDetailResponse.dart';
import 'package:gen_service/Models/TransactionModels/PaymentDetailResponse.dart';
import 'package:gen_service/Models/amcQuotationListResponse.dart';
import 'package:gen_service/Models/complaintListResponse.dart';
import 'package:gen_service/Models/generatorDetailsResponse.dart';
import 'package:gen_service/Models/quotationListResponse.dart';
import 'package:gen_service/Models/scheduleListResponse.dart';
import '../Models/AuthResponse.dart';
import '../Models/CommonResponse.dart';
import '../Models/DashboardResponse.dart';
......@@ -349,6 +354,131 @@ class ApiCalling {
// }
// }
//
static Future<generatorDetailsResponse?> generatorDetailsAPI(
String accId,
String sessionId,
genId
) async {
try {
Map<String, String> data = {
"acc_id": accId,
"session_id": sessionId,
'gen_id':genId
};
final res = await post(data, generatorDetailsUrl, {});
if (res != null) {
print(res.body);
return generatorDetailsResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint("❌ Dashboard API Error: $e");
return null;
}
}
static Future<scheduleListResponse?> scheduleListAPI(
String accId,
String sessionId,
gen_id
) async {
debugPrint("###############################Transaction Api calling ");
try {
Map<String, String> data = {
"acc_id": accId,
"session_id": sessionId,
"gen_id": gen_id,
};
final res = await post(data, scheduleListUrl, {});
print(data);
if (res != null) {
return scheduleListResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint("❌ Dashboard API Error: $e");
return null;
}
}
static Future<quotationListResponse?> quotationListAPI(
String accId,
String sessionId,
genID
) async {
try {
Map<String, String> data = {
"acc_id": accId,
"session_id": sessionId,
"gen_id": genID,
};
final res = await post(data, quotationListUrl, {});
if (res != null) {
return quotationListResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint("❌ Dashboard API Error: $e");
return null;
}
}
static Future<complaintListResponse?> complaintListAPI(
String accId,
String sessionId,
) async {
debugPrint("############################### Api calling ");
try {
Map<String, String> data = {
"acc_id": accId,
"session_id": sessionId,
};
final res = await post(data, complaintListUrl, {});
print(res!.body);
if (res != null) {
return complaintListResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint("❌ Dashboard API Error: $e");
return null;
}
}
static Future<amcQuotationListResponse?> amcQuoteListAPI(
String accId,
String sessionId,
genID
) async {
debugPrint("############################### Api calling ");
try {
Map<String, String> data = {
"acc_id": accId,
"session_id": sessionId,
"gen_id": genID,
};
final res = await post(data, amcQuoteListUrl, {});
if (res != null) {
return amcQuotationListResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint("❌ Dashboard API Error: $e");
return null;
}
}
}
......@@ -5,6 +5,7 @@ import 'package:provider/provider.dart';
import 'Notifiers/DashboardProvider.dart';
import 'Notifiers/HelpAndComplaintProvider.dart';
import 'Notifiers/generatorDetailsProvider.dart';
import 'Notifiers/theme_provider.dart';
import 'Screens/AuthScreen/LoginScreen.dart';
import 'Screens/SplashScreen.dart';
......@@ -25,6 +26,7 @@ class MyApp extends StatelessWidget {
ChangeNotifierProvider(create: (_) => DashboardProvider()),
ChangeNotifierProvider(create: (_) => TransactionsProvider()),
ChangeNotifierProvider(create: (_) => HelpAndComplaintProvider()),
ChangeNotifierProvider(create: (_) => Generatordetailsprovider()),
],
child: Consumer<ThemeProvider>(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment