TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Mar 2018 |
SPMSupports SPM | ✗ |
Maintained by xiaoyaogaojian.
Depends on: | |
RxSwift | ~> 4.0 |
RxCocoa | ~> 4.0 |
To run the example project, clone the repo, and run pod install
from the Example directory first.
RxAlert is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod 'RxAlert'
Create action to conform AlertActionType
protocol
enum AlertAction: AlertActionType {
case cancel
case delete
case ok
var title: String {
switch self {
case .cancel:
return "Cancel"
case .delete:
return "Delete"
case .ok:
return "OK"
}
}
var style: UIAlertActionStyle {
switch self {
case .cancel:
return .cancel
case .delete:
return .destructive
case .ok:
return .default
}
}
// Optional
var isEnabled: Bool {
return true
}
}
Using UIAlertController.rx
UIAlertController.rx
.presented(
by: self,
title: "Title",
message: "Some message",
preferredStyle: .alert,
actions: [AlertAction.ok, AlertAction.delete, AlertAction.cancel]
)
.subscribe(onNext: { action in
switch action {
case .ok: print("OK")
case .delete: print("Delete")
case .cancel: break
}
})
.disposed(by: disposeBag)
Use demo to get more information.
xiaoyaogaojian, [email protected]
RxAlert is available under the MIT license. See the LICENSE file for more info.