QMUIConfigurationTemplateDark.m 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // QMUIConfigurationTemplate.m
  3. // qmui
  4. //
  5. // Created by QMUI Team on 15/3/29.
  6. // Copyright (c) 2015年 QMUI Team. All rights reserved.
  7. //
  8. #import "QMUIConfigurationTemplateDark.h"
  9. @implementation QMUIConfigurationTemplateDark
  10. #pragma mark - <QMUIConfigurationTemplateProtocol>
  11. - (void)applyConfigurationTemplate {
  12. [super applyConfigurationTemplate];
  13. QMUICMI.keyboardAppearance = UIKeyboardAppearanceDark;
  14. QMUICMI.navBarBackgroundImage = nil;
  15. QMUICMI.navBarStyle = UIBarStyleBlack;
  16. QMUICMI.tabBarBackgroundImage = nil;
  17. QMUICMI.tabBarShadowImageColor = [UIColor qmui_colorWithThemeProvider:^UIColor * _Nonnull(__kindof QMUIThemeManager * _Nonnull manager, __kindof NSObject<NSCopying> * _Nullable identifier, NSObject<QDThemeProtocol> *theme) {
  18. return theme.themeSeparatorColor;
  19. }];// 这是一个 QMUIThemeColor,在应用配置表时,QMUIThemeImage 里还没 hook qmui_imageWithColor 方法,所以无法生成一个 QMUIThemeImage 对象,所以不会自动变化,所以需要手动在 Dark 配置表里再设置一次
  20. QMUICMI.tabBarStyle = UIBarStyleBlack;
  21. QMUICMI.toolBarShadowImageColor = [UIColor qmui_colorWithThemeProvider:^UIColor * _Nonnull(__kindof QMUIThemeManager * _Nonnull manager, __kindof NSObject<NSCopying> * _Nullable identifier, NSObject<QDThemeProtocol> *theme) {
  22. return theme.themeSeparatorColor;
  23. }];// 这是一个 QMUIThemeColor,在应用配置表时,QMUIThemeImage 里还没 hook qmui_imageWithColor 方法,所以无法生成一个 QMUIThemeImage 对象,所以不会自动变化,所以需要手动在 Dark 配置表里再设置一次
  24. QMUICMI.toolBarStyle = UIBarStyleBlack;
  25. }
  26. // QMUI 2.3.0 版本里,配置表新增这个方法,返回 YES 表示在 App 启动时要自动应用这份配置表。仅当你的 App 里存在多份配置表时,才需要把除默认配置表之外的其他配置表的返回值改为 NO。
  27. - (BOOL)shouldApplyTemplateAutomatically {
  28. [QMUIThemeManagerCenter.defaultThemeManager addThemeIdentifier:self.themeName theme:self];
  29. NSString *selectedThemeIdentifier = [[NSUserDefaults standardUserDefaults] stringForKey:QDSelectedThemeIdentifier];
  30. BOOL result = [selectedThemeIdentifier isEqualToString:self.themeName];
  31. if (result) {
  32. QMUIThemeManagerCenter.defaultThemeManager.currentTheme = self;
  33. }
  34. return result;
  35. }
  36. #pragma mark - <QDThemeProtocol>
  37. - (UIColor *)themeBackgroundColor {
  38. return UIColorBlack;
  39. }
  40. - (UIColor *)themeBackgroundColorLighten {
  41. return UIColorMake(28, 28, 30);
  42. }
  43. - (UIColor *)themeBackgroundColorHighlighted {
  44. return UIColorMake(48, 49, 51);
  45. }
  46. - (UIColor *)themeTintColor {
  47. return UIColorTheme10;
  48. }
  49. - (UIColor *)themeTitleTextColor {
  50. return UIColorDarkGray1;
  51. }
  52. - (UIColor *)themeMainTextColor {
  53. return UIColorDarkGray3;
  54. }
  55. - (UIColor *)themeDescriptionTextColor {
  56. return UIColorDarkGray6;
  57. }
  58. - (UIColor *)themePlaceholderColor {
  59. return UIColorDarkGray8;
  60. }
  61. - (UIColor *)themeCodeColor {
  62. return self.themeTintColor;
  63. }
  64. - (UIColor *)themeSeparatorColor {
  65. return UIColorMake(46, 50, 54);
  66. }
  67. - (NSString *)themeName {
  68. return QDThemeIdentifierDark;
  69. }
  70. @end