This project is a modern reimagining of the sample code from “The Complete iOS Development Bootcamp”, rebuilt entirely using SwiftUI. But this is more than a UIKit-to-SwiftUI migration — it also includes an interactive WidgetKit extension and AppIntents integration to support Siri and the Shortcuts app.
- Fully rewritten using SwiftUI, leveraging modern, declarative UI design.
- Integrated interactive widget with WidgetKit, allowing quick user interactions directly from the home screen.
- AppIntent integration to trigger actions via Siri voice commands or the Shortcuts app.
- Updated to support the latest versions of iOS (18) and Xcode (16).
struct ContentView: View {
let spacing: CGFloat = 8
var body: some View {
GeometryReader { geometry in
VStack(spacing: spacing) {
Group(subviews: musicalNotes) { subviews in
ForEach(subviews.indices, id: \.self) { index in
subviews[index]
.padding(.horizontal, getPadding(forIndex: index))
}
.frame(
height: getHeight(
withSubviewsCount: subviews.count,
geometry: geometry
)
)
}
}
}
}
@ViewBuilder
var musicalNotes: some View {
MusicalNote(note: "C", color: .red)
MusicalNote(note: "D", color: .orange)
MusicalNote(note: "E", color: .yellow)
MusicalNote(note: "F", color: .green)
MusicalNote(note: "G", color: .indigo)
MusicalNote(note: "A", color: .blue)
MusicalNote(note: "B", color: .purple)
}
func getHeight(withSubviewsCount count: Int, geometry: GeometryProxy) -> CGFloat {
let availableSpace = geometry.size.height - spacing * CGFloat(count - 1)
return availableSpace / CGFloat(count)
}
func getPadding(forIndex index: Int) -> CGFloat {
return CGFloat(index * 8)
}
}