Code Monkey home page Code Monkey logo

swifttheme's Introduction

Hi there 👋

  • 🇨🇳 I’m an iOS developer in Beijing
  • 💻 Focusing on Swift & iOS
  • 🌟 Github is amazing, I hope to create more useful things here

My SwiftUI Frameworks:

  • SwiftUI-WeChat: 🇨🇳 Learn how to make WeChat with SwiftUI. 微信 7.0 🟢
  • VideoPlayer: 📽 A video player for SwiftUI, support for caching, preload and custom control view.
  • Refresh: 🎈 Great SwiftUI drop-down refresh and scroll up to load more. 下拉刷新、上拉加载
  • TabBar: 🚥 TabBar for SwiftUI - Make custom TabView possible.

My UIKit Frameworks:

  • SwiftTheme: 🎨 Powerful theme/skin manager for iOS 9+ 主题/换肤, 暗色模式
  • GSMessages: A simple style messages/notifications, in Swift.
  • GSImageViewerController: An image viewer controller with zoom transition, in Swift.
  • GSPlayer: ⏯ Video player, support for caching, preload, fullscreen transition and custom control view.
  • GSRefresh: Fully customizable drop-down refresh and load more. 下拉刷新、上拉加载
  • GSCaptchaButton: 为普通按钮增加验证码倒计时功能,不影响按钮样式
  • GSChange: Automatically synchronize changes, such as likes, follow, etc.
  • GSVerificationCode: 验证码控件,支持设置输入长度、自定义外观等
  • GSAlert: [deprecated] UIAlertController support iOS 7+ and written in swift.
  • GSPhotos: [deprecated] PhotosKit+ALAssetsLibrary, support iOS 7+ and written in swift.
  • POP-SnapKit: [deprecated] Use SnapKit with the Facebook Pop animation framework.

swifttheme's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swifttheme's Issues

Keyboard appearance

Hi!

Is there any plans to support .keyboardAppearance for textfields?

Thanks for great lib :)

theme_setStatusBarStyle doesn't work as expected

Hi, thanks for your awesome project, it helps me a lot. But I got a problem.
theme colour and images works well but the status bar doesn't change respond to ThemeManager.setTheme

I add code below in my didFinishLaunchingWithOptions

UIApplication.sharedApplication().theme_setStatusBarStyle(ThemeStatusBarStylePicker(styles: .Default, .LightContent), animated: true)

It doesn't work, anything else I need to do to change my status bar style?

ThemePicker keypath 方式初始化的一些疑问

看了下代码,发现 ThemeFontPicker 和 ThemeDictionaryPicker 没有以keyPath为参数的初始化方法,ThemeFontPicker 没有比较好好理解,字符串确实不太好表达 Font,ThemeDictionaryPicker 没有就比较奇怪了(plist中是可以表达dictionary的呀),而且 ThemeManager+Plist 中也定义了 dictionaryForKeyPath(_),可能是我还没太理解,希望能够解释以下,谢谢~。

另外,上述两者如果没有 keypath初始化方法,那么使用的时候就会和其他picker不一致了,其他的picker只要指定 keypath,就可以自动完成根据theme切换属性值的功能,而如果是上述的两个picker的话,恐怕要外界自行根据theme去init?

tabBar.barStyle and navigationBar.barStyle stopped working with Swift 4

Hello, I recently updated to Swift 4 and noticed that this stopped working:

let navigationBar = UINavigationBar.appearance()
navigationBar.theme_barStyle = [.default, .black]

let tabBar = UITabBar.appearance()
tabBar.theme_barStyle = [.default, .black]

All I see is the default style that doesn't change when switching theme. Tested on both real device and simulator. However setting tabBar.barStyle = .black manually seems to work just fine. Any help?

Color of UITextField placeholder

Is there a way to style the color of an UITextField placeholder text?

Without SwiftTheme I use the attributedPlaceholder to change the color.

Theme doesn't change

