Image for post
Image for post
Expandable List with OutlineGroup & DisclosureGroup in SwiftUI 2.0

Building an expandable list with nested items is quite a complex and error prone task to implement when using UITableView in UIKit. Luckily with SwiftUI 2.0, Apple introduced OutlineGroup and DisclosureGroup. With the views in our arsenal, we can build a hierarchical expandable and collapsible list with minimal lines of code using declarative syntax and reactive state management.

What We Will Build

We’re going to explore about OutlineGroup and DisclosureGroup, and how we can use them in practice to build List that represent hierarchical data in the UI by building three different kind of screens:

  1. Using List to render hierarchical data.
  2. Using OutlineGroup in List to handle multiple kind of views. …


Image for post
Image for post
Swift REST API & AWS Lambda & DynamoDB

Last month, The Swift Core Team & Swift Server Work Group had announced the availability of Swift AWS Lambda Runtime as well as support of Swift on Amazon Linux 2 OS. With both of this announcement, we finally have some official support to run Swift on AWS Lambda environment.

Swift has many advantages such as low memory footprint, high performance, and quick start time. The Swift AWS Lambda runtime also uses SwiftNIO to provide high performance non blocking networking engine for us to run asynchronous event driven code.

The runtime itself provides built-in support for many Lambda supported events such as HTTP request event from API Gateway, S3 object storage event, Simple Notification Service, and Simple Queue Service. …


Image for post
Image for post
Image Filter SwiftUI macOS App

SwiftUI enables developers to use unified tools and API for building full native applications across Apple platforms. We can target specific platforms and build the UI component without having expertise for each target specific framework such as UIKit (iOS & tvOS), AppKit (macOS), and WatchKit (watchOS). As a developer, we can build apps much faster with declarative syntax, safer with reactive binding and state management between UI and model. At last, we don't have to do context switching when building across platforms.

What We Will Build

In this tutorial, we will build a native Image Filter macOS App with the following features:

  • Filter image using predefined filters from the GPUImage2 Swift library. …


Create an interactive custom push notification UI to display a video preview with buttons to add and favorite

Image for post
Image for post
Custom Interactive Push Notification in iOS

Since iOS 10, Apple has already provided rich notification support for push notification with the introduction of new frameworks, UserNotifications and UserNotificationsUI.

Using these frameworks, we can customize our push notification with abilities such as:

  1. Customize type and content/UI of the push notification.

2. Provide custom actions and responses for each of the types of notification.

3. Mutate the content of a received push notification before it is delivered to the user.

4. Customize a custom trigger for the push notification such as in a specific time interval or geographic region.

Besides all this rich notification support, Apple also added new interactive custom UI support in iOS 13. Before, we could only customize the actions for the user to select in an action-sheet like the iPhone UI. …


Image for post
Image for post
Table View Diffable Data Source

You can also read this article in my Xcoding With Alfian blog website using the link below.

Since the beginning of iOS SDK, UITableViewDataSource is the protocol that had the responsibility to drive the data and provide the cells in TableView. As good developers, we need to implement the protocol methods and making sure to sync our backing model with the data source properly to avoid any crashes because of inconsistencies between them.

optional func numberOfSections(in tableView: UITableView) -> Int
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

Also, when we need to perform granular updates for sections and rows in our TableView, we need to use the API like the sample code below. …


Image for post
Image for post
Property Wrappers in Swift

You can also read this article in my Xcoding With Alfian blog website using the link below.

Alongside many new feature that come with the Swift 5.1, one of the most interesting feature is Property wrappers. Basically, it’s a layer/delegate that sits in the middle between how the declared property should behave and how the property will be stored. Property wrappers can be defined by using struct, class, or enum. It can be used when we declare properties inside of those types also.

Swift has already provided several built in wrappers before Swift 5.1 such as lazy, @NSCopying, but with the introduction of Property Wrappers, developer can now also implement custom wrappers without making the language become more complex. …


Image for post
Image for post

You can also read this article in my Xcoding With Alfian blog website using the link below.

Combine is a framework that has just been recently released for all Apple platforms and it is included in Xcode 11. By using combine, it’s easier to process sequence of value over time whenever it is updated. It also helps us to simplify asynchronous code by not using delegation and avoiding complex nested callbacks.

There are several main components of Combine:

  1. Publisher. It’s a protocol that provides interface to publish value to the subscribers. Sometimes, it’s also referred as the upstream source. It provides generic for the Input type and Failure error type. …


Image for post
Image for post

You can also read this article in my Xcoding With Alfian blog website using the link below.

Opaque return types is a new language feature that is introduced in Swift 5.1 by Apple. It can be used to return some value for function/method , and property without revealing the concrete type of the value to client that calls the API. The return type will be some type that implement a protocol. Using this solution, the module API doesn’t have to publicly leak the underlying internal return type of the method, it just need to return the opaque type of the protocol using the some keyword. The Swift compiler also will be able to preserve the underlying identity of the return type unlike using protocol as the return type.


Image for post
Image for post
SwiftUI GameDB App

You can also read this article in my Xcoding With Alfian blog website using the link below.

SwiftUI is a new UI framework introduced by Apple at WWDC 2019 which can be used to build user interface for all Apple platforms from watchOS, tvOS, iOS, and macOS using single unified API and tools. It is using declarative syntax to describe the user interface. The smallest component, View is a protocol to conform for building custom view so it can be reused and composed together to build layout. …


Image for post
Image for post
GameDB App with Dependency Injection

Dependency Injection is a software engineering technique that can be used to pass other object/service as a dependency to an object that will use the service. It’s sometime also called inversion of control, which means the object delegates the responsibility of constructing the dependencies to another object. It’s the D part of the SOLID design principles, dependency inversion principle.

Here are some of the advantages of using dependency injection in your code:

1. Better separation of concerns between construction and the use of the service.

2. Loose coupling between objects, as the client object only has reference to the services using Protocol/Interface that will be injected by the injector. …

About

Alfian Losari

Mobile Developer and Lifelong Learner. Currently building super app @ Go-Jek. Xcoding with Alfian at https://alfianlosari.com

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