Merge branch 'development_sikander' into 'master'
Development sikander See merge request mirza.shafique/mohem_flutter_app!22merge-requests/1/merge
commit
e671f0413d
@ -0,0 +1,32 @@
|
||||
class GetSetValuesRequestModel {
|
||||
String? sEGMENTNAME;
|
||||
String? vALUECOLUMNNAME;
|
||||
String? dESCRIPTION;
|
||||
String? iDCOLUMNNAME;
|
||||
String? fLEXVALUESETNAME;
|
||||
|
||||
GetSetValuesRequestModel(
|
||||
{this.sEGMENTNAME,
|
||||
this.vALUECOLUMNNAME,
|
||||
this.dESCRIPTION,
|
||||
this.iDCOLUMNNAME,
|
||||
this.fLEXVALUESETNAME});
|
||||
|
||||
GetSetValuesRequestModel.fromJson(Map<String, dynamic> json) {
|
||||
sEGMENTNAME = json['SEGMENT_NAME'];
|
||||
vALUECOLUMNNAME = json['VALUE_COLUMN_NAME'];
|
||||
dESCRIPTION = json['DESCRIPTION'];
|
||||
iDCOLUMNNAME = json['ID_COLUMN_NAME'];
|
||||
fLEXVALUESETNAME = json['FLEX_VALUE_SET_NAME'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['SEGMENT_NAME'] = this.sEGMENTNAME;
|
||||
data['VALUE_COLUMN_NAME'] = this.vALUECOLUMNNAME;
|
||||
data['DESCRIPTION'] = this.dESCRIPTION;
|
||||
data['ID_COLUMN_NAME'] = this.iDCOLUMNNAME;
|
||||
data['FLEX_VALUE_SET_NAME'] = this.fLEXVALUESETNAME;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,91 +0,0 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mohem_flutter_app/api/my_attendance_api_client.dart';
|
||||
import 'package:mohem_flutter_app/classes/utils.dart';
|
||||
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||||
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||
import 'package:mohem_flutter_app/models/get_eit_dff_structure_list_model.dart';
|
||||
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
||||
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
|
||||
|
||||
class AddWorkFromHomeScreen extends StatefulWidget {
|
||||
AddWorkFromHomeScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_AddWorkFromHomeScreenState createState() {
|
||||
return _AddWorkFromHomeScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _AddWorkFromHomeScreenState extends State<AddWorkFromHomeScreen> {
|
||||
List<GetEITDFFStructureList>? getEitDffStructureList;
|
||||
String? callingFunction;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void getTransactionsStructure() async {
|
||||
try {
|
||||
Utils.showLoading(context);
|
||||
getEitDffStructureList = await MyAttendanceApiClient().getEitDffStructure(callingFunction!);
|
||||
getEitDffStructureList = getEitDffStructureList!.where((element) => element.dISPLAYFLAG == "Y").toList();
|
||||
Utils.hideLoading(context);
|
||||
setState(() {});
|
||||
} catch (ex) {
|
||||
Utils.hideLoading(context);
|
||||
Utils.handleException(ex, context, null);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (callingFunction == null) {
|
||||
callingFunction = "HMG_OTL_WFH_EIT_SS"; // ModalRoute.of(context)!.settings.arguments as WorkListResponseModel;
|
||||
getTransactionsStructure();
|
||||
}
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: AppBarWidget(
|
||||
context,
|
||||
title: LocaleKeys.workFromHome.tr(),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
(getEitDffStructureList == null
|
||||
? const SizedBox()
|
||||
: (getEitDffStructureList!.isEmpty
|
||||
? LocaleKeys.noDataAvailable.tr().toText16().center
|
||||
: ListView.separated(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
padding: EdgeInsets.all(21),
|
||||
itemBuilder: (cxt, int parentIndex) => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [],
|
||||
).objectContainerView(),
|
||||
separatorBuilder: (cxt, index) => 12.height,
|
||||
itemCount: getEitDffStructureList!.length)))
|
||||
.expanded,
|
||||
// 12.height,
|
||||
DefaultButton(
|
||||
LocaleKeys.next.tr(),
|
||||
(getEitDffStructureList ?? []).isEmpty
|
||||
? null
|
||||
: () => {
|
||||
//Navigator.of(context).pushNamed(LOGIN_TYPE)
|
||||
},
|
||||
).insideContainer,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,221 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mohem_flutter_app/api/my_attendance_api_client.dart';
|
||||
import 'package:mohem_flutter_app/classes/utils.dart';
|
||||
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||||
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||
import 'package:mohem_flutter_app/models/dyanmic_forms/get_set_values_request_model.dart';
|
||||
import 'package:mohem_flutter_app/models/generic_response_model.dart';
|
||||
import 'package:mohem_flutter_app/models/get_eit_dff_structure_list_model.dart';
|
||||
import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart';
|
||||
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
||||
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
|
||||
import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart';
|
||||
|
||||
class DynamicInputScreen extends StatefulWidget {
|
||||
DynamicInputScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_DynamicInputScreenState createState() {
|
||||
return _DynamicInputScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _DynamicInputScreenState extends State<DynamicInputScreen> {
|
||||
GenericResponseModel? genericResponseModel;
|
||||
List<GetEITDFFStructureList>? getEitDffStructureList;
|
||||
DynamicListViewParams? dynamicParams;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void getTransactionsStructure() async {
|
||||
try {
|
||||
Utils.showLoading(context);
|
||||
genericResponseModel = await MyAttendanceApiClient().getEitDffStructure(dynamicParams!.dynamicId);
|
||||
getEitDffStructureList = genericResponseModel?.getEITDFFStructureList ?? [];
|
||||
//getEitDffStructureList = getEitDffStructureList!.where((element) => element.dISPLAYFLAG != "N").toList();
|
||||
Utils.hideLoading(context);
|
||||
setState(() {});
|
||||
} catch (ex) {
|
||||
Utils.hideLoading(context);
|
||||
Utils.handleException(ex, context, null);
|
||||
}
|
||||
}
|
||||
|
||||
void calGetValueSetValues(GetEITDFFStructureList structureList) async {
|
||||
try {
|
||||
Utils.showLoading(context);
|
||||
String segmentId = structureList.cHILDSEGMENTSVS!;
|
||||
List<GetEITDFFStructureList> filteredList = getEitDffStructureList?.where((element) => element.cHILDSEGMENTSVS == segmentId).toList() ?? [];
|
||||
List<Map<String, dynamic>> values = filteredList
|
||||
.map((e) => GetSetValuesRequestModel(
|
||||
sEGMENTNAME: e.sEGMENTNAME, vALUECOLUMNNAME: e.eSERVICESDV!.pVALUECOLUMNNAME, dESCRIPTION: "", iDCOLUMNNAME: e.eSERVICESDV!.pIDCOLUMNNAME, fLEXVALUESETNAME: e.fLEXVALUESETNAME)
|
||||
.toJson())
|
||||
.toList();
|
||||
ESERVICESVS genericResponseModel = await MyAttendanceApiClient().getValueSetValues(structureList.cHILDSEGMENTSVS!, structureList.dESCFLEXCONTEXTCODE!, structureList.dESCFLEXNAME!, values);
|
||||
|
||||
int index = getEitDffStructureList!.indexWhere((element) => element.sEGMENTNAME == structureList.cHILDSEGMENTSVS);
|
||||
getEitDffStructureList![index].eSERVICESVS!.add(genericResponseModel);
|
||||
// getEitDffStructureList = genericResponseModel?.getEITDFFStructureList ?? [];
|
||||
//getEitDffStructureList = getEitDffStructureList!.where((element) => element.dISPLAYFLAG != "N").toList();
|
||||
Utils.hideLoading(context);
|
||||
setState(() {});
|
||||
} catch (ex) {
|
||||
Utils.hideLoading(context);
|
||||
Utils.handleException(ex, context, null);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (dynamicParams == null) {
|
||||
dynamicParams = ModalRoute.of(context)!.settings.arguments as DynamicListViewParams;
|
||||
getTransactionsStructure();
|
||||
}
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: AppBarWidget(
|
||||
context,
|
||||
title: dynamicParams!.title,
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
(getEitDffStructureList == null
|
||||
? const SizedBox()
|
||||
: (getEitDffStructureList!.isEmpty
|
||||
? LocaleKeys.noDataAvailable.tr().toText16().center
|
||||
: ListView.separated(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
padding: const EdgeInsets.all(21),
|
||||
itemBuilder: (cxt, int parentIndex) => parseDynamicFormatType(getEitDffStructureList![parentIndex], parentIndex),
|
||||
separatorBuilder: (cxt, index) => 0.height,
|
||||
itemCount: getEitDffStructureList!.length)))
|
||||
.expanded,
|
||||
// 12.height,
|
||||
DefaultButton(
|
||||
LocaleKeys.next.tr(),
|
||||
(getEitDffStructureList ?? []).isEmpty
|
||||
? null
|
||||
: () => {
|
||||
//Navigator.of(context).pushNamed(LOGIN_TYPE)
|
||||
},
|
||||
).insideContainer,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget parseDynamicFormatType(GetEITDFFStructureList model, int index) {
|
||||
if (model.dISPLAYFLAG != "N") {
|
||||
} else {
|
||||
return const SizedBox();
|
||||
}
|
||||
|
||||
if (model.fORMATTYPE == "C") {
|
||||
if (model.eSERVICESVS?.isNotEmpty ?? false) {
|
||||
return PopupMenuButton(
|
||||
child: DynamicTextFieldWidget(
|
||||
(model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""),
|
||||
model.eSERVICESDV?.pIDCOLUMNNAME ?? "",
|
||||
isEnable: false,
|
||||
isPopup: true,
|
||||
).paddingOnly(bottom: 12),
|
||||
itemBuilder: (_) => <PopupMenuItem<int>>[
|
||||
for (int i = 0; i < model.eSERVICESVS!.length; i++) PopupMenuItem<int>(child: Text(model.eSERVICESVS![i].vALUECOLUMNNAME!), value: i),
|
||||
],
|
||||
onSelected: (int index) {
|
||||
|
||||
ESERVICESDV eservicesdv = ESERVICESDV(
|
||||
pIDCOLUMNNAME: model.eSERVICESVS![index].vALUECOLUMNNAME,
|
||||
pRETURNMSG: "null",
|
||||
pRETURNSTATUS: getEitDffStructureList![index].dEFAULTVALUE,
|
||||
pVALUECOLUMNNAME: model.eSERVICESVS![index].vALUECOLUMNNAME);
|
||||
|
||||
print(model.eSERVICESVS![index].toJson());
|
||||
});
|
||||
}
|
||||
|
||||
return DynamicTextFieldWidget(
|
||||
(model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""),
|
||||
model.eSERVICESDV?.pIDCOLUMNNAME ?? "",
|
||||
isReadOnly: model.rEADONLY == "Y",
|
||||
onChange: (text) {
|
||||
model.fieldAnswer = text;
|
||||
},
|
||||
).paddingOnly(bottom: 12);
|
||||
} else if (model.fORMATTYPE == "X") {
|
||||
return DynamicTextFieldWidget(
|
||||
(model.sEGMENTPROMPT ?? "") + (model.rEQUIREDFLAG == "Y" ? "*" : ""),
|
||||
model.eSERVICESDV?.pIDCOLUMNNAME ?? (getEitDffStructureList![index].fieldAnswer ?? ""),
|
||||
suffixIconData: Icons.calendar_today,
|
||||
isEnable: false,
|
||||
onTap: () async {
|
||||
DateTime date = await _selectDate(context);
|
||||
DateTime date1 = DateTime(date.year, date.month, date.day);
|
||||
getEitDffStructureList![index].fieldAnswer = date.toString();
|
||||
ESERVICESDV eservicesdv = ESERVICESDV(
|
||||
pIDCOLUMNNAME: DateFormat('yyyy-MM-dd').format(date1),
|
||||
pRETURNMSG: "null",
|
||||
pRETURNSTATUS: getEitDffStructureList![index].dEFAULTVALUE,
|
||||
pVALUECOLUMNNAME: DateFormat('yyyy-MM-ddThh:mm:ss.s').format(date));
|
||||
getEitDffStructureList![index].eSERVICESDV = eservicesdv;
|
||||
setState(() {});
|
||||
if (model.cHILDSEGMENTSDVSplited?.isNotEmpty ?? false) {
|
||||
calGetValueSetValues(model);
|
||||
}
|
||||
},
|
||||
).paddingOnly(bottom: 12);
|
||||
}
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [],
|
||||
).objectContainerView();
|
||||
}
|
||||
|
||||
DateTime selectedDate = DateTime.now();
|
||||
|
||||
Future<DateTime> _selectDate(BuildContext context) async {
|
||||
DateTime time = selectedDate;
|
||||
if (!Platform.isIOS) {
|
||||
await showCupertinoModalPopup(
|
||||
context: context,
|
||||
builder: (cxt) => Container(
|
||||
height: 250,
|
||||
color: Colors.white,
|
||||
child: CupertinoDatePicker(
|
||||
backgroundColor: Colors.white,
|
||||
mode: CupertinoDatePickerMode.date,
|
||||
onDateTimeChanged: (value) {
|
||||
if (value != null && value != selectedDate) {
|
||||
time = value;
|
||||
}
|
||||
},
|
||||
initialDateTime: selectedDate,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
final DateTime? picked =
|
||||
await showDatePicker(context: context, initialDate: selectedDate, initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101));
|
||||
if (picked != null && picked != selectedDate) {
|
||||
time = picked;
|
||||
}
|
||||
}
|
||||
return time;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||
|
||||
class DynamicTextFieldWidget extends StatelessWidget {
|
||||
final String labelText;
|
||||
final String hintText;
|
||||
// final TextEditingController controller;
|
||||
final VoidCallback? onTap;
|
||||
final IconData? suffixIconData;
|
||||
final bool isEnable;
|
||||
final bool isReadOnly;
|
||||
final bool isPopup;
|
||||
final int? lines;
|
||||
final bool isInputTypeNum;
|
||||
final bool isObscureText;
|
||||
final bool isBackgroundEnable;
|
||||
final void Function(String)? onChange;
|
||||
|
||||
DynamicTextFieldWidget(this.labelText, this.hintText, //this.controller,
|
||||
{this.isObscureText = false,
|
||||
this.onTap,
|
||||
this.suffixIconData,
|
||||
this.isEnable = true,
|
||||
this.isReadOnly = false,
|
||||
this.isPopup = false,
|
||||
this.lines = 1,
|
||||
this.onChange,
|
||||
this.isInputTypeNum = false,
|
||||
this.isBackgroundEnable = false});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15),
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
color: isReadOnly ? MyColors.lightGreyEFColor : Colors.white,
|
||||
border: Border.all(
|
||||
color: MyColors.lightGreyEFColor,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
labelText,
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xff2B353E),
|
||||
letterSpacing: -0.44,
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
enabled: isEnable,
|
||||
scrollPadding: EdgeInsets.zero, readOnly: isReadOnly,
|
||||
keyboardType: isInputTypeNum ? TextInputType.number : TextInputType.text,
|
||||
//controller: controller,
|
||||
maxLines: lines,
|
||||
obscuringCharacter: "*",
|
||||
obscureText: isObscureText,
|
||||
onChanged: onChange,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
height: 21 / 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xff2B353E),
|
||||
letterSpacing: -0.44,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
hintText: hintText,
|
||||
fillColor: isReadOnly ? MyColors.borderColor : null,
|
||||
hintStyle: const TextStyle(
|
||||
fontSize: 14,
|
||||
height: 21 / 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Color(0xff575757),
|
||||
letterSpacing: -0.56,
|
||||
),
|
||||
// suffixIconConstraints: const BoxConstraints(minWidth: 50),
|
||||
// suffixIcon: suffixIconData == null ? null : Icon(suffixIconData, color: MyColors.darkTextColor),
|
||||
// suffixIcon: suffixTap == null ? null : IconButton(icon: Icon(suffixIconData, color: MyColors.darkTextColor), onPressed: suffixTap),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (isPopup) const Icon(Icons.keyboard_arrow_down_outlined, color: MyColors.darkTextColor),
|
||||
if (onTap != null) Icon(suffixIconData ?? Icons.keyboard_arrow_down_outlined, color: MyColors.darkTextColor),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue