Posts

Showing posts from March, 2020

RW.com: Navigation Tutorial - Part 1

Image
Alright! A new article - technically a tutorial to focus on. This one is all to do with navigation. Start Time - 14:20 Here is the link, from Audrey Tan: https://www.raywenderlich.com/5824937-swiftui-tutorial-navigation Before I start, just having look to see what's there. Good to see the ContentView empty at the moment - that's genuinely good to see we're adding from scratch! In the 'Artwork' file, we have a custom struct for Artwork, then an array full (17!) of different artwork values. Each has a whole list of properties. In the MapView file we have some code that I'm not familiar with. OK, let's go to the actual tutorial! SwiftUI Basics Yes I agree with Audrey - I MUCH prefer how the code directly matches to the view, so you can keep track of it all. Also, just the one main ContentView is easier than using storyboards. Another key point is that UIKit can still be used alongside UI. Declarative App Development So what does declarat...

RW.com: Animations Article - Part 2

Image
The run continues! Will be good to make the most of it, as there will not be anywhere near as much time over the next few weeks. Anyway, second and final part on animations. Let's do it! Start Time - 15:04 So we are starting with combing transitions Combining Transitions Here is an extension on AnyTransition - extension AnyTransition {     static var customTransition : AnyTransition {       let transition = AnyTransition . move (edge: . top )         . combined (with: . scale (scale: 0.2 , anchor: . topTrailing ))         . combined (with: . opacity )       return transition     }   } This basically means that there are three specific transitions saved into customTransition - and that is specifically for the type. I'm starting to understand when it is useful to use type properties! 10 minute delay Asynchronous Transition So we have replaced to tr...

RW.com: Animations Article - Part 1

Image
The run continues! Like I said, my plan is to absorb knowledge from these 'beginner' articles. I won't get ALL of it - there'll be stuff beyond me for sure. But there WILL be elements to glean from them, that's the point. In the past I've been too concerned with understanding every aspect but actually, it's more like gradually building a complex puzzle - one piece at a time! Start Time - 15:16 https://www.raywenderlich.com/5815412-getting-started-with-swiftui-animations *Article dated Dec 9th 2019 Again, this could well be over two parts. We'll see! The three key things we're going to learn are animation MODIFIERS and withAnimation - that's the function which lets you animate STATE CHANGES. And Custom Animations! Opened project - here are the various Swift files already put in! And here's what the view structure is - The app is to basically bring up info about the planets in the solar system. Basic Animations *subheading...

RW.com: Storyboards Segues Article - Consolidation

So, as mentioned, I need to consolidate this particular article. There was so much code there, I just wanted to look over it one more time and make sense of it all - from the Xcode project.  Start Time - 13:05 Let's look at one Swift File at a time. First of all the model - this is what was already created before the article: struct Player {   var name : String ?   var game : String ?   var rating : Int } A simple struct here. Name and game are optional because there may be no value (nil) put in - stops the program from crashing. Rating is an int - a score out of 5. That's interesting as anything could actually be set for it! The rating part wasn't actually covered in this project.  Now we have the view file: import UIKit class PlayerCell : UITableViewCell {      @IBOutlet weak var gameLabel : UILabel !   @IBOutlet weak var nameLabel : UILabel !   @IBOutlet weak var ratingIma...

RW.com: Storyboards Segues Article - Part 2

Image
Yes I'm back on the same day! One good thing about 'distancing' is having genuinely more time to code. Limiting in lots of other ways but every cloud and all that... So back on with the article - second and final part! Then a practical play around... Start Time - 13:20 Same article as before - https://www.raywenderlich.com/5055396-ios-storyboards-segues-and-more#toc-anchor-010 We're up to 'Selecting the Game' So for this, we have another 'unwind segue'. The exit bit now works after the game is selected, but nothing actually is selected. Here is what we're actually selecting. Right more fancy code added! Various bits about the GamePicker. Needing the identifier to match up to something or other. Again, I'm sure this is a lot easier in SwiftUI. This was specifically to get the checkmark in - if indexPath. row == gamesDataSource . selectedGameIndex {       cell. accessoryType = . checkmark     } else {       cell...

RW.com: Storyboards Segues Article - Part 1

Image
Here we are! Onto the next article. The first one was useful as it gave me a lot more confidence with connecting the different bits and pieces, along with a few segues. This next article (same author) is all about segues. So I'm sure that there will be various useful bits! Start Time - 8:07 Here is the link I'm following: https://www.raywenderlich.com/5055396-ios-storyboards-segues-and-more Great, something he makes clear that there will be full functionality this time! That's a relief as last time it was a bit strange not to have it after all that work! This time the project has been set up and organised. New VCs are going to be created. So a new Swift file made under the view controller folder. And here's the code added: class PlayersViewController : UITableViewController {      var playerDataSource = PlayersDataSource () } We have a UITableViewController, and in this an instance of the PlayersDataSource class (same name).  It is...