Skip to content

VitaliusSch/SwiftUi-MVVM-Cafe-Manager-WithCatApi

Repository files navigation

Cat Cafe Manager on SwiftUI MVVM

Build Status Swift Xcode MIT

About

Cat Cafe Manager is a training game project for learning SwiftUi. The following is implemented in this project:

Screenshots

Main View

CafeList View

CafeDetails View and Asynchronous Alert

FetchingList View

Asynchronous navigation


Generic way: you can use asynchronous navigation in the view model as follows

@MainActor func adoptCat() async {
	var selectedCat: CatModel = await navigation.pushViewGenericAsync(
		view: CatAdoptView(),
		animated: true,
		enableSwipeBack: true,
		title: "",
		titleHidden: true, 
		defaultValue: CatModel.aNewCat
	)
}


Collback way: you can use asynchronous navigation in the view model as follows

@MainActor func adoptCat() async {
	var selectedCat = CatModel.aNewCat
	await navigation.pushViewAsync(
		view: CatAdoptView(
			onCatSelect: { cat in
				selectedCat = cat
				self.navigation.popViewAsync()
			}
		),
		animated: true
	)
}

API KEY

To use this application please enter you API KEY in AppConstants file in the field marked: "AccessKey"
The API will return a list of cats in random order unless you enter an API KEY. Just register and get a free API-KEY https://thecatapi.com/

Suggestions

  • The code involved in the above example is in this repository code. It is recommended to download and run the view.
  • If you have better usage and suggestions about SwiftUI, look forward to sharing it!
  • If there are omissions and errors in the examples in this article, please create a Issue !
  • The example API is the cat API. https://thecatapi.com/

Requirements

  • Xcode 14.0
  • iOS 15.2

License

SwiftUI is released under the MIT license. See LICENSE for details.

Links

https://github.com/groue/GRDB.swift
https://github.com/Swinject/Swinject https://matteomanferdini.com/swiftui

About

Cat Cafe Manager is a training game project to learning SwiftUi

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages