https://github.com/cewitte/wordscramble
Paul Hudson's 100 Days of SwiftUI Project 5.
https://github.com/cewitte/wordscramble
Last synced: 11 months ago
JSON representation
Paul Hudson's 100 Days of SwiftUI Project 5.
- Host: GitHub
- URL: https://github.com/cewitte/wordscramble
- Owner: cewitte
- License: mit
- Created: 2024-07-20T16:13:43.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-21T12:44:03.000Z (almost 2 years ago)
- Last Synced: 2025-03-05T03:34:13.134Z (about 1 year ago)
- Language: Swift
- Size: 1.18 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WordScramble
Paul Hudson's 100 Days of SwiftUI Project 5.
## Accessibility support added
Paul added the `.accessibility...` code to the HStack below. `.accessibilityElement` groups the whole stack together. `.accessibilityLabel` makes VoiceOver read the word, and `.accessibilityHint` reads how many letters the word has. These changes make it possible for people with disabilities to play the game. If those changes weren't present, it would make it a very bad experience, i.e. VoiceObver would try to describe the image, which would add confusion to the context.
```swift
var body: some View {
NavigationStack {
List {
Section {
TextField("Enter your word", text: $newWord)
.textInputAutocapitalization(.never)
}
Section {
ForEach(usedWords, id: \.self) { word in
HStack {
Image(systemName: "\(word.count).circle")
Text(word)
}
.accessibilityElement()
.accessibilityLabel(word)
.accessibilityHint("\(word.count) letters")
}
}
}
.navigationTitle(rootWord)
.onSubmit(addNewWord)
.onAppear(perform: startGame)
.alert(errorTitle, isPresented: $showingError) {
Button("OK") {}
} message: {
Text(errorMessage)
}
}
}
```
Although it can only be experienced in a real device with VoiceOver turned on, here's the the working app:

## Acknowledgments
Original code created by: [Paul Hudson - @twostraws](https://x.com/twostraws) (Thank you!)
Made with :heart: by [@cewitte](https://x.com/cewitte)