mirror of
https://github.com/samsonjs/AccessibilityTalk.git
synced 2026-04-27 15:07:47 +00:00
Kick things off with several examples, form is WIP
This commit is contained in:
parent
3d36b78453
commit
7d48a898e6
13 changed files with 663 additions and 7 deletions
|
|
@ -11,6 +11,17 @@
|
||||||
96088D642B797B7700E062FB /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96088D632B797B7700E062FB /* ContentView.swift */; };
|
96088D642B797B7700E062FB /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96088D632B797B7700E062FB /* ContentView.swift */; };
|
||||||
96088D662B797B7900E062FB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96088D652B797B7900E062FB /* Assets.xcassets */; };
|
96088D662B797B7900E062FB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96088D652B797B7900E062FB /* Assets.xcassets */; };
|
||||||
96088D692B797B7900E062FB /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96088D682B797B7900E062FB /* Preview 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 */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
|
@ -19,6 +30,17 @@
|
||||||
96088D632B797B7700E062FB /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
96088D632B797B7700E062FB /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||||
96088D652B797B7900E062FB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
96088D652B797B7900E062FB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
96088D682B797B7900E062FB /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
96088D682B797B7900E062FB /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
||||||
|
96088D712B797FBA00E062FB /* FlipLayoutAxisView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlipLayoutAxisView.swift; sourceTree = "<group>"; };
|
||||||
|
96088D732B7980D700E062FB /* DynamicTypeAdaptiveView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicTypeAdaptiveView.swift; sourceTree = "<group>"; };
|
||||||
|
96088D752B7981DC00E062FB /* FlexibleSizingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlexibleSizingView.swift; sourceTree = "<group>"; };
|
||||||
|
96088D772B7981EB00E062FB /* ExampleFormView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleFormView.swift; sourceTree = "<group>"; };
|
||||||
|
96088D792B79827D00E062FB /* ExampleFormBadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleFormBadView.swift; sourceTree = "<group>"; };
|
||||||
|
96088D7B2B79828900E062FB /* FlexibleSizingBadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlexibleSizingBadView.swift; sourceTree = "<group>"; };
|
||||||
|
96088D7D2B79829000E062FB /* FlipLayoutAxisBadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlipLayoutAxisBadView.swift; sourceTree = "<group>"; };
|
||||||
|
96088D7F2B798DBE00E062FB /* FlexibleSizingBadViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlexibleSizingBadViewController.swift; sourceTree = "<group>"; };
|
||||||
|
96088D812B79925200E062FB /* FlexibleSizingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlexibleSizingViewController.swift; sourceTree = "<group>"; };
|
||||||
|
96088D832B799ABA00E062FB /* TextSizingBadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextSizingBadView.swift; sourceTree = "<group>"; };
|
||||||
|
96088D852B799B1400E062FB /* TextSizingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextSizingView.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
|
@ -52,9 +74,20 @@
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
96088D612B797B7700E062FB /* AccessibilityTalkApp.swift */,
|
96088D612B797B7700E062FB /* AccessibilityTalkApp.swift */,
|
||||||
96088D632B797B7700E062FB /* ContentView.swift */,
|
|
||||||
96088D652B797B7900E062FB /* Assets.xcassets */,
|
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 */,
|
96088D672B797B7900E062FB /* Preview Content */,
|
||||||
|
96088D832B799ABA00E062FB /* TextSizingBadView.swift */,
|
||||||
|
96088D852B799B1400E062FB /* TextSizingView.swift */,
|
||||||
);
|
);
|
||||||
path = AccessibilityTalk;
|
path = AccessibilityTalk;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
|
@ -137,8 +170,19 @@
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
96088D762B7981DC00E062FB /* FlexibleSizingView.swift in Sources */,
|
||||||
|
96088D742B7980D700E062FB /* DynamicTypeAdaptiveView.swift in Sources */,
|
||||||
96088D642B797B7700E062FB /* ContentView.swift in Sources */,
|
96088D642B797B7700E062FB /* ContentView.swift in Sources */,
|
||||||
96088D622B797B7700E062FB /* AccessibilityTalkApp.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;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,35 @@ import SwiftUI
|
||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
NavigationStack {
|
||||||
Image(systemName: "globe")
|
Form {
|
||||||
.imageScale(.large)
|
Section {
|
||||||
.foregroundStyle(.tint)
|
NavigationLink("❌ Text Sizing") { TextSizingBadView() }
|
||||||
Text("Hello, world!")
|
NavigationLink("✅ Text Sizing") { TextSizingView() }
|
||||||
}
|
}
|
||||||
.padding()
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var tktk: some View { Text("tktk") }
|
||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
|
|
|
||||||
47
AccessibilityTalk/DynamicTypeAdaptiveView.swift
Normal file
47
AccessibilityTalk/DynamicTypeAdaptiveView.swift
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
//
|
||||||
|
// DynamicTypeAdaptiveView.swift
|
||||||
|
// AccessibilityTalk
|
||||||
|
//
|
||||||
|
// Created by Work on 2024-02-11.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct DynamicTypeAdaptiveStack<Content: View>: 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")
|
||||||
|
}
|
||||||
|
}
|
||||||
74
AccessibilityTalk/ExampleFormBadView.swift
Normal file
74
AccessibilityTalk/ExampleFormBadView.swift
Normal file
|
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
64
AccessibilityTalk/ExampleFormView.swift
Normal file
64
AccessibilityTalk/ExampleFormView.swift
Normal file
|
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
26
AccessibilityTalk/FlexibleSizingBadView.swift
Normal file
26
AccessibilityTalk/FlexibleSizingBadView.swift
Normal file
|
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
97
AccessibilityTalk/FlexibleSizingBadViewController.swift
Normal file
97
AccessibilityTalk/FlexibleSizingBadViewController.swift
Normal file
|
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
27
AccessibilityTalk/FlexibleSizingView.swift
Normal file
27
AccessibilityTalk/FlexibleSizingView.swift
Normal file
|
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
92
AccessibilityTalk/FlexibleSizingViewController.swift
Normal file
92
AccessibilityTalk/FlexibleSizingViewController.swift
Normal file
|
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
32
AccessibilityTalk/FlipLayoutAxisBadView.swift
Normal file
32
AccessibilityTalk/FlipLayoutAxisBadView.swift
Normal file
|
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
87
AccessibilityTalk/FlipLayoutAxisView.swift
Normal file
87
AccessibilityTalk/FlipLayoutAxisView.swift
Normal file
|
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
23
AccessibilityTalk/TextSizingBadView.swift
Normal file
23
AccessibilityTalk/TextSizingBadView.swift
Normal file
|
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
22
AccessibilityTalk/TextSizingView.swift
Normal file
22
AccessibilityTalk/TextSizingView.swift
Normal file
|
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue