first commit
This commit is contained in:
328
lib/view/account/help/create_request.dart
Normal file
328
lib/view/account/help/create_request.dart
Normal file
@@ -0,0 +1,328 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
import '../../../constants/color_constants.dart';
|
||||
import '../../../constants/font_constants.dart';
|
||||
import '../../../domain/provider/profile/create_request.dart';
|
||||
import '../../../widgets/text_widget.dart';
|
||||
import 'request_page.dart';
|
||||
|
||||
class Help_Support extends StatefulWidget {
|
||||
const Help_Support({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<Help_Support> createState() => _Help_SupportState();
|
||||
}
|
||||
|
||||
class _Help_SupportState extends State<Help_Support> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
value: const SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.white,
|
||||
statusBarIconBrightness: Brightness.dark,
|
||||
statusBarBrightness: Brightness.light,
|
||||
),
|
||||
child: ChangeNotifierProvider(
|
||||
create: (_) => CustomerRequestProvider(),
|
||||
builder: (context, child) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.read<CustomerRequestProvider>().fetchCustomerRequests();
|
||||
});
|
||||
|
||||
return Consumer<CustomerRequestProvider>(
|
||||
builder: (context, provider, _) {
|
||||
return SafeArea(
|
||||
top: false,
|
||||
child: PopScope(
|
||||
canPop: true,
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (!didPop) {
|
||||
Get.back();
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.grey[100],
|
||||
|
||||
/// APPBAR
|
||||
appBar: AppBar(
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.white,
|
||||
surfaceTintColor: Colors.white,
|
||||
leadingWidth: 200,
|
||||
leading: Row(
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () =>
|
||||
Navigator.of(context).pop(),
|
||||
icon: const Icon(Icons.arrow_back,
|
||||
color: Colors.black),
|
||||
),
|
||||
const Expanded(
|
||||
child: ReusableTextWidget(
|
||||
text: "Help & Support",
|
||||
color: Colors.black,
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
textAlign: TextAlign.start,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
/// BODY
|
||||
body: provider.isLoading
|
||||
? ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: 5,
|
||||
itemBuilder: (_, index) => Container(
|
||||
margin:
|
||||
const EdgeInsets.symmetric(vertical: 8),
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius:
|
||||
BorderRadius.circular(14),
|
||||
),
|
||||
child: Shimmer.fromColors(
|
||||
baseColor: Colors.grey.shade300,
|
||||
highlightColor:
|
||||
Colors.grey.shade100,
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 18,
|
||||
color: Colors.white,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 14,
|
||||
color: Colors.white,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Container(
|
||||
width: 80,
|
||||
height: 14,
|
||||
color: Colors.white,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
/// EMPTY STATE
|
||||
: provider.requests.isEmpty
|
||||
? Center(
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 160,
|
||||
child: Lottie.asset(
|
||||
'assets/lotties/help.json',
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const ReusableTextWidget(
|
||||
text: "No requests found",
|
||||
color: Colors.black,
|
||||
fontFamily:
|
||||
FontConstants.fontFamily,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
/// LIST
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: provider.requests.length,
|
||||
itemBuilder: (context, index) {
|
||||
final request =
|
||||
provider.requests[index];
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(
|
||||
bottom: 12),
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius:
|
||||
BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black
|
||||
.withOpacity(0.04),
|
||||
blurRadius: 8,
|
||||
offset:
|
||||
const Offset(0, 3),
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
||||
/// TOP ROW
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment
|
||||
.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child:
|
||||
ReusableTextWidget(
|
||||
text:
|
||||
"Subject : ${request.subject}",
|
||||
color: Colors.black,
|
||||
fontFamily:
|
||||
FontConstants
|
||||
.fontFamily,
|
||||
fontSize: 14,
|
||||
fontWeight:
|
||||
FontWeight.bold,
|
||||
overflow:
|
||||
TextOverflow
|
||||
.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ReusableTextWidget(
|
||||
text: request.created
|
||||
.split('T')
|
||||
.first,
|
||||
color: Colors.grey,
|
||||
fontFamily:
|
||||
FontConstants
|
||||
.fontFamily,
|
||||
fontSize: 11,
|
||||
fontWeight:
|
||||
FontWeight.w500,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
/// REMARK
|
||||
ReusableTextWidget(
|
||||
text:
|
||||
"Remarks : ${request.remarks}",
|
||||
color: Colors.black87,
|
||||
fontFamily:
|
||||
FontConstants.fontFamily,
|
||||
fontSize: 13,
|
||||
fontWeight:
|
||||
FontWeight.normal,
|
||||
overflow:
|
||||
TextOverflow.ellipsis,
|
||||
maxLines: 2,
|
||||
),
|
||||
|
||||
const SizedBox(height: 10),
|
||||
|
||||
/// STATUS BADGE
|
||||
Row(
|
||||
children: [
|
||||
const ReusableTextWidget(
|
||||
text: "Status : ",
|
||||
color: Colors.black,
|
||||
fontFamily:
|
||||
FontConstants
|
||||
.fontFamily,
|
||||
fontSize: 13,
|
||||
),
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets
|
||||
.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: request
|
||||
.status ==
|
||||
1
|
||||
? Colors.green
|
||||
.withOpacity(
|
||||
0.1)
|
||||
: Colors.red
|
||||
.withOpacity(
|
||||
0.1),
|
||||
borderRadius:
|
||||
BorderRadius
|
||||
.circular(20),
|
||||
),
|
||||
child: ReusableTextWidget(
|
||||
text: request.status ==
|
||||
1
|
||||
? "Completed"
|
||||
: "Pending",
|
||||
color: request.status ==
|
||||
1
|
||||
? Colors.green
|
||||
: Colors.red,
|
||||
fontFamily:
|
||||
FontConstants
|
||||
.fontFamily,
|
||||
fontSize: 11,
|
||||
fontWeight:
|
||||
FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
/// FAB
|
||||
floatingActionButton: FloatingActionButton(
|
||||
elevation: 4,
|
||||
onPressed: () async {
|
||||
final result = await Get.to(
|
||||
() => const CustomerRequestPage(),
|
||||
);
|
||||
|
||||
if (result == true) {
|
||||
context
|
||||
.read<
|
||||
CustomerRequestProvider>()
|
||||
.fetchCustomerRequests();
|
||||
}
|
||||
},
|
||||
backgroundColor:
|
||||
ColorConstants.primaryColor,
|
||||
child: const Icon(Icons.add,
|
||||
color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
230
lib/view/account/help/request_page.dart
Normal file
230
lib/view/account/help/request_page.dart
Normal file
@@ -0,0 +1,230 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../../constants/color_constants.dart';
|
||||
import '../../../constants/font_constants.dart';
|
||||
import '../../../domain/provider/profile/create_request.dart';
|
||||
import '../../../modules/profile/customer_request.dart';
|
||||
import '../../../widgets/text_widget.dart';
|
||||
|
||||
class CustomerRequestPage extends StatefulWidget {
|
||||
const CustomerRequestPage({super.key});
|
||||
|
||||
@override
|
||||
State<CustomerRequestPage> createState() => _CustomerRequestPageState();
|
||||
}
|
||||
|
||||
class _CustomerRequestPageState extends State<CustomerRequestPage> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final TextEditingController subjectController = TextEditingController();
|
||||
final TextEditingController remarkController = TextEditingController();
|
||||
final CustomerRequestProvider provider = CustomerRequestProvider();
|
||||
|
||||
Future<void> _submitRequest() async {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
final model = CustomerRequestModel(
|
||||
referencedate: DateTime.now().toUtc().toIso8601String(),
|
||||
referencetype: "",
|
||||
customerid: 6164,
|
||||
tenantid: 0,
|
||||
locationid: 0,
|
||||
subject: subjectController.text.trim(),
|
||||
remarks: remarkController.text.trim(),
|
||||
status: 0,
|
||||
apptypeid: 98,
|
||||
);
|
||||
|
||||
final success = await provider.sendRequest(
|
||||
subjectController.text.trim(),
|
||||
remarkController.text.trim(),
|
||||
);
|
||||
|
||||
if (success) {
|
||||
Fluttertoast.showToast(
|
||||
msg: "Request submitted successfully!",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.TOP,
|
||||
backgroundColor: Colors.green,
|
||||
textColor: Colors.white,
|
||||
fontSize: 14,
|
||||
);
|
||||
|
||||
Navigator.pop(context, true);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text("Failed to submit request!")),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
subjectController.dispose();
|
||||
remarkController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
top: false,
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.grey[100],
|
||||
appBar: AppBar(
|
||||
elevation: 0,
|
||||
leadingWidth: 200,
|
||||
leading: Row(
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
icon: const Icon(Icons.arrow_back, color: Colors.black),
|
||||
),
|
||||
const Expanded(
|
||||
child: ReusableTextWidget(
|
||||
text: "Help & Support",
|
||||
color: Colors.black,
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
textAlign: TextAlign.start,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
),
|
||||
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: SingleChildScrollView(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(18),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.05),
|
||||
blurRadius: 10,
|
||||
spreadRadius: 2,
|
||||
offset: const Offset(0, 4),
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
||||
/// Your Requested Text Widget Usage
|
||||
ReusableTextWidget(
|
||||
text: "Customer Support",
|
||||
color: Colors.black.withOpacity(0.7),
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
/// SUBJECT
|
||||
const ReusableTextWidget(
|
||||
text: "Subject",
|
||||
color: Colors.black,
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
TextFormField(
|
||||
controller: subjectController,
|
||||
decoration: InputDecoration(
|
||||
hintText: "Enter subject",
|
||||
filled: true,
|
||||
fillColor: Colors.grey[100],
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 14, vertical: 14),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
),
|
||||
validator: (value) =>
|
||||
value!.isEmpty ? "Please enter subject" : null,
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
/// REMARK
|
||||
const ReusableTextWidget(
|
||||
text: "Remark",
|
||||
color: Colors.black,
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
TextFormField(
|
||||
controller: remarkController,
|
||||
maxLines: 4,
|
||||
decoration: InputDecoration(
|
||||
hintText: "Enter your remark",
|
||||
filled: true,
|
||||
fillColor: Colors.grey[100],
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 14, vertical: 14),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
),
|
||||
validator: (value) =>
|
||||
value!.isEmpty ? "Please enter remark" : null,
|
||||
),
|
||||
|
||||
const SizedBox(height: 30),
|
||||
|
||||
/// SUBMIT BUTTON
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: _submitRequest,
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 3,
|
||||
backgroundColor: ColorConstants.primaryColor,
|
||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
"Submit Request",
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user