-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerNotificationsView.swift
More file actions
104 lines (94 loc) · 4.1 KB
/
ContainerNotificationsView.swift
File metadata and controls
104 lines (94 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Copyright 2017 - 2025 Riigi Infosüsteemi Amet
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
import SwiftUI
import FactoryKit
struct ContainerNotificationsView: View {
@Environment(\.dismiss) private var dismiss
@Environment(LanguageSettings.self) private var languageSettings
@AppTheme private var theme
@AppTypography private var typography
private let isSettingsMenuBottomSheetVisible = false
let notifications: [ContainerNotificationType]
var body: some View {
TopBarContainer(
title: languageSettings.localized("Container notifications"),
onLeftClick: {
dismiss()
},
content: {
ScrollView {
VStack(alignment: .leading) {
Divider()
ForEach(notifications.indices, id: \.self) { index in
HStack(alignment: .center) {
Image("ic_m3_notifications_48pt_wght400")
.resizable()
.scaledToFit()
.foregroundStyle(theme.onBackground)
.frame(width: Dimensions.Icon.IconSizeXXS, height: Dimensions.Icon.IconSizeXXS)
.padding(Dimensions.Padding.XSPadding)
.accessibilityHidden(true)
let notificationMessage = message(for: notifications[index])
Text(verbatim: notificationMessage)
.font(typography.bodyMedium)
.foregroundStyle(theme.onSurfaceVariant)
.accessibilityLabel(
Text(
verbatim: "\(languageSettings.localized("Container notification")) " +
"\(index + 1). \(notificationMessage)"
)
)
}
.padding(.horizontal, Dimensions.Padding.XXSPadding)
Divider()
}
}
.padding(.vertical, Dimensions.Padding.SPadding)
}
}
)
}
private func message(for notification: ContainerNotificationType) -> String {
switch notification {
case .xadesFile:
return languageSettings.localized("Xades message")
case .cadesFile:
return languageSettings.localized("Cades message")
case .unknownSignatures(let count):
return languageSettings.localized("Unknown signature", [count])
case .invalidSignatures(let count):
return languageSettings.localized("Invalid signature", [count])
case .emptyFile:
return languageSettings.localized("Empty file in container")
case .unsupportedContainer:
return languageSettings.localized("Unsupported container")
}
}
}
#Preview {
ContainerNotificationsView(
notifications: [
.emptyFile,
.unknownSignatures(count: 1)
]
)
.environment(Container.shared.languageSettings())
.environment(Container.shared.themeSettings())
.environment(NavigationPathManager())
}