This is a demo app built using SwiftUI that works with the Public Transport Victoria (PTV) API. This is a demo both of building UI in SwiftUI as well as managing data flow with Combine. This repo is intended to serve as a playground for trying out SwiftUI.
This repo contains an Xcode project with some basic SwiftUI views that show PTV services, routes, stops and departure times, and yes, this is real data! Feel free to fork this repo, or download the zip to get started!
Not sure what you want to get started with? Here are some possible things you could look into:
- Change the text styling (see How to style text views with fonts, colors, line spacing & more)
- Change a view with a
List
to use custom views inForEach
(see How to create views in a loop using ForEach) - Add some images or icons (perhaps an icon to show the service type, see SF Symbols)
- Build some ViewModifiers for common UI styles
- Add loading state to each screen (the search screen especially)
- Add a
TabView
that includes "Services" and "Search" (see Adding TabView and tab item) - Add a complex animation (see Animating Views & Transitions)
- Add an MKMapView to see PTV stops (see Creating and combining views)
- Build a different layout for different size classes (see How to create different layouts using size classes)
- Add the ability to favourite different routes or stops
- Improve the
Search
class to use complex Combine operators, i.e. throttle user input every 300 milliseconds - Build a Core Data model which drives the views, and update the model when PTV content loads (see How to configure Core Data to work with SwiftUI)
WatchOS also supports SwiftUI, which could give you a lot more flexibility than the existing WatchKit API. See Building watchOS App Interfaces with SwiftUI
- To switch to fixture data, just change the
ptv
constant to.fixtures
inPTV.swift
- To run the app on your device, open the project settings, go to "Signing & Capabilities", and in the "Team" drop down, select a valid team. If you are having trouble with this feel free to ask any of the hosts to help you out.
Hacking with Swift - Get Started
Receiving and Handling Events with Combine
Hacking with Swift - 100 Days of SwiftUI
SwiftUI by Tutorials - Ray Wenderlich
Combine: Asynchronous Programming with Swift - Ray Wenderlich