Created
June 25, 2023 11:25
-
-
Save MoussaHellal/17a045610c4d7c7f67dbf260309d6d96 to your computer and use it in GitHub Desktop.
DrinkyFlow.swift Our main flow object that will handle navigation, holding passable data and Back to root and previous view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DrinkyFlow.swift | |
// CompleteNavigationSwiftUI | |
// | |
// Created by Moussa on 25/6/2023. | |
// | |
import Foundation | |
import SwiftUI | |
class DrinkyFlow: ObservableObject { | |
static let shared = DrinkyFlow() | |
@Published var path = NavigationPath() | |
@Published var selectedDrink: Drink = Drink(name: "", image: "", shortDescription: "", longDescription: "", ingredients: []) | |
func clear() { | |
path = .init() | |
} | |
func navigateBackToRoot() { | |
path.removeLast(path.count) | |
} | |
func backToPrevious() { | |
path.removeLast() | |
} | |
func navigateToDrinkyDetailView() { | |
path.append(DrinkyNavigation.drinkyDetails) | |
} | |
func navigateToDrinkyIngredientsView() { | |
path.append(DrinkyNavigation.drinkyIngredients) | |
} | |
func done() { | |
path = .init() | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment