-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix "Official Community" link, Improve navigation routing pattern (#656)
- Loading branch information
Showing
29 changed files
with
359 additions
and
319 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,31 @@ | ||
// | ||
// AnyNavigablePath.swift | ||
// Mlem | ||
// | ||
// Created by Bosco Ho on 2023-09-08. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
|
||
protocol AnyNavigablePath { | ||
|
||
associatedtype Route: Routable | ||
|
||
/// Implementation should make a route that makes sense for the passed-in data value and can be appended to the navigation path. | ||
static func makeRoute<V>(_ value: V) throws -> Route where V: Hashable | ||
|
||
/// The number of elements in this path. | ||
var count: Int { get } | ||
|
||
/// A Boolean that indicates whether this path is empty. | ||
var isEmpty: Bool { get } | ||
|
||
/// Appends a new value to the end of this path. | ||
mutating func append<V>(_ value: V) where V: Routable | ||
|
||
// swiftlint:disable identifier_name | ||
/// Removes values from the end of this path. | ||
mutating func removeLast(_ k: Int) | ||
// swiftlint:enable identifier_name | ||
} |
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,20 @@ | ||
// | ||
// DestinationValue.swift | ||
// Mlem | ||
// | ||
// Created by Bosco Ho on 2023-09-26. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Essentially a cheap "view-model", wrap `DestinationValue` inside a `Routable` value, then use that value as the data to define navigation destinations. | ||
/// | ||
/// Conforming types can be used to drive value-based navigation for destinations that are defined semantically or are not (yet) mapped to a particular data-type or view model. | ||
/// | ||
/// For example: | ||
/// - Many `Settings` views are presented based on their purpose and not the data they present. | ||
/// - In this scenario, we can define a set of semantically named enum cases (i.e. `.general` or `.about`), and treat these enum cases as values that drive navigation. | ||
/// - See `AppRoute` settings routes for an example implementation. | ||
/// | ||
/// - Warning: Avoid directly adding `DestinationValue` to a navigation path or using them as data to define `navigationDestination(...)`. | ||
protocol DestinationValue: Hashable {} |
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,47 @@ | ||
// | ||
// SettingsRoutes.swift | ||
// Mlem | ||
// | ||
// Created by Bosco Ho on 2023-08-18. | ||
// | ||
|
||
import Foundation | ||
|
||
enum SettingsPage: DestinationValue { | ||
case accounts | ||
case general | ||
case accessibility | ||
case appearance | ||
case contentFilters | ||
case about | ||
case advanced | ||
} | ||
|
||
enum AboutSettingsPage: DestinationValue { | ||
case contributors | ||
/// e.g. `Privacy Policy` or `EULA`. | ||
case document(Document) | ||
case licenses | ||
} | ||
|
||
enum AppearanceSettingsPage: DestinationValue { | ||
case theme | ||
case appIcon | ||
case posts | ||
case comments | ||
case communities | ||
case users | ||
case tabBar | ||
} | ||
|
||
enum CommentSettingsPage: DestinationValue { | ||
case layoutWidget | ||
} | ||
|
||
enum PostSettingsPage: DestinationValue { | ||
case customizeWidgets | ||
} | ||
|
||
enum LicensesSettingsPage: DestinationValue { | ||
case licenseDocument(Document) | ||
} |
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.