Building a Vending Machine App - Part 4

I can explain the absence over the past few days - Goodwood Festival of Speed! Literally did not have a moment to do any Swift at all. I did a handwritten 'summary' of everything I know about Swift - useful to do and did highlight a couple of things about reference/value type that I wasn't sure about. Anyway, I won't go into that now. My focus is to finish this 'Vending Machine' course. To be honest, it's been difficult and confusing - to put it nicely! I just want to get it done. There's always something you can learn, if you look for it! Something I remember was the 'error handling' aspect being about the user accessing this, rather than just being coded for the sake of it. There's been some useful experience of seeing enums used within classes, the table organiser view...not a complete a waste of time!

Temporary Views

OK, first of all I've opened Pasan's project file as mine has an error in it somewhere/somehow and after an hour or so last time of checking each element, I've given up with that! So I'm using a code that definitely works!

At the moment, we don't have error handling code for if we want to purchase something that is too much. IOS apps are not limited to one view - you can have many per app! There are different ways to present views on the screen.

There are three different temporary views -

Alert - gives important info that affects their use of the device/app. This looks familiar being an iPhone user! Has an optional message. One or more buttons to take certain actions.

The Human Interface Guidelines (HIG) has information about how to set out views.
*Homework! Pasan has instructed me to read up on temporary views. Here we go....

https://developer.apple.com/design/human-interface-guidelines/ios/overview/themes/

OK, so this information is about the design of an app. To sum this up:


Three DESIGN THEMES to consider - clarity, deference and depth...

Clarity: legibility of text, use of colour, font, negative spaces etc.

Deference: filling the screen properly, gradients, translucency, blurring....

Depth: use of hierarchy, transitions...


DESIGN PRINCIPLES:

Aesthetic Integrity - how the appearance matches up to the behaviour of the app e.g. serious app - simple, no fuss; exciting game - colourful and wacky!

Consistency - uniform terminology, well known icons etc...people using it should be able to know what to expect!

Direct Manipulation - rotating the screen, touching to change views...immediate results of actions seen.

Feedback - every user action should show some sort of result, e.g. clicking that highlights, text feedback, progress indicators, sounds and animations...

Metaphors - interesting one this! So virtual objects and actions are metaphors e.g. flicking through pages of a book, dragging and swiping, moving toggles....

User Control - the user should be in control! You don't want the app to do too much decision making. Avoiding unwanted outcomes, making it easy to cancel operations etc....

OK, reading done!


Displaying an Alert View

 func showAlertWith(title: String, message: String, style: UIAlertControllerStyle = .alert) {
        let alertController = UIAlertController(title: title, message: message, preferredStyle: style)
        
        let okAction = UIAlertAction(title: "OK", style: .default, handler: dismissAlert)
        alertController.addAction(okAction)
        
        present(alertController, animated: true, completion: nil)
    }
    
    func dismissAlert(sender: UIAlertAction) -> Void {
        updateDisplayWith(balance: 0, totalPrice: 0, itemPrice: 0, itemQuantity: 1)

    }

OK - all this code was done on Pasan's Xcode file! So I didn't have to type it out - but here it is for reference.

There are a couple of useful keywords here - 'present', which is used to show the actual error message. the UIAlertController is a built-in class.

Modal view - prevent the user from using the underlying view until they perform the action in the modal view. E.g. the error alert on your iPhone - have to click 'OK' or whatever before continuing with the action!

An app has a view hierarchy. The view stack changes as we present different views - makes sense. The style of the error button is created by the system - that is out of our control, for now!

That's about half of this last part - the rest of this Vending Machine course will be finished off today!

Comments

Popular posts from this blog

*Xcode Project Entry 2* F1 Quiz - part 1

Angela Yu Course Part 10 (up to lesson 112)

Angela Yu Xcode 12 Course - Part 7 (lectures 74 to 79)