GithubHelp home page GithubHelp logo

0xyanis / clean-swiftui Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 1.0 91 KB

A simple example of a CleanSwift architecture with SwiftUI

License: MIT License

Swift 100.00%
clean-architecture swift swiftui clean-swift coordinator example mvvm mvvm-coordinator sample dependency-injection

clean-swiftui's Introduction

Clean SwiftUI Architecture

This repository contains a sample application using CleanSwift Architecture consisting of two screens - a user list and their todos.

Installation

To run this application on your device, follow these steps:

  1. Ensure Xcode is installed on your computer.
  2. Clone this repository to your computer.
git clone https://github.com/0xYanis/Clean-SwiftUI
  1. Open the project file in Xcode.
  2. Build and run it on the simulator or device of your choice.

Usage

This repository demonstrates an example of using Clean Swift Architecture for app development. You can study the code and project structure to better understand the principles of Clean Swift. At the same time, this repository shows how easy it is to create unnecessary entities in a simple application ))

Project Structure

  • User List Screen: Displays a list of users.
  • User Todos Screen: Displays the todos for the selected user.

Thinking out loud

Of course, no one forces you to build an application using so many components, and you can limit yourself to something like this:

struct UserListView: View {
    @State var users = [User]()
    
    var body: some View {
        NavigationStack {
            List(users) { user in
                Text(user.name)
            }
            .navigationTitle("Users")
        }
        .onAppear {
            Task {
                let url = URL(string: "https://jsonplaceholder.typicode.com/users")!
                let (data, _) = try! await URLSession.shared.data(from: url)
                let users = try! JSONDecoder().decode([User].self, from: data)
                await MainActor.run(body: {
                    self.users = users
                })
            }
        }
    }
}

However, architecture is the foundation of the application.

Borrowing

The following borrowings were used in this application:

Contribution

If you have any suggestions for improving this sample, please create an issue or submit a pull request.

License

This project is licensed under the MIT License.

clean-swiftui's People

Contributors

0xyanis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

angeloffury7

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.