Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Magic of SwiftUI

Magic of SwiftUI

With the new iOS 13, SwiftUI has been one of the best feature offered by Apple. This talk will be a kick start to the new features SwiftUI has to offer to ease out the development process. The declarative and bindable nature would be the main focus here.

Speaker: Akanksha Sharma
GitHub: https://github.com/akanksharma
Twitter: https://twitter.com/akanksharmaa

Presented at Swift Mumbai Chapter 9 Meetup hosted by Dream11
https://www.meetup.com/Swift-Mumbai/events/260541095/

Swift India

June 22, 2019
Tweet

More Decks by Swift India

Other Decks in Programming

Transcript

  1. • Introduction to SwiftUI • What new in Swift UI?

    • Basic elements of SwiftUI • Is it Bye Bye Storyboards forever? • Scaling your app with SwiftUI • Time for some live coding
  2. AppKit - Construct and manage a graphical, event-driven Swift -

    Build apps using a powerful open language UIKit - Construct and manage a graphical, event-driven user interface Metal - Render advanced 3D graphics Foundation - Access essential data types, collections, and operating-system services Core Data - Persist or cache data Vision - Apply computer vision algorithms Core Animation - Render, compose, and animate visual elements. How Apple defines its frameworks
  3. Declare When you don’t or maybe don’t want to care

    about how the task is done, you just DECLARE it to be done by someone Here SwiftUI is doing the how part of the task, we just have to care about What has to be done.
  4. Example of text label & color in UI Kit textLabel.text

    = "Hello World" textLabel.textColor = UIColor.green textLabel.font = UIFont.systemFont(ofSize: 17.0) Example of text label & color in SwiftUI Text("Hello World") .font(.title) .color(.green)
  5. 1 2

  6. • Merge issues with large storyboards • Interface Builder has

    no idea about how are code is working • UITableViews/CollectionViews or creating a view controller from storyboards or triggering segues, strings are used to name them These problems exist because IB and Swift are very separate things. This isn’t a huge surprise – not only does Interface Builder date from way before the original Mac OS X was a thing, but it’s also very much designed around the way Objective-C works User Interface
  7. Behavior State and Data Flow Control and respond to the

    flow of data and changes within your app’s models. Gestures Define interactions from taps, clicks, and swipes to fine-grained gestures.
  8. Multiple Platform Support • SwiftUI runs on iOS 13, macOS

    10.15, tvOS 13, and watchOS 6, or any future later versions of those platforms • The official line seems to be that SwiftUI is not a multi-platform framework, but is instead a framework for creating apps on multiple platforms. • Apple isn’t saying that you can use identical SwiftUI code on every platform
  9. • ContentView - struct that implements View Protocol • Body

    - protocol conformance Variable • some View - return type of body which id of Opaque Type • Text("Hello World") - A label • ContentView_Previews -
  10. • UITableView : List • UICollectionView : No SwiftUI equivalent

    • UILabel : Text • UITextField : TextField • UITextField with isSecureTextEntry set to true : SecureField • UITextView : No SwiftUI equivalent • UISwitch : Toggle • UISlider : Slider • UIButton : Button • UINavigationController : NavigationView • UIAlertController with style .alert : Alert • UIAlertController with style .actionSheet : ActionSheet • UIStackView with horizontal axis : HStack • UIStackView with vertical axis : VStack • UIImageView : Image • UISegmentedControl : SegmentedControl • UIStepper : Stepper • UIDatePicker : DatePicker • NSAttributedString : Incompatible with SwiftUI; use Text instead.