-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00bb1cc
commit bad3524
Showing
17 changed files
with
1,133 additions
and
1,016 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// Copyright © 2024 Alexander Romanov | ||
// File.swift, created on 06.05.2024 | ||
// | ||
|
||
import Foundation | ||
|
||
public class MenuRouter<Menu: Menuble>: ObservableObject { | ||
@Published public var menu: Menu? | ||
@Published public var subMenu: Menu? | ||
|
||
public init(menu: Menu) { | ||
self.menu = menu | ||
} | ||
|
||
public func changeMenu(_ menu: Menu) { | ||
self.menu = menu | ||
} | ||
|
||
public func changeSubMenu(_ menu: Menu) { | ||
self.menu = menu | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// Copyright © 2024 Alexander Romanov | ||
// PresentationRouter.swift, created on 16.05.2024 | ||
// | ||
|
||
import Foundation | ||
|
||
public enum HUDMessageType { | ||
case `default` | ||
case success | ||
case destructive | ||
case deleted | ||
case archived | ||
} | ||
|
||
public class PresentationRouter<RootAlert: Alertable>: ObservableObject { | ||
// Alert | ||
@Published public var alert: RootAlert? = nil | ||
@Published public var isShowHud: Bool = false | ||
@Published public var hudText: String = "" | ||
@Published public var type: HUDMessageType = .default | ||
|
||
public init() {} | ||
} | ||
|
||
public extension PresentationRouter { | ||
func present(_ alert: RootAlert) { | ||
self.alert = alert | ||
} | ||
|
||
func dismiss() { | ||
alert = nil | ||
} | ||
} | ||
|
||
public extension PresentationRouter { | ||
func present(_ text: String, type: HUDMessageType = .default) { | ||
hudText = text | ||
self.type = type | ||
isShowHud = true | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// Copyright © 2024 Alexander Romanov | ||
// File.swift, created on 06.05.2024 | ||
// | ||
|
||
public protocol Menuble: CaseIterable, Equatable, Identifiable {} | ||
|
||
public extension Menuble { | ||
func hash(into hasher: inout Hasher) { | ||
hasher.combine(id) | ||
} | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.