-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 🎸 [JIRA:HCPSDKFIORIUIKIT-2806] Processing Indicator #906
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
67 changes: 67 additions & 0 deletions
67
Apps/Examples/Examples/FioriSwiftUICore/Indicator/ProcessingIndicatorExample.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,67 @@ | ||
import FioriSwiftUICore | ||
import FioriThemeManager | ||
import SwiftUI | ||
|
||
struct Blur: UIViewRepresentable { | ||
var style: UIBlurEffect.Style = .extraLight | ||
func makeUIView(context: Context) -> UIVisualEffectView { | ||
let view = UIVisualEffectView(effect: UIBlurEffect(style: .extraLight)) | ||
DispatchQueue.main.async { | ||
view.superview?.superview?.backgroundColor = .clear | ||
} | ||
return view | ||
} | ||
|
||
func updateUIView(_ uiView: UIVisualEffectView, context: Context) { | ||
uiView.effect = UIBlurEffect(style: self.style) | ||
} | ||
} | ||
|
||
struct ProcessingIndicatorExample: View { | ||
@State var labelText: String = "Processing" | ||
@State var showModalIndicator: Bool = false | ||
@State var showInContainer: Bool = false | ||
|
||
var body: some View { | ||
VStack { | ||
Spacer() | ||
Button("Show modal indicator", action: { | ||
self.showModalIndicator.toggle() | ||
}) | ||
Button("Show/hide in container", action: { | ||
self.showInContainer.toggle() | ||
}) | ||
TextFieldFormView(title: "Set label", text: self.$labelText).padding() | ||
ProcessingIndicator(optionalTitle: AttributedString(self.labelText)) | ||
Spacer() | ||
if self.showInContainer { | ||
Image("rw") | ||
.overlay(ProcessingIndicator() | ||
.frame(maxWidth: 130, maxHeight: 130) | ||
.background(Color.white.opacity(0.7)) | ||
) | ||
} else { | ||
Image("rw") | ||
} | ||
Spacer() | ||
} | ||
.padding() | ||
.fullScreenCover(isPresented: self.$showModalIndicator, content: { | ||
VStack { | ||
ProcessingIndicator(optionalTitle: AttributedString(self.labelText)) | ||
.frame(maxWidth: .infinity, maxHeight: .infinity) | ||
.background(Color.clear) | ||
Button("Dismiss", action: { | ||
self.showModalIndicator.toggle() | ||
}) | ||
} | ||
.background(Blur()) | ||
}) | ||
} | ||
} | ||
|
||
struct ProcessingIndicatorExample_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ProcessingIndicatorExample() | ||
} | ||
} |
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
47 changes: 47 additions & 0 deletions
47
Sources/FioriSwiftUICore/_FioriStyles/ProcessingIndicatorStyle.fiori.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,47 @@ | ||
import FioriThemeManager | ||
|
||
// Generated using Sourcery 2.1.7 — https://github.com/krzysztofzablocki/Sourcery | ||
// DO NOT EDIT | ||
import Foundation | ||
import SwiftUI | ||
|
||
// Base Layout style | ||
public struct ProcessingIndicatorBaseStyle: ProcessingIndicatorStyle { | ||
struct ProcessingIndicatorStyle: ProgressIndicatorStyle { | ||
func makeBody(_ configuration: ProgressIndicatorConfiguration) -> some View { | ||
ProgressIndicator(configuration) | ||
.frame(width: 56, height: 56) | ||
} | ||
} | ||
|
||
public func makeBody(_ configuration: ProcessingIndicatorConfiguration) -> some View { | ||
VStack { | ||
ProgressIndicator(progress: Binding<Double>.constant(0.0)) | ||
.progressIndicatorStyle(ProcessingIndicatorStyle()) | ||
.progressIndicatorStyle(.processing) | ||
if !configuration.optionalTitle.isEmpty { | ||
configuration.optionalTitle | ||
.offset(y: 15) | ||
} | ||
}.padding() | ||
} | ||
} | ||
|
||
// Default fiori styles | ||
extension ProcessingIndicatorFioriStyle { | ||
struct ContentFioriStyle: ProcessingIndicatorStyle { | ||
func makeBody(_ configuration: ProcessingIndicatorConfiguration) -> some View { | ||
ProcessingIndicator(configuration) | ||
} | ||
} | ||
|
||
struct OptionalTitleFioriStyle: OptionalTitleStyle { | ||
let processingIndicatorConfiguration: ProcessingIndicatorConfiguration | ||
|
||
func makeBody(_ configuration: OptionalTitleConfiguration) -> some View { | ||
OptionalTitle(configuration) | ||
.foregroundStyle(Color.preferredColor(.primaryLabel)) | ||
.font(.fiori(fixedSize: 12)) | ||
} | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
...re/_generated/StyleableComponents/ProcessingIndicator/ProcessingIndicator.generated.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,69 @@ | ||
// Generated using Sourcery 2.1.7 — https://github.com/krzysztofzablocki/Sourcery | ||
// DO NOT EDIT | ||
import Foundation | ||
import SwiftUI | ||
|
||
/// `ProcessingIndicator` provides a circular indeterminate indicator with an optional title below the indicator. | ||
/// | ||
/// ## Usage | ||
/// ```swift | ||
/// ProcessingIndicator(optionalTitle: "Processing") | ||
/// ``` | ||
public struct ProcessingIndicator { | ||
let optionalTitle: any View | ||
|
||
@Environment(\.processingIndicatorStyle) var style | ||
|
||
fileprivate var _shouldApplyDefaultStyle = true | ||
|
||
public init(@ViewBuilder optionalTitle: () -> any View = { EmptyView() }) { | ||
self.optionalTitle = OptionalTitle(optionalTitle: optionalTitle) | ||
} | ||
} | ||
|
||
public extension ProcessingIndicator { | ||
init(optionalTitle: AttributedString?) { | ||
self.init(optionalTitle: { OptionalText(optionalTitle) }) | ||
} | ||
} | ||
|
||
public extension ProcessingIndicator { | ||
init(_ configuration: ProcessingIndicatorConfiguration) { | ||
self.init(configuration, shouldApplyDefaultStyle: false) | ||
} | ||
|
||
internal init(_ configuration: ProcessingIndicatorConfiguration, shouldApplyDefaultStyle: Bool) { | ||
self.optionalTitle = configuration.optionalTitle | ||
self._shouldApplyDefaultStyle = shouldApplyDefaultStyle | ||
} | ||
} | ||
|
||
extension ProcessingIndicator: View { | ||
public var body: some View { | ||
if self._shouldApplyDefaultStyle { | ||
self.defaultStyle() | ||
} else { | ||
self.style.resolve(configuration: .init(optionalTitle: .init(self.optionalTitle))).typeErased | ||
.transformEnvironment(\.processingIndicatorStyleStack) { stack in | ||
if !stack.isEmpty { | ||
stack.removeLast() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private extension ProcessingIndicator { | ||
func shouldApplyDefaultStyle(_ bool: Bool) -> some View { | ||
var s = self | ||
s._shouldApplyDefaultStyle = bool | ||
return s | ||
} | ||
|
||
func defaultStyle() -> some View { | ||
ProcessingIndicator(.init(optionalTitle: .init(self.optionalTitle))) | ||
.shouldApplyDefaultStyle(false) | ||
.processingIndicatorStyle(ProcessingIndicatorFioriStyle.ContentFioriStyle()) | ||
.typeErased | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...enerated/StyleableComponents/ProcessingIndicator/ProcessingIndicatorStyle.generated.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,35 @@ | ||
// Generated using Sourcery 2.1.7 — https://github.com/krzysztofzablocki/Sourcery | ||
// DO NOT EDIT | ||
import Foundation | ||
import SwiftUI | ||
|
||
public protocol ProcessingIndicatorStyle: DynamicProperty { | ||
associatedtype Body: View | ||
|
||
func makeBody(_ configuration: ProcessingIndicatorConfiguration) -> Body | ||
} | ||
|
||
struct AnyProcessingIndicatorStyle: ProcessingIndicatorStyle { | ||
let content: (ProcessingIndicatorConfiguration) -> any View | ||
|
||
init(@ViewBuilder _ content: @escaping (ProcessingIndicatorConfiguration) -> any View) { | ||
self.content = content | ||
} | ||
|
||
public func makeBody(_ configuration: ProcessingIndicatorConfiguration) -> some View { | ||
self.content(configuration).typeErased | ||
} | ||
} | ||
|
||
public struct ProcessingIndicatorConfiguration { | ||
public let optionalTitle: OptionalTitle | ||
|
||
public typealias OptionalTitle = ConfigurationViewWrapper | ||
} | ||
|
||
public struct ProcessingIndicatorFioriStyle: ProcessingIndicatorStyle { | ||
public func makeBody(_ configuration: ProcessingIndicatorConfiguration) -> some View { | ||
ProcessingIndicator(configuration) | ||
.optionalTitleStyle(OptionalTitleFioriStyle(processingIndicatorConfiguration: configuration)) | ||
} | ||
} |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File Length Violation: File should contain 700 lines or less: currently contains 728 (file_length)