Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

알람 사운드 설정 화면에 '닫기'버튼 추가 #48

Merged
merged 6 commits into from
Aug 9, 2023
8 changes: 8 additions & 0 deletions Multimer/Multimer/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -24,3 +26,9 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
window?.makeKeyAndVisible()
}
}

private extension SceneDelegate {
func configureDefaultNavigationBarAppearance() {
UINavigationBar.appearance().barTintColor = .systemBackground
}
}
3 changes: 3 additions & 0 deletions Multimer/Multimer/Localizing/LocalizableString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum LocalizableString {
case checkNotificationPermissions
case allowNotificationAuthorizationAlert
case goToSettings
case selectRingtone
case alertTones
case ringtones
case ringtoneName(ringtone: Ringtone)
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions Multimer/Multimer/Localizing/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

// MARK: - Ringtones

"selectRingtone" = "Select Alarm Sound";

"alertTones" = "ALERT TONES";
"ringtones" = "RINGTONES";

Expand Down
2 changes: 2 additions & 0 deletions Multimer/Multimer/Localizing/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

// MARK: - Ringtones

"selectRingtone" = "アラーム音を選択";

"alertTones" = "ALERT TONES";
"ringtones" = "RINGTONES";

Expand Down
2 changes: 2 additions & 0 deletions Multimer/Multimer/Localizing/ko.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

// MARK: - Ringtones

"selectRingtone" = "알람음 설정";

"alertTones" = "알림 소리";
"ringtones" = "벨소리";

Expand Down
30 changes: 16 additions & 14 deletions Multimer/Multimer/Localizing/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -40,33 +40,35 @@

// 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" = "Маяк";
"bulletin" = "Звук объявления";
"duck" = "Звук утки";
"illuminate" = "Освещение";
"marimba" = "Маримба";
"oldPhone" = "Мелодия звонка телефона";
"pianoRiff" = "Фортепианный рифф";
"oldPhone" = "Мелодия Звонка Телефона";
"pianoRiff" = "Фортепианный Рифф";
"pinball" = "Пинбол";
"presto" = "Престо";
"radar" = "Радар";
"reflection" = "Отражение";
"сенча" = "зеленый чай";
"сенча" = "Зеленый Чай";
"signal" = "Сигнал";
"stargaze" = "Звездочет";
"strum" = "гитара";
"trill" = "трель";
"xylophone" = "ксилофон";
"strum" = "Гитара";
"trill" = "Трель";
"xylophone" = "Ксилофон";
2 changes: 2 additions & 0 deletions Multimer/Multimer/Localizing/vi.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

// MARK: - Ringtones

"selectRingtone" = "Chọn Nhạc Chuông";

"alertTones" = "ALERT TONES";
"ringtones" = "RINGTONES";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

// MARK: - Ringtones

"selectRingtone" = "选择警报声";

"alertTones" = "警报音调";
"ringtones" = "铃声";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ final class DefaultHomeCoordinator: HomeCoordinator {
navigationController.dismiss(animated: true)
case .finishTimerEditScene:
navigationController.popViewController(animated: true)
case .finishRingtoneSelectScene:
navigationController.dismiss(animated: true)
}
}
}
Expand Down Expand Up @@ -77,8 +79,12 @@ private extension DefaultHomeCoordinator {

func presentRingtoneSelectViewController(selectedRingtoneRelay: BehaviorRelay<Ringtone>) {
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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ enum HomeCoordinatorAction {
case showRingtoneSelectScene(selectedRingtoneRelay: BehaviorRelay<Ringtone>)
case finishTimerCreateScene
case finishTimerEditScene
case finishRingtoneSelectScene
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ final class RingtoneSelectReactor: Reactor {
enum Action {
case viewDidLoad
case ringtoneDidSelect(IndexPath)
case closeButtonDidTap
}

enum Mutation {
Expand All @@ -26,9 +27,11 @@ final class RingtoneSelectReactor: Reactor {
}

var initialState = State()
private weak var coordinator: HomeCoordinator?
private let selectedRingtoneRelay: BehaviorRelay<Ringtone>

init(selectedRingtoneRelay: BehaviorRelay<Ringtone>) {
init(coordinator: HomeCoordinator?, selectedRingtoneRelay: BehaviorRelay<Ringtone>) {
self.coordinator = coordinator
self.selectedRingtoneRelay = selectedRingtoneRelay
}

Expand All @@ -49,6 +52,9 @@ final class RingtoneSelectReactor: Reactor {
.just(.selectRingtone(selectedRingtone)),
acceptSelectedRingtone(selectedRingtone)
)

case .closeButtonDidTap:
return finishScene()
}
}

Expand All @@ -71,6 +77,11 @@ private extension RingtoneSelectReactor {
selectedRingtoneRelay.accept(ringtone)
return .empty()
}

func finishScene() -> Observable<Mutation> {
coordinator?.coordinate(by: .finishRingtoneSelectScene)
return .empty()
}
}

// MARK: - Supporting Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -20,17 +21,15 @@ final class RingtoneSelectViewController: UIViewController, View {
return tableView
}()


private let closeBarButton = UIBarButtonItem(systemItem: .close)

private var audioPlayer: AVAudioPlayer?
var disposeBag = DisposeBag()

override func viewDidLoad() {
super.viewDidLoad()
setupTableView()

navigationItem.rightBarButtonItem = closeBarButton
configureUI()
layoutUI()
}

func bind(reactor: RingtoneSelectReactor) {
Expand All @@ -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) {
Expand All @@ -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
}
}
Expand Down