Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct BackupImportCodeScannerView: View {
isImagePickerVisible: $isCodeImagePickerGalleryVisible,
)
.padding()
.modifier(HorizontallyCenter())
.frame(maxWidth: .infinity)
}
}
}
32 changes: 20 additions & 12 deletions Vault/Sources/VaultiOS/Views/Detail/EncryptedItemDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,29 +81,37 @@ struct EncryptedItemDetailView: View {
}
}

@ViewBuilder
private var passwordEntrySection: some View {
Section {
FormRow(image: Image(systemName: "lock.fill"), color: .primary, style: .standard) {
SecureField("Password...", text: $viewModel.enteredEncryptionPassword)
}
} footer: {
}
.onChange(of: viewModel.enteredEncryptionPassword) { _, _ in
// When the text changes, reset the state.
viewModel.resetState()
}

Section {
AsyncButton {
await viewModel.startDecryption()
} label: {
Label("Decrypt", systemImage: "key.horizontal.fill")
decryptRow {
Text("Decrypt")
.foregroundStyle(Color.accentColor)
}
} loading: {
ProgressView()
.tint(.white)
decryptRow {
ProgressView()
}
}
.modifier(ProminentButtonModifier())
.animation(.easeOut, value: viewModel.state)
.padding()
.modifier(HorizontallyCenter())
.disabled(!viewModel.canStartDecryption)
}
.onChange(of: viewModel.enteredEncryptionPassword) { _, _ in
// When the text changes, reset the state.
viewModel.resetState()
}
.animation(.easeOut, value: viewModel.state)
}

private func decryptRow(@ViewBuilder content: @escaping () -> some View) -> some View {
FormRow(image: Image(systemName: "key.horizontal.fill"), color: .accentColor, content: content)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ struct OTPCodeCreateView<
isImagePickerVisible: $isCodeImagePickerGalleryVisible,
)
.padding()
.modifier(HorizontallyCenter())
.frame(maxWidth: .infinity)
}
}
}
18 changes: 10 additions & 8 deletions Vault/Sources/VaultiOS/Views/Detail/OTP/OTPCodeDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ struct OTPCodeDetailView<PreviewGenerator: VaultItemPreviewViewGenerator<VaultIt
errorTitle: viewModel.strings.inputKeyErrorTitle,
)
.padding()
.modifier(HorizontallyCenter())
.frame(maxWidth: .infinity)
}
}

Expand Down Expand Up @@ -335,6 +335,7 @@ struct OTPCodeDetailView<PreviewGenerator: VaultItemPreviewViewGenerator<VaultIt
}
}

@ViewBuilder
private var editingActionsSection: some View {
Section {
Button {
Expand Down Expand Up @@ -416,12 +417,11 @@ struct OTPCodeDetailView<PreviewGenerator: VaultItemPreviewViewGenerator<VaultIt
}
}
}
} footer: {
if viewModel.shouldShowDeleteButton {
}

if viewModel.shouldShowDeleteButton {
Section {
deleteButton
.padding(.horizontal)
.modifier(HorizontallyCenter())
.padding(.vertical, 12)
}
}
}
Expand All @@ -430,9 +430,11 @@ struct OTPCodeDetailView<PreviewGenerator: VaultItemPreviewViewGenerator<VaultIt
Button {
isShowingDeleteConfirmation = true
} label: {
Label(localized(key: "action.delete.title"), systemImage: "trash.fill")
FormRow(image: Image(systemName: "trash.fill"), color: .red) {
Text(localized(key: "action.delete.title"))
.foregroundStyle(Color.red)
}
}
.modifier(ProminentButtonModifier(color: .red))
}

func copyableViewGenerator() -> VaultItemOnTapDecoratorViewGenerator<PreviewGenerator> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ struct SecureNoteDetailView: View {
}
}

@ViewBuilder
private var editingActionsSection: some View {
Section {
Picker(selection: $viewModel.editingModel.detail.textFormat) {
Expand Down Expand Up @@ -382,12 +383,11 @@ struct SecureNoteDetailView: View {
}
}
}
} footer: {
if viewModel.shouldShowDeleteButton {
}

if viewModel.shouldShowDeleteButton {
Section {
deleteButton
.padding(.horizontal)
.modifier(HorizontallyCenter())
.padding(.vertical, 12)
}
}
}
Expand All @@ -396,9 +396,11 @@ struct SecureNoteDetailView: View {
Button {
isShowingDeleteConfirmation = true
} label: {
Label(localized(key: "action.delete.title"), systemImage: "trash.fill")
FormRow(image: Image(systemName: "trash.fill"), color: .red) {
Text(localized(key: "action.delete.title"))
.foregroundStyle(Color.red)
}
}
.modifier(ProminentButtonModifier(color: .red))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct VaultDetailEncryptionEditView: View {
}
}

