diff --git a/AccessibilityTalk.xcodeproj/project.pbxproj b/AccessibilityTalk.xcodeproj/project.pbxproj index e6dd8d1..dbfeb03 100644 --- a/AccessibilityTalk.xcodeproj/project.pbxproj +++ b/AccessibilityTalk.xcodeproj/project.pbxproj @@ -11,6 +11,17 @@ 96088D642B797B7700E062FB /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96088D632B797B7700E062FB /* ContentView.swift */; }; 96088D662B797B7900E062FB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96088D652B797B7900E062FB /* Assets.xcassets */; }; 96088D692B797B7900E062FB /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96088D682B797B7900E062FB /* Preview Assets.xcassets */; }; + 96088D722B797FBA00E062FB /* FlipLayoutAxisView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96088D712B797FBA00E062FB /* FlipLayoutAxisView.swift */; }; + 96088D742B7980D700E062FB /* DynamicTypeAdaptiveView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96088D732B7980D700E062FB /* DynamicTypeAdaptiveView.swift */; }; + 96088D762B7981DC00E062FB /* FlexibleSizingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96088D752B7981DC00E062FB /* FlexibleSizingView.swift */; }; + 96088D782B7981EB00E062FB /* ExampleFormView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96088D772B7981EB00E062FB /* ExampleFormView.swift */; }; + 96088D7A2B79827D00E062FB /* ExampleFormBadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96088D792B79827D00E062FB /* ExampleFormBadView.swift */; }; + 96088D7C2B79828900E062FB /* FlexibleSizingBadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96088D7B2B79828900E062FB /* FlexibleSizingBadView.swift */; }; + 96088D7E2B79829000E062FB /* FlipLayoutAxisBadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96088D7D2B79829000E062FB /* FlipLayoutAxisBadView.swift */; }; + 96088D802B798DBE00E062FB /* FlexibleSizingBadViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96088D7F2B798DBE00E062FB /* FlexibleSizingBadViewController.swift */; }; + 96088D822B79925200E062FB /* FlexibleSizingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96088D812B79925200E062FB /* FlexibleSizingViewController.swift */; }; + 96088D842B799ABA00E062FB /* TextSizingBadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96088D832B799ABA00E062FB /* TextSizingBadView.swift */; }; + 96088D862B799B1400E062FB /* TextSizingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96088D852B799B1400E062FB /* TextSizingView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -19,6 +30,17 @@ 96088D632B797B7700E062FB /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 96088D652B797B7900E062FB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 96088D682B797B7900E062FB /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + 96088D712B797FBA00E062FB /* FlipLayoutAxisView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlipLayoutAxisView.swift; sourceTree = ""; }; + 96088D732B7980D700E062FB /* DynamicTypeAdaptiveView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicTypeAdaptiveView.swift; sourceTree = ""; }; + 96088D752B7981DC00E062FB /* FlexibleSizingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlexibleSizingView.swift; sourceTree = ""; }; + 96088D772B7981EB00E062FB /* ExampleFormView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleFormView.swift; sourceTree = ""; }; + 96088D792B79827D00E062FB /* ExampleFormBadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleFormBadView.swift; sourceTree = ""; }; + 96088D7B2B79828900E062FB /* FlexibleSizingBadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlexibleSizingBadView.swift; sourceTree = ""; }; + 96088D7D2B79829000E062FB /* FlipLayoutAxisBadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlipLayoutAxisBadView.swift; sourceTree = ""; }; + 96088D7F2B798DBE00E062FB /* FlexibleSizingBadViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlexibleSizingBadViewController.swift; sourceTree = ""; }; + 96088D812B79925200E062FB /* FlexibleSizingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlexibleSizingViewController.swift; sourceTree = ""; }; + 96088D832B799ABA00E062FB /* TextSizingBadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextSizingBadView.swift; sourceTree = ""; }; + 96088D852B799B1400E062FB /* TextSizingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextSizingView.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -52,9 +74,20 @@ isa = PBXGroup; children = ( 96088D612B797B7700E062FB /* AccessibilityTalkApp.swift */, - 96088D632B797B7700E062FB /* ContentView.swift */, 96088D652B797B7900E062FB /* Assets.xcassets */, + 96088D632B797B7700E062FB /* ContentView.swift */, + 96088D732B7980D700E062FB /* DynamicTypeAdaptiveView.swift */, + 96088D792B79827D00E062FB /* ExampleFormBadView.swift */, + 96088D772B7981EB00E062FB /* ExampleFormView.swift */, + 96088D7B2B79828900E062FB /* FlexibleSizingBadView.swift */, + 96088D7F2B798DBE00E062FB /* FlexibleSizingBadViewController.swift */, + 96088D752B7981DC00E062FB /* FlexibleSizingView.swift */, + 96088D812B79925200E062FB /* FlexibleSizingViewController.swift */, + 96088D7D2B79829000E062FB /* FlipLayoutAxisBadView.swift */, + 96088D712B797FBA00E062FB /* FlipLayoutAxisView.swift */, 96088D672B797B7900E062FB /* Preview Content */, + 96088D832B799ABA00E062FB /* TextSizingBadView.swift */, + 96088D852B799B1400E062FB /* TextSizingView.swift */, ); path = AccessibilityTalk; sourceTree = ""; @@ -137,8 +170,19 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 96088D762B7981DC00E062FB /* FlexibleSizingView.swift in Sources */, + 96088D742B7980D700E062FB /* DynamicTypeAdaptiveView.swift in Sources */, 96088D642B797B7700E062FB /* ContentView.swift in Sources */, 96088D622B797B7700E062FB /* AccessibilityTalkApp.swift in Sources */, + 96088D722B797FBA00E062FB /* FlipLayoutAxisView.swift in Sources */, + 96088D842B799ABA00E062FB /* TextSizingBadView.swift in Sources */, + 96088D822B79925200E062FB /* FlexibleSizingViewController.swift in Sources */, + 96088D7A2B79827D00E062FB /* ExampleFormBadView.swift in Sources */, + 96088D782B7981EB00E062FB /* ExampleFormView.swift in Sources */, + 96088D7E2B79829000E062FB /* FlipLayoutAxisBadView.swift in Sources */, + 96088D7C2B79828900E062FB /* FlexibleSizingBadView.swift in Sources */, + 96088D802B798DBE00E062FB /* FlexibleSizingBadViewController.swift in Sources */, + 96088D862B799B1400E062FB /* TextSizingView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/AccessibilityTalk/ContentView.swift b/AccessibilityTalk/ContentView.swift index 6dd4afc..3ba6f87 100644 --- a/AccessibilityTalk/ContentView.swift +++ b/AccessibilityTalk/ContentView.swift @@ -9,14 +9,35 @@ import SwiftUI struct ContentView: View { var body: some View { - VStack { - Image(systemName: "globe") - .imageScale(.large) - .foregroundStyle(.tint) - Text("Hello, world!") + NavigationStack { + Form { + Section { + NavigationLink("❌ Text Sizing") { TextSizingBadView() } + NavigationLink("✅ Text Sizing") { TextSizingView() } + } + Section { + NavigationLink("❌ Flexible Sizing (UIKit)") { FlexibleSizingBadUIView() } + NavigationLink("✅ Flexible Sizing (UIKit)") { FlexibleSizingUIView() } + } + Section { + NavigationLink("❌ Flexible Sizing (SwiftUI)") { FlexibleSizingBadView() } + NavigationLink("✅ Flexible Sizing (SwiftUI)") { FlexibleSizingView() } + } + Section { + NavigationLink("❌ Flip Layout Axis") { FlipLayoutAxisBadView() } + NavigationLink("✅ Flip Layout Axis") { FlipLayoutAxisView() } + } + Section { + NavigationLink("❌ Example Form") { ExampleFormBadView() } + NavigationLink("✅ Example Form") { ExampleFormView() } + } + } + .navigationTitle("Accessibility Demo") + .navigationBarTitleDisplayMode(.inline) } - .padding() } + + var tktk: some View { Text("tktk") } } #Preview { diff --git a/AccessibilityTalk/DynamicTypeAdaptiveView.swift b/AccessibilityTalk/DynamicTypeAdaptiveView.swift new file mode 100644 index 0000000..c5b4edf --- /dev/null +++ b/AccessibilityTalk/DynamicTypeAdaptiveView.swift @@ -0,0 +1,47 @@ +// +// DynamicTypeAdaptiveView.swift +// AccessibilityTalk +// +// Created by Work on 2024-02-11. +// + +import SwiftUI + +struct DynamicTypeAdaptiveStack: View { + let verticalThreshold: DynamicTypeSize + + let spacing: Double + + let content: Content + + @Environment(\.dynamicTypeSize) private var typeSize + + init( + verticalThreshold: DynamicTypeSize, + spacing: Double = 16, + @ViewBuilder content: () -> Content + ) { + self.verticalThreshold = verticalThreshold + self.spacing = spacing + self.content = content() + } + + var body: some View { + layout { content } + } + + private var layout: AnyLayout { + if typeSize >= verticalThreshold { + return AnyLayout(VStackLayout(spacing: spacing)) + } else { + return AnyLayout(HStackLayout(spacing: spacing)) + } + } +} + +#Preview { + DynamicTypeAdaptiveStack(verticalThreshold: .xxxLarge) { + Text("first") + Text("second") + } +} diff --git a/AccessibilityTalk/ExampleFormBadView.swift b/AccessibilityTalk/ExampleFormBadView.swift new file mode 100644 index 0000000..61f77d5 --- /dev/null +++ b/AccessibilityTalk/ExampleFormBadView.swift @@ -0,0 +1,74 @@ +// +// ExampleFormBadView.swift +// AccessibilityTalk +// +// Created by Work on 2024-02-11. +// + +import SwiftUI + +struct ExampleFormBadView: View { + @State var name = "" + @State var email = "" + @State var password = "" + @State var passwordConfirmation = "" + @State var wantsNewsletter = false + + private let labelWidth: Double = 150 + + var body: some View { + VStack { + Text("Sign Up") + .font(.largeTitle) + .bold() + + HStack { + label("Name") + TextField("", text: $name, prompt: Text("Johnny Appleseed")) + .textContentType(.name) + .textFieldStyle(.roundedBorder) + } + + HStack { + label("Email") + TextField("", text: $email, prompt: Text("johnny@appleseed.net")) + .textContentType(.emailAddress) + .textFieldStyle(.roundedBorder) + } + + HStack { + label("Password") + TextField("", text: $name, prompt: Text("super secret")) + .textContentType(.newPassword) + .textFieldStyle(.roundedBorder) + } + + Toggle(isOn: $wantsNewsletter) { + label("Sign up for our newsletter") + } + .padding(.horizontal) + + Spacer() + + Button {} label: { + Label("Create Account", systemImage: "arrow.right") + .frame(width: 300, height: 44) + } + .buttonStyle(.borderedProminent) + } + .padding() + .navigationTitle("❌ Example Form") + .navigationBarTitleDisplayMode(.inline) + } + + private func label(_ title: String) -> some View { + Text(title) + .frame(minWidth: labelWidth, alignment: .trailing) + } +} + +#Preview { + NavigationStack { + ExampleFormBadView() + } +} diff --git a/AccessibilityTalk/ExampleFormView.swift b/AccessibilityTalk/ExampleFormView.swift new file mode 100644 index 0000000..7e52ef8 --- /dev/null +++ b/AccessibilityTalk/ExampleFormView.swift @@ -0,0 +1,64 @@ +// +// ExampleFormView.swift +// AccessibilityTalk +// +// Created by Work on 2024-02-11. +// + +import SwiftUI + +struct ExampleFormView: View { + @State var name = "" + @State var email = "" + @State var password = "" + @State var wantsNewsletter = false + + private let labelWidth: Double = 150 + + var body: some View { + VStack { + Text("Sign Up") + .font(.largeTitle) + .bold() + + TextField(text: $name) { Text("Name") } + .textContentType(.name) + .textFieldStyle(.roundedBorder) + + TextField(text: $email) { Text("Email") } + .textContentType(.emailAddress) + .textFieldStyle(.roundedBorder) + + SecureField(text: $password) { Text("Password") } + .textContentType(.newPassword) + .textFieldStyle(.roundedBorder) + + Toggle(isOn: $wantsNewsletter) { + label("Sign up for our newsletter") + } + .padding(.horizontal) + + Spacer() + + Button {} label: { + Label("Create Account", systemImage: "arrow.right") + .frame(width: 300, height: 44) + } + .buttonStyle(.borderedProminent) + } + .padding() + .navigationTitle("✅ Example Form") + .navigationBarTitleDisplayMode(.inline) + } + + private func label(_ title: String) -> some View { + Text(title) + .frame(maxWidth: .infinity, alignment: .leading) + } +} + +#Preview { + NavigationStack { + ExampleFormView() + } +} diff --git a/AccessibilityTalk/FlexibleSizingBadView.swift b/AccessibilityTalk/FlexibleSizingBadView.swift new file mode 100644 index 0000000..a6bd9d0 --- /dev/null +++ b/AccessibilityTalk/FlexibleSizingBadView.swift @@ -0,0 +1,26 @@ +// +// FlexibleSizingBadView.swift +// AccessibilityTalk +// +// Created by Work on 2024-02-11. +// + +import SwiftUI + +struct FlexibleSizingBadView: View { + var body: some View { + Button {} label: { + Text("Reticulate Splines") + .frame(width: 180, height: 44) + } + .buttonStyle(.borderedProminent) + .navigationTitle("❌ Flexible Sizing (SwiftUI)") + .navigationBarTitleDisplayMode(.inline) + } +} + +#Preview { + NavigationStack { + FlexibleSizingBadView() + } +} diff --git a/AccessibilityTalk/FlexibleSizingBadViewController.swift b/AccessibilityTalk/FlexibleSizingBadViewController.swift new file mode 100644 index 0000000..f32c8c0 --- /dev/null +++ b/AccessibilityTalk/FlexibleSizingBadViewController.swift @@ -0,0 +1,97 @@ +// +// FlexibleSizingViewController.swift +// AccessibilityTalk +// +// Created by Work on 2024-02-11. +// + +import SwiftUI +import UIKit + +class FlexibleSizingBadViewController: UIViewController { + var buttonTitle: String { + didSet { + button.setTitle(buttonTitle, for: .normal) + } + } + + var width: CGFloat { + didSet { + updateButtonConstraints() + } + } + + var height: CGFloat { + didSet { + updateButtonConstraints() + } + } + + init(title: String, width: CGFloat, height: CGFloat) { + self.buttonTitle = title + self.width = width + self.height = height + super.init(nibName: nil, bundle: nil) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private let button = UIButton(configuration: .borderedProminent()) + private var constraints: [NSLayoutConstraint] = [] + + override func viewDidLoad() { + super.viewDidLoad() + + button.setTitle(buttonTitle, for: .normal) + button.translatesAutoresizingMaskIntoConstraints = false + view.addSubview(button) + updateButtonConstraints() + } + + private func updateButtonConstraints() { + NSLayoutConstraint.deactivate(constraints) + constraints = [ + button.centerXAnchor.constraint(equalTo: view.centerXAnchor), + button.centerYAnchor.constraint(equalTo: view.centerYAnchor), + button.widthAnchor.constraint(equalToConstant: width), + button.heightAnchor.constraint(equalToConstant: height), + ] + NSLayoutConstraint.activate(constraints) + } +} + +struct _FlexibleSizingBadUIView: UIViewControllerRepresentable { + var title: String + var width: CGFloat + var height: CGFloat + + func makeUIViewController(context: Context) -> FlexibleSizingBadViewController { + FlexibleSizingBadViewController(title: title, width: width, height: height) + } + + func updateUIViewController(_ uiViewController: FlexibleSizingBadViewController, context: Context) { + uiViewController.buttonTitle = title + uiViewController.width = width + uiViewController.height = height + } +} + +struct FlexibleSizingBadUIView: View { + var title: String = "Reticulate Splines" + var width: CGFloat = 180 + var height: CGFloat = 44 + + var body: some View { + _FlexibleSizingBadUIView(title: title, width: width, height: height) + .navigationTitle("❌ Flexible Sizing (UIKit)") + .navigationBarTitleDisplayMode(.inline) + } +} + +#Preview { + NavigationStack { + FlexibleSizingBadUIView() + } +} diff --git a/AccessibilityTalk/FlexibleSizingView.swift b/AccessibilityTalk/FlexibleSizingView.swift new file mode 100644 index 0000000..7fed8d0 --- /dev/null +++ b/AccessibilityTalk/FlexibleSizingView.swift @@ -0,0 +1,27 @@ +// +// FlexibleSizingView.swift +// AccessibilityTalk +// +// Created by Work on 2024-02-11. +// + +import SwiftUI + +struct FlexibleSizingView: View { + var body: some View { + Button {} label: { + Text("Reticulate Splines") + .padding(.horizontal, 24) + .padding(.vertical, 12) + } + .buttonStyle(.borderedProminent) + .navigationTitle("✅ Flexible Sizing (SwiftUI)") + .navigationBarTitleDisplayMode(.inline) + } +} + +#Preview { + NavigationStack { + FlexibleSizingView() + } +} diff --git a/AccessibilityTalk/FlexibleSizingViewController.swift b/AccessibilityTalk/FlexibleSizingViewController.swift new file mode 100644 index 0000000..473bfc8 --- /dev/null +++ b/AccessibilityTalk/FlexibleSizingViewController.swift @@ -0,0 +1,92 @@ +// +// FlexibleSizingViewController.swift +// AccessibilityTalk +// +// Created by Work on 2024-02-11. +// + +import SwiftUI +import UIKit + +class FlexibleSizingViewController: UIViewController { + var buttonTitle: String { + didSet { + button.setTitle(buttonTitle, for: .normal) + } + } + + var horizontalPadding: CGFloat { + didSet { + button.configuration?.contentInsets.leading = horizontalPadding + button.configuration?.contentInsets.trailing = horizontalPadding + } + } + + var verticalPadding: CGFloat { + didSet { + button.configuration?.contentInsets.top = verticalPadding + button.configuration?.contentInsets.bottom = verticalPadding + } + } + + init(title: String, horizontalPadding: CGFloat, verticalPadding: CGFloat) { + self.buttonTitle = title + self.horizontalPadding = horizontalPadding + self.verticalPadding = verticalPadding + super.init(nibName: nil, bundle: nil) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private let button = UIButton(configuration: .borderedProminent()) + private var constraints: [NSLayoutConstraint] = [] + + override func viewDidLoad() { + super.viewDidLoad() + + button.setTitle(buttonTitle, for: .normal) + button.translatesAutoresizingMaskIntoConstraints = false + view.addSubview(button) + NSLayoutConstraint.activate([ + button.centerXAnchor.constraint(equalTo: view.centerXAnchor), + button.centerYAnchor.constraint(equalTo: view.centerYAnchor), + button.widthAnchor.constraint(lessThanOrEqualTo: view.widthAnchor), + ]) + } +} + +struct _FlexibleSizingUIView: UIViewControllerRepresentable { + var title: String + var horizontalPadding: CGFloat + var verticalPadding: CGFloat + + func makeUIViewController(context: Context) -> FlexibleSizingViewController { + FlexibleSizingViewController(title: title, horizontalPadding: horizontalPadding, verticalPadding: verticalPadding) + } + + func updateUIViewController(_ uiViewController: FlexibleSizingViewController, context: Context) { + uiViewController.buttonTitle = title + uiViewController.horizontalPadding = horizontalPadding + uiViewController.verticalPadding = verticalPadding + } +} + +struct FlexibleSizingUIView: View { + var title: String = "Reticulate Splines" + var horizontalPadding: CGFloat = 24 + var verticalPadding: CGFloat = 12 + + var body: some View { + _FlexibleSizingUIView(title: title, horizontalPadding: horizontalPadding, verticalPadding: verticalPadding) + .navigationTitle("✅ Flexible Sizing (UIKit)") + .navigationBarTitleDisplayMode(.inline) + } +} + +#Preview { + NavigationStack { + FlexibleSizingUIView() + } +} diff --git a/AccessibilityTalk/FlipLayoutAxisBadView.swift b/AccessibilityTalk/FlipLayoutAxisBadView.swift new file mode 100644 index 0000000..47b9818 --- /dev/null +++ b/AccessibilityTalk/FlipLayoutAxisBadView.swift @@ -0,0 +1,32 @@ +// +// FlipLayoutAxisBadView.swift +// AccessibilityTalk +// +// Created by Work on 2024-02-11. +// + +import SwiftUI + +struct FlipLayoutAxisBadView: View { + private let titles: [String] = ["Video", "Audio", "Info"] + + var body: some View { + HStack { + ForEach(titles, id: \.self) { title in + Button {} label: { + Text(title) + .frame(minWidth: 80) + } + .buttonStyle(.borderedProminent) + } + } + .navigationTitle("❌ Flip Layout") + .navigationBarTitleDisplayMode(.inline) + } +} + +#Preview { + NavigationStack { + FlipLayoutAxisBadView() + } +} diff --git a/AccessibilityTalk/FlipLayoutAxisView.swift b/AccessibilityTalk/FlipLayoutAxisView.swift new file mode 100644 index 0000000..3fe3ffd --- /dev/null +++ b/AccessibilityTalk/FlipLayoutAxisView.swift @@ -0,0 +1,87 @@ +// +// FlipLayoutAxisView.swift +// AccessibilityTalk +// +// Created by Work on 2024-02-11. +// + +import SwiftUI + +struct FlipLayoutAxisView: View { + private let titles: [String] = ["Video", "Audio", "Info"] + + var body: some View { + DynamicTypeAdaptiveStack(verticalThreshold: .accessibility3) { + ForEach(titles, id: \.self) { title in + Button {} label: { + Text(title) + .frame(minWidth: 80) + } + .buttonStyle(.borderedProminent) + } + } + .navigationTitle("✅ Flip Layout") + .navigationBarTitleDisplayMode(.inline) + } +} + + /* + if dynamicTypeSize.isAccessibilitySize { + VStack { + DynamicTypeAdapticStack(verticalThreshold: .accessibility1) { + originalSizeViews + } + Text("↓") + DynamicTypeAdapticStack(verticalThreshold: .accessibility1) { + estimatedSizeViews + } + } + } else { + HStack { + VStack { + originalSizeViews + } + .frame(maxWidth: .infinity) + Text("→") + .padding(.horizontal) + VStack { + estimatedSizeViews + } + .frame(maxWidth: .infinity) + } + } + */ + + /* + @ViewBuilder + private var dimensionsSection: some View { + Section( + header: Text("size"), + footer: Text("originally \(viewModel.originalDimensionsText)") + ) { + Picker(selection: $viewModel.selectedSizeClass) { + ForEach(viewModel.availableSizeClasses) { sizeClass in + HStack { + DynamicTypeAdapticStack(verticalThreshold: .accessibility1) { + Text(sizeClass.description) + .foregroundColor(Color(.label)) + Text(viewModel.dimensions(of: sizeClass)) + .foregroundColor(Color(.secondaryLabel)) + .frame(maxWidth: .infinity, alignment: .trailing) + } + Image(systemSymbol: .chevronForward) + .hidden() + } + .tag(sizeClass) + } + } label: { EmptyView() } + .pickerStyle(.inline) + } + } + */ + +#Preview { + NavigationStack { + FlipLayoutAxisView() + } +} diff --git a/AccessibilityTalk/TextSizingBadView.swift b/AccessibilityTalk/TextSizingBadView.swift new file mode 100644 index 0000000..9c6c78d --- /dev/null +++ b/AccessibilityTalk/TextSizingBadView.swift @@ -0,0 +1,23 @@ +// +// TextSizingBadView.swift +// AccessibilityTalk +// +// Created by Work on 2024-02-11. +// + +import SwiftUI + +struct TextSizingBadView: View { + var body: some View { + Text("No bueno") + .font(.system(size: 16)) + .navigationTitle("❌ Text Sizing") + .navigationBarTitleDisplayMode(.inline) + } +} + +#Preview { + NavigationStack { + TextSizingBadView() + } +} diff --git a/AccessibilityTalk/TextSizingView.swift b/AccessibilityTalk/TextSizingView.swift new file mode 100644 index 0000000..08fc1f3 --- /dev/null +++ b/AccessibilityTalk/TextSizingView.swift @@ -0,0 +1,22 @@ +// +// TextSizingView.swift +// AccessibilityTalk +// +// Created by Work on 2024-02-11. +// + +import SwiftUI + +struct TextSizingView: View { + var body: some View { + Text("¡Mucho mejor!") + .navigationTitle("✅ Text Sizing") + .navigationBarTitleDisplayMode(.inline) + } +} + +#Preview { + NavigationStack { + TextSizingView() + } +}