getMainView method
Implementation
Widget getMainView(Map<String, dynamic> data, String tableName, {int? viewID}) {
var dataReponse = Methods.getList(data['data'], tableName);
IActionEvent iAction = data['ActionEvent'] as IActionEvent;
List<Map<String, Object>> dsAction = data['dsAction'];
double height = 0;
int id = 0;
String keyTitle='';
if (dataReponse.isNotEmpty) {
height = Methods.getDouble(dataReponse.first, 'heightButton', defaultValue: 0);
id = Methods.getInt(dataReponse.first, 'ID', defaultValue: 0);
keyTitle = Methods.getString(dataReponse.first, 'keyTitle');
}
if (height == 0) {
height = 60;
}
if(keyTitle.isEmpty){
keyTitle = 'BUTTON_DANG_KY';
}
return Container(
width: Get.width,
alignment: Alignment.center,
child: Container(
padding: const EdgeInsets.symmetric(vertical: 8),
height: height,
child: ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith<Color>((state) {
return const Color(0xFFF79750);
}),
padding: MaterialStateProperty.all<EdgeInsets>(
const EdgeInsets.symmetric(horizontal: 16, vertical: 8)),
shape: MaterialStateProperty.all<OutlinedBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
minimumSize: MaterialStateProperty.all<Size>(const Size(0, 0)),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
onPressed: () {
iAction.actionCompoment(4, dsAction, idData: id, params: {'@id': id,'oldViewID':viewID??0},
resultData: (data,nameProcedure){
var lstData = Methods.getList(data, nameProcedure);
String? sID;
for(var item in lstData){
String id = Methods.getString(item, 'ID');
if(sID == null || sID.isEmpty){
sID = id;
}else{
sID = ',$id';
}
}
return {'dsID':sID!};
}
);
},
child: Container(
width: Get.width,
alignment: Alignment.center,
child: Text(
Message.getMessage(keyTitle),
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
),
),
),
);
}