Code Monkey home page Code Monkey logo

news-yc---iphone's Introduction

banner

About

News/YC is an iOS app that tries to do one thing, give you Hacker News and get the hell out of the way. If the app isn't doing something you feel it should, or if you think there's an easier way to get an action accomplished - open up an Issue! I want your feedback. This app was made by me, for my usage, so it probably won't line up with everybody's tastes and there is probably a huge group of people with better taste than me. Feel free to be vocal - it's the only way to make this app the best!

This app does not use the new HackerNews API, but instead relies on libHN for the interface to HN content.

App Store

  • 3.0
  • Swift

Table of Contents

General Architecture

This app is built in Swift, but is really a port of an existing app with a little bit clearer design and modularity of components. There are a few architecture decisions I made to make some things easier that may or may not be defacto architecture or MVC considerations. The first of which is...

HNNavigationBrain

This class is literally the arbiter for all navigation related activities. I made this class with the idea that I shouldn't have to constantly defer navigation-related logic up through a chain to meet a UIViewController which then actually does it. That's too much of a chain, and honestly too much of a hassle. I wanted the system to be slightly knowledgable about itself. I wanted to be able to navigate at any time I want.

Enter the Brain.

The navigation brain works by making every navigable View Controller a subclass of HNViewController which handles a lot of boilerplate logic like building the navigation bar and responding to theme changes, etc. The biggest thing this view controller does is listen for navigation notifications, and responding if they are valid. HNNavigationBrain initiates navigation by a bunch of possible methods (navigate to Posts, navigate to comments for Post, etc) and passes a newly instantiated HNViewController instance through the NSNotificationCenter to the top-most view controller in the UINavigationController's stack.

What this effectively means, is that anything can initiate navigation. All views, models, and controllers have this functionality thanks to the brain. This scheme is not without possible problems, however, but we try to minimize these as much as possible. Navigation events are fairly predictable reactions to button presses, so we don't have to worry so much about different classes calling navigation notifications at the same time. But it is beneficial to think about this as you commit and contribute to the project.

It's fairly easy to use the navigation brain as well:

HNNavigationBrain.navigateToComments(somePost)

HNTheme

HNTheme.currentTheme() acts as the main interface for all them and color related functionality of the app. The currentTheme() singleton instance determines how all UI color schemes are assigned, and handles the notifications blasted out when the theme is changed. All HNViewControllers and their subclasses override the resetUI() method to reset after a theme change.

Currently there are four themes in the app, two light (Day and Minima) and two dark (Night and SpaceOne). Since I'm an art guy myself, you can bet your butt there will be more themes and theme packs later.

View Controllers

As mentioned earlier, all navigable view controllers in the app are subclasses of HNViewController - but those don't account for all view controllers in the app.

HNViewController subclassed

  • HNPostsViewController
  • HNCommentsViewController
  • HNWebViewController

UIViewController subclassed

  • HNSubmissionViewController
  • HNNavigationViewController

What's Next?

Apart from library changes here and there whenever YC starts messing with the site site's HTML markup, here's the list of functionality I'd like to add:

  • Nesting Comments
  • Find text in comment strings
  • More themes!

news-yc---iphone's People

Contributors

bennyguitar avatar imavca avatar xonder avatar gshahbazian avatar reygonzales avatar btmills avatar vexocide avatar troyharris avatar krohling avatar

Watchers

Chew Chit Siang avatar James Cloos avatar  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.