wxr
2020-07-06 23c075a9c27946773feccf05abc90489a6bf5203
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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);
                });
 
 
        }
 
    }
 
 
 
}