recursivelyPushPicker method
Implementation
DialogShower? recursivelyPushPicker({bool isRoot = true}) {
BoxDecoration _itemInteractionDecoration(bool isTap) {
return BoxDecoration(
color: isTap ? const Color(0xFFE0E0E0) : Colors.white,
border: const Border(bottom: BorderSide(width: 1, color: Color(0xFFECECF2))),
);
}
AnythingHeaderOptions headerOptions = AnythingHeaderOptions()
..headerHeight = 56
..rightTitle = null
..leftEvent = () {
DialogWrapper.popOrDismiss();
}
..leftWidget = isRoot ? null : const Icon(Icons.arrow_back_ios, size: 20, color: Color(0xFF3C78FE));
headerOptions = onHeaderOptions?.call(this, headerOptions) ?? headerOptions;
AnythingSelectorOptions selectorOptions = AnythingSelectorOptions()
..itemMargin = const EdgeInsets.symmetric(horizontal: 16)
..itemPadding = const EdgeInsets.symmetric(horizontal: 8, vertical: 16)
..itemDecorationNormal = _itemInteractionDecoration(false)
..itemDecorationTapped = _itemInteractionDecoration(true)
..itemSuffixWidget = isHasNextLevel(this, relativeIndexes.lastSafe, relativeElements.lastSafe) ? null : kArrowIcon;
selectorOptions = onSelectorOptions?.call(this, selectorOptions) ?? selectorOptions;
Widget widget = AnythingSelector(
isSearchEnable: isSearchEnable,
header: funcOfTitle(this, relativeIndexes.lastSafe, relativeElements.lastSafe),
funcOfValues: () async {
return funcOfValues(this, relativeIndexes.lastSafe, relativeElements.lastSafe);
},
funcOfItemName: (view, i, e) {
return funcOfItemName(this, i, e);
},
funcOfItemOnTapped: (view, i, e) {
relativeIndexes.add(i);
relativeElements.add(e);
if (!isHasNextLevel(this, i, e)) {
if (!(funcOfLeafItemOnTapped(this, i, e) ?? false)) {
pickerState.widget.selectedValue = e;
pickerState.refresh();
DialogWrapper.dismissTopDialog();
}
return true;
}
recursivelyPushPicker(isRoot: false);
return true;
},
options: selectorOptions,
headerOptions: headerOptions,
);
widget = ColoredBox(color: Colors.white, child: widget);
if (isRoot) {
DialogShower shower = DialogWrapper.pushRoot(widget, width: onShowerWidth?.call(this));
shower
..context = DialogWrapper.getTopNavigatorDialog()?.getNavigator()?.context ?? DialogShower.gContext
..isUseRootNavigator = false
..barrierDismissible = true
..alignment = Alignment.centerRight
..barrierOnTapCallback = (dialog, offset) {
DialogShower.isKeyboardShowing() ? FocusManager.instance.primaryFocus?.unfocus() : DialogWrapper.dismissTopDialog();
return true;
}
..transitionBuilder = (context, animation, animationVice, child) {
return SlideTransition(
position: Tween<Offset>(begin: const Offset(1.0, 0.0), end: const Offset(0.0, 0.0)).animate(animation),
child: child,
);
};
onShower?.call(this, shower);
return shower;
}
DialogWrapper.push(widget);
return null;
}