Skip to content

Commit b5d0e1f

Browse files
committed
🎨 refactor navigation title
1 parent 3e41de0 commit b5d0e1f

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

BaseSwiftUI/Presentation/Component/Screen.swift

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,23 @@ struct Screen<Content>: View where Content: View {
1313
@Binding private var isLoading: Bool
1414
@State private var language = Defaults[.language]
1515
@Default(.isDarkMode) var isDarkMode
16-
private var localizeTitleResource: StringResource?
1716
private var title: String?
1817

1918
var content: () -> Content
2019

2120
init(isLoading: Binding<Bool> = .constant(false),
22-
localizeTitleResource: StringResource? = nil,
2321
title: String? = nil,
2422
content: @escaping () -> Content) {
2523
_isLoading = isLoading
26-
self.localizeTitleResource = localizeTitleResource
2724
self.title = title
2825
self.content = content
2926
}
3027

31-
private func getTitle() -> String {
32-
if let resource = localizeTitleResource {
33-
return String(resource: resource, preferredLanguages: [language])
34-
}
35-
return title ?? ""
36-
}
37-
3828
var body: some View {
3929
LoadingView(isShowing: $isLoading) {
4030
content()
4131
}
42-
.navigationTitle(getTitle())
32+
.navigationTitle(title ?? "")
4333
.background(Color(R.color.backgroundPrimary))
4434
.environment(\.colorScheme, isDarkMode ? .dark : .light)
4535
.preferredColorScheme(isDarkMode ? .dark : .light)

BaseSwiftUI/Presentation/Scene/Home/Movie/TopMovies/TopMoviesScreen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct TopMoviesScreen: View {
4848
}
4949

5050
var body: some View {
51-
Screen(isLoading: $output.isLoading, localizeTitleResource: R.string.localizable.movieWatchTitle) {
51+
Screen(isLoading: $output.isLoading, title: R.string.localizable.movieWatchTitle()) {
5252
ScrollView(showsIndicators: false) {
5353
VStack(alignment: .leading, spacing: 16) {
5454
if !output.data.upcoming.isEmpty {

BaseSwiftUI/Presentation/Scene/Home/Todo/Todos/TodosScreen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct TodosScreen: View {
1919
private let toTodoItems = PublishRelay<TodoCategory>()
2020

2121
var body: some View {
22-
Screen(localizeTitleResource: R.string.localizable.todoTitle) {
22+
Screen(title: R.string.localizable.todoTitle()) {
2323
ZStack {
2424
if output.todoLists.isEmpty {
2525
emptyView()

0 commit comments

Comments
 (0)