I'm trying to add night mode to an app, but nothing happens. My current implementation:
I have a settings view controller which is managed by a settings presenter. That settings presenter has a segmented control for night mode On/Off.

            configurationManager.nightModeState = state
    }

Switching the state from the presenter calls a configuration manager to set and persist the night mode state

 var nightModeState: NightState {
        didSet {
            defaults.setValue(nightModeState.rawValue, forKey: ConfigurationKeys.NightModeState)
            setNightModeFor(nightModeState)
        }
    }

func setNightModeFor(_ state: NightState) {
        switch state {
        case .On:
            ThemeManager.setTheme(index: 1)
        case .Off:
            ThemeManager.setTheme(index: 0)
        }
    }

And my colors are set in appDelegate didFinishLaunching

private func setupTheming() {
        UINavigationBar.appearance().theme_backgroundColor = [UIColor.blue.description, UIColor.darkBlueNavBar.description]
        UIView.appearance().theme_backgroundColor = [UIColor.cream.description, UIColor.darkBlue.description]
    }

following with breakpoints, I can see that the notification is fired from

    public class func setTheme(index: Int) {
        currentThemeIndex = index
        NotificationCenter.default.post(name: Notification.Name(rawValue: ThemeUpdateNotification), object: nil)
    }

but nothing happens.

Anyone has any idea? Thanks!

Setting tab bar image icon and background Image

Thanks for great library, I'm trying to add themes in my tab bar application, I've different images to set for icons, but I wasn't able to find anything to achieve this scenario

Adding a notification in sub class of UITabbar or tabbarcontroller is something in my mind , you think it's good way?

特殊情况:结合SDWebImage使用

我在实际使用中遇到这种情况

[self.avatar sd_setBackgroundImageWithURL:[NSURL URLWithString:self.avatar]
                                     forState:UIControlStateNormal
                             placeholderImage:[UIImage imageWithName:@"img_avatar_user_default"]];

要求placeholderImage根据主题不同使用不同图片,不知道有什么合适的方法

SwiftTheme WARNING: Not found string key path

SwiftTheme WARNING: Not found string key path: Global.backgroundColor

I keep receiving this warning when I use setTheme in the viewDidLoad method. However, it is actually working fine and recognizes the Global.backgroundColor and sets it to the correct color depending on the current theme; there isn't any actual problem. I don't know how to stop this warning.

how can i set button state?

怎样给一个按钮 设置点击和正常不同状态的背景色? 我用的是配置plist 的方式
how can i switch button's background color with diffrent state?


v.theme_backgroundColor = "" 没有设置状态的参数 ,,谢谢

Navigation Bar themable title

