calimarkus / JDStatusBarNotification

Highly customizable & feature rich notifications. Interactive dismiss. Custom Views. SwiftUI. Tap-to-hold. Progress. Written in Swift, compatible for ObjC!
http://calimarkus.github.io/JDStatusBarNotification/documentation/jdstatusbarnotification
MIT License
4.22k stars 562 forks source link

No method showWithStatus in Swift #58

Closed khuong291 closed 7 years ago

krodak commented 8 years ago
JDStatusBarNotification.showWithStatus("Uploading...", styleName: "my_style")

Works perfectly for me.

jpatel956 commented 7 years ago

@krodak , can you please provide swift syntax of below method.

[JDStatusBarNotification addStyleNamed:<#identifier#> prepare:^JDStatusBarStyle(JDStatusBarStyle style) {

                               // main properties
                               style.barColor = <#color#>;
                               style.textColor = <#color#>;
                               style.font = <#font#>;

                               // advanced properties
                               style.animationType = <#type#>;
                               style.textShadow = <#shadow#>;
                               style.textVerticalPositionAdjustment = <#adjustment#>;

                               // progress bar
                               style.progressBarColor = <#color#>;
                               style.progressBarHeight = <#height#>;
                               style.progressBarPosition = <#position#>;

                               return style;
                           }];

I am tring lot but do not get success. kindly help me to out. Thanks

krodak commented 7 years ago
 enum StatusBarStyles : String {
        case Success
        case Failure
        case Uploading
    }

    //MARK: Styles
    class func setupCustomStyles() {
        JDStatusBarNotification.addStyleNamed(StatusBarStyles.Success.rawValue) { (style) -> JDStatusBarStyle! in
            style.barColor      = .cp__successBackground()
            style.textColor     = .cp__successFontColor()
            style.font          = UIFont.latoRegular(12.0)
            style.textShadow    = nil
            style.animationType = .Bounce

            return style
        }

        JDStatusBarNotification.addStyleNamed(StatusBarStyles.Uploading.rawValue) { (style) -> JDStatusBarStyle! in
            style.barColor              = .redColor()
            style.textColor             = .whiteColor()
            style.font                  = UIFont.latoRegular(12.0)
            style.textShadow            = nil
            style.animationType         = .Move
            style.progressBarColor      = .whiteColor()
            style.progressBarHeight     = CGFloat(1.0)
            style.progressBarPosition   = .Bottom
            return style
        }

        JDStatusBarNotification.addStyleNamed(StatusBarStyles.Failure.rawValue) { (style) -> JDStatusBarStyle! in
            style.barColor              = .redColor()
            style.textColor             = .whiteColor()
            style.font                  = UIFont.latoRegular(12.0)
            style.textShadow            = nil
            style.animationType         = .Bounce
            return style
        }
    }

It's Swift 2.3 as I don't have anything more up to date, but you should be fine :+1:

jpatel956 commented 7 years ago

@krodak, Thanks for your update. it will save my too many hours. thanks once again.