-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 💡 step progress indicator (#944)
* refactor: 💡 step progress indicator * docs: ✏️ update --------- Co-authored-by: dyongxu <61523257+dyongxu@users.noreply.github.com>
- Loading branch information
1 parent
46e9a91
commit cf92494
Showing
40 changed files
with
2,031 additions
and
208 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
446 changes: 317 additions & 129 deletions
446
...amples/Examples/FioriSwiftUICore/StepProgressIndicator/StepProgressIndicatorExample.swift
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
41 changes: 41 additions & 0 deletions
41
Sources/FioriSwiftUICore/Views/StepProgressIndicator/StepsStack.swift
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,41 @@ | ||
import SwiftUI | ||
|
||
struct StepsStack: View { | ||
var steps: [StepItem] | ||
var selection: Binding<String>? = nil | ||
/// :nodoc: | ||
init(_ steps: [StepItem], selection: Binding<String>? = nil) { | ||
self.steps = steps | ||
self.selection = selection | ||
} | ||
|
||
var body: some View { | ||
ForEach(0 ..< self.count, id: \.self) { index in | ||
self.view(at: index) | ||
} | ||
} | ||
} | ||
|
||
extension StepsStack: IndexedViewContainer { | ||
/// :nodoc: | ||
public var count: Int { | ||
self.steps.count | ||
} | ||
|
||
/// :nodoc: | ||
@ViewBuilder public func view(at index: Int) -> some View { | ||
if index < self.count { | ||
_DefaultSteps(stepItems: self.steps, selection: self.selection ?? .constant("")).view(at: index) | ||
} else { | ||
EmptyView() | ||
} | ||
} | ||
|
||
@ViewBuilder func titleView(for title: String?) -> some View { | ||
if let title { | ||
Text(title) | ||
} else { | ||
EmptyView() | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.