Skip to content
This repository was archived by the owner on Jun 12, 2025. It is now read-only.

Commit 6c70b1b

Browse files
authored
Merge pull request #4 from easydev991/update-1-15
- Обновил локализацию - На экране со списком стран/городов добавил вьюху на случай пустого списка, чтобы можно было написать письмо в поддержку
2 parents 198ace2 + 296cb01 commit 6c70b1b

File tree

7 files changed

+113
-96
lines changed

7 files changed

+113
-96
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import PackageDescription
55

66
let package = Package(
77
name: "SWDesignSystem",
8-
defaultLocalization: "ru",
8+
defaultLocalization: "en",
99
platforms: [.iOS(.v15)],
1010
products: [
1111
.library(name: "SWDesignSystem", targets: ["SWDesignSystem"])

Sources/SWDesignSystem/Localizable.xcstrings

Lines changed: 39 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,98 +2,71 @@
22
"sourceLanguage" : "en",
33
"strings" : {
44
"" : {
5-
5+
"shouldTranslate" : false
66
},
7-
"Выбери город" : {
7+
"Accept" : {
8+
"comment" : "Принять заявку на добавление в друзья",
89
"localizations" : {
9-
"en" : {
10-
"stringUnit" : {
11-
"state" : "translated",
12-
"value" : "Select a city"
13-
}
14-
},
1510
"ru" : {
1611
"stringUnit" : {
1712
"state" : "translated",
18-
"value" : "Выбери город"
13+
"value" : "Добавить"
1914
}
2015
}
2116
}
2217
},
23-
"Выбери страну" : {
18+
"Close" : {
2419
"localizations" : {
25-
"en" : {
26-
"stringUnit" : {
27-
"state" : "translated",
28-
"value" : "Select a country"
29-
}
30-
},
3120
"ru" : {
3221
"stringUnit" : {
3322
"state" : "translated",
34-
"value" : "Выбери страну"
23+
"value" : "Закрыть"
3524
}
3625
}
3726
}
3827
},
39-
"Добавить" : {
40-
"comment" : "Принять заявку на добавление в друзья",
28+
"Configure" : {
4129
"localizations" : {
42-
"en" : {
43-
"stringUnit" : {
44-
"state" : "translated",
45-
"value" : "Accept"
46-
}
47-
},
4830
"ru" : {
4931
"stringUnit" : {
5032
"state" : "translated",
51-
"value" : "Добавить"
33+
"value" : "Настроить"
5234
}
5335
}
5436
}
5537
},
56-
"Загрузка..." : {
57-
"extractionState" : "manual",
38+
"Contact us" : {
5839
"localizations" : {
59-
"en" : {
60-
"stringUnit" : {
61-
"state" : "translated",
62-
"value" : "Loading…"
63-
}
64-
},
6540
"ru" : {
6641
"stringUnit" : {
6742
"state" : "translated",
68-
"value" : "Загрузка..."
43+
"value" : "Напиши нам"
6944
}
7045
}
7146
}
7247
},
73-
"Закрыть" : {
48+
"Decline" : {
7449
"localizations" : {
75-
"en" : {
76-
"stringUnit" : {
77-
"state" : "translated",
78-
"value" : "Close"
79-
}
80-
},
8150
"ru" : {
8251
"stringUnit" : {
8352
"state" : "translated",
84-
"value" : "Закрыть"
53+
"value" : "Отклонить"
8554
}
8655
}
8756
}
8857
},
89-
"Изменить" : {
58+
"Delete" : {
9059
"localizations" : {
91-
"en" : {
60+
"ru" : {
9261
"stringUnit" : {
9362
"state" : "translated",
94-
"value" : "Edit"
63+
"value" : "Удалить"
9564
}
96-
},
65+
}
66+
}
67+
},
68+
"Edit" : {
69+
"localizations" : {
9770
"ru" : {
9871
"stringUnit" : {
9972
"state" : "translated",
@@ -102,82 +75,74 @@
10275
}
10376
}
10477
},
105-
"Настроить" : {
78+
"Help.CityNotFound" : {
10679
"localizations" : {
10780
"en" : {
10881
"stringUnit" : {
10982
"state" : "translated",
110-
"value" : "Configure"
83+
"value" : "Didn’t find your city?"
11184
}
11285
},
11386
"ru" : {
11487
"stringUnit" : {
11588
"state" : "translated",
116-
"value" : "Настроить"
89+
"value" : "Нет твоего города?"
11790
}
11891
}
11992
}
12093
},
121-
"Отклонить" : {
94+
"Help.CountryNotFound" : {
12295
"localizations" : {
12396
"en" : {
12497
"stringUnit" : {
12598
"state" : "translated",
126-
"value" : "Decline"
99+
"value" : "Didn’t find your country?"
127100
}
128101
},
129102
"ru" : {
130103
"stringUnit" : {
131104
"state" : "translated",
132-
"value" : "Отклонить"
105+
"value" : "Нет твоей страны?"
133106
}
134107
}
135108
}
136109
},
137-
"Пожаловаться" : {
110+
"Pick a city" : {
138111
"localizations" : {
139-
"en" : {
140-
"stringUnit" : {
141-
"state" : "translated",
142-
"value" : "Report"
143-
}
144-
},
145112
"ru" : {
146113
"stringUnit" : {
147114
"state" : "translated",
148-
"value" : "Пожаловаться"
115+
"value" : "Выбери город"
149116
}
150117
}
151118
}
152119
},
153-
"Поиск" : {
120+
"Pick a country" : {
154121
"localizations" : {
155-
"en" : {
156-
"stringUnit" : {
157-
"state" : "translated",
158-
"value" : "Search"
159-
}
160-
},
161122
"ru" : {
162123
"stringUnit" : {
163124
"state" : "translated",
164-
"value" : "Поиск"
125+
"value" : "Выбери страну"
165126
}
166127
}
167128
}
168129
},
169-
"Удалить" : {
130+
"Report" : {
170131
"localizations" : {
171-
"en" : {
132+
"ru" : {
172133
"stringUnit" : {
173134
"state" : "translated",
174-
"value" : "Delete"
135+
"value" : "Пожаловаться"
175136
}
176-
},
137+
}
138+
}
139+
},
140+
"Search" : {
141+
"localizations" : {
177142
"ru" : {
178143
"stringUnit" : {
179144
"state" : "translated",
180-
"value" : "Удалить"
145+
"value" : "Поиск"
181146
}
182147
}
183148
}

Sources/SWDesignSystem/Public/CloseButton.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public struct CloseButton: View {
2121
switch mode {
2222
case .text:
2323
Button(action: action) {
24-
Text("Закрыть", bundle: .module)
24+
Text("Close", bundle: .module)
2525
}
2626
case .xmark:
2727
Button(action: action) {

Sources/SWDesignSystem/Public/ItemListScreen.swift

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,28 @@ public struct ItemListScreen: View {
99
private let mode: Mode
1010
private let allItems: [String]
1111
private let selectedItem: String
12+
private let didTapContactUs: (_ mode: Mode) -> Void
1213
private let didSelectItem: (String) -> Void
1314

1415
/// Инициализирует экран
1516
/// - Parameters:
1617
/// - allItems: Список всех элементов
1718
/// - selectedItem: Выбранный элемент
1819
/// - didSelectItem: Возвращает выбранный элемент
20+
/// - didTapContactUs: Замыкание для перехода в почту,
21+
/// чтобы сообщить о стране/городе, который нужно добавить в базу
1922
public init(
2023
mode: Mode,
2124
allItems: [String],
2225
selectedItem: String,
23-
didSelectItem: @escaping (String) -> Void
26+
didSelectItem: @escaping (String) -> Void,
27+
didTapContactUs: @escaping (_ mode: Mode) -> Void
2428
) {
2529
self.mode = mode
2630
self.allItems = allItems
2731
self.selectedItem = selectedItem
2832
self.didSelectItem = didSelectItem
33+
self.didTapContactUs = didTapContactUs
2934
}
3035

3136
public var body: some View {
@@ -45,15 +50,19 @@ public struct ItemListScreen: View {
4550
}
4651
.withDivider(if: index != filteredItems.endIndex - 1)
4752
}
53+
if filteredItems.isEmpty {
54+
emptyStateView
55+
}
4856
}
4957
}
58+
.animation(.default, value: filteredItems.isEmpty)
5059
.padding()
5160
}
5261
.background(Color.swBackground)
5362
.searchable(
5463
text: $searchQuery,
5564
placement: .navigationBarDrawer(displayMode: .always),
56-
prompt: Text("Поиск", bundle: .module)
65+
prompt: Text("Search", bundle: .module)
5766
)
5867
.navigationTitle(Text(mode.title, bundle: .module))
5968
.navigationBarTitleDisplayMode(.inline)
@@ -65,8 +74,14 @@ public extension ItemListScreen {
6574
case country, city
6675
var title: LocalizedStringKey {
6776
switch self {
68-
case .country: "Выбери страну"
69-
case .city: "Выбери город"
77+
case .country: "Pick a country"
78+
case .city: "Pick a city"
79+
}
80+
}
81+
var helpMessage: LocalizedStringKey {
82+
switch self {
83+
case .country: "Help.CountryNotFound"
84+
case .city: "Help.CityNotFound"
7085
}
7186
}
7287
}
@@ -78,15 +93,52 @@ private extension ItemListScreen {
7893
? allItems
7994
: allItems.filter { $0.contains(searchQuery) }
8095
}
96+
97+
var emptyStateView: some View {
98+
HStack(spacing: 12) {
99+
Text(mode.helpMessage, bundle: .module)
100+
.frame(maxWidth: .infinity, alignment: .leading)
101+
Button {
102+
didTapContactUs(mode)
103+
} label: {
104+
Text("Contact us", bundle: .module)
105+
}
106+
.buttonStyle(
107+
SWButtonStyle(mode: .filled, size: .small, maxWidth: nil)
108+
)
109+
}
110+
.padding(12)
111+
}
81112
}
82113

83114
#if DEBUG
84-
#Preview {
85-
ItemListScreen(
86-
mode: .country,
87-
allItems: ["Россия, Канада, Австралия"],
88-
selectedItem: "Россия",
89-
didSelectItem: { _ in }
90-
)
115+
@available(iOS 17.0, *)
116+
#Preview("Поиск страны") {
117+
@Previewable @State var selectedItem: String = "Россия"
118+
NavigationStack {
119+
ItemListScreen(
120+
mode: .country,
121+
allItems: ["Россия", "Канада", "Австралия"],
122+
selectedItem: selectedItem,
123+
didSelectItem: { newItem in selectedItem = newItem },
124+
didTapContactUs: { _ in }
125+
)
126+
}
127+
.environment(\.locale, .init(identifier: "ru"))
128+
}
129+
130+
@available(iOS 17.0, *)
131+
#Preview("Поиск города") {
132+
@Previewable @State var selectedItem: String = "Москва"
133+
NavigationStack {
134+
ItemListScreen(
135+
mode: .city,
136+
allItems: ["Москва", "Киров", "Волгоград"],
137+
selectedItem: selectedItem,
138+
didSelectItem: { newItem in selectedItem = newItem },
139+
didTapContactUs: { _ in }
140+
)
141+
}
142+
.environment(\.locale, .init(identifier: "ru"))
91143
}
92144
#endif

Sources/SWDesignSystem/Public/Rows/CommentRowView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,22 @@ private extension CommentRowView {
7878
if isCommentByMainUser {
7979
Button(action: { action(.edit) }) {
8080
Label {
81-
Text("Изменить", bundle: .module)
81+
Text("Edit", bundle: .module)
8282
} icon: {
8383
Image(systemName: Icons.Regular.pencil.rawValue)
8484
}
8585
}
8686
Button(role: .destructive, action: { action(.delete) }) {
8787
Label {
88-
Text("Удалить", bundle: .module)
88+
Text("Delete", bundle: .module)
8989
} icon: {
9090
Image(systemName: Icons.Regular.trash.rawValue)
9191
}
9292
}
9393
} else {
9494
Button(role: .destructive, action: { action(.report) }) {
9595
Label {
96-
Text("Пожаловаться", bundle: .module)
96+
Text("Report", bundle: .module)
9797
} icon: {
9898
Image(systemName: Icons.Regular.exclamation.rawValue)
9999
}

0 commit comments

Comments
 (0)