diff --git a/Multimer/Multimer/Application/SceneDelegate.swift b/Multimer/Multimer/Application/SceneDelegate.swift index d210e08..f5f2432 100644 --- a/Multimer/Multimer/Application/SceneDelegate.swift +++ b/Multimer/Multimer/Application/SceneDelegate.swift @@ -16,6 +16,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { guard let windowScene = (scene as? UIWindowScene) else { return } window = UIWindow(windowScene: windowScene) + configureDefaultNavigationBarAppearance() + let rootNavigationController = UINavigationController() homeCoordinator = DefaultHomeCoordinator(navigationController: rootNavigationController) homeCoordinator?.start() @@ -24,3 +26,9 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { window?.makeKeyAndVisible() } } + +private extension SceneDelegate { + func configureDefaultNavigationBarAppearance() { + UINavigationBar.appearance().barTintColor = .systemBackground + } +} diff --git a/Multimer/Multimer/Localizing/LocalizableString.swift b/Multimer/Multimer/Localizing/LocalizableString.swift index 955812e..1c98188 100644 --- a/Multimer/Multimer/Localizing/LocalizableString.swift +++ b/Multimer/Multimer/Localizing/LocalizableString.swift @@ -39,6 +39,7 @@ enum LocalizableString { case checkNotificationPermissions case allowNotificationAuthorizationAlert case goToSettings + case selectRingtone case alertTones case ringtones case ringtoneName(ringtone: Ringtone) @@ -108,6 +109,8 @@ enum LocalizableString { return String(format: NSLocalizedString("allowNotificationAuthorizationAlert", comment: "")) case .goToSettings: return String(format: NSLocalizedString("goToSettings", comment: "")) + case .selectRingtone: + return String(format: NSLocalizedString("selectRingtone", comment: "")) case .alertTones: return String(format: NSLocalizedString("alertTones", comment: "")) case .ringtones: diff --git a/Multimer/Multimer/Localizing/en.lproj/Localizable.strings b/Multimer/Multimer/Localizing/en.lproj/Localizable.strings index 7ad744a..6b2e471 100644 --- a/Multimer/Multimer/Localizing/en.lproj/Localizable.strings +++ b/Multimer/Multimer/Localizing/en.lproj/Localizable.strings @@ -40,6 +40,8 @@ // MARK: - Ringtones +"selectRingtone" = "Select Alarm Sound"; + "alertTones" = "ALERT TONES"; "ringtones" = "RINGTONES"; diff --git a/Multimer/Multimer/Localizing/ja.lproj/Localizable.strings b/Multimer/Multimer/Localizing/ja.lproj/Localizable.strings index ef28bbf..7606a8b 100644 --- a/Multimer/Multimer/Localizing/ja.lproj/Localizable.strings +++ b/Multimer/Multimer/Localizing/ja.lproj/Localizable.strings @@ -40,6 +40,8 @@ // MARK: - Ringtones +"selectRingtone" = "アラーム音を選択"; + "alertTones" = "ALERT TONES"; "ringtones" = "RINGTONES"; diff --git a/Multimer/Multimer/Localizing/ko.lproj/Localizable.strings b/Multimer/Multimer/Localizing/ko.lproj/Localizable.strings index 585803f..cc4f5d7 100644 --- a/Multimer/Multimer/Localizing/ko.lproj/Localizable.strings +++ b/Multimer/Multimer/Localizing/ko.lproj/Localizable.strings @@ -40,6 +40,8 @@ // MARK: - Ringtones +"selectRingtone" = "알람음 설정"; + "alertTones" = "알림 소리"; "ringtones" = "벨소리"; diff --git a/Multimer/Multimer/Localizing/ru.lproj/Localizable.strings b/Multimer/Multimer/Localizing/ru.lproj/Localizable.strings index 6fd0218..701c5ec 100644 --- a/Multimer/Multimer/Localizing/ru.lproj/Localizable.strings +++ b/Multimer/Multimer/Localizing/ru.lproj/Localizable.strings @@ -40,17 +40,19 @@ // MARK: - Ringtones +"selectRingtone" = "Выберите Звук"; + "alertTones" = "ALERT TONES"; "ringtones" = "RINGTONES"; -"default1" = "звук уведомления 1"; -"default2" = "звук уведомления 2"; -"default3" = "звук уведомления 3"; -"default4" = "звук уведомления 4"; -"default5" = "звук уведомления 5"; -"default6" = "звук уведомления 6"; -"default7" = "звук уведомления 7"; -"default8" = "звук уведомления 8"; +"default1" = "Звук уведомления 1"; +"default2" = "Звук уведомления 2"; +"default3" = "Звук уведомления 3"; +"default4" = "Звук уведомления 4"; +"default5" = "Звук уведомления 5"; +"default6" = "Звук уведомления 6"; +"default7" = "Звук уведомления 7"; +"default8" = "Звук уведомления 8"; "alarm" = "Сигнал тревоги"; "bark" = "Звук лая собаки"; "beacon" = "Маяк"; @@ -58,15 +60,15 @@ "duck" = "Звук утки"; "illuminate" = "Освещение"; "marimba" = "Маримба"; -"oldPhone" = "Мелодия звонка телефона"; -"pianoRiff" = "Фортепианный рифф"; +"oldPhone" = "Мелодия Звонка Телефона"; +"pianoRiff" = "Фортепианный Рифф"; "pinball" = "Пинбол"; "presto" = "Престо"; "radar" = "Радар"; "reflection" = "Отражение"; -"сенча" = "зеленый чай"; +"сенча" = "Зеленый Чай"; "signal" = "Сигнал"; "stargaze" = "Звездочет"; -"strum" = "гитара"; -"trill" = "трель"; -"xylophone" = "ксилофон"; +"strum" = "Гитара"; +"trill" = "Трель"; +"xylophone" = "Ксилофон"; diff --git a/Multimer/Multimer/Localizing/vi.lproj/Localizable.strings b/Multimer/Multimer/Localizing/vi.lproj/Localizable.strings index 7c62b95..72775f1 100644 --- a/Multimer/Multimer/Localizing/vi.lproj/Localizable.strings +++ b/Multimer/Multimer/Localizing/vi.lproj/Localizable.strings @@ -40,6 +40,8 @@ // MARK: - Ringtones +"selectRingtone" = "Chọn Nhạc Chuông"; + "alertTones" = "ALERT TONES"; "ringtones" = "RINGTONES"; diff --git a/Multimer/Multimer/Localizing/zh-Hans.lproj/Localizable.strings b/Multimer/Multimer/Localizing/zh-Hans.lproj/Localizable.strings index f5f8599..f6c7f8b 100644 --- a/Multimer/Multimer/Localizing/zh-Hans.lproj/Localizable.strings +++ b/Multimer/Multimer/Localizing/zh-Hans.lproj/Localizable.strings @@ -40,6 +40,8 @@ // MARK: - Ringtones +"selectRingtone" = "选择警报声"; + "alertTones" = "警报音调"; "ringtones" = "铃声"; diff --git a/Multimer/Multimer/Presentation/Coordinator/Home/DefaultHomeCoordinator.swift b/Multimer/Multimer/Presentation/Coordinator/Home/DefaultHomeCoordinator.swift index eb3c855..b0e0336 100644 --- a/Multimer/Multimer/Presentation/Coordinator/Home/DefaultHomeCoordinator.swift +++ b/Multimer/Multimer/Presentation/Coordinator/Home/DefaultHomeCoordinator.swift @@ -35,6 +35,8 @@ final class DefaultHomeCoordinator: HomeCoordinator { navigationController.dismiss(animated: true) case .finishTimerEditScene: navigationController.popViewController(animated: true) + case .finishRingtoneSelectScene: + navigationController.dismiss(animated: true) } } } @@ -77,8 +79,12 @@ private extension DefaultHomeCoordinator { func presentRingtoneSelectViewController(selectedRingtoneRelay: BehaviorRelay) { let ringtoneSelectViewController = RingtoneSelectViewController() - let ringtoneSelectReactor = RingtoneSelectReactor(selectedRingtoneRelay: selectedRingtoneRelay) + let ringtoneSelectReactor = RingtoneSelectReactor( + coordinator: self, + selectedRingtoneRelay: selectedRingtoneRelay + ) ringtoneSelectViewController.reactor = ringtoneSelectReactor - navigationController.visibleViewController?.present(ringtoneSelectViewController, animated: true) + let containerNavigationController = UINavigationController(rootViewController: ringtoneSelectViewController) + navigationController.visibleViewController?.present(containerNavigationController, animated: true) } } diff --git a/Multimer/Multimer/Presentation/Coordinator/Home/HomeCoordinatorAction.swift b/Multimer/Multimer/Presentation/Coordinator/Home/HomeCoordinatorAction.swift index 730f7e4..f803ca3 100644 --- a/Multimer/Multimer/Presentation/Coordinator/Home/HomeCoordinatorAction.swift +++ b/Multimer/Multimer/Presentation/Coordinator/Home/HomeCoordinatorAction.swift @@ -14,4 +14,5 @@ enum HomeCoordinatorAction { case showRingtoneSelectScene(selectedRingtoneRelay: BehaviorRelay) case finishTimerCreateScene case finishTimerEditScene + case finishRingtoneSelectScene } diff --git a/Multimer/Multimer/Presentation/RingtoneSelect/RingtoneSelectReactor.swift b/Multimer/Multimer/Presentation/RingtoneSelect/RingtoneSelectReactor.swift index df3f1e9..675570c 100644 --- a/Multimer/Multimer/Presentation/RingtoneSelect/RingtoneSelectReactor.swift +++ b/Multimer/Multimer/Presentation/RingtoneSelect/RingtoneSelectReactor.swift @@ -13,6 +13,7 @@ final class RingtoneSelectReactor: Reactor { enum Action { case viewDidLoad case ringtoneDidSelect(IndexPath) + case closeButtonDidTap } enum Mutation { @@ -26,9 +27,11 @@ final class RingtoneSelectReactor: Reactor { } var initialState = State() + private weak var coordinator: HomeCoordinator? private let selectedRingtoneRelay: BehaviorRelay - init(selectedRingtoneRelay: BehaviorRelay) { + init(coordinator: HomeCoordinator?, selectedRingtoneRelay: BehaviorRelay) { + self.coordinator = coordinator self.selectedRingtoneRelay = selectedRingtoneRelay } @@ -49,6 +52,9 @@ final class RingtoneSelectReactor: Reactor { .just(.selectRingtone(selectedRingtone)), acceptSelectedRingtone(selectedRingtone) ) + + case .closeButtonDidTap: + return finishScene() } } @@ -71,6 +77,11 @@ private extension RingtoneSelectReactor { selectedRingtoneRelay.accept(ringtone) return .empty() } + + func finishScene() -> Observable { + coordinator?.coordinate(by: .finishRingtoneSelectScene) + return .empty() + } } // MARK: - Supporting Methods diff --git a/Multimer/Multimer/Presentation/RingtoneSelect/RingtoneSelectViewController.swift b/Multimer/Multimer/Presentation/RingtoneSelect/RingtoneSelectViewController.swift index 4218d2b..19248e9 100644 --- a/Multimer/Multimer/Presentation/RingtoneSelect/RingtoneSelectViewController.swift +++ b/Multimer/Multimer/Presentation/RingtoneSelect/RingtoneSelectViewController.swift @@ -12,6 +12,7 @@ import ReactorKit import RxCocoa final class RingtoneSelectViewController: UIViewController, View { + private lazy var tableViewDiffableDataSource = RingtoneSelectTableViewDiffableDataSource(tableView: tableView) private lazy var tableView: UITableView = { let tableView = UITableView(frame: .zero, style: .insetGrouped) @@ -20,7 +21,6 @@ final class RingtoneSelectViewController: UIViewController, View { return tableView }() - private let closeBarButton = UIBarButtonItem(systemItem: .close) private var audioPlayer: AVAudioPlayer? @@ -28,9 +28,8 @@ final class RingtoneSelectViewController: UIViewController, View { override func viewDidLoad() { super.viewDidLoad() - setupTableView() - - navigationItem.rightBarButtonItem = closeBarButton + configureUI() + layoutUI() } func bind(reactor: RingtoneSelectReactor) { @@ -52,6 +51,11 @@ private extension RingtoneSelectViewController { .map { Reactor.Action.ringtoneDidSelect($0) } .bind(to: reactor.action) .disposed(by: disposeBag) + + closeBarButton.rx.tap + .map { Reactor.Action.closeButtonDidTap } + .bind(to: reactor.action) + .disposed(by: disposeBag) } func bindState(reactor: RingtoneSelectReactor) { @@ -74,13 +78,20 @@ private extension RingtoneSelectViewController { // MARK: - UI Layout private extension RingtoneSelectViewController { - func setupTableView() { + func configureUI() { + view.backgroundColor = .systemGray5 + title = LocalizableString.selectRingtone.localized + navigationController?.navigationBar.barTintColor = .systemGray5 + navigationItem.rightBarButtonItem = closeBarButton + } + + func layoutUI() { view.addSubview(tableView) tableView.translatesAutoresizingMaskIntoConstraints = false - tableView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 6).isActive = true - tableView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 6).isActive = true - tableView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -6).isActive = true + tableView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true + tableView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor).isActive = true + tableView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor).isActive = true tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true } }