Giter VIP home page Giter VIP logo

swpedia's Introduction

SWPedia

Description

SWPedia is a sample app that uses the Stars Wars API (SWAPI) to explore Star Wars characters.

The app runs on the iPhone, iPad and macOS (as a Catalyst app).

It supports the following features:

  • portrait and landscape orientation;
  • light and dark mode;
  • automatic list paging while scrolling;
  • offline browsing;
  • searching.

It doesn't support characters sorting (e.g. by name) because APIs don't offer this feature, and implementing it client-side along with paging would be impossible.

Dependencies

The app has the following dependencies (handled via SwiftPM):

  • RxSwift (to bring some reactive magic into the app);
  • Kingfisher (for image loading through the Internet).

Project structure

The app is organized in a workspace using two different Xcode projects:

  • SWPedia is the main app that contains all the UI code (VCs, views, and view models);
  • SWPediaKit is a dynamic framework that contains the model and a small networking layer.

By splitting the code this way we will be able to reuse some business logic in different targets if needed (e.g. for building a watchOS app or a home screen widget).

App Architecture

The app (as simple as it is) follows a MVVM architecture. It's based on UIKit built just using UICollectionView with compositional layouts (for creating both list and grid visualizations) and diffable data sources.

All the networking is made with a tiny custom wrapper built around URLSession (APIRequest + HTTPClient). Requests are exposed as RxSwift observables and models are decoded using the standard Swift Decodable protocol.

Offline browsing was implemented using a lightweight solution based on URLCache. Using more complex implementations (e.g. custom filesystem storage or Core Data) wasn't worth.

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.