PWD-1: add and apply input style

This commit is contained in:
Markus Thielker 2025-01-21 14:25:03 +01:00
parent 0435cb45f6
commit 7b82797cb5
No known key found for this signature in database
3 changed files with 25 additions and 1 deletions

View file

@ -0,0 +1,22 @@
//
// ModernInputStyle.swift
// password
//
// Created by Markus Thielker on 19.01.25.
//
import SwiftUI
struct PwdTextFieldStyle: TextFieldStyle {
@Environment(\.colorScheme) var colorScheme
func _body(configuration: TextField<Self._Label>) -> some View {
configuration
.padding(EdgeInsets(top: 8, leading: 8, bottom: 8, trailing: 8))
.background(colorScheme == .dark ? .black : .white)
.foregroundColor(colorScheme == .dark ? .white : .black)
.textFieldStyle(.plain)
.cornerRadius(12)
}
}

View file

@ -26,7 +26,9 @@ struct AddPasswordView: View {
.padding(EdgeInsets(top: 0, leading: 0, bottom: 10, trailing: 0))
Form {
TextField("Name", text: $name)
.textFieldStyle(PwdTextFieldStyle())
TextField("Value", text: $value)
.textFieldStyle(PwdTextFieldStyle())
Text("The password will not be visible again later. Make sure to save it somewhere else too!")
.font(.footnote)
HStack {

View file

@ -28,7 +28,7 @@ struct DetailView: View {
Text("Enter the password for \(viewModel.password.name) and submit with \"Enter\"")
Form {
SecureField("", text: $value)
.textFieldStyle(RoundedBorderTextFieldStyle())
.textFieldStyle(PwdTextFieldStyle())
.onChange(of: value) { _, _ in
if (value.isEmpty){
startTime = nil