Skip to content

khoinguyenpham04/ios-weather-app

Repository files navigation

WeatherApp Logo

Overview

WeatherApp is a sleek and intuitive iOS application that provides real-time weather updates for your current location. Built with SwiftUI and leveraging the OpenWeatherMap API, this app offers a seamless user experience with visually appealing graphics and accurate weather data.

Features

  • Real-time Weather Data: Get up-to-date weather information for your current location.
  • Beautiful UI: Enjoy a clean and modern user interface designed with SwiftUI.
  • Location Services: Automatically fetch weather data based on your current location.
  • Weather Details: View detailed weather information including temperature, humidity, wind speed, and more.
  • Dynamic Backgrounds: Experience visually appealing backgrounds that change based on the weather conditions.

Installation

To run this project locally, follow these steps:

  1. Clone the repository:

    git clone https://github.com/yourusername/WeatherApp.git
    cd WeatherApp
  2. Open the project in Xcode:

    open WeatherApp.xcodeproj
  3. Install dependencies: Ensure you have the necessary dependencies installed. You can use CocoaPods or Swift Package Manager if required.

  4. Run the app: Select the target device or simulator and hit the Run button in Xcode.

Usage

  1. Launch the app on your iOS device or simulator.
  2. Allow location access when prompted to get weather updates for your current location.
  3. View the weather details including temperature, weather conditions, and more.

Code Structure

  • WeatherApp.swift: The main entry point of the app.
  • ContentView.swift: The main view that handles location and weather data fetching.
  • WeatherView.swift: Displays the weather information.
  • WelcomeView.swift: Initial view prompting the user to share their location.
  • WeatherManager.swift: Handles API calls to fetch weather data.
  • ModelData.swift: Loads preview data for SwiftUI previews.
  • WeatherRow.swift: A reusable component to display individual weather details.

API Integration

This app uses the OpenWeatherMap API to fetch real-time weather data. Ensure you have an API key from OpenWeatherMap and replace the placeholder in WeatherManager.swift with your actual API key.

let url = URL(string: "https://api.openweathermap.org/data/2.5/weather?lat=\(latitude)&lon=\(longtitude)&appid=\("YOUR_API_KEY")&units=metric")

Contributing

Contributions are welcome! If you have any suggestions or improvements, feel free to create a pull request or open an issue.

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes.
  4. Commit your changes (git commit -m 'Add some feature').
  5. Push to the branch (git push origin feature-branch).
  6. Open a pull request.

License

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

Acknowledgements

Thank you for checking out WeatherApp! We hope you find it useful and enjoyable.

About

A simple, yet elegant, IOS Weather App

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages