Skip to content

MalingaBandara/H4XOR-News-iOS-App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

H4XOR News iOS App

Project Overview

H4XOR News is an iOS application designed to display top stories from Hacker News. The app fetches data from the Hacker News API and presents it in a SwiftUI-based interface, providing a clean and user-friendly experience. The app supports seamless navigation between story listings and detailed views, enabling users to stay up-to-date with the latest tech news.

Key Features

  • Top Stories Listing: Displays a list of the most popular stories from Hacker News.
  • SwiftUI Interface: Modern and responsive UI built with SwiftUI.
  • Story Details View: Provides more detailed information and a link to the full article.

Technologies Used

  • Swift
  • SwiftUI
  • Hacker News API

Project Structure and Code Explanation

  1. Fetching Data from API:

    • The app retrieves data using the Hacker News API and handles JSON decoding.
    func fetchStories() {
        if let url = URL(string: "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty") {
            URLSession.shared.dataTask(with: url) { data, response, error in
                if let safeData = data {
                    // Parse the data
                }
            }.resume()
        }
    }
  2. Story Listing View:

    • SwiftUI is used to create a responsive list view that displays the fetched stories.
    struct StoryListView: View {
        var body: some View {
            List(stories) { story in
                Text(story.title)
            }
        }
    }
  3. Navigation and Story Details:

    • The app allows users to tap on a story to navigate to a detailed view with more information.
    struct StoryDetailView: View {
        var story: Story
        var body: some View {
            VStack {
                Text(story.title)
                Text(story.url)
            }
        }
    }

Project Output

Here are some screenshots showing the key features and output of the application:

H4XOR News APP

Screens

How to Run the Project

  1. Clone the repository:
    git clone https://github.com/MalingaBandara/H4XOR-News-iOS-App.git
  2. Open the project in Xcode.
  3. Run the project on an iOS simulator or device.

Purpose and Future Enhancements

The H4XOR News project was developed to demonstrate fetching and displaying API data in an iOS app using SwiftUI. Future enhancements may include adding search functionality, sorting options, and improved error handling.

License

This project is licensed under the MIT License.

About

Hacker News App

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages