fist commit ftc staff app clone
This commit is contained in:
@@ -0,0 +1,202 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:ftc_mobile_app/ftc_mobile_app.dart';
|
||||
import 'package:ftc_mobile_app/models/clients/documents_list_model.dart';
|
||||
import 'package:ftc_mobile_app/models/profileData/user_data.dart';
|
||||
import 'package:ftc_mobile_app/view/custom_widgets/custom_app_bar_with_action.dart';
|
||||
import 'package:ftc_mobile_app/view/custom_widgets/edit_icon.dart';
|
||||
import 'package:ftc_mobile_app/view/screens/clientsListing/widgets/search_bar_widget.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class DocumentsListScreen extends StatefulWidget {
|
||||
final UserData userData;
|
||||
|
||||
const DocumentsListScreen({Key? key, required this.userData})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<DocumentsListScreen> createState() => _DocumentsListScreenState();
|
||||
}
|
||||
|
||||
class _DocumentsListScreenState extends State<DocumentsListScreen> {
|
||||
late final DocumentsListScreenController controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
controller = Get.put(DocumentsListScreenController(widget.userData));
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: CustomAppColors.kPrimaryColor,
|
||||
appBar: _appBar(context),
|
||||
body: Column(
|
||||
children: [
|
||||
SearchBarWidget(
|
||||
controller: controller.searchTEC,
|
||||
onSearchTextChange: controller.onSearch,
|
||||
),
|
||||
Expanded(
|
||||
child: Obx(
|
||||
() {
|
||||
return controller.documentsList.isEmpty
|
||||
? FrequentFunctions.centerText(text: "No data found")
|
||||
: listView();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
AppBar _appBar(BuildContext context) {
|
||||
return CustomAppBarWithAction(
|
||||
context,
|
||||
titleText: "Documents",
|
||||
actionText: '+ Add New',
|
||||
onActionTap: () async {
|
||||
dynamic response = await Navigator.pushNamed(
|
||||
context, CustomRouteNames.kAddNewDocumentScreenRoute,
|
||||
arguments: controller.serviceUser.value);
|
||||
if (response is DocumentModel) {
|
||||
controller.documentsList.insert(0, response);
|
||||
controller.documentsList.refresh();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _tableHeading(String text) {
|
||||
return TableCell(
|
||||
child: Padding(
|
||||
padding: REdgeInsets.symmetric(horizontal: 12, vertical: 12),
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 12.sp,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget listView() {
|
||||
return InteractiveViewer(
|
||||
constrained: false,
|
||||
scaleEnabled: false,
|
||||
child: SizedBox(
|
||||
width: Get.width + 100.r,
|
||||
child: Table(
|
||||
border: TableBorder.all(
|
||||
color: CustomAppColors.kSmokeColor,
|
||||
),
|
||||
columnWidths: const <int, TableColumnWidth>{
|
||||
0: FlexColumnWidth(30.2),
|
||||
1: FlexColumnWidth(35.0),
|
||||
2: FlexColumnWidth(25.0),
|
||||
// 3: FlexColumnWidth(15.0),
|
||||
},
|
||||
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
|
||||
children: [
|
||||
TableRow(
|
||||
children: [
|
||||
_tableHeading("Document Name"),
|
||||
_tableHeading("Details"),
|
||||
_tableHeading("Date"),
|
||||
// _tableHeading("Actions"),
|
||||
],
|
||||
),
|
||||
...controller.documentsList
|
||||
.map((e) => tableRow(controller.documentsList.indexOf(e), e))
|
||||
.toList()
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
TableRow tableRow(index, DocumentModel e) {
|
||||
return TableRow(
|
||||
decoration: BoxDecoration(
|
||||
color: controller.documentsList.indexOf(e) % 2 == 0
|
||||
? CustomAppColors.kLightGreyColor.withOpacity(0.25)
|
||||
: Colors.white),
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: REdgeInsets.symmetric(vertical: 8.0, horizontal: 12),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const CustomImageWidget(imagePath: AssetsManager.kFolderIcon),
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(left: 5),
|
||||
child: CustomTextWidget(
|
||||
text: e.title,
|
||||
textAlign: TextAlign.left,
|
||||
fontSize: 11.sp,
|
||||
isExpanded: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: REdgeInsets.symmetric(vertical: 8.0, horizontal: 12),
|
||||
child: CustomTextWidget(
|
||||
text: e.details,
|
||||
textAlign: TextAlign.left,
|
||||
fontSize: 11.sp,
|
||||
isExpanded: false,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: REdgeInsets.symmetric(vertical: 8.0, horizontal: 12),
|
||||
child: CustomTextWidget(
|
||||
text: DateFormat("MMM/dd/yyyy").format(
|
||||
DateTime.tryParse(e.createdAt)?.toLocal() ?? DateTime.now()),
|
||||
textAlign: TextAlign.left,
|
||||
fontSize: 11.sp,
|
||||
isExpanded: false,
|
||||
),
|
||||
),
|
||||
// Padding(
|
||||
// padding: REdgeInsets.symmetric(vertical: 8.0, horizontal: 12),
|
||||
// child: Row(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// EditIcon(
|
||||
// onTap: () => _onEditTap(index, e),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// )
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// _onEditTap(int index, documentModel) async {
|
||||
// var response = await Navigator.pushNamed(
|
||||
// context, CustomRouteNames.kAddNewDocumentScreenRoute,
|
||||
// arguments: [documentModel, controller.serviceUser()]);
|
||||
// if (response is DocumentModel) {
|
||||
// // int index = controller.documentsList.value.documentList.indexWhere((item) => item == documentModel);
|
||||
// controller.documentsList[index]
|
||||
// ..title = response.title
|
||||
// ..details = response.details
|
||||
// ..docPath = response.docPath;
|
||||
// controller.documentsList.refresh();
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user