From cd08d3c19c34dc88d5f5240998afc88a42efcd5d Mon Sep 17 00:00:00 2001 From: George Garside Date: Fri, 20 Oct 2023 16:59:41 +0100 Subject: [PATCH] Show numbers where icon does not exist --- Rule/PasswordRuleDetail.swift | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Rule/PasswordRuleDetail.swift b/Rule/PasswordRuleDetail.swift index fb41bef..74ab678 100644 --- a/Rule/PasswordRuleDetail.swift +++ b/Rule/PasswordRuleDetail.swift @@ -10,8 +10,13 @@ struct PasswordRuleDetail: View { HStack(alignment: .firstTextBaseline) { if let min = rule.minLength { VStack { - Image(systemName: "\(min).square.fill") - .font(.largeTitle) + if min <= 50 { + Image(systemName: "\(min).square.fill") + .font(.largeTitle) + } else { + Text(min.description) + .font(.title2) + } Text("min") } } @@ -20,10 +25,15 @@ struct PasswordRuleDetail: View { .font(.largeTitle) .foregroundStyle(.secondary) } - if let min = rule.maxLength { + if let max = rule.maxLength { VStack { - Image(systemName: "\(min).square.fill") - .font(.largeTitle) + if max <= 50 { + Image(systemName: "\(max).square.fill") + .font(.largeTitle) + } else { + Text(max.description) + .font(.title2) + } Text("max") } } @@ -192,9 +202,9 @@ struct PasswordRuleDetail: View { #Preview("Demo") { PasswordRuleDetail(rule: .init( id: "example.com", originalRule: "one: two; three: four; five: six;", - minLength: 8, maxLength: 16, + minLength: 8, maxLength: 60, required: .init(arrayLiteral: .lower, .upper, .digit), - allowed: .init(arrayLiteral: .lower, .upper, .digit, .special, .unicode, .other(.init(arrayLiteral: "a", "b"))) + allowed: .init(arrayLiteral: .lower, .upper, .digit, .special, .unicode, .other(.init("[- !\"#$&'()*+,.:;<=>?@[^_`{|}~]]"))) )) }