Git Product home page Git Product logo

wafer-coding-challenge's Introduction

Wafer Coding Challenge

Country Viewing App

Building And Running The Project (Requirements)

  • Swift 2.3+
  • Xcode 8
  • iOS 10.0+

Architecture

This application uses the Model-View-ViewModel (refered to as MVVM) architecture. The main purpose of the MVVM is to move the data state from the View to the ViewModel.

The Following is gotten from: https://www.toptal.com/ios/swift-tutorial-introduction-to-mvvm

Model

In the MVVM design pattern, Model is the same as in MVC pattern. It represents simple data.

View

View is represented by the UIView or UIViewController objects, accompanied with their .xib and .storyboard files, which should only display prepared data. (We don’t want to have NSDateFormatter code, for example, inside the View.)

ViewModel

Only a simple, formatted string that comes from the ViewModel.

ViewModel hides all asynchronous networking code, data preparation code for visual presentation, and code listening for Model changes. All of these are hidden behind a well-defined API modeled to fit this particular View.

One of the benefits of using MVVM is testing.

Walkthrough Fetching Countries

CountryManager / CountryManagerProtocol

In the CountryManagerProtocol, we have a protocol that has a fetchcountries(completion: ...)

CountryManager Implements this, and provides an implementation for fetchcountries(completion: ...)

Testing Country Mananeger

Unit test was writing for testing countrymanager / Delegate. I tested for the following:

  • Test For success by mocking it
  • Test for bad data by mocking it also
  • Test Manager itself by checking for reachability before utilizing it

CountryViewViewModel

Here, we initialized CountryManagerProtocol and perform country data fetching, pagination, passing data to view when done

Testing CountryViewViewModel

I ran test for:

  • Loading stat
  • Successful data
  • Error Fetching data

CountryTableViewCell

This here, displays information about a tableview.

Task / Solution

Solving Task Given To Implement On Cell:

  • It should have an anchor point for where the swipe just shows the delete icon.
  • On a fast swipe past anchor point the row should delete.
  • On a slow swipe past anchor point, swiped area should swipe back to anchor point showing the delete icon
  • On a slow swipe till anchor point, the swipe should get cancelled.
  • Clicking/Swiping any other row should cancel the current swipe.

Solution

  • Setup Gesture recognizer and slide action views
  • In the gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool I ensured swipe is enabled only alog x axis
  • When moving view, make sure every moving view is in sync by using the centerPoint and leftAnchorConstraint
  • If pan velocity of view goes beyond the 1000 point threshold, view should be deleted
  • If delete button is clicked, it should delete
  • If slow swiped to anchor-point, it should return
  • If slow swiped past anchor-point it should return to anchor-point
  • Clicking / Swipping any other cell dismisses any other active cell by checking if a cell is active. I achieved this bu making sure that evey time a new cell wants to swipe, I keep a reference of it

wafer-coding-challenge's People

Contributors

tonespy avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.