add confirm while delete

This commit is contained in:
cheykrym 2025-10-23 22:29:23 +03:00
parent 6b81860960
commit 43a5d8193d
2 changed files with 57 additions and 8 deletions

View File

@ -102,7 +102,7 @@
}
},
"OK" : {
"comment" : "Profile update alert button",
"comment" : "Common OK\nProfile update alert button",
"localizations" : {
"en" : {
"stringUnit" : {
@ -386,6 +386,9 @@
}
}
},
"Добавление новых блокировок появится позже." : {
"comment" : "Add blocked user placeholder message"
},
"Другое" : {
"localizations" : {
"en" : {
@ -1268,6 +1271,9 @@
},
"Открыть правила" : {
},
"Отмена" : {
"comment" : "Common cancel"
},
"Отображаемое имя" : {
@ -1609,6 +1615,9 @@
}
}
},
"Пользователь \"%1$@\" будет удалён из списка заблокированных." : {
"comment" : "Unblock confirmation message"
},
"Пользователь Системы 1" : {
"comment" : "Тестовая подмена офф аккаунта",
"extractionState" : "manual",
@ -1828,7 +1837,7 @@
},
"Разблокировать" : {
"comment" : "Unblock confirmation action"
},
"Разрешить пересылку сообщений" : {
"localizations" : {
@ -2027,6 +2036,9 @@
"Скопировать" : {
"comment" : "Search placeholder copy"
},
"Скоро" : {
"comment" : "Add blocked user placeholder title"
},
"Скоро появится мини-игра, где можно заработать очки для кастомизации профиля. Следите за обновлениями!" : {
"comment" : "Concept tab placeholder description"
},
@ -2206,6 +2218,9 @@
}
}
},
"Удалить из заблокированных?" : {
"comment" : "Unblock confirmation title"
},
"Удалить чат (скоро)" : {
"localizations" : {
"en" : {

View File

@ -4,6 +4,9 @@ struct BlockedUsersView: View {
@State private var blockedUsers: [BlockedUser] = []
@State private var isLoading = false
@State private var loadError: String?
@State private var showAddBlockedUserAlert = false
@State private var pendingUnblock: BlockedUser?
@State private var showUnblockConfirmation = false
private let blockedUsersService = BlockedUsersService()
@ -37,26 +40,57 @@ struct BlockedUsersView: View {
}
}
Spacer()
Button(role: .destructive) {
unblock(user)
} label: {
Text(NSLocalizedString("Разблокировать", comment: ""))
}
.buttonStyle(.borderless)
}
.padding(.vertical, 4)
.swipeActions(edge: .trailing) {
Button(role: .destructive) {
pendingUnblock = user
showUnblockConfirmation = true
} label: {
Label(NSLocalizedString("Разблокировать", comment: ""), systemImage: "person.crop.circle.badge.xmark")
}
}
}
}
}
}
.navigationTitle(NSLocalizedString("Заблокированные", comment: ""))
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button {
showAddBlockedUserAlert = true
} label: {
Image(systemName: "plus")
}
}
}
.task {
await loadBlockedUsers()
}
.refreshable {
await loadBlockedUsers()
}
.alert(NSLocalizedString("Скоро", comment: "Add blocked user placeholder title"), isPresented: $showAddBlockedUserAlert) {
Button(NSLocalizedString("OK", comment: "Common OK"), role: .cancel) {}
} message: {
Text(NSLocalizedString("Добавление новых блокировок появится позже.", comment: "Add blocked user placeholder message"))
}
.confirmationDialog(
NSLocalizedString("Удалить из заблокированных?", comment: "Unblock confirmation title"),
isPresented: $showUnblockConfirmation,
presenting: pendingUnblock
) { user in
Button(NSLocalizedString("Разблокировать", comment: "Unblock confirmation action"), role: .destructive) {
unblock(user)
pendingUnblock = nil
}
Button(NSLocalizedString("Отмена", comment: "Common cancel"), role: .cancel) {
pendingUnblock = nil
}
} message: { user in
Text(String(format: NSLocalizedString("Пользователь \"%1$@\" будет удалён из списка заблокированных.", comment: "Unblock confirmation message"), user.displayName))
}
}
private var emptyState: some View {