Skip to content

olderMonster/CheckLoginModule

Repository files navigation

CheckLoginModule

Language Swift 5 License NIT Platform

CheckLoginModule

CheckLoginModule主要是为了解决登录操作的后续逻辑。一般情况下我们在登录完成后通过代理或者callback的方式解决阻断操作连续性的问题,而通过这个库使用注解可以方便的在登录成功后自动执行注解对应的方法。

安装方式

pod 'CheckLoginModule', :git => 'https://github.com/olderMonster/CheckLoginModule.git'

使用说明

如果是在OC类中使用,在需要登录权限的方法上注解即可。 CheckLoginOC需要两个参数,当前注解方法的target以及action

@CheckLoginOC(MTViewController,buyGoodsAction)
- (void)buyGoodsAction {
    [User createOrderAlertWithViewController:self];
}

如果是在Swift类中使用,那么需要将对应的方法使用dynamic修饰 同时需要新建一个OC的类,然后在其中声明注解,同时这边需要传入的参数除了target以及action意外还需要传入对应的Module 注意这里的target也需要使用@objc修饰

@objc class DetailViewController: UIViewController {

    //被注解的方法需要使用 dynamic 修饰
    @objc dynamic func buyAction() {
        User.createOrderAlert(viewController: self)
    }
    
}

@interface CheckLoginImp()

@end

@implementation CheckLoginImp

@CheckLogin(DetailViewController,buyAction,CheckLoginModule_Example)
@CheckLogin(DetailViewController,jumpToMessagePage,CheckLoginModule_Example)


@end

实现登录操作 在定义的类中实现AnnotationDelegate协议

class User: AnnotationDelegate {

    public func authorizeAccess() -> Bool {
        return LCApplication.default.currentUser != nil
    }
    
    public func requestAuthorizeAccess(_ authoried: @escaping () -> Void) {
        if let rootViewController = UIViewController.keyWindow?.rootViewController as? UINavigationController {
            let viewController = LoginViewController()
            viewController.success = {
                authoried()
            }
            rootViewController.pushViewController(viewController, animated: true)
        }
    }
}

Author

olderMonster, 406416312@qq.com

License

CheckLoginModule is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published