In the previous episode, we created the structure of the app but with not pretty look&feel, in this post, we see how to improve a bit.

First, I remember that the code of the project is here: https://github.com/niqt/EEnigma

Contacts list

To change the NavigationBar we ha to define a init function in the ContentView:

init() {
let coloredAppearance = UINavigationBarAppearance()
coloredAppearance.configureWithTransparentBackground()
coloredAppearance.backgroundColor = .clear
coloredAppearance.titleTextAttributes = [.foregroundColor: UIColor.white]…

In the previous posts, we have seen the fundaments of the SwiftUI. Now is the moment to starts to build something a bit more complex, how to implement the navigation in our apps with NavigationBar and the TabView.

NavigationBar

Start from the code of the previous post ( https://nicoladefilippo.com/list-in-swiftui/):

struct Vehicle: Identifiable {
var id = UUID()
var name: String
var image: String
}

struct ContentView: View {
@State var vehicles = [Vehicle(name: "car", image: "car")…


In this post, I explain how to use the list to show a list of elements.

The first simple example:

struct ContentView: View {
var body: some View {
List {
Text("Element One")
Text("Element Two")
}
}
}

The magic word is List, which has two text elements:


State

In every software or application we need to share information from the different components, in this post we’ll see how to do it in SwiftUI.

In the first example, we want to make a simple application that tapping on a button, the app shows the number of times that the button is tapped, more simple to show that to explain:


In this post, we see how to use the images with SwiftUI and how to create some beautiful effect.

In beginning, we have to add an image to the assets of the XCode project. Click on the assets:


Vertical Stack

In the previous post we saw a single object in the view, but to build a nice and helpful interface we need to combine more objects. We start with a simple example, we want a text and a button.

VStack() {
Button(action: {

}) {
Text("Press")
.padding()
.foregroundColor(.white)
.background(LinearGradient(gradient: Gradient(colors: [Color.black, Color.green]), startPoint: .trailing, endPoint: .leading
))
.clipShape(Ellipse())
}
Text("Me")
.foregroundColor(Color.red)
}

In the code, I used a vertical stack (VStack) the object is showed as in the column. See the picture:


In this post, I’ll show the fundamentals of the Swift language. It’s the first of a series where I’ll show how to build a chat app using Swift and SwiftUI.

Let’s start with the simpler things, comments, variables and constants:

// It's a line comment

/*
This is a multiline
comment
*/

// Variable definition:
// var varname: Type = Initial value

var name: String = "Nicola"

The variables are defined using the “var” keyword, a name, after the “:” we must write the type of the variable (String, Double, Float, Array, Set,..)

The variable can be also declared shortly…


In 2019 Apple introduced the SwuifUI, a declarative language to develop the UI on Apple devices, in fact with this language is more simple to port an application from iPhone on the other devices type (AppleTV. iWatch, ..) and vice versa. Now in the Xcode, the default way to develop an application is to use SwuiftUI, instead is an optional use of UIKit (but it is not obsolete, in some case we need the uikit yet). Creating a new project we see the dialog to choose the project name and the Combobox to choose the toolkit.


There isn’t a way to catch the shake gesture only using SwiftUI, so it’s necessary use these frameworks: Uikit and Combine .

Combine is very helpful in this case because how is wrote in the Apple documentation: “Combine declares publishers to expose values that can change over time, and subscribers to receive those values from the publishers.”

In the example, the goal is catch the Shake gesture with the UiKit, with the Combine framework we publish this event and get the combine published info in the SwiftUI view that is a subscriber. Let’s start.

We must create a Swift file…

Nicola De Filippo

Software Engineer and Entrepreneur

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store