LookinDashboardBlueprint.m 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145
  1. //
  2. // LookinDashboardBlueprint.m
  3. // Lookin
  4. //
  5. // Created by Li Kai on 2019/6/5.
  6. // https://lookin.work
  7. //
  8. #import "LookinDashboardBlueprint.h"
  9. @implementation LookinDashboardBlueprint
  10. + (NSArray<LookinAttrGroupIdentifier> *)groupIDs {
  11. static NSArray<LookinAttrGroupIdentifier> *array;
  12. static dispatch_once_t onceToken;
  13. dispatch_once(&onceToken,^{
  14. array = @[
  15. LookinAttrGroup_Class,
  16. LookinAttrGroup_Relation,
  17. LookinAttrGroup_Layout,
  18. LookinAttrGroup_AutoLayout,
  19. LookinAttrGroup_ViewLayer,
  20. LookinAttrGroup_UIVisualEffectView,
  21. LookinAttrGroup_UIImageView,
  22. LookinAttrGroup_UILabel,
  23. LookinAttrGroup_UIControl,
  24. LookinAttrGroup_UIButton,
  25. LookinAttrGroup_UIScrollView,
  26. LookinAttrGroup_UITableView,
  27. LookinAttrGroup_UITextView,
  28. LookinAttrGroup_UITextField
  29. ];
  30. });
  31. return array;
  32. }
  33. + (NSArray<LookinAttrSectionIdentifier> *)sectionIDsForGroupID:(LookinAttrGroupIdentifier)groupID {
  34. static NSDictionary<LookinAttrGroupIdentifier, NSArray<LookinAttrSectionIdentifier> *> *dict;
  35. static dispatch_once_t onceToken;
  36. dispatch_once(&onceToken,^{
  37. dict = @{
  38. LookinAttrGroup_Class: @[LookinAttrSec_Class_Class],
  39. LookinAttrGroup_Relation: @[LookinAttrSec_Relation_Relation],
  40. LookinAttrGroup_Layout: @[LookinAttrSec_Layout_Frame,
  41. LookinAttrSec_Layout_Bounds,
  42. LookinAttrSec_Layout_SafeArea,
  43. LookinAttrSec_Layout_Position,
  44. LookinAttrSec_Layout_AnchorPoint],
  45. LookinAttrGroup_AutoLayout: @[LookinAttrSec_AutoLayout_Constraints,
  46. LookinAttrSec_AutoLayout_IntrinsicSize,
  47. LookinAttrSec_AutoLayout_Hugging,
  48. LookinAttrSec_AutoLayout_Resistance],
  49. LookinAttrGroup_ViewLayer: @[
  50. LookinAttrSec_ViewLayer_Visibility,
  51. LookinAttrSec_ViewLayer_InterationAndMasks,
  52. LookinAttrSec_ViewLayer_BgColor,
  53. LookinAttrSec_ViewLayer_Border,
  54. LookinAttrSec_ViewLayer_Corner,
  55. LookinAttrSec_ViewLayer_Shadow,
  56. LookinAttrSec_ViewLayer_ContentMode,
  57. LookinAttrSec_ViewLayer_TintColor,
  58. LookinAttrSec_ViewLayer_Tag
  59. ],
  60. LookinAttrGroup_UIVisualEffectView: @[
  61. LookinAttrSec_UIVisualEffectView_Style,
  62. LookinAttrSec_UIVisualEffectView_QMUIForegroundColor
  63. ],
  64. LookinAttrGroup_UIImageView: @[LookinAttrSec_UIImageView_Name,
  65. LookinAttrSec_UIImageView_Open],
  66. LookinAttrGroup_UILabel: @[
  67. LookinAttrSec_UILabel_Text,
  68. LookinAttrSec_UILabel_Font,
  69. LookinAttrSec_UILabel_NumberOfLines,
  70. LookinAttrSec_UILabel_TextColor,
  71. LookinAttrSec_UILabel_BreakMode,
  72. LookinAttrSec_UILabel_Alignment,
  73. LookinAttrSec_UILabel_CanAdjustFont],
  74. LookinAttrGroup_UIControl: @[LookinAttrSec_UIControl_EnabledSelected,
  75. LookinAttrSec_UIControl_QMUIOutsideEdge,
  76. LookinAttrSec_UIControl_VerAlignment,
  77. LookinAttrSec_UIControl_HorAlignment],
  78. LookinAttrGroup_UIButton: @[LookinAttrSec_UIButton_ContentInsets,
  79. LookinAttrSec_UIButton_TitleInsets,
  80. LookinAttrSec_UIButton_ImageInsets],
  81. LookinAttrGroup_UIScrollView: @[LookinAttrSec_UIScrollView_ContentInset,
  82. LookinAttrSec_UIScrollView_AdjustedInset,
  83. LookinAttrSec_UIScrollView_QMUIInitialInset,
  84. LookinAttrSec_UIScrollView_IndicatorInset,
  85. LookinAttrSec_UIScrollView_Offset,
  86. LookinAttrSec_UIScrollView_ContentSize,
  87. LookinAttrSec_UIScrollView_Behavior,
  88. LookinAttrSec_UIScrollView_ShowsIndicator,
  89. LookinAttrSec_UIScrollView_Bounce,
  90. LookinAttrSec_UIScrollView_ScrollPaging,
  91. LookinAttrSec_UIScrollView_ContentTouches,
  92. LookinAttrSec_UIScrollView_Zoom],
  93. LookinAttrGroup_UITableView: @[LookinAttrSec_UITableView_Style,
  94. LookinAttrSec_UITableView_SectionsNumber,
  95. LookinAttrSec_UITableView_RowsNumber,
  96. LookinAttrSec_UITableView_SeparatorStyle,
  97. LookinAttrSec_UITableView_SeparatorColor,
  98. LookinAttrSec_UITableView_SeparatorInset],
  99. LookinAttrGroup_UITextView: @[LookinAttrSec_UITextView_Basic,
  100. LookinAttrSec_UITextView_Text,
  101. LookinAttrSec_UITextView_Font,
  102. LookinAttrSec_UITextView_TextColor,
  103. LookinAttrSec_UITextView_Alignment,
  104. LookinAttrSec_UITextView_ContainerInset],
  105. LookinAttrGroup_UITextField: @[LookinAttrSec_UITextField_Text,
  106. LookinAttrSec_UITextField_Placeholder,
  107. LookinAttrSec_UITextField_Font,
  108. LookinAttrSec_UITextField_TextColor,
  109. LookinAttrSec_UITextField_Alignment,
  110. LookinAttrSec_UITextField_Clears,
  111. LookinAttrSec_UITextField_CanAdjustFont,
  112. LookinAttrSec_UITextField_ClearButtonMode],
  113. };
  114. });
  115. return dict[groupID];
  116. }
  117. + (NSArray<LookinAttrIdentifier> *)attrIDsForSectionID:(LookinAttrSectionIdentifier)sectionID {
  118. static NSDictionary<LookinAttrSectionIdentifier, NSArray<LookinAttrIdentifier> *> *dict;
  119. static dispatch_once_t onceToken;
  120. dispatch_once(&onceToken,^{
  121. dict = @{
  122. LookinAttrSec_Class_Class: @[LookinAttr_Class_Class_Class],
  123. LookinAttrSec_Relation_Relation: @[LookinAttr_Relation_Relation_Relation],
  124. LookinAttrSec_Layout_Frame: @[LookinAttr_Layout_Frame_Frame],
  125. LookinAttrSec_Layout_Bounds: @[LookinAttr_Layout_Bounds_Bounds],
  126. LookinAttrSec_Layout_SafeArea: @[LookinAttr_Layout_SafeArea_SafeArea],
  127. LookinAttrSec_Layout_Position: @[LookinAttr_Layout_Position_Position],
  128. LookinAttrSec_Layout_AnchorPoint: @[LookinAttr_Layout_AnchorPoint_AnchorPoint],
  129. LookinAttrSec_AutoLayout_Hugging: @[LookinAttr_AutoLayout_Hugging_Hor,
  130. LookinAttr_AutoLayout_Hugging_Ver],
  131. LookinAttrSec_AutoLayout_Resistance: @[LookinAttr_AutoLayout_Resistance_Hor,
  132. LookinAttr_AutoLayout_Resistance_Ver],
  133. LookinAttrSec_AutoLayout_Constraints: @[LookinAttr_AutoLayout_Constraints_Constraints],
  134. LookinAttrSec_AutoLayout_IntrinsicSize: @[LookinAttr_AutoLayout_IntrinsicSize_Size],
  135. LookinAttrSec_ViewLayer_Visibility: @[LookinAttr_ViewLayer_Visibility_Hidden,
  136. LookinAttr_ViewLayer_Visibility_Opacity],
  137. LookinAttrSec_ViewLayer_InterationAndMasks: @[LookinAttr_ViewLayer_InterationAndMasks_Interaction,
  138. LookinAttr_ViewLayer_InterationAndMasks_MasksToBounds],
  139. LookinAttrSec_ViewLayer_Corner: @[LookinAttr_ViewLayer_Corner_Radius],
  140. LookinAttrSec_ViewLayer_BgColor: @[LookinAttr_ViewLayer_BgColor_BgColor],
  141. LookinAttrSec_ViewLayer_Border: @[LookinAttr_ViewLayer_Border_Color,
  142. LookinAttr_ViewLayer_Border_Width],
  143. LookinAttrSec_ViewLayer_Shadow: @[LookinAttr_ViewLayer_Shadow_Color,
  144. LookinAttr_ViewLayer_Shadow_Opacity,
  145. LookinAttr_ViewLayer_Shadow_Radius,
  146. LookinAttr_ViewLayer_Shadow_OffsetW,
  147. LookinAttr_ViewLayer_Shadow_OffsetH],
  148. LookinAttrSec_ViewLayer_ContentMode: @[LookinAttr_ViewLayer_ContentMode_Mode],
  149. LookinAttrSec_ViewLayer_TintColor: @[LookinAttr_ViewLayer_TintColor_Color,
  150. LookinAttr_ViewLayer_TintColor_Mode],
  151. LookinAttrSec_ViewLayer_Tag: @[LookinAttr_ViewLayer_Tag_Tag],
  152. LookinAttrSec_UIVisualEffectView_Style: @[LookinAttr_UIVisualEffectView_Style_Style],
  153. LookinAttrSec_UIVisualEffectView_QMUIForegroundColor: @[LookinAttr_UIVisualEffectView_QMUIForegroundColor_Color],
  154. LookinAttrSec_UIImageView_Name: @[LookinAttr_UIImageView_Name_Name],
  155. LookinAttrSec_UIImageView_Open: @[LookinAttr_UIImageView_Open_Open],
  156. LookinAttrSec_UILabel_Font: @[LookinAttr_UILabel_Font_Name,
  157. LookinAttr_UILabel_Font_Size],
  158. LookinAttrSec_UILabel_NumberOfLines: @[LookinAttr_UILabel_NumberOfLines_NumberOfLines],
  159. LookinAttrSec_UILabel_Text: @[LookinAttr_UILabel_Text_Text],
  160. LookinAttrSec_UILabel_TextColor: @[LookinAttr_UILabel_TextColor_Color],
  161. LookinAttrSec_UILabel_BreakMode: @[LookinAttr_UILabel_BreakMode_Mode],
  162. LookinAttrSec_UILabel_Alignment: @[LookinAttr_UILabel_Alignment_Alignment],
  163. LookinAttrSec_UILabel_CanAdjustFont: @[LookinAttr_UILabel_CanAdjustFont_CanAdjustFont],
  164. LookinAttrSec_UIControl_EnabledSelected: @[LookinAttr_UIControl_EnabledSelected_Enabled,
  165. LookinAttr_UIControl_EnabledSelected_Selected],
  166. LookinAttrSec_UIControl_QMUIOutsideEdge: @[LookinAttr_UIControl_QMUIOutsideEdge_Edge],
  167. LookinAttrSec_UIControl_VerAlignment: @[LookinAttr_UIControl_VerAlignment_Alignment],
  168. LookinAttrSec_UIControl_HorAlignment: @[LookinAttr_UIControl_HorAlignment_Alignment],
  169. LookinAttrSec_UIButton_ContentInsets: @[LookinAttr_UIButton_ContentInsets_Insets],
  170. LookinAttrSec_UIButton_TitleInsets: @[LookinAttr_UIButton_TitleInsets_Insets],
  171. LookinAttrSec_UIButton_ImageInsets: @[LookinAttr_UIButton_ImageInsets_Insets],
  172. LookinAttrSec_UIScrollView_ContentInset: @[LookinAttr_UIScrollView_ContentInset_Inset],
  173. LookinAttrSec_UIScrollView_AdjustedInset: @[LookinAttr_UIScrollView_AdjustedInset_Inset],
  174. LookinAttrSec_UIScrollView_QMUIInitialInset: @[LookinAttr_UIScrollView_QMUIInitialInset_Inset],
  175. LookinAttrSec_UIScrollView_IndicatorInset: @[LookinAttr_UIScrollView_IndicatorInset_Inset],
  176. LookinAttrSec_UIScrollView_Offset: @[LookinAttr_UIScrollView_Offset_Offset],
  177. LookinAttrSec_UIScrollView_ContentSize: @[LookinAttr_UIScrollView_ContentSize_Size],
  178. LookinAttrSec_UIScrollView_Behavior: @[LookinAttr_UIScrollView_Behavior_Behavior],
  179. LookinAttrSec_UIScrollView_ShowsIndicator: @[LookinAttr_UIScrollView_ShowsIndicator_Hor,
  180. LookinAttr_UIScrollView_ShowsIndicator_Ver],
  181. LookinAttrSec_UIScrollView_Bounce: @[LookinAttr_UIScrollView_Bounce_Hor,
  182. LookinAttr_UIScrollView_Bounce_Ver],
  183. LookinAttrSec_UIScrollView_ScrollPaging: @[LookinAttr_UIScrollView_ScrollPaging_ScrollEnabled,
  184. LookinAttr_UIScrollView_ScrollPaging_PagingEnabled],
  185. LookinAttrSec_UIScrollView_ContentTouches: @[LookinAttr_UIScrollView_ContentTouches_Delay,
  186. LookinAttr_UIScrollView_ContentTouches_CanCancel],
  187. LookinAttrSec_UIScrollView_Zoom: @[LookinAttr_UIScrollView_Zoom_Bounce,
  188. LookinAttr_UIScrollView_Zoom_Scale,
  189. LookinAttr_UIScrollView_Zoom_MinScale,
  190. LookinAttr_UIScrollView_Zoom_MaxScale],
  191. LookinAttrSec_UITableView_Style: @[LookinAttr_UITableView_Style_Style],
  192. LookinAttrSec_UITableView_SectionsNumber: @[LookinAttr_UITableView_SectionsNumber_Number],
  193. LookinAttrSec_UITableView_RowsNumber: @[LookinAttr_UITableView_RowsNumber_Number],
  194. LookinAttrSec_UITableView_SeparatorInset: @[LookinAttr_UITableView_SeparatorInset_Inset],
  195. LookinAttrSec_UITableView_SeparatorColor: @[LookinAttr_UITableView_SeparatorColor_Color],
  196. LookinAttrSec_UITableView_SeparatorStyle: @[LookinAttr_UITableView_SeparatorStyle_Style],
  197. LookinAttrSec_UITextView_Basic: @[LookinAttr_UITextView_Basic_Editable,
  198. LookinAttr_UITextView_Basic_Selectable],
  199. LookinAttrSec_UITextView_Text: @[LookinAttr_UITextView_Text_Text],
  200. LookinAttrSec_UITextView_Font: @[LookinAttr_UITextView_Font_Name,
  201. LookinAttr_UITextView_Font_Size],
  202. LookinAttrSec_UITextView_TextColor: @[LookinAttr_UITextView_TextColor_Color],
  203. LookinAttrSec_UITextView_Alignment: @[LookinAttr_UITextView_Alignment_Alignment],
  204. LookinAttrSec_UITextView_ContainerInset: @[LookinAttr_UITextView_ContainerInset_Inset],
  205. LookinAttrSec_UITextField_Text: @[LookinAttr_UITextField_Text_Text],
  206. LookinAttrSec_UITextField_Placeholder: @[LookinAttr_UITextField_Placeholder_Placeholder],
  207. LookinAttrSec_UITextField_Font: @[LookinAttr_UITextField_Font_Name,
  208. LookinAttr_UITextField_Font_Size],
  209. LookinAttrSec_UITextField_TextColor: @[LookinAttr_UITextField_TextColor_Color],
  210. LookinAttrSec_UITextField_Alignment: @[LookinAttr_UITextField_Alignment_Alignment],
  211. LookinAttrSec_UITextField_Clears: @[LookinAttr_UITextField_Clears_ClearsOnBeginEditing,
  212. LookinAttr_UITextField_Clears_ClearsOnInsertion],
  213. LookinAttrSec_UITextField_CanAdjustFont: @[LookinAttr_UITextField_CanAdjustFont_CanAdjustFont,
  214. LookinAttr_UITextField_CanAdjustFont_MinSize],
  215. LookinAttrSec_UITextField_ClearButtonMode: @[LookinAttr_UITextField_ClearButtonMode_Mode]
  216. };
  217. });
  218. return dict[sectionID];
  219. }
  220. + (void)getHostGroupID:(inout LookinAttrGroupIdentifier *)groupID_inout sectionID:(inout LookinAttrSectionIdentifier *)sectionID_inout fromAttrID:(LookinAttrIdentifier)targetAttrID {
  221. __block LookinAttrGroupIdentifier targetGroupID = nil;
  222. __block LookinAttrSectionIdentifier targetSecID = nil;
  223. [[self groupIDs] enumerateObjectsUsingBlock:^(LookinAttrGroupIdentifier _Nonnull groupID, NSUInteger idx, BOOL * _Nonnull stop0) {
  224. [[self sectionIDsForGroupID:groupID] enumerateObjectsUsingBlock:^(LookinAttrSectionIdentifier _Nonnull secID, NSUInteger idx, BOOL * _Nonnull stop1) {
  225. [[self attrIDsForSectionID:secID] enumerateObjectsUsingBlock:^(LookinAttrIdentifier _Nonnull attrID, NSUInteger idx, BOOL * _Nonnull stop2) {
  226. if ([attrID isEqualToString:targetAttrID]) {
  227. targetGroupID = groupID;
  228. targetSecID = secID;
  229. *stop0 = YES;
  230. *stop1 = YES;
  231. *stop2 = YES;
  232. }
  233. }];
  234. }];
  235. }];
  236. if (groupID_inout && targetGroupID) {
  237. *groupID_inout = targetGroupID;
  238. }
  239. if (sectionID_inout && targetSecID) {
  240. *sectionID_inout = targetSecID;
  241. }
  242. }
  243. + (NSString *)groupTitleWithGroupID:(LookinAttrGroupIdentifier)groupID {
  244. static dispatch_once_t onceToken;
  245. static NSDictionary *rawInfo = nil;
  246. dispatch_once(&onceToken,^{
  247. rawInfo = @{
  248. LookinAttrGroup_Class: @"Class",
  249. LookinAttrGroup_Relation: @"Relation",
  250. LookinAttrGroup_Layout: @"Layout",
  251. LookinAttrGroup_AutoLayout: @"AutoLayout",
  252. LookinAttrGroup_ViewLayer: @"CALayer / UIView",
  253. LookinAttrGroup_UIImageView: @"UIImageView",
  254. LookinAttrGroup_UILabel: @"UILabel",
  255. LookinAttrGroup_UIControl: @"UIControl",
  256. LookinAttrGroup_UIButton: @"UIButton",
  257. LookinAttrGroup_UIScrollView: @"UIScrollView",
  258. LookinAttrGroup_UITableView: @"UITableView",
  259. LookinAttrGroup_UITextView: @"UITextView",
  260. LookinAttrGroup_UITextField: @"UITextField",
  261. LookinAttrGroup_UIVisualEffectView: @"UIVisualEffectView"
  262. };
  263. });
  264. NSString *title = rawInfo[groupID];
  265. NSAssert(title.length, @"");
  266. return title;
  267. }
  268. + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID {
  269. static dispatch_once_t onceToken;
  270. static NSDictionary *rawInfo = nil;
  271. dispatch_once(&onceToken,^{
  272. rawInfo = @{
  273. LookinAttrSec_Layout_Frame: @"Frame",
  274. LookinAttrSec_Layout_Bounds: @"Bounds",
  275. LookinAttrSec_Layout_SafeArea: @"SafeArea",
  276. LookinAttrSec_Layout_Position: @"Position",
  277. LookinAttrSec_Layout_AnchorPoint: @"AnchorPoint",
  278. LookinAttrSec_AutoLayout_Hugging: @"HuggingPriority",
  279. LookinAttrSec_AutoLayout_Resistance: @"ResistancePriority",
  280. LookinAttrSec_AutoLayout_IntrinsicSize: @"IntrinsicSize",
  281. LookinAttrSec_ViewLayer_Corner: @"CornerRadius",
  282. LookinAttrSec_ViewLayer_BgColor: @"BackgroundColor",
  283. LookinAttrSec_ViewLayer_Border: @"Border",
  284. LookinAttrSec_ViewLayer_Shadow: @"Shadow",
  285. LookinAttrSec_ViewLayer_ContentMode: @"ContentMode",
  286. LookinAttrSec_ViewLayer_TintColor: @"TintColor",
  287. LookinAttrSec_ViewLayer_Tag: @"Tag",
  288. LookinAttrSec_UIVisualEffectView_Style: @"Style",
  289. LookinAttrSec_UIVisualEffectView_QMUIForegroundColor: @"ForegroundColor",
  290. LookinAttrSec_UIImageView_Name: @"ImageName",
  291. LookinAttrSec_UILabel_TextColor: @"TextColor",
  292. LookinAttrSec_UITextView_TextColor: @"TextColor",
  293. LookinAttrSec_UITextField_TextColor: @"TextColor",
  294. LookinAttrSec_UILabel_BreakMode: @"LineBreakMode",
  295. LookinAttrSec_UILabel_NumberOfLines: @"NumberOfLines",
  296. LookinAttrSec_UILabel_Text: @"Text",
  297. LookinAttrSec_UITextView_Text: @"Text",
  298. LookinAttrSec_UITextField_Text: @"Text",
  299. LookinAttrSec_UITextField_Placeholder: @"Placeholder",
  300. LookinAttrSec_UILabel_Alignment: @"TextAlignment",
  301. LookinAttrSec_UITextView_Alignment: @"TextAlignment",
  302. LookinAttrSec_UITextField_Alignment: @"TextAlignment",
  303. LookinAttrSec_UIControl_HorAlignment: @"HorizontalAlignment",
  304. LookinAttrSec_UIControl_VerAlignment: @"VerticalAlignment",
  305. LookinAttrSec_UIControl_QMUIOutsideEdge: @"QMUI_outsideEdge",
  306. LookinAttrSec_UIButton_ContentInsets: @"ContentInsets",
  307. LookinAttrSec_UIButton_TitleInsets: @"TitleInsets",
  308. LookinAttrSec_UIButton_ImageInsets: @"ImageInsets",
  309. LookinAttrSec_UIScrollView_QMUIInitialInset: @"QMUI_initialContentInset",
  310. LookinAttrSec_UIScrollView_ContentInset: @"ContentInset",
  311. LookinAttrSec_UIScrollView_AdjustedInset: @"AdjustedContentInset",
  312. LookinAttrSec_UIScrollView_IndicatorInset: @"ScrollIndicatorInsets",
  313. LookinAttrSec_UIScrollView_Offset: @"ContentOffset",
  314. LookinAttrSec_UIScrollView_ContentSize: @"ContentSize",
  315. LookinAttrSec_UIScrollView_Behavior: @"InsetAdjustmentBehavior",
  316. LookinAttrSec_UIScrollView_ShowsIndicator: @"ShowsScrollIndicator",
  317. LookinAttrSec_UIScrollView_Bounce: @"AlwaysBounce",
  318. LookinAttrSec_UIScrollView_Zoom: @"Zoom",
  319. LookinAttrSec_UITableView_Style: @"Style",
  320. LookinAttrSec_UITableView_SectionsNumber: @"NumberOfSections",
  321. LookinAttrSec_UITableView_RowsNumber: @"NumberOfRows",
  322. LookinAttrSec_UITableView_SeparatorColor: @"SeparatorColor",
  323. LookinAttrSec_UITableView_SeparatorInset: @"SeparatorInset",
  324. LookinAttrSec_UITableView_SeparatorStyle: @"SeparatorStyle",
  325. LookinAttrSec_UILabel_Font: @"Font",
  326. LookinAttrSec_UITextField_Font: @"Font",
  327. LookinAttrSec_UITextView_Font: @"Font",
  328. LookinAttrSec_UITextView_ContainerInset: @"ContainerInset",
  329. LookinAttrSec_UITextField_ClearButtonMode: @"ClearButtonMode",
  330. };
  331. });
  332. return rawInfo[secID];
  333. }
  334. /**
  335. className: 必填项,标识该属性是哪一个类拥有的
  336. fullTitle: 完整的名字,将作为搜索的 keywords,也会展示在搜索结果中,如果为 nil 则不会被搜索到
  337. briefTitle:简略的名字,仅 checkbox 和那种自带标题的 input 才需要这个属性,如果需要该属性但该属性又为空,则会读取 fullTitle
  338. setterString:用户试图修改属性值时会用到,若该字段为空字符串(即 @“”)则该属性不可修改,若该字段为 nil 则会在 fullTitle 的基础上自动生成(自动改首字母大小写、加前缀后缀,比如 alpha 会被转换为 setAlpha:)
  339. getterString:必填项,业务中读取属性值时会用到。如果该字段为 nil ,则会在 fullTitle 的基础上自动生成(自动把 fullTitle 的第一个字母改成小写,比如 Alpha 会被转换为 alpha)。如果该字段为空字符串(比如 image_open_open)则属性值会被固定为 nil,attrType 会被指为 LookinAttrTypeCustomObj
  340. typeIfObj:当某个 LookinAttribute 确定是 NSObject 类型时,该方法返回它具体是什么对象,比如 UIColor、NSString
  341. enumList:如果某个 attribute 是 enum,则这里标识了相应的 enum 的名称(如 "NSTextAlignment"),业务可通过这个名称进而查询可用的枚举值列表
  342. patch:如果为 YES,则用户修改了该 Attribute 的值后,Lookin 会重新拉取和更新相关图层的位置、截图等信息,如果为 nil 则默认是 NO
  343. hideIfNil:如果为 YES,则当获取的 value 为 nil 时,Lookin 不会传输该 attr。如果为 NO,则即使 value 为 nil 也会传输(比如 label 的 text 属性,即使它是 nil 我们也要显示,所以它的 hideIfNil 应该为 NO)。如果该字段为 nil 则默认是 NO
  344. osVersion: 该属性需要的最低的 iOS 版本,比如 safeAreaInsets 从 iOS 11.0 开始出现,则该属性应该为 @11,如果为 nil 则表示不限制 iOS 版本(注意 Lookin 项目仅支持 iOS 8.0+)
  345. */
  346. + (NSDictionary<NSString *, id> *)_infoForAttrID:(LookinAttrIdentifier)attrID {
  347. static NSDictionary<LookinAttrIdentifier, NSDictionary<NSString *, id> *> *dict;
  348. static dispatch_once_t onceToken;
  349. dispatch_once(&onceToken,^{
  350. dict = @{
  351. LookinAttr_Class_Class_Class: @{
  352. @"className": @"CALayer",
  353. @"getterString": @"lks_relatedClassChainList",
  354. @"setterString": @"",
  355. @"typeIfObj": @(LookinAttrTypeCustomObj)
  356. },
  357. LookinAttr_Relation_Relation_Relation: @{
  358. @"className": @"CALayer",
  359. @"getterString": @"lks_selfRelation",
  360. @"setterString": @"",
  361. @"typeIfObj": @(LookinAttrTypeCustomObj),
  362. @"hideIfNil": @(YES)
  363. },
  364. LookinAttr_Layout_Frame_Frame: @{
  365. @"className": @"CALayer",
  366. @"fullTitle": @"Frame",
  367. @"patch": @(YES)
  368. },
  369. LookinAttr_Layout_Bounds_Bounds: @{
  370. @"className": @"CALayer",
  371. @"fullTitle": @"Bounds",
  372. @"patch": @(YES)
  373. },
  374. LookinAttr_Layout_SafeArea_SafeArea: @{
  375. @"className": @"UIView",
  376. @"fullTitle": @"SafeAreaInsets",
  377. @"setterString": @"",
  378. @"osVersion": @(11)
  379. },
  380. LookinAttr_Layout_Position_Position: @{
  381. @"className": @"CALayer",
  382. @"fullTitle": @"Position",
  383. @"patch": @(YES)
  384. },
  385. LookinAttr_Layout_AnchorPoint_AnchorPoint: @{
  386. @"className": @"CALayer",
  387. @"fullTitle": @"AnchorPoint",
  388. @"patch": @(YES)
  389. },
  390. LookinAttr_AutoLayout_Hugging_Hor: @{
  391. @"className": @"UIView",
  392. @"fullTitle": @"ContentHuggingPriority(Horizontal)",
  393. @"getterString": @"lks_horizontalContentHuggingPriority",
  394. @"setterString": @"setLks_horizontalContentHuggingPriority:",
  395. @"briefTitle": @"H",
  396. @"patch": @(YES)
  397. },
  398. LookinAttr_AutoLayout_Hugging_Ver: @{
  399. @"className": @"UIView",
  400. @"fullTitle": @"ContentHuggingPriority(Vertical)",
  401. @"getterString": @"lks_verticalContentHuggingPriority",
  402. @"setterString": @"setLks_verticalContentHuggingPriority:",
  403. @"briefTitle": @"V",
  404. @"patch": @(YES)
  405. },
  406. LookinAttr_AutoLayout_Resistance_Hor: @{
  407. @"className": @"UIView",
  408. @"fullTitle": @"ContentCompressionResistancePriority(Horizontal)",
  409. @"getterString": @"lks_horizontalContentCompressionResistancePriority",
  410. @"setterString": @"setLks_horizontalContentCompressionResistancePriority:",
  411. @"briefTitle": @"H",
  412. @"patch": @(YES)
  413. },
  414. LookinAttr_AutoLayout_Resistance_Ver: @{
  415. @"className": @"UIView",
  416. @"fullTitle": @"ContentCompressionResistancePriority(Vertical)",
  417. @"getterString": @"lks_verticalContentCompressionResistancePriority",
  418. @"setterString": @"setLks_verticalContentCompressionResistancePriority:",
  419. @"briefTitle": @"V",
  420. @"patch": @(YES)
  421. },
  422. LookinAttr_AutoLayout_Constraints_Constraints: @{
  423. @"className": @"UIView",
  424. @"getterString": @"lks_constraints",
  425. @"setterString": @"",
  426. @"typeIfObj": @(LookinAttrTypeCustomObj),
  427. @"hideIfNil": @(YES)
  428. },
  429. LookinAttr_AutoLayout_IntrinsicSize_Size: @{
  430. @"className": @"UIView",
  431. @"fullTitle": @"IntrinsicContentSize",
  432. @"setterString": @""
  433. },
  434. LookinAttr_ViewLayer_Visibility_Hidden: @{
  435. @"className": @"CALayer",
  436. @"fullTitle": @"Hidden",
  437. @"getterString": @"isHidden",
  438. @"patch": @(YES)
  439. },
  440. LookinAttr_ViewLayer_Visibility_Opacity: @{
  441. @"className": @"CALayer",
  442. @"fullTitle": @"Opacity / Alpha",
  443. @"setterString": @"setOpacity:",
  444. @"getterString": @"opacity",
  445. @"patch": @(YES)
  446. },
  447. LookinAttr_ViewLayer_InterationAndMasks_Interaction: @{
  448. @"className": @"UIView",
  449. @"fullTitle": @"UserInteractionEnabled",
  450. @"getterString": @"isUserInteractionEnabled",
  451. @"patch": @(NO)
  452. },
  453. LookinAttr_ViewLayer_InterationAndMasks_MasksToBounds: @{
  454. @"className": @"CALayer",
  455. @"fullTitle": @"MasksToBounds / ClipsToBounds",
  456. @"briefTitle": @"MasksToBounds",
  457. @"setterString": @"setMasksToBounds:",
  458. @"getterString": @"masksToBounds",
  459. @"patch": @(YES)
  460. },
  461. LookinAttr_ViewLayer_Corner_Radius: @{
  462. @"className": @"CALayer",
  463. @"fullTitle": @"CornerRadius",
  464. @"briefTitle": @"",
  465. @"patch": @(YES)
  466. },
  467. LookinAttr_ViewLayer_BgColor_BgColor: @{
  468. @"className": @"CALayer",
  469. @"fullTitle": @"BackgroundColor",
  470. @"setterString": @"setLks_backgroundColor:",
  471. @"getterString": @"lks_backgroundColor",
  472. @"typeIfObj": @(LookinAttrTypeUIColor),
  473. @"patch": @(YES)
  474. },
  475. LookinAttr_ViewLayer_Border_Color: @{
  476. @"className": @"CALayer",
  477. @"fullTitle": @"BorderColor",
  478. @"setterString": @"setLks_borderColor:",
  479. @"getterString": @"lks_borderColor",
  480. @"typeIfObj": @(LookinAttrTypeUIColor),
  481. @"patch": @(YES)
  482. },
  483. LookinAttr_ViewLayer_Border_Width: @{
  484. @"className": @"CALayer",
  485. @"fullTitle": @"BorderWidth",
  486. @"patch": @(YES)
  487. },
  488. LookinAttr_ViewLayer_Shadow_Color: @{
  489. @"className": @"CALayer",
  490. @"fullTitle": @"ShadowColor",
  491. @"setterString": @"setLks_shadowColor:",
  492. @"getterString": @"lks_shadowColor",
  493. @"typeIfObj": @(LookinAttrTypeUIColor),
  494. @"patch": @(YES)
  495. },
  496. LookinAttr_ViewLayer_Shadow_Opacity: @{
  497. @"className": @"CALayer",
  498. @"fullTitle": @"ShadowOpacity",
  499. @"briefTitle": @"Opacity",
  500. @"patch": @(YES)
  501. },
  502. LookinAttr_ViewLayer_Shadow_Radius: @{
  503. @"className": @"CALayer",
  504. @"fullTitle": @"ShadowRadius",
  505. @"briefTitle": @"Radius",
  506. @"patch": @(YES)
  507. },
  508. LookinAttr_ViewLayer_Shadow_OffsetW: @{
  509. @"className": @"CALayer",
  510. @"fullTitle": @"ShadowOffsetWidth",
  511. @"briefTitle": @"OffsetW",
  512. @"setterString": @"setLks_shadowOffsetWidth:",
  513. @"getterString": @"lks_shadowOffsetWidth",
  514. @"patch": @(YES)
  515. },
  516. LookinAttr_ViewLayer_Shadow_OffsetH: @{
  517. @"className": @"CALayer",
  518. @"fullTitle": @"ShadowOffsetHeight",
  519. @"briefTitle": @"OffsetH",
  520. @"setterString": @"setLks_shadowOffsetHeight:",
  521. @"getterString": @"lks_shadowOffsetHeight",
  522. @"patch": @(YES)
  523. },
  524. LookinAttr_ViewLayer_ContentMode_Mode: @{
  525. @"className": @"UIView",
  526. @"fullTitle": @"ContentMode",
  527. @"enumList": @"UIViewContentMode",
  528. @"patch": @(YES)
  529. },
  530. LookinAttr_ViewLayer_TintColor_Color: @{
  531. @"className": @"UIView",
  532. @"fullTitle": @"TintColor",
  533. @"typeIfObj": @(LookinAttrTypeUIColor),
  534. @"patch": @(YES)
  535. },
  536. LookinAttr_ViewLayer_TintColor_Mode: @{
  537. @"className": @"UIView",
  538. @"fullTitle": @"TintAdjustmentMode",
  539. @"enumList": @"UIViewTintAdjustmentMode",
  540. @"patch": @(YES)
  541. },
  542. LookinAttr_ViewLayer_Tag_Tag: @{
  543. @"className": @"UIView",
  544. @"fullTitle": @"Tag",
  545. @"briefTitle": @"",
  546. @"patch": @(NO)
  547. },
  548. LookinAttr_UIVisualEffectView_Style_Style: @{
  549. @"className": @"UIVisualEffectView",
  550. @"setterString": @"setLks_blurEffectStyleNumber:",
  551. @"getterString": @"lks_blurEffectStyleNumber",
  552. @"enumList": @"UIBlurEffectStyle",
  553. @"typeIfObj": @(LookinAttrTypeCustomObj),
  554. @"patch": @(YES),
  555. @"hideIfNil": @(YES)
  556. },
  557. LookinAttr_UIVisualEffectView_QMUIForegroundColor_Color: @{
  558. @"className": @"QMUIVisualEffectView",
  559. @"fullTitle": @"ForegroundColor",
  560. @"typeIfObj": @(LookinAttrTypeUIColor),
  561. @"patch": @(YES),
  562. },
  563. LookinAttr_UIImageView_Name_Name: @{
  564. @"className": @"UIImageView",
  565. @"fullTitle": @"ImageName",
  566. @"setterString": @"",
  567. @"getterString": @"lks_imageSourceName",
  568. @"typeIfObj": @(LookinAttrTypeNSString),
  569. @"hideIfNil": @(YES)
  570. },
  571. LookinAttr_UIImageView_Open_Open: @{
  572. @"className": @"UIImageView",
  573. @"setterString": @"",
  574. @"getterString": @"lks_imageViewOidIfHasImage",
  575. @"typeIfObj": @(LookinAttrTypeCustomObj),
  576. @"hideIfNil": @(YES)
  577. },
  578. LookinAttr_UILabel_Text_Text: @{
  579. @"className": @"UILabel",
  580. @"fullTitle": @"Text",
  581. @"typeIfObj": @(LookinAttrTypeNSString),
  582. @"patch": @(YES)
  583. },
  584. LookinAttr_UILabel_NumberOfLines_NumberOfLines: @{
  585. @"className": @"UILabel",
  586. @"fullTitle": @"NumberOfLines",
  587. @"briefTitle": @"",
  588. @"patch": @(YES)
  589. },
  590. LookinAttr_UILabel_Font_Size: @{
  591. @"className": @"UILabel",
  592. @"fullTitle": @"FontSize",
  593. @"briefTitle": @"FontSize",
  594. @"setterString": @"setLks_fontSize:",
  595. @"getterString": @"lks_fontSize",
  596. @"patch": @(YES)
  597. },
  598. LookinAttr_UILabel_Font_Name: @{
  599. @"className": @"UILabel",
  600. @"fullTitle": @"FontName",
  601. @"setterString": @"",
  602. @"getterString": @"lks_fontName",
  603. @"typeIfObj": @(LookinAttrTypeNSString),
  604. @"patch": @(NO)
  605. },
  606. LookinAttr_UILabel_TextColor_Color: @{
  607. @"className": @"UILabel",
  608. @"fullTitle": @"TextColor",
  609. @"typeIfObj": @(LookinAttrTypeUIColor),
  610. @"patch": @(YES)
  611. },
  612. LookinAttr_UILabel_Alignment_Alignment: @{
  613. @"className": @"UILabel",
  614. @"fullTitle": @"TextAlignment",
  615. @"enumList": @"NSTextAlignment",
  616. @"patch": @(YES)
  617. },
  618. LookinAttr_UILabel_BreakMode_Mode: @{
  619. @"className": @"UILabel",
  620. @"fullTitle": @"LineBreakMode",
  621. @"enumList": @"NSLineBreakMode",
  622. @"patch": @(YES)
  623. },
  624. LookinAttr_UILabel_CanAdjustFont_CanAdjustFont: @{
  625. @"className": @"UILabel",
  626. @"fullTitle": @"AdjustsFontSizeToFitWidth",
  627. @"patch": @(YES)
  628. },
  629. LookinAttr_UIControl_EnabledSelected_Enabled: @{
  630. @"className": @"UIControl",
  631. @"fullTitle": @"Enabled",
  632. @"getterString": @"isEnabled",
  633. @"patch": @(NO)
  634. },
  635. LookinAttr_UIControl_EnabledSelected_Selected: @{
  636. @"className": @"UIControl",
  637. @"fullTitle": @"Selected",
  638. @"getterString": @"isSelected",
  639. @"patch": @(YES)
  640. },
  641. LookinAttr_UIControl_VerAlignment_Alignment: @{
  642. @"className": @"UIControl",
  643. @"fullTitle": @"ContentVerticalAlignment",
  644. @"enumList": @"UIControlContentVerticalAlignment",
  645. @"patch": @(YES)
  646. },
  647. LookinAttr_UIControl_HorAlignment_Alignment: @{
  648. @"className": @"UIControl",
  649. @"fullTitle": @"ContentHorizontalAlignment",
  650. @"enumList": @"UIControlContentHorizontalAlignment",
  651. @"patch": @(YES)
  652. },
  653. LookinAttr_UIControl_QMUIOutsideEdge_Edge: @{
  654. @"className": @"UIControl",
  655. @"fullTitle": @"qmui_outsideEdge"
  656. },
  657. LookinAttr_UIButton_ContentInsets_Insets: @{
  658. @"className": @"UIButton",
  659. @"fullTitle": @"ContentEdgeInsets",
  660. @"patch": @(YES)
  661. },
  662. LookinAttr_UIButton_TitleInsets_Insets: @{
  663. @"className": @"UIButton",
  664. @"fullTitle": @"TitleEdgeInsets",
  665. @"patch": @(YES)
  666. },
  667. LookinAttr_UIButton_ImageInsets_Insets: @{
  668. @"className": @"UIButton",
  669. @"fullTitle": @"ImageEdgeInsets",
  670. @"patch": @(YES)
  671. },
  672. LookinAttr_UIScrollView_Offset_Offset: @{
  673. @"className": @"UIScrollView",
  674. @"fullTitle": @"ContentOffset",
  675. @"patch": @(YES)
  676. },
  677. LookinAttr_UIScrollView_ContentSize_Size: @{
  678. @"className": @"UIScrollView",
  679. @"fullTitle": @"ContentSize",
  680. @"patch": @(YES)
  681. },
  682. LookinAttr_UIScrollView_ContentInset_Inset: @{
  683. @"className": @"UIScrollView",
  684. @"fullTitle": @"ContentInset",
  685. @"patch": @(YES)
  686. },
  687. LookinAttr_UIScrollView_QMUIInitialInset_Inset: @{
  688. @"className": @"UIScrollView",
  689. @"fullTitle": @"qmui_initialContentInset",
  690. @"patch": @(YES)
  691. },
  692. LookinAttr_UIScrollView_AdjustedInset_Inset: @{
  693. @"className": @"UIScrollView",
  694. @"fullTitle": @"AdjustedContentInset",
  695. @"setterString": @"",
  696. @"osVersion": @(11)
  697. },
  698. LookinAttr_UIScrollView_Behavior_Behavior: @{
  699. @"className": @"UIScrollView",
  700. @"fullTitle": @"ContentInsetAdjustmentBehavior",
  701. @"enumList": @"UIScrollViewContentInsetAdjustmentBehavior",
  702. @"patch": @(YES),
  703. @"osVersion": @(11)
  704. },
  705. LookinAttr_UIScrollView_IndicatorInset_Inset: @{
  706. @"className": @"UIScrollView",
  707. @"fullTitle": @"ScrollIndicatorInsets",
  708. @"patch": @(NO)
  709. },
  710. LookinAttr_UIScrollView_ScrollPaging_ScrollEnabled: @{
  711. @"className": @"UIScrollView",
  712. @"fullTitle": @"ScrollEnabled",
  713. @"getterString": @"isScrollEnabled",
  714. @"patch": @(NO)
  715. },
  716. LookinAttr_UIScrollView_ScrollPaging_PagingEnabled: @{
  717. @"className": @"UIScrollView",
  718. @"fullTitle": @"PagingEnabled",
  719. @"getterString": @"isPagingEnabled",
  720. @"patch": @(NO)
  721. },
  722. LookinAttr_UIScrollView_Bounce_Ver: @{
  723. @"className": @"UIScrollView",
  724. @"fullTitle": @"AlwaysBounceVertical",
  725. @"briefTitle": @"Vertical",
  726. @"patch": @(NO)
  727. },
  728. LookinAttr_UIScrollView_Bounce_Hor: @{
  729. @"className": @"UIScrollView",
  730. @"fullTitle": @"AlwaysBounceHorizontal",
  731. @"briefTitle": @"Horizontal",
  732. @"patch": @(NO)
  733. },
  734. LookinAttr_UIScrollView_ShowsIndicator_Hor: @{
  735. @"className": @"UIScrollView",
  736. @"fullTitle": @"ShowsHorizontalScrollIndicator",
  737. @"briefTitle": @"Horizontal",
  738. @"patch": @(NO)
  739. },
  740. LookinAttr_UIScrollView_ShowsIndicator_Ver: @{
  741. @"className": @"UIScrollView",
  742. @"fullTitle": @"ShowsVerticalScrollIndicator",
  743. @"briefTitle": @"Vertical",
  744. @"patch": @(NO)
  745. },
  746. LookinAttr_UIScrollView_ContentTouches_Delay: @{
  747. @"className": @"UIScrollView",
  748. @"fullTitle": @"DelaysContentTouches",
  749. @"patch": @(NO)
  750. },
  751. LookinAttr_UIScrollView_ContentTouches_CanCancel: @{
  752. @"className": @"UIScrollView",
  753. @"fullTitle": @"CanCancelContentTouches",
  754. @"patch": @(NO)
  755. },
  756. LookinAttr_UIScrollView_Zoom_MinScale: @{
  757. @"className": @"UIScrollView",
  758. @"fullTitle": @"MinimumZoomScale",
  759. @"briefTitle": @"MinScale",
  760. @"patch": @(NO)
  761. },
  762. LookinAttr_UIScrollView_Zoom_MaxScale: @{
  763. @"className": @"UIScrollView",
  764. @"fullTitle": @"MaximumZoomScale",
  765. @"briefTitle": @"MaxScale",
  766. @"patch": @(NO)
  767. },
  768. LookinAttr_UIScrollView_Zoom_Scale: @{
  769. @"className": @"UIScrollView",
  770. @"fullTitle": @"ZoomScale",
  771. @"briefTitle": @"Scale",
  772. @"patch": @(YES)
  773. },
  774. LookinAttr_UIScrollView_Zoom_Bounce: @{
  775. @"className": @"UIScrollView",
  776. @"fullTitle": @"BouncesZoom",
  777. @"patch": @(NO)
  778. },
  779. LookinAttr_UITableView_Style_Style: @{
  780. @"className": @"UITableView",
  781. @"fullTitle": @"Style",
  782. @"setterString": @"",
  783. @"enumList": @"UITableViewStyle",
  784. @"patch": @(YES)
  785. },
  786. LookinAttr_UITableView_SectionsNumber_Number: @{
  787. @"className": @"UITableView",
  788. @"fullTitle": @"NumberOfSections",
  789. @"setterString": @"",
  790. @"patch": @(YES)
  791. },
  792. LookinAttr_UITableView_RowsNumber_Number: @{
  793. @"className": @"UITableView",
  794. @"setterString": @"",
  795. @"getterString": @"lks_numberOfRows",
  796. @"typeIfObj": @(LookinAttrTypeCustomObj)
  797. },
  798. LookinAttr_UITableView_SeparatorInset_Inset: @{
  799. @"className": @"UITableView",
  800. @"fullTitle": @"SeparatorInset",
  801. @"patch": @(NO)
  802. },
  803. LookinAttr_UITableView_SeparatorColor_Color: @{
  804. @"className": @"UITableView",
  805. @"fullTitle": @"SeparatorColor",
  806. @"typeIfObj": @(LookinAttrTypeUIColor),
  807. @"patch": @(YES)
  808. },
  809. LookinAttr_UITableView_SeparatorStyle_Style: @{
  810. @"className": @"UITableView",
  811. @"fullTitle": @"SeparatorStyle",
  812. @"enumList": @"UITableViewCellSeparatorStyle",
  813. @"patch": @(YES)
  814. },
  815. LookinAttr_UITextView_Text_Text: @{
  816. @"className": @"UITextView",
  817. @"fullTitle": @"Text",
  818. @"typeIfObj": @(LookinAttrTypeNSString),
  819. @"patch": @(YES)
  820. },
  821. LookinAttr_UITextView_Font_Name: @{
  822. @"className": @"UITextView",
  823. @"fullTitle": @"FontName",
  824. @"setterString": @"",
  825. @"getterString": @"lks_fontName",
  826. @"typeIfObj": @(LookinAttrTypeNSString),
  827. @"patch": @(NO)
  828. },
  829. LookinAttr_UITextView_Font_Size: @{
  830. @"className": @"UITextView",
  831. @"fullTitle": @"FontSize",
  832. @"setterString": @"setLks_fontSize:",
  833. @"getterString": @"lks_fontSize",
  834. @"patch": @(YES)
  835. },
  836. LookinAttr_UITextView_Basic_Editable: @{
  837. @"className": @"UITextView",
  838. @"fullTitle": @"Editable",
  839. @"getterString": @"isEditable",
  840. @"patch": @(NO)
  841. },
  842. LookinAttr_UITextView_Basic_Selectable: @{
  843. @"className": @"UITextView",
  844. @"fullTitle": @"Selectable",
  845. @"getterString": @"isSelectable",
  846. @"patch": @(NO)
  847. },
  848. LookinAttr_UITextView_TextColor_Color: @{
  849. @"className": @"UITextView",
  850. @"fullTitle": @"TextColor",
  851. @"typeIfObj": @(LookinAttrTypeUIColor),
  852. @"patch": @(YES)
  853. },
  854. LookinAttr_UITextView_Alignment_Alignment: @{
  855. @"className": @"UITextView",
  856. @"fullTitle": @"TextAlignment",
  857. @"enumList": @"NSTextAlignment",
  858. @"patch": @(YES)
  859. },
  860. LookinAttr_UITextView_ContainerInset_Inset: @{
  861. @"className": @"UITextView",
  862. @"fullTitle": @"TextContainerInset",
  863. @"patch": @(YES)
  864. },
  865. LookinAttr_UITextField_Font_Name: @{
  866. @"className": @"UITextField",
  867. @"fullTitle": @"FontName",
  868. @"setterString": @"",
  869. @"getterString": @"lks_fontName",
  870. @"typeIfObj": @(LookinAttrTypeNSString),
  871. @"patch": @(NO)
  872. },
  873. LookinAttr_UITextField_Font_Size: @{
  874. @"className": @"UITextField",
  875. @"fullTitle": @"FontSize",
  876. @"setterString": @"setLks_fontSize:",
  877. @"getterString": @"lks_fontSize",
  878. @"patch": @(YES)
  879. },
  880. LookinAttr_UITextField_TextColor_Color: @{
  881. @"className": @"UITextField",
  882. @"fullTitle": @"TextColor",
  883. @"typeIfObj": @(LookinAttrTypeUIColor),
  884. @"patch": @(YES)
  885. },
  886. LookinAttr_UITextField_Alignment_Alignment: @{
  887. @"className": @"UITextField",
  888. @"fullTitle": @"TextAlignment",
  889. @"enumList": @"NSTextAlignment",
  890. @"patch": @(YES)
  891. },
  892. LookinAttr_UITextField_Text_Text: @{
  893. @"className": @"UITextField",
  894. @"fullTitle": @"Text",
  895. @"typeIfObj": @(LookinAttrTypeNSString),
  896. @"patch": @(YES)
  897. },
  898. LookinAttr_UITextField_Placeholder_Placeholder: @{
  899. @"className": @"UITextField",
  900. @"fullTitle": @"Placeholder",
  901. @"typeIfObj": @(LookinAttrTypeNSString),
  902. @"patch": @(YES)
  903. },
  904. LookinAttr_UITextField_Clears_ClearsOnBeginEditing: @{
  905. @"className": @"UITextField",
  906. @"fullTitle": @"ClearsOnBeginEditing",
  907. @"patch": @(NO)
  908. },
  909. LookinAttr_UITextField_Clears_ClearsOnInsertion: @{
  910. @"className": @"UITextField",
  911. @"fullTitle": @"ClearsOnInsertion",
  912. @"patch": @(NO)
  913. },
  914. LookinAttr_UITextField_CanAdjustFont_CanAdjustFont: @{
  915. @"className": @"UITextField",
  916. @"fullTitle": @"AdjustsFontSizeToFitWidth",
  917. @"patch": @(YES)
  918. },
  919. LookinAttr_UITextField_CanAdjustFont_MinSize: @{
  920. @"className": @"UITextField",
  921. @"fullTitle": @"MinimumFontSize",
  922. @"patch": @(YES)
  923. },
  924. LookinAttr_UITextField_ClearButtonMode_Mode: @{
  925. @"className": @"UITextField",
  926. @"fullTitle": @"ClearButtonMode",
  927. @"enumList": @"UITextFieldViewMode",
  928. @"patch": @(NO)
  929. },
  930. };
  931. });
  932. NSDictionary<NSString *, id> *targetInfo = dict[attrID];
  933. return targetInfo;
  934. }
  935. + (LookinAttrType)objectAttrTypeWithAttrID:(LookinAttrIdentifier)attrID {
  936. NSDictionary<NSString *, id> *attrInfo = [self _infoForAttrID:attrID];
  937. NSNumber *typeIfObj = attrInfo[@"typeIfObj"];
  938. return [typeIfObj integerValue];
  939. }
  940. + (NSString *)classNameWithAttrID:(LookinAttrIdentifier)attrID {
  941. NSDictionary<NSString *, id> *attrInfo = [self _infoForAttrID:attrID];
  942. NSString *className = attrInfo[@"className"];
  943. NSAssert(className.length > 0, @"");
  944. return className;
  945. }
  946. + (BOOL)isUIViewPropertyWithAttrID:(LookinAttrIdentifier)attrID {
  947. NSString *className = [self classNameWithAttrID:attrID];
  948. if ([className isEqualToString:@"CALayer"]) {
  949. return NO;
  950. }
  951. return YES;
  952. }
  953. + (NSString *)enumListNameWithAttrID:(LookinAttrIdentifier)attrID {
  954. NSDictionary<NSString *, id> *attrInfo = [self _infoForAttrID:attrID];
  955. NSString *name = attrInfo[@"enumList"];
  956. return name;
  957. }
  958. + (BOOL)needPatchAfterModificationWithAttrID:(LookinAttrIdentifier)attrID {
  959. NSDictionary<NSString *, id> *attrInfo = [self _infoForAttrID:attrID];
  960. NSNumber *needPatch = attrInfo[@"patch"];
  961. return [needPatch boolValue];
  962. }
  963. + (NSString *)fullTitleWithAttrID:(LookinAttrIdentifier)attrID {
  964. NSDictionary<NSString *, id> *attrInfo = [self _infoForAttrID:attrID];
  965. NSString *fullTitle = attrInfo[@"fullTitle"];
  966. return fullTitle;
  967. }
  968. + (NSString *)briefTitleWithAttrID:(LookinAttrIdentifier)attrID {
  969. NSDictionary<NSString *, id> *attrInfo = [self _infoForAttrID:attrID];
  970. NSString *briefTitle = attrInfo[@"briefTitle"];
  971. if (!briefTitle) {
  972. briefTitle = attrInfo[@"fullTitle"];
  973. }
  974. return briefTitle;
  975. }
  976. + (SEL)getterWithAttrID:(LookinAttrIdentifier)attrID {
  977. NSDictionary<NSString *, id> *attrInfo = [self _infoForAttrID:attrID];
  978. NSString *getterString = attrInfo[@"getterString"];
  979. if (getterString && getterString.length == 0) {
  980. // 空字符串,比如 image_open_open
  981. return nil;
  982. }
  983. if (!getterString) {
  984. NSString *fullTitle = attrInfo[@"fullTitle"];
  985. NSAssert(fullTitle.length > 0, @"");
  986. getterString = [NSString stringWithFormat:@"%@%@", [fullTitle substringToIndex:1].lowercaseString, [fullTitle substringFromIndex:1]].copy;
  987. }
  988. return NSSelectorFromString(getterString);
  989. }
  990. + (SEL)setterWithAttrID:(LookinAttrIdentifier)attrID {
  991. NSDictionary<NSString *, id> *attrInfo = [self _infoForAttrID:attrID];
  992. NSString *setterString = attrInfo[@"setterString"];
  993. if ([setterString isEqualToString:@""]) {
  994. // 该属性不可在 Lookin 客户端中被修改
  995. return nil;
  996. }
  997. if (!setterString) {
  998. NSString *fullTitle = attrInfo[@"fullTitle"];
  999. NSAssert(fullTitle.length > 0, @"");
  1000. setterString = [NSString stringWithFormat:@"set%@%@:", [fullTitle substringToIndex:1].uppercaseString, [fullTitle substringFromIndex:1]];
  1001. }
  1002. return NSSelectorFromString(setterString);
  1003. }
  1004. + (BOOL)hideIfNilWithAttrID:(LookinAttrIdentifier)attrID {
  1005. NSDictionary<NSString *, id> *attrInfo = [self _infoForAttrID:attrID];
  1006. NSNumber *boolValue = attrInfo[@"hideIfNil"];
  1007. return boolValue.boolValue;
  1008. }
  1009. + (NSInteger)minAvailableOSVersionWithAttrID:(LookinAttrIdentifier)attrID {
  1010. NSDictionary<NSString *, id> *attrInfo = [self _infoForAttrID:attrID];
  1011. NSNumber *minVerNum = attrInfo[@"osVersion"];
  1012. NSInteger minVer = [minVerNum integerValue];
  1013. return minVer;
  1014. }
  1015. @end