Extending Groser iOS and Rails apps to support grocery delivery in multiple cities - Part 3
3 minute read
Right now you can shop and order delivery only in Moscow from single chain of supermarkets. My goal in this post, is to allow customers to switch cities, and load catalog of the supermarket chain we happen to deliver from in the given city.
Floating Menu Bar
I want to devide floating department selection bar in half and make left part open city selection view controller.
Floating Menu Bar
I need to move labels to the right, embedd labels and image view into wrapper view and anchor it to the center of the parent view.
I’ll use separator view with auto layout constraints set to center it vertically and horizontally and then will constrain left edge of the department wrapper view to the separator view. Repeat steps for the left half and constrain right edge of the left wrapper view to separator view.
City and Department Bar
City selection
Tapping on the left part of FloatingMenuBar should show available cities in CitiesViewController, which I’ll create now.
CitiesViewController.swift
Hook up FloatingMenuBar with CitiesViewController.
GRFloatingMenuBar.mGRStoreViewController.m
Update city and store labels in FloatingMenuBar when city changes.
GRFloatingMenuBar.m
Change current city and load default store
Let’s download default city’s Store with shelves and departments.
GRStoreViewController.m
Save and restore selected city
To simplify things I’ll store selected GRCity object into NSUserDefaults. To do that I’ll need to conform GRCity and GRStore to NSCoding protocol.
GRCity.mGRStore.m
Now I can save and restore selected GRCity in GRGroser.
GRGroser.m
Switching Cities
In Part 4 I will ask customers to select their delivery city or allow app to detect their city using Location Services.
Thank you for purchasing my iOS control. If you have any questions that are beyond the scope of this help file, please feel free to email via my user page co...
This is Part 2 of multi part series about how I re-architect Rails and iOS apps to support grocery delivery in multiple cities to enable our new business mod...