Implementation
getItemIcon(Map param, context) {
myLogAll('getItemIcon');
//如果是日期并且高级搜索,显示。。。
dynamic item = param[gItem];
dynamic type = item[gType];
bool isAdvancedSearch = false;
if (!isNull(param[gParam0])) {
isAdvancedSearch = param[gParam0][gAdvanceSearch] ?? false;
}
if ((type == gDate || type == gDatetime) && isAdvancedSearch) {
List<Widget> icons = [];
List labelList = [
'Today',
'Yesterday',
'This week',
'This month',
'This year',
'All',
'Customized'
];
for (int i = 0; i < labelList.length; i++) {
String labelI =
labelList[i].toString().replaceAll(' ', '').toLowerCase();
dynamic value = '${item[gId]}=@$labelI';
if (labelList[i] == 'All') {
value = '';
} else if (labelList[i] == 'Customized') {
value = 'showDateChoiceBetween';
}
Map paramTip = {
gLabel: labelList[i],
gType: gLocalAction,
gActionid: 'setTableWhere',
gValue: value,
gParam: param,
gTableID: param[gName],
//gCharacter: true,
gItem: item
/*gWidth: getDouble(
(getCharLength({gLabel: labelList[i]}) + 20.0).toString()),*/
};
//{label: 12%, type: localAction, actionid: setFormValueByParent, value: 12, parent: amount, key: %, col: tip, color: 4278238420, width: 40.0}
//if (i < labelList.length / 2) {
icons.add(MyButton(paramTip));
icons.add(const SizedBox(height: 5.0));
/*} else {
icons1.add(MyButton(paramTip));
//icons1.add(const SizedBox(width: 10.0));
}*/
}
item[gSuffixIcon] = SizedBox(
width: MediaQuery.of(context).size.width -
getDouble(
(getCharLength({gLabel: getSCurrent(item[gLabel])}) + 70.0)
.toString()),
height: MediaQuery.of(context).size.height - 280.0,
child: SingleChildScrollView(
child: Column(children: icons
/*[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: icons,
),
const SizedBox(
height: 8.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: icons1,
),
],*/
),
),
);
return;
}
//不合法(空或非法),或非焦点,或readonly则不显示图标 -- 邮箱,电话,URL
if (!param[gFocus]) {
param[gItem][gSuffixIcon] = null;
return;
}
bool isReadonly = isreadonly(param[gItem], _mFocusNode[gName]);
if (isReadonly) {
param[gItem][gSuffixIcon] = null;
return;
}
if (isItemEmail(param[gItem])) {
if (!isNull(param[gAlert]) || isNull(param[gValue])) {
param[gItem][gSuffixIcon] = null;
return;
}
if (param[gItem][gSuffixIcon] == null) {
param[gItem][gSuffixIcon] = IconButton(
//icon: const Icon(Icons.email_outlined
icon: const Icon(Icons.email_outlined
//color: Theme.of(context).disabledColor,
),
onPressed: () {
getItemIconFunc(param, context);
});
}
return;
}
if (type == gPhone) {
if (!isNull(param[gAlert]) || isNull(param[gValue])) {
param[gItem][gSuffixIcon] = null;
return;
}
if (param[gItem][gSuffixIcon] == null) {
param[gItem][gSuffixIcon] = IconButton(
icon: const Icon(Icons.phone_outlined),
onPressed: () {
getItemIconFunc(param, context);
});
}
return;
}
if (type == gUrl) {
if (!isNull(param[gAlert]) || isNull(param[gValue])) {
item[gSuffixIcon] = null;
return;
}
if (param[gItem][gSuffixIcon] == null) {
param[gItem][gSuffixIcon] = IconButton(
icon: const Icon(Icons.web_outlined),
onPressed: () {
getItemIconFunc(param, context);
});
}
return;
}
if (type == gIcon ||
type == gSelfie ||
type == gPhoto ||
type == gScan ||
type == gMoney ||
type == gTip) {
if (item[gSuffixIcon] == null) {
var value = getValue(
_mFocusNode[gName], _mFocusNode[gCol], _mFocusNode[gId])[gValue];
List<Widget> icons = [];
if (type == gIcon) {
icons = [
IconButton(
icon: const Icon(Icons.image_search_outlined),
onPressed: () {
List<Widget> lImgs = [];
lImgs.add(InkWell(
onTap: () {
finishme([], context);
showPopupItem(
param[gItem],
_mFocusNode[gTypeOwner],
_mFocusNode[gName],
value,
_mFocusNode[gId],
null,
context,
true);
},
child: Center(
child: MyLabel(
const {gLabel: 'Browse icon'}, _colorList[0].value),
),
));
lImgs.add(const Divider());
lImgs.add(InkWell(
onTap: () {
try {
finishme([], context);
loadFile(_mFocusNode[gName], param[gItem], param[gId],
context);
} catch (e) {
showMsg(context, e, null);
}
},
child: Center(
child: MyLabel(
const {gLabel: 'Browse file'}, _colorList[0].value),
),
));
lImgs.add(const Divider());
lImgs.add(InkWell(
onTap: () {
finishme([], context);
try {
takePic(context, false, getFormItemFocusLabel());
} catch (e) {
showMsg(context, e, null);
}
},
child: Center(
child: MyLabel(
const {gLabel: 'Take photo'}, _colorList[0].value),
),
));
lImgs.add(const Divider());
lImgs.add(InkWell(
onTap: () {
try {
finishme([], context);
takePic(context, true, getFormItemFocusLabel());
} catch (e) {
showMsg(context, e, null);
}
},
child: Center(
child: MyLabel(
const {gLabel: 'Take selfie'}, _colorList[0].value),
),
));
showDialogByList(context, lImgs);
/*showPopupItem(
param[gItem],
_mFocusNode[gTypeOwner],
_mFocusNode[gName],
value,
_mFocusNode[gId],
null,
context,
true);*/
}),
/*const SizedBox(width: 5.0),
IconButton(
icon: const Icon(Icons.file_upload_outlined),
onPressed: () {
try {
loadFile(
_mFocusNode[gName], param[gItem], param[gId], context);
} catch (e) {
showMsg(context, e, null);
}
}),*/
];
} else if (type == gSelfie || type == gPhoto) {
Icon aIcon = Icon((type == gSelfie)
? Icons.camera_front_outlined
: Icons.camera_alt_outlined);
icons = [
IconButton(
icon: aIcon,
onPressed: () {
try {
getItemIconFunc(param, context);
} catch (e) {
showMsg(context, e, null);
}
})
];
} else if (type == gScan) {
Icon aIcon = const Icon(IconData(
62170,
fontFamily: 'MaterialIcons',
));
icons = [
IconButton(
icon: aIcon,
onPressed: () {
try {
resetLastBarcode();
getItemIconFunc(param, context);
} catch (e) {
showMsg(context, e, null);
}
})
];
} else if (type == gMoney && isNull(param[gItem][gCompute] ?? '')) {
Icon aIcon = const Icon(IconData(
0xf1e0,
fontFamily: 'MaterialIcons',
));
icons = [
IconButton(
icon: aIcon,
onPressed: () {
try {
getItemIconFunc(param, context);
} catch (e) {
showMsg(context, e, null);
}
})
];
} else if (type == gTip) {
Icon aIcon = const Icon(IconData(
0xf336,
fontFamily: 'MaterialIcons',
));
icons = [
IconButton(
icon: aIcon,
onPressed: () {
try {
getItemIconFunc(param, context);
} catch (e) {
showMsg(context, e, null);
}
})
];
/*List tableData = getTableData(gZzytip, context);
if (isNull(tableData)) {
return;
}
icons = [];
for (int i = 0; i < tableData.length; i++) {
var tip = tableData[i][gTip];
var tipLabel = appParam['$gTip$gParam'][gLabel];
Map paramTip = {
gLabel: '$tip$tipLabel',
gType: gLocalAction,
gActionid: 'setFormValueByParent',
gValue: tip,
gParent: gAmount,
gKey: tipLabel,
gCol: gTip,
gWidth: 340.0,
};
//{label: 12%, type: localAction, actionid: setFormValueByParent, value: 12, parent: amount, key: %, col: tip, color: 4278238420, width: 40.0}
icons.add(MyButton(paramTip));
}
param[gItem][gBottomIcon] = Column(
children: icons,
);*/
}
if (isNull(item[gBottomIcon])) {
item[gSuffixIcon] = Row(
children: icons,
);
}
}
return;
}
if (param[gItem][gType] == gDate || param[gItem][gType] == gDatetime) {
var value = getValue(
_mFocusNode[gName], _mFocusNode[gCol], _mFocusNode[gId])[gValue];
showPopupItem(param[gItem], _mFocusNode[gTypeOwner], _mFocusNode[gName],
value, _mFocusNode[gId], null, context, false);
/*if (param[gItem][gSuffixIcon] == null) {
param[gItem][gSuffixIcon] = IconButton(
icon: Icon(Icons.date_range_outlined),
onPressed: () {
var value = getValue(_mFocusNode[gName], _mFocusNode[gCol],
_mFocusNode[gId])[gValue];
showPopupItem(param[gItem], _mFocusNode[gTypeOwner],
_mFocusNode[gName], value, _mFocusNode[gId], null, context);
});
}*/
return;
}
if (param[gItem][gType] == gAddress) {
if (param[gItem][gSuffixIcon] == null) {
param[gItem][gSuffixIcon] = IconButton(
icon: const Icon(Icons.place_outlined),
onPressed: () {
var value = getValue(_mFocusNode[gName], _mFocusNode[gCol],
_mFocusNode[gId])[gValue];
if (isNull(value)) {
return;
}
if (value.length < 3) {
return;
}
var dpid = gDpAddress;
dpList[dpid] = [];
//将焦点变为只读
_mFocusNode[gIsLabel] = true;
sendRequestOne(
gDroplist,
{
gType: gAddress,
//gType: gDroplist,
gValue: value,
gActionid: dpid,
gTypeOwner: _mFocusNode[gTypeOwner],
gName: _mFocusNode[gName],
gId: _mFocusNode[gId],
gCol: _mFocusNode[gCol]
},
context);
/*showPopupItem(param[gItem], _mFocusNode[gTypeOwner],
_mFocusNode[gName], value, _mFocusNode[gId], null, context);*/
});
}
return;
}
//密码如果非焦点,不合法
if (param[gItem][gType] == gPassword) {
if (param[gItem][gSuffixIcon] == null) {
param[gItem][gPasswordShow] = param[gItem][gPasswordShow] ?? true;
param[gItem][gSuffixIcon] = IconButton(
icon: Icon(
param[gItem][gPasswordShow]
? Icons.visibility_off_outlined
: Icons.visibility_outlined,
color: Theme.of(context).disabledColor,
),
onPressed: () {
param[gItem][gPasswordShow] = !param[gItem][gPasswordShow];
myNotifyListeners();
});
return;
}
}
var droplist = param[gItem][gDroplist] ?? '';
if (isNull(droplist)) {
return;
}
if (param[gIsLabel] && isNullID(param[gId])) {
return;
}
param[gItem][gSuffixIcon] = IconButton(
icon: Icon((param[gItem][gType] == gSearch)
? Icons.content_paste_search_outlined
: Icons.arrow_drop_down_circle_sharp
//color: Theme.of(context).disabledColor,
),
onPressed: () {
_mFocusNode[gIsLabel] = true;
var value = getValue(
_mFocusNode[gName], _mFocusNode[gCol], _mFocusNode[gId])[gValue];
showPopupItem(param[gItem], _mFocusNode[gTypeOwner],
_mFocusNode[gName], value, _mFocusNode[gId], null, context, true);
});
}