Giter Site home page Giter Site logo

serhatcihangir / 1-cleanweather Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 4.95 MB

IOS Weather App

Swift 100.00%
ios-design-patterns ios-weather ios-weather-app swift swift-delegate swift-designpattern swift-example swift-extensions swift-learning swift-restful

1-cleanweather's Introduction

github CleanWeather: Your Simple iOS Weather App

Introduction

CleanWeather is an iOS weather app that offers an elegant way to check the weather. It uses the OpenWeather API to provide real-time weather data, and it's built with a clean and user-friendly UI. The app employs various design patterns and technologies to ensure a robust and responsive user experience.

CleanWeather App Screen

Features

  • Real-Time Weather Data: CleanWeather fetches the latest weather data using the OpenWeather. This includes current conditions, temperature and more.

  • MVC Design Pattern: CleanWeather follows the Model-View-Controller (MVC) architectural pattern, ensuring a clean separation of concerns and maintainability of the codebase.

  • Delegate Design Pattern with Protocols: Delegates and protocols are used to facilitate communication between different parts of the app, promoting modularity and extensibility.

  • Swift URLSession: Swift's URLSession is used for efficient data retrieval from the web, guaranteeing a responsive user experience.

    func apiRequest(with url: URLComponents) {
        if let urlRequest = url.url {
            let session = URLSession(configuration: .default)
            let task = session.dataTask(with: urlRequest) { data, response, error in
                if error != nil {
                    print("Error apiRequest")
                    self.delegate?.didFail(error: error!)
                    return
                }
                if let safeData = data {
                    if let weather = self.jsonParse(weatherData: safeData) {
                        self.delegate?.didUpdateWeather(self, weather: weather)
                    }
                }
            }
            task.resume()
        }
    }
  • Swift Extensions: Swift extensions are harnessed to enhance the app's functionality and maintainability.

  • Swift CoreLocation: The app utilizes Swift CoreLocation to determine the user's location, enabling access to weather information for the current location or any other specified location.

  extension ViewController: CLLocationManagerDelegate {
      func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
          if let location = locations.last{
              locationManager.stopUpdatingLocation()
              let lat = location.coordinate.latitude
              let lon = location.coordinate.longitude
              apiManager.getWeatherData(latitude: lat, longitude: lon)
          }
      }
      func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
          print(error)
      }
  }
  • JSON Decoding: JSON decoding is employed to parse data from the OpenWeather API, ensuring accurate and meaningful weather information.

  • Dark Mode Support: CleanWeather iOS weather app supports Dark Mode, providing users with the option to switch between light and dark interfaces for comfortable viewing in various lighting conditions.

Design Patterns

MVC (Model-View-Controller)

CleanWeather follows the Model-View-Controller design pattern for structured and organized code architecture. The Model handles data and business logic, the View handles the user interface, and the Controller acts as the intermediary.

MVC Design Pattern

Delegate Design Pattern with Protocols

The app uses the Delegate design pattern in combination with protocols to facilitate data communication and separation of concerns. This ensures modular and efficient code.

Dependencies

  • OpenWeather RESTful API (Free Subscription): The app relies on a RESTful API to obtain weather data. You'll need to sign up for a free API key from OpenWeather REST API provider and integrate it into the project to fetch weather data. To use the REST API, you'll need to make HTTP requests to specific endpoints provided by the API service and handle responses according to their documentation. This transition allows the app to access accurate and up-to-date weather data while maintaining a responsive user experience. OpenWeather's RESTful API is commonly used by developers to integrate weather information into their applications and services.
RESTful API Diagram

How It Works

CleanWeather works by fetching weather data from the OpenWeather API based on the specified location or the user's current location. It uses Swift's CoreLocation framework to determine the device's location. The app follows the MVC design pattern for structured code organization and the delegate design pattern with protocols for efficient data communication.

Getting Started

To run CleanWeather on your local machine, follow these steps:

  1. Clone the repository: git clone https://github.com/serhatcihangir/CleanWeather.git

  2. Open the Xcode project.

  3. Build and run the app on your iOS device or simulator.

‼️ Before running the app, ensure that you have obtained an API key from OpenWeather and added it to the project to fetch weather data.[ CleanWeather/Model/ApiManager.swift (apiKey variable) ]

How to Contribute

We welcome contributions from the open-source community! Whether you want to report a bug, suggest a feature, or submit a pull request, your involvement is appreciated. Here's how to contribute:

  1. Fork the repository.
  2. Create a new branch (e.g., feature/new-feature).
  3. Commit your changes.
  4. Push to your branch.
  5. Create a Pull Request.

1-cleanweather's People

Contributors

serhatcihangir avatar

Watchers

 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.