mirror of
https://github.com/Finb/Bark.git
synced 2025-12-08 21:36:01 +00:00
批量清除时,添加二次确认
This commit is contained in:
parent
e5c0f7384f
commit
f8e2b28be2
@ -75,3 +75,6 @@ lastHour = "The last hour";
|
|||||||
today = "Today";
|
today = "Today";
|
||||||
todayAndYesterday = "Today and yesterday";
|
todayAndYesterday = "Today and yesterday";
|
||||||
allTime = "All time";
|
allTime = "All time";
|
||||||
|
|
||||||
|
clearFrom = "Clear from:";
|
||||||
|
clear = "Clear";
|
||||||
|
|||||||
@ -76,3 +76,7 @@ lastHour = "过去一小时";
|
|||||||
today = "今天";
|
today = "今天";
|
||||||
todayAndYesterday = "昨天和今天";
|
todayAndYesterday = "昨天和今天";
|
||||||
allTime = "所有时间";
|
allTime = "所有时间";
|
||||||
|
|
||||||
|
clearFrom = "清除以下时间段的历史消息:";
|
||||||
|
|
||||||
|
clear = "清除";
|
||||||
|
|||||||
@ -13,11 +13,22 @@ import RxCocoa
|
|||||||
import RxDataSources
|
import RxDataSources
|
||||||
import MJRefresh
|
import MJRefresh
|
||||||
|
|
||||||
enum MessageDeleteType {
|
enum MessageDeleteType: Int{
|
||||||
case lastHour
|
case lastHour = 0
|
||||||
case today
|
case today
|
||||||
case todayAndYesterday
|
case todayAndYesterday
|
||||||
case allTime
|
case allTime
|
||||||
|
|
||||||
|
var string: String{
|
||||||
|
get {
|
||||||
|
return [
|
||||||
|
NSLocalizedString("lastHour"),
|
||||||
|
NSLocalizedString("today"),
|
||||||
|
NSLocalizedString("todayAndYesterday"),
|
||||||
|
NSLocalizedString("allTime"),
|
||||||
|
][self.rawValue]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MessageListViewController: BaseViewController {
|
class MessageListViewController: BaseViewController {
|
||||||
@ -33,6 +44,7 @@ class MessageListViewController: BaseViewController {
|
|||||||
tableView.separatorStyle = .none
|
tableView.separatorStyle = .none
|
||||||
tableView.backgroundColor = Color.grey.lighten5
|
tableView.backgroundColor = Color.grey.lighten5
|
||||||
tableView.register(MessageTableViewCell.self, forCellReuseIdentifier: "\(MessageTableViewCell.self)")
|
tableView.register(MessageTableViewCell.self, forCellReuseIdentifier: "\(MessageTableViewCell.self)")
|
||||||
|
tableView.contentInset = UIEdgeInsets(top: 20, left: 0, bottom: 20, right: 0)
|
||||||
return tableView
|
return tableView
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -62,21 +74,30 @@ class MessageListViewController: BaseViewController {
|
|||||||
.tap
|
.tap
|
||||||
.flatMapLatest { Void -> PublishRelay<MessageDeleteType> in
|
.flatMapLatest { Void -> PublishRelay<MessageDeleteType> in
|
||||||
let relay = PublishRelay<MessageDeleteType>()
|
let relay = PublishRelay<MessageDeleteType>()
|
||||||
|
|
||||||
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
func alert(_ type:MessageDeleteType){
|
||||||
|
let alertController = UIAlertController(title: nil, message: "\(NSLocalizedString("clearFrom"))\n\(type.string)", preferredStyle: .alert)
|
||||||
|
alertController.addAction(UIAlertAction(title: NSLocalizedString("clear"), style: .destructive, handler: { _ in
|
||||||
|
relay.accept(type)
|
||||||
|
}))
|
||||||
|
alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel"), style: .cancel, handler: nil))
|
||||||
|
self.navigationController?.present(alertController, animated: true, completion: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
let alertController = UIAlertController(title: nil, message: NSLocalizedString("clearFrom"), preferredStyle: .actionSheet)
|
||||||
alertController.addAction(UIAlertAction(title: NSLocalizedString("lastHour"), style: .default, handler: { _ in
|
alertController.addAction(UIAlertAction(title: NSLocalizedString("lastHour"), style: .default, handler: { _ in
|
||||||
relay.accept(.lastHour)
|
alert(.lastHour)
|
||||||
}))
|
}))
|
||||||
alertController.addAction(UIAlertAction(title: NSLocalizedString("today"), style: .default, handler: { _ in
|
alertController.addAction(UIAlertAction(title: NSLocalizedString("today"), style: .default, handler: { _ in
|
||||||
relay.accept(.today)
|
alert(.today)
|
||||||
}))
|
}))
|
||||||
alertController.addAction(UIAlertAction(title: NSLocalizedString("todayAndYesterday"), style: .default, handler: { _ in
|
alertController.addAction(UIAlertAction(title: NSLocalizedString("todayAndYesterday"), style: .default, handler: { _ in
|
||||||
relay.accept(.todayAndYesterday)
|
alert(.todayAndYesterday)
|
||||||
}))
|
}))
|
||||||
alertController.addAction(UIAlertAction(title: NSLocalizedString("allTime"), style: .default, handler: { _ in
|
alertController.addAction(UIAlertAction(title: NSLocalizedString("allTime"), style: .default, handler: { _ in
|
||||||
relay.accept(.allTime)
|
alert(.allTime)
|
||||||
}))
|
}))
|
||||||
alertController.addAction(UIAlertAction(title: NSLocalizedString("cancel"), style: .cancel, handler: nil))
|
alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel"), style: .cancel, handler: nil))
|
||||||
self.navigationController?.present(alertController, animated: true, completion: nil)
|
self.navigationController?.present(alertController, animated: true, completion: nil)
|
||||||
|
|
||||||
return relay
|
return relay
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user