paulsoham / NewsReaderApp

Husqvarna - This application is a trendy news reader developed in SwiftUI that fetches articles from the NewsAPI, stores them locally using SwiftData, and presents them in a user-friendly interface. Users can browse articles, read full content, bookmark articles, and filter by category.

Repository from Github https://github.compaulsoham/NewsReaderAppRepository from Github https://github.compaulsoham/NewsReaderApp

News Reader App

Overview

News Reader is an iOS application developed using SwiftUI that allows users to browse and read news articles from various sources. The app fetches articles from the NewsAPI, allows users to bookmark articles for offline reading of title and description, and provides filtering options for a personalized reading experience.

Requirements

  • iOS 17.0 or later
  • Xcode 14.0 or later
  • SwiftUI and SwiftData

Screenshots

News List Bookmarked News List News Detail

Usage

  • Launch the app to view the latest news articles.
  • Tap on an article to read its details.
  • Bookmark articles by tapping the bookmark icon.
  • Navigate to the Bookmarks tab to view saved articles.

Localization

The app supports localization for various strings to enhance user experience. All localizable strings are stored in the Localizable.strings file.

Features

  • Fetch News Articles: Retrieve articles from the NewsAPI based on user preferences.
  • Bookmark Articles: Save articles locally for offline access.
  • Read Full Content: View detailed information about each article.
  • Filter Articles: Easily filter articles by category.
  • Offline Access: Access bookmarked articles without an internet connection.
  • User-Friendly Interface: A clean and intuitive design using SwiftUI.

Technologies

  • SwiftUI: For building the user interface.
  • SwiftData: For local data storage of bookmarked articles.
  • Network Framework: For monitoring internet connectivity.

Architecture

The application follows the MVVM (Model-View-ViewModel) architecture pattern to separate concerns and enhance testability.

Data Model

The main data model is NewsArticle, which is represented as a SwiftData entity with the following properties:

  • id: Unique identifier for the article.
  • sourceName: Name of the news source.
  • author: Author of the article.
  • title: Title of the article.
  • articleDescription: Brief description of the article.
  • url: Link to the article.
  • urlToImage: URL of the article's image.
  • publishedAt: Date the article was published.
  • content: Full content of the article.
  • isBookmarked: Boolean indicating if the article is bookmarked.

Network Monitoring

The NewsNetworkMonitor class observes internet connectivity using the Network framework to notify users about connectivity changes.

Error Handling

The app implements error handling for network requests and database operations, ensuring that users are informed of any issues encountered.

Unit Testing

The application includes unit tests written using XCTest. Tests cover:

  • Validating the fetching of articles and their properties.
  • Bookmarking and unbookmarking articles.
  • Ensuring articles are correctly stored and retrieved from the database.

Mocking

A mock version of ModelContext, called MockModelContext, is used to simulate database operations during testing, ensuring that tests do not affect real data.

Database Management

Before executing tests that modify the database, the database is cleared to ensure each test runs in isolation. SWiftUI database is used to store offline bookmarked articles of title and description.

Installation

Clone the Repository git clone https://github.com/paulsoham/NewsReaderApp.git

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

About

Husqvarna - This application is a trendy news reader developed in SwiftUI that fetches articles from the NewsAPI, stores them locally using SwiftData, and presents them in a user-friendly interface. Users can browse articles, read full content, bookmark articles, and filter by category.

License:MIT License


Languages

Language:Swift 100.0%