CCKeyboardModel.m 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. //
  2. // CCKeyboardModel.m
  3. // CustomKeyboard
  4. //
  5. // Created by Ternence on 2021/5/14.
  6. //
  7. #import "CCKeyboardModel.h"
  8. #import <objc/runtime.h>
  9. @implementation CCKeyboardModel
  10. + (CCKeyboardModel *)analyzeModelWithDict:(NSDictionary *)dict {
  11. CCKeyboardModel *obj = [[CCKeyboardModel alloc] init];
  12. unsigned count;
  13. Ivar *ivarList = class_copyIvarList(CCKeyboardModel.class, &count);
  14. for (NSInteger i = 0; i < count; i ++) {
  15. Ivar ivar = ivarList[i];
  16. NSString *ivarName = [NSString stringWithUTF8String:ivar_getName(ivar)];
  17. NSString * key = [ivarName substringFromIndex:1];
  18. id value = dict[key];
  19. [obj setValue:value forKey:key];
  20. }
  21. return obj;
  22. }
  23. + (NSArray<NSDictionary *> *)rightKeyboardModelDicts {
  24. return @[@{@"string": @"delete_skinMaker_24x24_",
  25. @"keyboardAction": @(CCKeyboardActionDelete)},
  26. @{@"string": @"。",
  27. @"keyboardAction": @(CCKeyboardActionText)},
  28. @{@"string": @"@",
  29. @"keyboardAction": @(CCKeyboardActionText)},
  30. @{@"string": @"换行",
  31. @"keyboardAction": @(CCKeyboardActionWrap)}];
  32. }
  33. + (NSArray<NSDictionary *> *)leftKeyboardModelDicts {
  34. return @[@{@"string": @"%",
  35. @"keyboardAction": @(CCKeyboardActionText)},
  36. @{@"string": @"-",
  37. @"keyboardAction": @(CCKeyboardActionText)},
  38. @{@"string": @"+",
  39. @"keyboardAction": @(CCKeyboardActionText)},
  40. @{@"string": @"!",
  41. @"keyboardAction": @(CCKeyboardActionText)},
  42. @{@"string": @"...",
  43. @"keyboardAction": @(CCKeyboardActionText)},
  44. @{@"string": @"~",
  45. @"keyboardAction": @(CCKeyboardActionText)},
  46. @{@"string": @"'",
  47. @"keyboardAction": @(CCKeyboardActionText)},
  48. @{@"string": @"、",
  49. @"keyboardAction": @false},
  50. @{@"string": @"符号",
  51. @"keyboardAction": @(CCKeyboardActionAdd)}];
  52. }
  53. + (NSArray<NSDictionary *> *)centerKeyboardModelDicts {
  54. return @[@{@"string": @"1",
  55. @"keyboardAction": @(CCKeyboardActionText)},
  56. @{@"string": @"2",
  57. @"keyboardAction": @(CCKeyboardActionText)},
  58. @{@"string": @"3",
  59. @"keyboardAction": @(CCKeyboardActionText)},
  60. @{@"string": @"4",
  61. @"keyboardAction": @(CCKeyboardActionText)},
  62. @{@"string": @"5",
  63. @"keyboardAction": @(CCKeyboardActionText)},
  64. @{@"string": @"6",
  65. @"keyboardAction": @(CCKeyboardActionText)},
  66. @{@"string": @"7",
  67. @"keyboardAction": @(CCKeyboardActionText)},
  68. @{@"string": @"8",
  69. @"keyboardAction": @(CCKeyboardActionText)},
  70. @{@"string": @"9",
  71. @"keyboardAction": @(CCKeyboardActionText)},
  72. @{@"string": @"切换",
  73. @"keyboardAction": @(CCKeyboardActionSwitchBoard)},
  74. @{@"string": @"0",
  75. @"keyboardAction": @(CCKeyboardActionText)},
  76. @{@"string": @"空格",
  77. @"keyboardAction": @(CCKeyboardActionSpace)}
  78. ];
  79. }
  80. @end