SwiftUI open source project - ZYSwiftUIFrame comes with a complete sample project on the server side (updating...)

Gitee address: https://gitee.com/szluyu99/ZYSwiftUIFrame

Github address: https://github.com/szluyu99/ZYSwiftUIFrame

This project mainly maintains the Github address, and will push it to the Gitee address synchronously (equivalent to a mirror)

foreword

I'm not a professional IOS developer, and I haven't been exposed to IOS before, but for some reason, the team needs to develop an IOS App, and then I came into contact with Swift and SwiftUI. Of course, I didn't learn OC and UIKit. Almost nothing related to UIKit is used in this project (some Google searched the code and copied it directly), and it is basically completely developed using SwiftUI.

I always feel that there should not be too much intersection with IOS in the future, but I have been studying the technology for so long, and I always hope to leave something behind, so this project was born. I tried to integrate the knowledge points and technologies I learned and accumulated when developing IOS into this project as much as possible, the framework may be iterated continuously (if I still have the opportunity to touch IOS).

Once again, I am not a professional IOS developer , many coding styles and thinking may be the development experience of other projects, welcome to discuss.

Hopefully my project will bring a tinge of light to SwiftUI.

main features

From the point of view of a person who has no basic knowledge of IOS, I have inquired about many projects before, but the functionality of many projects is biased towards a certain aspect, and most of them focus on the view layer or other functionality. Can encounter a relatively complete project (maybe my opinion is not professional). And SwiftUI development will inevitably encounter some obstacles such as: pull-down refresh, pull-up loading, displaying network pictures, etc. The main reason is that SwiftUI is not particularly mature at present, but it is inevitable as a future trend.

The SwiftUI project includes complete functions such as network request, pull-down refresh, pull-up load more, data addition, deletion, modification and search, image upload, image preview and other functions (will continue to be updated in the future). The code is extracted into a framework system: such as a general ViewModel etc., it is very suitable for rapid development.

Program features:

  • I have a server-side project . In order to simulate the actual project scenario, I use Go to develop
  • Including the network request part , combined with the above server, realizes the addition, deletion, modification and query of database data
  • Even if the server is not running, the project also has a stand-alone Demo for you to quickly understand its main functions
  • It encapsulates silky pull-up refresh, pull-down loading more (based on BBSwiftUIKit), and can also imitate my code and encapsulate it by itself
  • The code is elegant , the style is neat, and the comments are more detailed
  • pending upgrade…

Project technology

IOS technology stack: based on Swift language

  • SwiftUI

Server-side technology stack: based on Go language

  • Web Framework: Gin
  • ORM Framework: GORM

Project preview

1. No need to open the server

There is no need to open the server. The function is a simplified version of the "Server needs to be opened" function below. It is only used for local demonstration and does not involve data requests.

1.1 User List

Pull down to refresh, pull up to load more:

Add, delete, modify:

Help, search:

2. Need to open the server

Open the data of the server, simulate the real request background, and realize the operation of the database.

2.1 Message List

Pull up, pull down, delete:

2.2 Conference List

Show help, delete, pull down to refresh, search:

Update, add:

Image upload, preview, delete, save:

Run the tutorial

Run the IOS project

This should go without saying, pull down the project and open the ZYSwiftUIFrame.xcodeprojfile .

Before running, you need to modify the signature and other operations.


After the project is running, it can be viewed directly without the interface of the server. It needs the interface of the server and also needs to run the server.

When the server is running Api/NetworkManager.swift, NetworkAPIBaseURLchange the in to your current LAN IP.

(The default port is 8080, no need to modify)

Make sure your real machine and the computer running the server are under the same local area network, or run the project directly using the emulator.

How to check your computer's current IP: Check it in Network Preferences.

Run the server project

A Go language environment is required.

I have already packaged the project, which is the mainfile , which ./maincan be run in the terminal.

Remember to modify the configuration file in the configdirectory , and modify it to your own database name, user name, and password.

Database related

My local database is MySQL 8.

Golang's database framework has an automatic migration function . On the basis of connecting to the database, directly running the project will automatically create a table.

I also initialized and generated some test data in the code, so as long as the database connection is normal and the project is running, there is data.

Of course, I also provided the SQL statements (structure + data) in the project's sqlfiles .

file upload directory

The file is uploaded to the local, and it is currently the uploads/filedirectory .

Backend interface documentation

The interface documentation is generated by ApiPost:

https://console-docs.apipost.cn/cover.html?url=36557b241534caed&salt=6015c9b386e133e0

Guess you like

Origin blog.csdn.net/weixin_43734095/article/details/123944987