Previous Next

SwiftUI Apprentice Beginning iOS Programming with SwiftUI (Audrey Tam Caroline Begbie) (z-library.sk, 1lib.sk, z-lib.sk)

Author: Audrey Tam, Caroline Begbie

移动

No Description

📄 File Format: PDF
💾 File Size: 8.5 MB
9
Views
0
Downloads
0.00
Total Donations

📄 Text Preview (First 20 pages)

ℹ️

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

📄 Page 1
(This page has no text content)
📄 Page 2
SwiftUI Apprentice By Audrey Tam & Caroline Begbie Copyright ©2021 Razeware LLC. Notice of Rights All rights reserved. No part of this book or corresponding materials (such as text, images, or source code) may be reproduced or distributed by any means without prior written permission of the copyright owner. Notice of Liability This book and all corresponding materials (such as source code) are provided on an “as is” basis, without warranty of any kind, express of implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in action of contract, tort or otherwise, arising from, out of or in connection with the software or the use of other dealing in the software. Trademarks All trademarks and registered trademarks appearing in this book are the property of their own respective owners. SwiftUI Apprentice raywenderlich.com 2
📄 Page 3
Table of Contents: Overview Book License 14............................................................................................. Before You Begin 15................................................................ What You Need 16........................................................................................ Book Source Code & Forums 17............................................................. About the Cover 18...................................................................................... How to Read This Book 23........................................................................ Section I: Your first app: HIITFit 24.................................... Chapter 1: Checking Your Tools 25............................................ Chapter 2: Planning a Paged App 60......................................... Chapter 3: Prototyping the Main View 79.............................. Chapter 4: Prototyping Supplementary Views 107............ Chapter 5: Organizing Your App's Data 130.......................... Chapter 6: Adding Functionality to Your App 156.............. Chapter 7: Observing Objects 176............................................ Chapter 8: Saving Settings 192................................................... Chapter 9: Saving History Data 218.......................................... Chapter 10: Refining Your App 246........................................... Chapter 11: Understanding Property Wrappers 277........ Chapter 12: Apple App Development Ecosystem 298...... Section II: Your second app: Cards 321............................. Chapter 13: Outlining a Photo Collage App 322.................. SwiftUI Apprentice raywenderlich.com 3
📄 Page 4
Chapter 14: Gestures 346............................................................. Chapter 15: Structures, Classes & Protocols 374................ Chapter 16: Adding Assets to Your App 405......................... Chapter 17: Interfacing With UIKit 435.................................. Chapter 18: Paths & Custom Shapes 454............................... Chapter 19: Saving Files 479........................................................ Chapter 20: Delightful UX — Layout 506................................ Chapter 21: Delightful UX — Final Touches 535.................. Section III: Your third app: RWFreeView 565................. Chapter 22: Lists & Navigation 566........................................... Chapter 23: Just Enough Web Stuff 596................................. Chapter 24: Downloading Data 625......................................... Chapter 25: Implementing Filter Options 652..................... Chapter 26: Widgets 680.............................................................. Conclusion 706.............................................................................................. SwiftUI Apprentice raywenderlich.com 4
📄 Page 5
Table of Contents: Extended Book License 14. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Before You Begin 15. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . What You Need 16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Book Source Code & Forums 17. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . About the Cover 18. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . About the Authors 21. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . About the Editors 21. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . About the Artist 22. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to Read This Book 23. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Section I: Your first app: HIITFit 24. . . . . . . . . . . . . . . . . . . . Chapter 1: Checking Your Tools 25. . . . . . . . . . . . . . . . . . . . . . . . . . . . . Getting started 25. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a new Xcode project 27. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A quick tour of Xcode 30. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ContentView.swift 33. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a new SwiftUI View file 37. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . What else is in your project? 40. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Xcode Preferences 43. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Running your project 48. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 59. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 2: Planning a Paged App 60. . . . . . . . . . . . . . . . . . . . . . . . . . . . Making lists: views and actions 60. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating Pages 63. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Grouping files 70. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Passing parameters 71. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Looping 74. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SwiftUI Apprentice raywenderlich.com 5
📄 Page 6
Key points 78. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Where to go from here? 78. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 3: Prototyping the Main View 79. . . . . . . . . . . . . . . . . . . . . . Creating the Exercise view 79. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating the Header view 82. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Playing a video 93. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Finishing the Exercise view 98. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 106. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Where to go from here? 106. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 4: Prototyping Supplementary Views 107. . . . . . . . . . . . . Creating the History view 107. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating the Welcome view 114. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Challenge 127. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 129. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Where to go from here? 129. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 5: Organizing Your App's Data 130. . . . . . . . . . . . . . . . . . . . Creating the Exercise structure 131. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Structuring HistoryView data 135. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Localizing your app 140. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 155. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 6: Adding Functionality to Your App 156. . . . . . . . . . . . . . Managing your app’s data 156. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Navigating TabView 158. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Interacting with page numbers and ratings 164. . . . . . . . . . . . . . . . . . . . . . . . . Showing and hiding modal sheets 169. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 175. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 7: Observing Objects 176. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Showing/Hiding the timer 176. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding an exercise to history 184. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Challenge 190. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SwiftUI Apprentice raywenderlich.com 6
📄 Page 7
Key points 191. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 8: Saving Settings 192. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Data persistence 193. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Saving the ratings to UserDefaults 193. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Data directories 195. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Swift Dive: Strings 203. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Thinking of possible errors 208. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Multiple scenes 210. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Apps, Scenes and Views 213. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Restoring scene state with SceneStorage 215. . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 217. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 9: Saving History Data 218. . . . . . . . . . . . . . . . . . . . . . . . . . . . Using optionals 219. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Debugging HistoryStore 223. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Swift error checking 228. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Alerts 231. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Saving history 233. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Closures 235. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Property list serialization 240. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Challenge 244. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 245. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 10: Refining Your App 246. . . . . . . . . . . . . . . . . . . . . . . . . . . . . Neumorphism 247. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a neumorphic button 248. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Styles 249. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Abstracting your button 253. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The embossed button 256. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @ViewBuilder 260. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ViewBuilder container view 265. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Designing WelcomeView 268. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SwiftUI Apprentice raywenderlich.com 7
📄 Page 8
Gradients 270. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Challenge 274. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 276. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 11: Understanding Property Wrappers 277. . . . . . . . . . . Getting started 278. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tools for managing data 279. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Managing UI state values 281. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Accessing environment values 286. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Managing model data objects 289. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wrapping up property wrappers 295. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 297. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 12: Apple App Development Ecosystem 298. . . . . . . . . . A brief history of SwiftUI 298. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SwiftUI vs. UIKit 300. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Apple Developer 303. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Housekeeping & trouble-shooting 313. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 320. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Section II: Your second app: Cards 321. . . . . . . . . . . . . . . . Chapter 13: Outlining a Photo Collage App 322. . . . . . . . . . . . . . . . Initial app idea 323. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating the project 324. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating the first view for your project 325. . . . . . . . . . . . . . . . . . . . . . . . . . . . . Refactoring the view 328. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Navigation toolbar 333. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Challenge 345. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 345. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 14: Gestures 346. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating the resizable view 347. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating transforms 348. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SwiftUI Apprentice raywenderlich.com 8
📄 Page 9
Creating a drag gesture 350. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a rotation gesture 354. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a scale gesture 358. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating custom view modifiers 360. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Other gestures 366. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Type properties 367. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating global defaults for Cards 369. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Challenge 372. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 373. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Where to go from here? 373. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 15: Structures, Classes & Protocols 374. . . . . . . . . . . . . . . Data structure 375. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Value and reference types 376. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Swift Dive: Structure vs class 377. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating the card store 378. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Class inheritance 379. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Protocols 381. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The preview data 383. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Listing the cards 385. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Understanding State and Binding property wrappers 395. . . . . . . . . . . . . . Deletion 400. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Challenge 403. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 404. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Where to go from here? 404. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 16: Adding Assets to Your App 405. . . . . . . . . . . . . . . . . . . . The starter project 406. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Asset catalog 406. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Launch screen 411. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding sticker images to your app 416. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Reference folders 419. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using lazy grid views 428. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SwiftUI Apprentice raywenderlich.com 9
📄 Page 10
Challenges 433. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 434. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Where to go from here? 434. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 17: Interfacing With UIKit 435. . . . . . . . . . . . . . . . . . . . . . . . UIKit 436. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Representable protocols 436. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . UIKit delegate pattern 438. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Picking photos 439. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . NSItemProvider 442. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding PhotoPicker to your app 444. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Drag and drop from other apps 446. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Challenge 452. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 453. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 18: Paths & Custom Shapes 454. . . . . . . . . . . . . . . . . . . . . . . The starter project 454. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Shapes 455. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Paths 457. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Strokes and fills 465. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Clip shapes modal 467. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Associated types 468. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Shape selection modal 472. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Add the frame picker modal to the card 473. . . . . . . . . . . . . . . . . . . . . . . . . . . . . Challenges 476. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 478. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 19: Saving Files 479. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The starter project 480. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The saved data format 480. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . When to save the data 481. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . JSON files 484. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Codable 484. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SwiftUI Apprentice raywenderlich.com 10
📄 Page 11
Encoding and decoding custom types 488. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Loading Cards 497. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Challenges 502. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 505. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 20: Delightful UX — Layout 506. . . . . . . . . . . . . . . . . . . . . . . The starter app 506. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Designing the cards list 508. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Layout 509. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Designing the card detail screen 523. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Scaling the card to fit the device 525. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Alignment 528. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Challenge 533. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 534. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 21: Delightful UX — Final Touches 535. . . . . . . . . . . . . . . . The starter project 535. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Animated splash screen 536. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SwiftUI Animation 541. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Explicit and implicit animation 546. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Animated transitions 547. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Transition from card list to single card 550. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Supporting multiple view types 552. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding a picker 553. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sharing the card 556. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Challenges 562. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 564. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Where to go from here? 564. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Section III: Your third app: RWFreeView 565. . . . . . . . . Chapter 22: Lists & Navigation 566. . . . . . . . . . . . . . . . . . . . . . . . . . . . . Getting started 566. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . List 567. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SwiftUI Apprentice raywenderlich.com 11
📄 Page 12
NavigationView 570. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Header view 579. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Custom design 584. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 595. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 23: Just Enough Web Stuff 596. . . . . . . . . . . . . . . . . . . . . . . . Servers and resources 597. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . REST API 600. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sending and receiving HTTP messages 601. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exploring api.raywenderlich.com 605. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Challenge 618. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . POST request & authentication 619. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 624. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 24: Downloading Data 625. . . . . . . . . . . . . . . . . . . . . . . . . . . . Getting started 625. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Asynchronous functions 626. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a REST request 626. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Decoding JSON 633. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Decoding the contents response 640. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 651. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 25: Implementing Filter Options 652. . . . . . . . . . . . . . . . . . Getting started 652. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . From playground to app 653. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Debugging with a breakpoint 658. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Improving the user experience 661. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Challenge 662. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Implementing HeaderView options 666. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Implementing filters in FilterOptionsView 671. . . . . . . . . . . . . . . . . . . . . . . . . . Implementing query filters in HeaderView 675. . . . . . . . . . . . . . . . . . . . . . . . . . One last thing… 678. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 679. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SwiftUI Apprentice raywenderlich.com 12
📄 Page 13
Chapter 26: Widgets 680. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Getting started 680. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . WidgetKit 680. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding a widget extension 681. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating entries from your app’s data 686. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating widget views 688. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Providing a timeline of entries 692. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deep-linking into your app 700. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . One last thing 703. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 705. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Conclusion 706. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SwiftUI Apprentice raywenderlich.com 13
📄 Page 14
LBook License By purchasing SwiftUI Apprentice, you have the following license: • You are allowed to use and/or modify the source code in SwiftUI Apprentice in as many apps as you want, with no attribution required. • You are allowed to use and/or modify all art, images and designs that are included in SwiftUI Apprentice in as many apps as you want, but must include this attribution line somewhere inside your app: “Artwork/images/designs: from SwiftUI Apprentice, available at www.raywenderlich.com”. • The source code included in SwiftUI Apprentice is for your personal use only. You are NOT allowed to distribute or sell the source code in SwiftUI Apprentice without prior authorization. • This book is for your personal use only. You are NOT allowed to sell this book without prior authorization, or distribute it to friends, coworkers or students; they would need to purchase their own copies. All materials provided with this book are provided on an “as is” basis, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. All trademarks and registered trademarks appearing in this guide are the properties of their respective owners. raywenderlich.com 14
📄 Page 15
Before You Begin This section tells you a few things you need to know before you get started, such as what you’ll need for hardware and software, where to find the project files for this book, and more. raywenderlich.com 15
📄 Page 16
iWhat You Need To follow along with this book, you’ll need the following: • A Mac computer with an Intel or ARM processor. Any Mac that you’ve bought in the last few years will do, even a Mac mini or MacBook Air. • Xcode 12.5 or later. Xcode is the main development environment for building iOS Apps. It includes the Swift compiler, the debugger and other development tools you’ll need. You can download the latest version of Xcode for free from the Mac App Store. • Optionally, an iPhone, iPad or iPod Touch running iOS 14. raywenderlich.com 16
📄 Page 17
iiBook Source Code & Forums Where to download the materials for this book The materials for this book can be cloned or downloaded from the GitHub book materials repository: • https://github.com/raywenderlich/suia-materials/tree/editions/1.0 Forums We’ve also set up an official forum for the book at https://forums.raywenderlich.com/ c/books/swiftui-apprentice/79. This is a great place to ask questions about the book or to submit any errors you may find. raywenderlich.com 17
📄 Page 18
iiiAbout the Cover SwiftUI Apprentice That’s not an 18th-century writer’s quill on the cover or even a gorgeous deep water plant, but a sea pen — a creature belonging to the Cnidaria family, which includes jellyfish, coral and sea anemone. The earliest fossils date this colonial creature to the Cambrian period — some 541 million years before being featured on our book — and the pens are still thriving today in both coastal and deep temperate and tropical waters. You can observe the soft colorful stalks of the pens lodged in the seafloor, often grouped like an underwater garden of feathers. And just as you glance at an application on your phone and take in one interface that is actually made of many working features, the sea pen isn’t one creature at all, but a colony of creatures. raywenderlich.com 18
📄 Page 19
The main stem is one polyp — the first to take root — that then supports many other smaller polyps whose tentacles make up the fringes we see. And like the various aspects of the seamless interfaces made with SwiftUI, the delicate polyps are cleverly designed for different purposes to support the whole creature – intaking water, maintaining structure, eating and reproducing. The pens have been observed expanding and shrinking, articulating their frayed bodies, reacting to crabs and other touch, and even glowing. A sea pen may be stationary, like any application anchored within the confines of your device. But the pens show us that with the right construction and design, you can architect something cohesive, fluid, beautiful and dynamic. SwiftUI Apprentice About the Cover raywenderlich.com 19
📄 Page 20
“To the raywenderlich.com community, who help create my happy place.” — Audrey Tam “To my children, Robin and Kayla, who make my real life a better place.” — Caroline Begbie SwiftUI Apprentice Dedications raywenderlich.com 20
The above is a preview of the first 20 pages. Register to read the complete e-book.

💝 Support Author

0.00
Total Amount (¥)
0
Donation Count

Login to support the author

Login Now

Recommended for You

Loading recommended books...
Failed to load, please try again later
Back to List