Image for post
Image for post

If you’re creating an application that supports international purchases, you would definitely want to show the prices in the user’s localised currency and formatting (since different countries have different formats). Doing this cleanly and efficiently would be a challenge. So we will be using 2 packages by Daniel Stainback that will make this easy and efficient.

Part A — Installation and Configuration

Install the packages

We will install 2 packages. The torann/currency package for currency conversion and formatting, and the torann/geoip package for detecting the local currency of the user.

composer require torann/currency
composer require torann/geoip

Let us publish the config and migration files so that we can make changes. …

Image for post
Image for post

The latest versions of Laravel and Cashier have brought many changes and made it significantly easier to build features in our web applications. In this tutorial, we will build a simple subscription system using Stripe.

1. Install the Cashier package

Run the following command.

composer require laravel/cashier

This will install migrations for adding required columns to the users table, and also create a subscriptions table. So let us run the migrations.

php artisan migrate

Optionally, you can publish the migration files to your project database directory along with other migrations.

php artisan vendor:publish --tag="cashier-migrations"

We will also require stripe-php package later for retrieving our subsriptions from our stripe account, so let us install it also. …

Image for post
Image for post

Assuming you have an existing Laravel project, we will create a database for Books and we will write endpoints for its CRUD operations, which means Create, Read, Update and Delete. We will create the following endpoints:

GET /api/books : to return a list of all the books

GET /api/books/{id} : to return details of a particular book by ID

POST /api/books : to create a new book

PUT /api/books/{id} : to update details of a book by iD

DELETE /api/books/{id} : to delete a book by ID

So let’s get started.

Note: If you don’t have an existing Laravel project, please check this and this.

Image for post
Image for post

Laravel makes API authentication a breeze using Laravel Passport, which provides a full OAuth2 server implementation for your Laravel application in a matter of minutes.

If you are new to Laravel, I suggest you go through this article first to learn how to set up and create a new project.

Once you have a project, you can continue below.

Step 1

Install Passport

In your laravel project, run the command

composer require laravel/passport

and then run migrate command to create all the necessary tables.

php artisan migrate

Finally, install it

php artisan passport:install

This command will create the encryption keys needed to generate secure access tokens. …

Image for post
Image for post

This tutorial is concise and assumes that you already know how to add constraints, connect outlets, and create delegates.

Leave a comment below if you are a beginner and need assistance with these!


First let us design the alert view.

Drag a ViewController on to your storyboard.

Add a view, add necessary constraints, header labels and the most important part — a UIPickerView. Also add OK and Cancel buttons at the bottom. Here’s how my view looks after design.

Image for post
Image for post


Now create a Swift class for this ViewController that we created, named MyTimePickerAlert.swift. We also need to create a Delegate for this, so that we can communicate data back to our main view controller from where we will be presenting this alert. …

Image for post
Image for post


In this tutorial, we shall have a project named ‘mystore’, which can have 2 kinds of users, either ‘admin’ or ‘seller’. They will have separate dashboards with separate features and functionalities. When a user logs in to our website, they will be redirected to a dashboard according to their role. Also, the routes should be protected, meaning, the logged in user should not be able to access the dashboard or any of the inside pages of the other role, even if they type the URL in the browser. So let us begin.

If you are new to Laravel, I recommend going through this article, to learn how to set up Laravel and create and run Laravel projects. …

Image for post
Image for post

Showing the AppBar as soon as you begin scrolling upward

The SliverAppBar provided by Flutter, supports a floating app bar that hides upon scrolling down. But there’s one downside about it, it reappears only when the user scrolls back up all way to the top of the scroll view. This can be undesirable if the scroll content happens to be larger. For example in the Medium app, the app bar shows up as soon as you start scrolling upward, no matter where you are. This is what we want.

Image for post
Image for post

So in this tutorial we will implement this action using ScrollController and AnimatedContainer.

Let us begin by creating a simple screen, a stateful widget. …

Image for post
Image for post

Apple’s MapKit makes it very easy to get directions from one coordinate to another. Let us see how to use this to show a route on an MKMapView.

First, make the ViewController conform to the MKMapViewDelegate protocol.

and make sure the outlet of the map view is attached and the delegate is set.

mapView.delegate = self

Now write this method for showing the route. This method performs the following actions

  1. Takes 2 coordinates as parameters
  2. Fetches direction between the 2 points
  3. Displays the fetched route on the map
  4. Zooms the map to the route area.
func showRouteOnMap(pickupCoordinate: CLLocationCoordinate2D, destinationCoordinate: CLLocationCoordinate2D) {

let request = MKDirections.Request()
request.source = MKMapItem(placemark: MKPlacemark(coordinate: pickupCoordinate, addressDictionary: nil))
request.destination = MKMapItem(placemark: MKPlacemark(coordinate: destinationCoordinate, addressDictionary: nil))
request.requestsAlternateRoutes = true
request.transportType = .automobile

let directions = MKDirections(request: request)

directions.calculate { [unowned self] response, error in
guard let unwrappedResponse = response else { return }

//for getting just one route
if let route = unwrappedResponse.routes.first {
//show on map
//set the map area to show the route
self.mapView.setVisibleMapRect(route.polyline.boundingMapRect, edgePadding: UIEdgeInsets.init(top: 80.0, left: 20.0, bottom: 100.0, right: 20.0), animated: true)

//if you want to show multiple routes then you can get all routes in a loop in the following statement
//for route in unwrappedResponse.routes …

Image for post
Image for post

This tutorial shows, in a Swift app, how we can use MapKit’s free direction service MKDirections, to get a route between two coordinates and show the resulting route on a Google Map, GMSMapView.

First, get this file, and save it within your project as Polyline.swift. This will be used to create Polyline from coordinates:

Second, use the two coordinates and pin markers on the points.

import UIKit
import GoogleMaps
import MapKit
func setMapMarkersRoute(vLoc: CLLocationCoordinate2D, toLoc: CLLocationCoordinate2D) {

//add the markers for the 2 locations
let markerTo = GMSMarker.init(position: toLoc) = mapView
let vMarker = GMSMarker.init(position: vLoc) = mapView

//zoom the map to show the desired area
var bounds = GMSCoordinateBounds()
bounds = bounds.includingCoordinate(vLoc)
bounds = bounds.includingCoordinate(toLoc)
self.mapView.moveCamera( …

Image for post
Image for post

Image Picker is a common component we often need for user-profiles and other stuff. We will be using this plugin by Flutter developers.

Step 1 — Add the dependency to your pubspec.yaml file.

image_picker: ^0.6.6+5

Step 2 — Configure native platforms

Next, we need to configure native settings. For the Android platform, nothing is needed. For iOS, open Info.plist file found under ios/Runner folder and add the following keys.

<string>Allow access to photo library</string>

<string>Allow access to camera to capture photos</string>

<string>Allow access to microphone</string>

Step 3 — Image Picker function

In our screen’s StatefulWidget’s State class, declare a File variable to hold the image picked by the user.

File _image;

Now write two functions for picking image via Camera and Photo Library respectively. The optional parameter imageQuality accepts any value between 0and 100, you can adjust it according to the size and quality required by your app. After obtaining the image file, we save it into the _image variable and call setState() so that it can be displayed in the screen. …


Zeba Rahman

App Developer |

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