PWD-1: add custom UI style #5

Merged
MarkusThielker merged 14 commits from 1-implement-custom-ui into development 2025-01-24 12:45:09 +00:00
3 changed files with 25 additions and 1 deletions
Showing only changes of commit 7b82797cb5 - Show all commits

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)) .padding(EdgeInsets(top: 0, leading: 0, bottom: 10, trailing: 0))
Form { Form {
TextField("Name", text: $name) TextField("Name", text: $name)
.textFieldStyle(PwdTextFieldStyle())
TextField("Value", text: $value) TextField("Value", text: $value)
.textFieldStyle(PwdTextFieldStyle())
Text("The password will not be visible again later. Make sure to save it somewhere else too!") Text("The password will not be visible again later. Make sure to save it somewhere else too!")
.font(.footnote) .font(.footnote)
HStack { HStack {

View file

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