@ViewBuilder
private var createEncryptionSection: some View {
Section {
FormRow(image: Image(systemName: "lock.fill"), color: .primary, style: .standard) {
Expand All @@ -68,22 +69,25 @@ struct VaultDetailEncryptionEditView: View {
SecureField("Confirm Password", text: $newEncryptionPasswordConfirm)
}
}
} footer: {
if newEncryptionPassword.isNotBlank {
}

if newEncryptionPassword.isNotBlank {
Section {
Button {
didSetNewEncryptionPassword(newEncryptionPassword)
dismiss()
} label: {
Label("Encrypt", systemImage: "checkmark.circle.fill")
FormRow(image: Image(systemName: "checkmark.circle.fill"), color: .accentColor) {
Text("Encrypt")
.foregroundStyle(Color.accentColor)
}
}
.modifier(ProminentButtonModifier())
.padding()
.modifier(HorizontallyCenter())
.disabled(!doPasswordsMatch)
}
}
}

@ViewBuilder
private var removeEncryptionSection: some View {
Section {
Text("""
Expand All @@ -93,16 +97,18 @@ struct VaultDetailEncryptionEditView: View {
""")
.foregroundStyle(.secondary)
.font(.caption)
} footer: {
}

Section {
Button {
didRemoveEncryption()
dismiss()
} label: {
Label("Remove Encryption", systemImage: "xmark.circle.fill")
FormRow(image: Image(systemName: "xmark.circle.fill"), color: .red) {
Text("Remove Encryption")
.foregroundStyle(Color.red)
}
}
.modifier(ProminentButtonModifier(color: .red))
.padding()
.modifier(HorizontallyCenter())
}
}
}
33 changes: 21 additions & 12 deletions Vault/Sources/VaultiOS/Views/Detail/VaultItemDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,22 @@ struct VaultItemDetailView<ChildViewModel: DetailViewModel, ContentsView: View>:
)
.padding()
.containerRelativeFrame(.horizontal)
} footer: {
}

Section {
AsyncButton {
try await authenticationService.validateAuthentication(reason: "Unlock item")
viewModel.isLocked = false
} label: {
Label("Unlock", systemImage: "key.horizontal.fill")
unlockRow {
Text("Unlock")
.foregroundStyle(Color.accentColor)
}
} loading: {
ProgressView()
.tint(.white)
unlockRow {
ProgressView()
}
}
.modifier(ProminentButtonModifier())
.containerRelativeFrame(.horizontal)
.padding()
}
} else {
Section {
Expand All @@ -128,19 +131,25 @@ struct VaultItemDetailView<ChildViewModel: DetailViewModel, ContentsView: View>:
.foregroundStyle(.secondary)
}
}
} footer: {
}

Section {
Button {
viewModel.isLocked = false
} label: {
Text("Dismiss")
FormRow(image: Image(systemName: "xmark.circle.fill"), color: .accentColor) {
Text("Dismiss")
.foregroundStyle(Color.accentColor)
}
}
.modifier(ProminentButtonModifier())
.containerRelativeFrame(.horizontal)
.padding()
}
}
}

private func unlockRow(@ViewBuilder content: @escaping () -> some View) -> some View {
FormRow(image: Image(systemName: "key.horizontal.fill"), color: .accentColor, content: content)
}

private var cancelCreationItem: some ToolbarContent {
// This button always dismisses immediately (without saving) if it's the initial creation.
// (Dirty or not!)
Expand Down
10 changes: 0 additions & 10 deletions Vault/Sources/VaultiOS/Views/General/Color+Constrast.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ extension Color {
return 0.0
}

/// Determine appropriate foreground color for contrast
var contrastingForegroundColor: Color {
isPercievedLight ? .black.opacity(0.8) : .white
}

/// Determine appropriate foreground color for contrast
var contrastingBackgroudColor: Color {
isPercievedLight ? .primary.opacity(0.8) : Color(UIColor.systemBackground).opacity(0.8)
}

var isPercievedLight: Bool {
percievedBrightness > 0.9
}
Expand Down
30 changes: 0 additions & 30 deletions Vault/Sources/VaultiOS/Views/General/ProminentButtonModifier.swift

This file was deleted.

44 changes: 0 additions & 44 deletions Vault/Sources/VaultiOS/Views/General/SearchTextField.swift

This file was deleted.

Loading