using System;
|
using Foundation;
|
using System.Collections.Generic;
|
using Shared.IOS.TBL;
|
|
namespace Shared
|
{
|
public static class PickerView
|
{
|
//public static void Show(List<KeyValuePair<string, string[]>> list, Action<int> action, string sure = "Sure", string beforeValue = "")
|
//{
|
// var tempList = new List<NSDictionary>();
|
// foreach (KeyValuePair<string, string[]> kv in list)
|
// {
|
// tempList.Add(NSDictionary.FromObjectAndKey(NSArray.FromStrings(kv.Value), new NSString(kv.Key)));
|
// }
|
// var nSArray = NSArray.FromNSObjects(tempList.ToArray());
|
// ZJPickerView.Zj_showWithDataList(nSArray,
|
// NSDictionary.FromObjectsAndKeys(new NSString[]{
|
// new NSString(beforeValue),
|
// new NSString(sure),
|
// //new NSString(cancel),
|
// }, new NSString[] {
|
// Constants.ZJPickerViewPropertyTipLabelTextKey ,
|
// Constants.ZJPickerViewPropertySureBtnTitleKey,
|
// //Constants.ZJPickerViewPropertyCanceBtnTitleKey
|
// }), (selectIndex1, selectIndex2, selectIndex3s) =>
|
// {
|
// if (action != null)
|
// {
|
// action((int)selectIndex1);
|
// }
|
// });
|
//}
|
|
|
public static void Show(List<string> mList, Action<int> action, int mSelectIndex1 = 0, string title = "", string sure = "确认", string cancel = "取消")
|
{
|
|
//设置默认选中索引 格式:"selectIndex1-selectIndex2-selectIndex3"
|
string selectStr = mSelectIndex1 + "-0-0";
|
|
ZJPickerView.Zj_showWithDataList(NSArray.FromObjects(mList.ToArray()),
|
NSDictionary.FromObjectsAndKeys(new NSString[]{
|
new NSString(title),
|
new NSString(sure),
|
new NSString(cancel),
|
new NSString(selectStr)//设置默认选中索引
|
}, new NSString[] {
|
Constants.ZJPickerViewPropertyTipLabelTextKey,
|
Constants.ZJPickerViewPropertySureBtnTitleKey,
|
Constants.ZJPickerViewPropertyCanceBtnTitleKey,
|
Constants.ZJPickerViewPropertyDefaultSelectedIndexKey
|
|
}), (selectIndex1, selectIndex2, selectIndex3) => {
|
action?.Invoke((int)selectIndex1);
|
});
|
}
|
|
/// <summary>
|
/// 二级联动弹窗 支持自定义标题,确认按钮,取消按钮文字
|
/// </summary>
|
public static void ShowSecondary(List<string> mFirstList, List<List<string>> mSecondList, Action<int, int> action, int mSelectIndex1 = 0, int mSelectIndex2 = 0, string title = "", string sure = "确认", string cancel = "取消")
|
{
|
if (mFirstList == null)
|
{
|
return;
|
}
|
|
if (mFirstList.Count != mSecondList.Count)
|
{
|
|
return;
|
}
|
|
//设置默认选中索引 格式:"selectIndex1-selectIndex2-selectIndex3"
|
string selectStr = mSelectIndex1 + "-" + mSelectIndex2 + "-0";
|
|
var dictDataList = new NSMutableArray();
|
|
|
for (int i = 0; i < mFirstList.Count; i++)
|
{
|
|
dictDataList.Add(NSDictionary.FromObjectAndKey(NSArray.FromObjects(mSecondList[i].ToArray()), new NSString(mFirstList[i])));
|
|
}
|
|
//Shared.HDLUtils.WriteLine("OnOptionsSelect: ZJPickerView:" + dictDataList.ToString());
|
|
NSDictionary settingNSDictionary = NSDictionary.FromObjectsAndKeys(new NSString[]{
|
new NSString(title),
|
new NSString(sure),
|
new NSString(cancel),
|
new NSString(selectStr)//设置默认选中索引
|
}, new NSString[] {
|
Constants.ZJPickerViewPropertyTipLabelTextKey,
|
Constants.ZJPickerViewPropertySureBtnTitleKey,
|
Constants.ZJPickerViewPropertyCanceBtnTitleKey,
|
Constants.ZJPickerViewPropertyDefaultSelectedIndexKey
|
|
});
|
|
ZJPickerView.Zj_showWithDataList(
|
dictDataList,
|
settingNSDictionary,
|
(selectIndex1, selectIndex2, selectIndex3) => {
|
action?.Invoke((int)selectIndex1, (int)selectIndex2);
|
});
|
|
|
}
|
|
|
|
|
/// <summary>
|
/// 不联动支持自定义标题,确认按钮,取消按钮文字
|
/// </summary>
|
public static void ShowNormal(List<string> mFirstList, List<string> mSecondList, List<string> mThirdList, Action<int, int, int> action, int mSelectIndex1 = 0, int mSelectIndex2 = 0, int mSelectIndex3 = 0, string title = "", string sure = "确认", string cancel = "取消")
|
{
|
if (mFirstList == null)
|
{
|
return;
|
}
|
|
if (mSecondList == null)
|
{
|
return;
|
}
|
|
NSArray mThirdListNSArray = null;
|
if (mThirdList != null)
|
{
|
mThirdListNSArray = NSArray.FromObjects(mThirdList.ToArray());
|
}
|
|
|
|
//设置默认选中索引 格式:"selectIndex1-selectIndex2-selectIndex3"
|
string selectStr = mSelectIndex1 + "-" + mSelectIndex2 + "-" + mSelectIndex3;
|
|
|
NSDictionary settingNSDictionary = NSDictionary.FromObjectsAndKeys(new NSString[]{
|
new NSString(title),
|
new NSString(sure),
|
new NSString(cancel),
|
new NSString(selectStr)//设置默认选中索引
|
}, new NSString[] {
|
Constants.ZJPickerViewPropertyTipLabelTextKey,
|
Constants.ZJPickerViewPropertySureBtnTitleKey,
|
Constants.ZJPickerViewPropertyCanceBtnTitleKey,
|
Constants.ZJPickerViewPropertyDefaultSelectedIndexKey
|
|
});
|
|
|
Shared.HDLUtils.WriteLine("OnOptionsSelect: ZJPickerView:" + NSArray.FromObjects(mFirstList.ToArray()).ToString() + "\n mSecondList:" + NSArray.FromObjects(mSecondList.ToArray()).ToString());
|
|
ZJPickerView.Zj_showWithDataListWithNotLinked(
|
NSArray.FromObjects(mFirstList.ToArray()),
|
NSArray.FromObjects(mSecondList.ToArray()),
|
mThirdListNSArray,
|
settingNSDictionary,
|
(selectIndex1, selectIndex2, selectIndex3) => {
|
action?.Invoke((int)selectIndex1, (int)selectIndex2, (int)selectIndex3);
|
});
|
|
|
}
|
|
}
|
|
|
|
}
|