I'm trying to set the navigation bar title a themable value, so I have in AppDelegate

        private func setupTheming() {
        let _ = UITextField.appearance().backgroundColor?.toHexString() ?? "000000"
        let attributes = [NSAttributedStringKey.foregroundColor.rawValue: UIColor.red.toHexString()] as [String: AnyObject]
        UINavigationBar.appearance().theme_barTintColor = [UIColor.blue.toHexString(), UIColor.nightDarkGray.toHexString()]
        UINavigationBar.appearance().theme_tintColor = [UIColor.cream.toHexString(), UIColor.nightOrange.toHexString()]
        UINavigationBar.appearance().theme_titleTextAttributes = ThemeDictionaryPicker.pickerWithDicts([attributes])

So it should be set to red, but nothing happens.
If I set the value to a a UILabel.appearance it works

UILabel.appearance().theme_textColor = [UIColor.blueGray.toHexString(), UIColor.orange.toHexString()]

Any idea on how to proceed?

Named colors in plist

Thanks for this wonderful library! I am missing just one feature at the moment and that is to name colors in the plist file so we can reference them via their name within the plist file. This way we can change just the hex value of one named color to change many elements at once. It will be convenient and will lead to less errors.

Like the color #ECF0F1 in the PlistDemo used in several places https://github.com/jiecao-fm/SwiftTheme/blob/master/PlistDemo/Night.plist

EDIT:
Maybe even shared named colors palette between multiple themes/plists? I am adding a night mode to an app and they both use the same palette.

Error Ambiguous use of init(rgba_throws:)

I'm trying to implement Plist demo inside my project after I copied the plist files from the demo then I copied your AppDelegate to my project:

     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    
    // default: Red.plist
    
    ThemeManager.setTheme(plistName: "Red", path: .mainBundle)
    
    // status bar
    
    UIApplication.shared.theme_setStatusBarStyle("UIStatusBarStyle", animated: true)
    
    // navigation bar
    
    let navigationBar = UINavigationBar.appearance()
    
    navigationBar.theme_tintColor = "Global.barTextColor"
    navigationBar.theme_barTintColor = "Global.barTintColor"
    
    navigationBar.theme_titleTextAttributes = ThemeDictionaryPicker(keyPath: "Global.barTextColor", map: { value in
        guard
            let rgba = value as? String,
            let color = try? UIColor(rgba_throws: rgba) else {
                return nil
        }
        
        let shadow = NSShadow(); shadow.shadowOffset = CGSize.zero
        let titleTextAttributes = [
            NSForegroundColorAttributeName: color,
            NSFontAttributeName: UIFont.systemFont(ofSize: 16),
            NSShadowAttributeName: shadow
        ]
        
        return titleTextAttributes
    })
    
    // tab bar
    
    let tabBar = UITabBar.appearance()
    
    tabBar.theme_tintColor = "Global.barTextColor"
    tabBar.theme_barTintColor = "Global.barTintColor"
    
    
    UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
    UINavigationBar.appearance().shadowImage = UIImage()
  }

Any ideas to solve it ?

ThemePicker初始化方法pickerWithKeyPath的问题

pickerWithKeyPath传入的路径有误,或者对应路径的值不存在,ThemePicker的对象仍旧会创建成功,并且没有其他属性来判断对象的值是否真实有效。这对于开发的容错处理造成了很大麻烦。本地的Plist文件因为自己控制可以完全避免,但是网络上的Plist皮肤文件就很有必要做这个处理了,App会随着更新改变Plist的结构来满足新的皮肤更改需求。这时候就涉及到新老Plist文件兼容,在这种情况下,这个容错处理逻辑变得极为重要,一不小心App就会随时崩溃。

an advice

maybe could add a travis auto testing to the project? so developer could see the building pass conditions
😃

Cheers

How to make fonts themeable ?

May be this sound noob but I am looking to make fonts available from theme. Is there any way to achieve this using this awesome library ?

编译出错了

你好,我编译PlistDemo时出现编译错误,在NSObject+Theme.swift页面中提示:Expcted','separator。

我对swift不熟悉,请多指教,谢谢

can not use Plist Mode in Objective-C

plist模式无法在OC中使用。
.h文件中只生成了+ (void)setTheme:(NSInteger)index;方法

SWIFT_CLASS_NAMED("ThemeManager")
@interface ThemeManager : NSObject
+ (double)animationDuration;
+ (void)setAnimationDuration:(double)value;
+ (NSDictionary * _Nullable)currentTheme;
+ (void)setCurrentTheme:(NSDictionary * _Nullable)value;
+ (NSInteger)currentThemeIndex;
+ (void)setCurrentThemeIndex:(NSInteger)value;
+ (void)setTheme:(NSInteger)index;
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
@end

原因:
ThemePath使用了Swift中的enum,而OC只支持简单的枚举,ThemePath无法导出给OC使用。

Swift的enum很强大,但为了支持OC,建议更改ThemePath的实现(有意贡献代码)

颜色扩展在iOS10后有些不同

在开发的时候发现同一个16进制的颜色在自己写的工具类和使用SwiftTheme时颜色不太一样
发现在UIColorExtension.swift中初始化颜色的时候只使用了

self.init(red: red, green: green, blue: blue, alpha: alpha)

因为在iOS10后苹果推荐使用sRGB,举其中一个函数为例子:

