contact us

This commit is contained in:
Rajshinde046
2024-05-02 12:54:15 +05:30
parent 6c358ce8b6
commit 1951f5b9a3
3 changed files with 400 additions and 27 deletions

View File

@@ -1,4 +1,5 @@
import 'dart:developer';
import 'dart:ffi';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@@ -6,6 +7,8 @@ import 'package:gap/gap.dart';
import 'package:get/get.dart';
import 'package:traderscircuit/controller/contact_us_controller.dart';
import 'package:traderscircuit/model/ContactUsModel/contact_us_cat_model.dart';
import 'package:traderscircuit/model/ContactUsModel/contact_us_model.dart'
as ContactModel;
import 'package:traderscircuit/model/ContactUsModel/contact_us_model.dart';
import 'package:traderscircuit/resources/routes/route_name.dart';
import 'package:traderscircuit/view_model/ContactUsApi/contact_us_api.dart';
@@ -22,6 +25,10 @@ class ContactUsMainScreen extends StatefulWidget {
State<ContactUsMainScreen> createState() => _ContactUsMainScreenState();
}
Map<int, List<ContactModel.Data>> status1Map = {};
Map<int, List<ContactModel.Data>> status2Map = {};
Map<int, List<ContactModel.Data>> status3Map = {};
class _ContactUsMainScreenState extends State<ContactUsMainScreen> {
ContactUsController contactUsController = Get.put(ContactUsController());
@@ -36,12 +43,32 @@ class _ContactUsMainScreenState extends State<ContactUsMainScreen> {
contactUsController.contactModel = ContactUsModel.fromJson(value.data);
contactUsController.isLoading.value = false;
log(contactUsController.isLoading.value.toString());
status1Map.clear();
status2Map.clear();
status3Map.clear();
// Iterate over the data and categorize them based on their status
for (var item in contactUsController.contactModel!.data!) {
if (item.status == 1) {
status1Map.putIfAbsent(item.status!, () => []).add(item);
} else if (item.status == 2) {
status2Map.putIfAbsent(item.status!, () => []).add(item);
} else if (item.status == 3) {
status3Map.putIfAbsent(item.status!, () => []).add(item);
}
}
});
});
super.initState();
}
@override
void dispose() {
status1Map.clear();
status2Map.clear();
status3Map.clear();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Obx(() => DefaultTabController(
@@ -115,9 +142,15 @@ class _ContactUsMainScreenState extends State<ContactUsMainScreen> {
Tab(
text:
"All Tickets (${contactUsController.contactModel.data!.length.toString()})"),
Tab(text: "Open Tickets (2)"),
Tab(text: "Closed (1)"),
Tab(text: "Resolved (1)"),
Tab(
text:
"Open Tickets (${status1Map.values.expand((list) => list).length.toString()})"),
Tab(
text:
"Closed (${status2Map.values.expand((list) => list).length.toString()})"),
Tab(
text:
"Resolved (${status3Map.values.expand((list) => list).length.toString()})"),
],
),
SizedBox(
@@ -131,19 +164,25 @@ class _ContactUsMainScreenState extends State<ContactUsMainScreen> {
index, "ALL");
}),
ListView.builder(
itemCount: dataL.length,
itemCount: status1Map.values
.expand((list) => list)
.length,
itemBuilder: (ctx, index) {
return ticketCardWidget(
index, "OPEN");
}),
ListView.builder(
itemCount: dataL.length,
itemCount: status2Map.values
.expand((list) => list)
.length,
itemBuilder: (ctx, index) {
return ticketCardWidget(
index, "CLOSED");
}),
ListView.builder(
itemCount: dataL.length,
itemCount: status3Map.values
.expand((list) => list)
.length,
itemBuilder: (ctx, index) {
return ticketCardWidget(
index, "RESOLVED");
@@ -162,7 +201,8 @@ class _ContactUsMainScreenState extends State<ContactUsMainScreen> {
Widget ticketCardWidget(index, type) {
ContactUsController contactUsController = Get.put(ContactUsController());
return contactUsController.contactModel.data!.elementAt(index).status != 0
return contactUsController.contactModel.data!.elementAt(index).status != 0 &&
type == "ALL"
? InkWell(
onTap: () {
contactUsController.attachmentFileDetailsList.clear();
@@ -295,8 +335,7 @@ Widget ticketCardWidget(index, type) {
),
),
)
: contactUsController.contactModel.data!.elementAt(index).status != 1 &&
type != "ALL"
: type == "OPEN"
? InkWell(
onTap: () {
contactUsController.attachmentFileDetailsList.clear();
@@ -332,24 +371,53 @@ Widget ticketCardWidget(index, type) {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
text16W600(contactUsController.contactModel.data!
text16W600(status1Map.values
.expand((list) => list)
.elementAt(index)
.ticketCategoryXid
.toString()),
Row(
children: [
text16W500(dataL[index]["type"],
clr: dataL[index]["type"] == "OPEN"
text16W500(
status1Map.values
.expand((list) => list)
.elementAt(index)
.status
.toString() ==
"1"
? "OPEN"
: "Open",
clr: status1Map.values
.expand((list) => list)
.elementAt(index)
.status
.toString() ==
"1"
? const Color(0xFFFFAD31)
: dataL[index]["type"] == "CLOSED"
: status1Map.values
.expand((list) => list)
.elementAt(index)
.status
.toString() ==
"2"
? const Color(0xFF95CCFF)
: const Color(0xFF34C759)),
const Gap(8),
CircleAvatar(
radius: 10,
backgroundColor: dataL[index]["type"] == "OPEN"
backgroundColor: status1Map.values
.expand((list) => list)
.elementAt(index)
.status
.toString() ==
"1"
? const Color(0xFFFFAD31)
: dataL[index]["type"] == "CLOSED"
: status1Map.values
.expand((list) => list)
.elementAt(index)
.status
.toString() ==
"2"
? const Color(0xFF95CCFF)
: const Color(0xFF34C759),
child: const Center(
@@ -365,9 +433,18 @@ Widget ticketCardWidget(index, type) {
],
),
const Gap(10),
text16W600(dataL[index]["date"]),
text16W600(status1Map.values
.expand((list) => list)
.elementAt(index)
.createdAt
.toString()),
const Gap(5),
text16W400(dataL[index]["category"]),
text16W400(status1Map.values
.expand((list) => list)
.elementAt(index)
.ticketCategory!
.name
.toString()),
const Gap(22),
Container(
padding: const EdgeInsets.symmetric(
@@ -384,7 +461,12 @@ Widget ticketCardWidget(index, type) {
),
),
child: Center(
child: text16W400(dataL[index]["desc"],
child: text16W400(
status1Map.values
.expand((list) => list)
.elementAt(index)
.description
.toString(),
clr: const Color(0xFF9E9E9E),
textOver: TextOverflow.ellipsis),
),
@@ -394,7 +476,298 @@ Widget ticketCardWidget(index, type) {
),
),
)
: SizedBox();
: type == "CLOSED"
? InkWell(
onTap: () {
contactUsController.attachmentFileDetailsList.clear();
contactUsController.attachmentPathNameDetailsList.clear();
Get.toNamed(RouteName.contactUsMainDetails);
},
child: Container(
width: Get.width,
height: 190,
margin:
EdgeInsets.only(bottom: 18, top: index == 0 ? 15 : 0),
decoration: ShapeDecoration(
gradient: LinearGradient(
begin: const Alignment(0.98, -0.21),
end: const Alignment(-0.98, 0.21),
colors: [
Colors.white.withOpacity(0.03999999910593033),
Colors.white.withOpacity(0.05999999865889549)
],
),
shape: RoundedRectangleBorder(
side: const BorderSide(
width: 1, color: Color(0xFF393939)),
borderRadius: BorderRadius.circular(8),
),
),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 15,
horizontal: 10,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
text16W600(status2Map.values
.expand((list) => list)
.elementAt(index)
.ticketCategoryXid
.toString()),
Row(
children: [
text16W500(
status2Map.values
.expand((list) => list)
.elementAt(index)
.status
.toString() ==
"2"
? "CLOSED"
: "Closed",
clr: status2Map.values
.expand((list) => list)
.elementAt(index)
.status
.toString() ==
"1"
? const Color(0xFFFFAD31)
: status2Map.values
.expand((list) => list)
.elementAt(index)
.status
.toString() ==
"2"
? const Color(0xFF95CCFF)
: const Color(0xFF34C759)),
const Gap(8),
CircleAvatar(
radius: 10,
backgroundColor: status2Map.values
.expand((list) => list)
.elementAt(index)
.status
.toString() ==
"1"
? const Color(0xFFFFAD31)
: status2Map.values
.expand((list) => list)
.elementAt(index)
.status
.toString() ==
"2"
? const Color(0xFF95CCFF)
: const Color(0xFF34C759),
child: const Center(
child: Icon(
Icons.check_rounded,
size: 15,
color: Colors.white,
),
),
)
],
),
],
),
const Gap(10),
text16W600(status2Map.values
.expand((list) => list)
.elementAt(index)
.createdAt
.toString()),
const Gap(5),
text16W400(status2Map.values
.expand((list) => list)
.elementAt(index)
.ticketCategory!
.name
.toString()),
const Gap(22),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 12,
),
width: Get.width,
height: 50,
decoration: ShapeDecoration(
color:
Colors.black.withOpacity(0.03999999910593033),
shape: RoundedRectangleBorder(
side: const BorderSide(
width: 1, color: Color(0xFF393939)),
borderRadius: BorderRadius.circular(8),
),
),
child: Center(
child: text16W400(
status2Map.values
.expand((list) => list)
.elementAt(index)
.description
.toString(),
clr: const Color(0xFF9E9E9E),
textOver: TextOverflow.ellipsis),
),
)
],
),
),
),
)
: type == "RESOLVED"
? InkWell(
onTap: () {
contactUsController.attachmentFileDetailsList.clear();
contactUsController.attachmentPathNameDetailsList
.clear();
Get.toNamed(RouteName.contactUsMainDetails);
},
child: Container(
width: Get.width,
height: 190,
margin: EdgeInsets.only(
bottom: 18, top: index == 0 ? 15 : 0),
decoration: ShapeDecoration(
gradient: LinearGradient(
begin: const Alignment(0.98, -0.21),
end: const Alignment(-0.98, 0.21),
colors: [
Colors.white.withOpacity(0.03999999910593033),
Colors.white.withOpacity(0.05999999865889549)
],
),
shape: RoundedRectangleBorder(
side: const BorderSide(
width: 1, color: Color(0xFF393939)),
borderRadius: BorderRadius.circular(8),
),
),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 15,
horizontal: 10,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
text16W600(status3Map.values
.expand((list) => list)
.elementAt(index)
.ticketCategoryXid
.toString()),
Row(
children: [
text16W500(
status3Map.values
.expand((list) => list)
.elementAt(index)
.status
.toString() ==
"3"
? "RESOLVED"
: "Resolved",
clr: status3Map.values
.expand((list) => list)
.elementAt(index)
.status
.toString() ==
"1"
? const Color(0xFFFFAD31)
: status3Map.values
.expand(
(list) => list)
.elementAt(index)
.status
.toString() ==
"2"
? const Color(0xFF95CCFF)
: const Color(0xFF34C759)),
const Gap(8),
CircleAvatar(
radius: 10,
backgroundColor: status3Map.values
.expand((list) => list)
.elementAt(index)
.status
.toString() ==
"1"
? const Color(0xFFFFAD31)
: status3Map.values
.expand((list) => list)
.elementAt(index)
.status
.toString() ==
"2"
? const Color(0xFF95CCFF)
: const Color(0xFF34C759),
child: const Center(
child: Icon(
Icons.check_rounded,
size: 15,
color: Colors.white,
),
),
)
],
),
],
),
const Gap(10),
text16W600(status3Map.values
.expand((list) => list)
.elementAt(index)
.createdAt
.toString()),
const Gap(5),
text16W400(status3Map.values
.expand((list) => list)
.elementAt(index)
.ticketCategory!
.name
.toString()),
const Gap(22),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 12,
),
width: Get.width,
height: 50,
decoration: ShapeDecoration(
color: Colors.black
.withOpacity(0.03999999910593033),
shape: RoundedRectangleBorder(
side: const BorderSide(
width: 1, color: Color(0xFF393939)),
borderRadius: BorderRadius.circular(8),
),
),
child: Center(
child: text16W400(
status3Map.values
.expand((list) => list)
.elementAt(index)
.description
.toString(),
clr: const Color(0xFF9E9E9E),
textOver: TextOverflow.ellipsis),
),
)
],
),
),
),
)
: SizedBox();
}
List<dynamic> dataL = [

View File

@@ -79,16 +79,16 @@ class CreateTicketBottomSheet {
TicketConfirmedBottomSheet().bottomSheet(context);
} else if (resp.status == ResponseStatus.PRIVATE) {
Get.back();
String? message = resp.data['message'];
Utils.showToast("$message");
List? message = resp.data['message'];
Utils.showToast("${message!.first}");
} else if (resp.status == ResponseStatus.ERROR) {
Get.back();
String? message = resp.data['message'];
Utils.showToast("$message");
List? message = resp.data['message'];
Utils.showToast("${message!.first}");
} else {
Get.back();
String? message = resp.data['message'];
Utils.showToast("$message");
List? message = resp.data['message'];
Utils.showToast("${message!.first}");
}
}
}

View File

@@ -46,7 +46,7 @@ class ContactUsApi {
Future<ResponseData<dynamic>> getContactUsData() async {
final response =
await NetworkApiServices().getApi(ApiUrls.getcontactus, isAuth: true);
log(response.data.toString());
// log(response.data.toString());
if (response.status == ResponseStatus.SUCCESS) {
Map<String, dynamic> responseData =
Map<String, dynamic>.from(response.data);