From f8e2b28be22fe53aba4b1bd75a66db6937613221 Mon Sep 17 00:00:00 2001 From: Fin Date: Wed, 26 May 2021 12:43:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=B8=85=E9=99=A4=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=BA=8C=E6=AC=A1=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bark/en.lproj/Localizable.strings | 3 ++ Bark/zh-Hans.lproj/Localizable.strings | 4 +++ Controller/MessageListViewController.swift | 39 +++++++++++++++++----- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/Bark/en.lproj/Localizable.strings b/Bark/en.lproj/Localizable.strings index 3a04b68..49cad7d 100644 --- a/Bark/en.lproj/Localizable.strings +++ b/Bark/en.lproj/Localizable.strings @@ -75,3 +75,6 @@ lastHour = "The last hour"; today = "Today"; todayAndYesterday = "Today and yesterday"; allTime = "All time"; + +clearFrom = "Clear from:"; +clear = "Clear"; diff --git a/Bark/zh-Hans.lproj/Localizable.strings b/Bark/zh-Hans.lproj/Localizable.strings index d484955..deb3532 100644 --- a/Bark/zh-Hans.lproj/Localizable.strings +++ b/Bark/zh-Hans.lproj/Localizable.strings @@ -76,3 +76,7 @@ lastHour = "过去一小时"; today = "今天"; todayAndYesterday = "昨天和今天"; allTime = "所有时间"; + +clearFrom = "清除以下时间段的历史消息:"; + +clear = "清除"; diff --git a/Controller/MessageListViewController.swift b/Controller/MessageListViewController.swift index c1dda5d..6f16cfd 100644 --- a/Controller/MessageListViewController.swift +++ b/Controller/MessageListViewController.swift @@ -13,11 +13,22 @@ import RxCocoa import RxDataSources import MJRefresh -enum MessageDeleteType { - case lastHour +enum MessageDeleteType: Int{ + case lastHour = 0 case today case todayAndYesterday case allTime + + var string: String{ + get { + return [ + NSLocalizedString("lastHour"), + NSLocalizedString("today"), + NSLocalizedString("todayAndYesterday"), + NSLocalizedString("allTime"), + ][self.rawValue] + } + } } class MessageListViewController: BaseViewController { @@ -33,6 +44,7 @@ class MessageListViewController: BaseViewController { tableView.separatorStyle = .none tableView.backgroundColor = Color.grey.lighten5 tableView.register(MessageTableViewCell.self, forCellReuseIdentifier: "\(MessageTableViewCell.self)") + tableView.contentInset = UIEdgeInsets(top: 20, left: 0, bottom: 20, right: 0) return tableView }() @@ -62,21 +74,30 @@ class MessageListViewController: BaseViewController { .tap .flatMapLatest { Void -> PublishRelay in let relay = PublishRelay() - - 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 - relay.accept(.lastHour) + alert(.lastHour) })) 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 - relay.accept(.todayAndYesterday) + alert(.todayAndYesterday) })) 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) return relay