public convenience init(hex8: UInt32) {
        let divisor = CGFloat(255)
        let red     = CGFloat((hex8 & 0xFF000000) >> 24) / divisor
        let green   = CGFloat((hex8 & 0x00FF0000) >> 16) / divisor
        let blue    = CGFloat((hex8 & 0x0000FF00) >>  8) / divisor
        let alpha   = CGFloat( hex8 & 0x000000FF       ) / divisor
	if #available(iOS 10.0, *) {
		self.init(displayP3Red: red, green: green, blue: blue, alpha: alpha)
	} else {
		self.init(red: red, green: green, blue: blue, alpha: alpha)
	}
}

最后说一句,感谢开发者们,这款工具真的十分不错~

Add Changelog

Could you please add a changelog? It'd be nice to know the differences when new versions come out.

Change alpha for ighlighting rows with theme_backgroundColor

Hi,

Thanks for your awesome repo. 👌🏼

Before using SwiftTheme I set highlight row as follow:

`override func tableView(_ tableView: UITableView, didHighlightRowAt indexPath: IndexPath) {

        let cell = tableView.cellForRow(at: indexPath)
        
        cell?.contentView.backgroundColor = UIColor(red: 0, green: 169/255, blue: 168/255, alpha: 0.25)
}`

So as you can see I need alpha = 0.25, alpha just for the backgroundColor not for the contentView.

Is there a way to set alpha using theme_backgroundColor ??

cell?.contentView.theme_backgroundColor = ["#00a9a8", "#292b38"]

Thanks.

Swift compiler warning

Hey guys,

Thanks for creating this! Super useful!

Got a question:

  • is anyone is working on this?

Swift compiler warning

If not, I can see about submitting a PR? (Just didn't want to duplicate work in case someone already fixed it ^_^)

Thank you,
Alex

Cocoapods not working

I installed the cocoapods and them tried to set the theme (plist mode) in App Delegate using following code :

ThemeManager.setTheme(plistName: "Red", path: .mainBundle)

I was not able to get autocomplete predictions, as well as, on building the project, I was getting error on this line

Please help!!!

OC 调用Bug

下载到Documents里的plist文件,在调用setThemeWithPlistInSandbox方法的时候,会自动在plist文件名参数后拼接一个.plist后缀,导致原本的文件名由xxx.plist变成xxx.plist.plist,然后识别失败。

SwiftTheme WARNING: Not read plist 'momentsBear_theme.plist' with: /Users/fiber/Library/Developer/CoreSimulator/Devices/1FEF7344-AA28-494C-9B96-B4DF9D6F285F/data/Containers/Data/Application/D9F52344-3E99-42A8-819B-2C471D349709/Documents/Theme/1/theme3x/momentsBear_theme.plist.plist

textField.layer.theme_borderColor不生效

    textField.layer.theme_borderColor = ThemeCGColorPicker(keyPath: " LogInColors.textFieldLineColor") 一直是黑色 但我文件设置的是白色; 

我这样设置就能生效:
if let colorString = ThemeManager.value(for: "LogInColors.textFieldLineColor") as? String {
textField.layer.borderColor = UIColor.colorWithCSS(css: colorString).cgColor
}
麻烦您看下

和#11类似的问题

看了#11的问题,感觉差不多,就是一些地方的控件需要跟随夜间模式一起更改,我就扩写了UIView

extension UIView {
// 是否跟随主题自动切换背景色
    @IBInspectable var isThemed: Bool? {
        get {
            return false
        }
        
        set {
            guard let _ = newValue else { return }
            guard let _ = newValue else { return }
            //globalThemeCommonBackgroundColor是一个全局的颜色,大概就是夜间模式变黑色,其他则是白色
            theme_backgroundColor = newValue! ? globalThemeCommonBackgroundColor : nil
        }
    }
}

在StoryBoard中我勾选了一个view的Is Themed属性为On,但是在切换至夜间模式的时候并没有效果,不知道为啥,是代码的问题?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.