PWD-1: add and apply input style
This commit is contained in:
parent
0435cb45f6
commit
7b82797cb5
3 changed files with 25 additions and 1 deletions
22
password/ui/styles/PwdTextFieldStyle.swift
Normal file
22
password/ui/styles/PwdTextFieldStyle.swift
Normal 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)
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue