Skip to content

Commit

Permalink
Merge branch 'main' into feat/HCPSDKFIORIUIKIT-2717
Browse files Browse the repository at this point in the history
  • Loading branch information
dyongxu authored Sep 20, 2024
2 parents e94fcc7 + 29f33b8 commit 1a078a1
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ struct NoteFormViewExample: View {
NoteFormView(text: self.$valueText3, placeholder: "Please enter something", errorMessage: self.getErrorMessage(), minTextEditorHeight: 50, maxTextEditorHeight: 100, maxTextLength: self.getMaxTextLength(), hintText: self.getHintText(), isCharCountEnabled: self.showsCharCount, allowsBeyondLimit: self.allowsBeyondLimit)

Text("Disabled")
NoteFormView(text: self.$disabledText, placeholder: "Disabled", controlState: .disabled, minTextEditorHeight: 50, maxTextEditorHeight: 100)
NoteFormView(text: self.$disabledText, placeholder: "Disabled", controlState: .disabled, maxTextEditorHeight: 100)

Text("Read-Only")
NoteFormView(text: self.$readOnlyText, placeholder: "Read-Only", controlState: .readOnly, minTextEditorHeight: 50, maxTextEditorHeight: 200, hidesReadOnlyHint: self.hidesReadonlyHint)
NoteFormView(text: self.$readOnlyText, placeholder: "Read-Only", controlState: .readOnly, maxTextEditorHeight: 200, hidesReadOnlyHint: self.hidesReadonlyHint)
}
#if !os(visionOS)
.scrollDismissesKeyboard(.immediately)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,30 @@ struct TitleFormViewExample: View {

Text("Default TitleForm")
TitleFormView(text: self.$valueText1, placeholder: "TitleFormView", errorMessage: self.getErrorMessage(), maxTextLength: self.getMaxTextLength(), hintText: self.getHintText(), isCharCountEnabled: self.showsCharCount, allowsBeyondLimit: self.allowsBeyondLimit)

.padding(.leading, -4)
.padding(.trailing, -4)

Text("Existing Text")
.italic()
TitleFormView(text: self.$valueText2, placeholder: "TitleFormView", errorMessage: self.getErrorMessage(), maxTextLength: self.getMaxTextLength(), hintText: self.getHintText(), isCharCountEnabled: self.showsCharCount, allowsBeyondLimit: self.allowsBeyondLimit)
.padding(.leading, -4)
.padding(.trailing, -4)

Text("Empty Text")
.italic()
TitleFormView(text: self.$valueText3, placeholder: "Please enter something", errorMessage: self.getErrorMessage(), maxTextLength: self.getMaxTextLength(), hintText: self.getHintText(), isCharCountEnabled: self.showsCharCount, allowsBeyondLimit: self.allowsBeyondLimit)
.padding(.leading, -4)
.padding(.trailing, -4)

Text("Disabled")
TitleFormView(text: self.$disabledText, placeholder: "Disabled", controlState: .disabled)
.padding(.leading, -4)
.padding(.trailing, -4)

Text("Read-Only")
TitleFormView(text: self.$readOnlyText, placeholder: "Read-Only", controlState: .readOnly, hidesReadOnlyHint: self.hidesReadonlyHint)
.padding(.leading, -4)
.padding(.trailing, -4)
}
#if !os(visionOS)
.scrollDismissesKeyboard(.immediately)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ We plan to progressively bring more Fiori UI components into this module in the
| ProfileHeader | :white_check_mark: |
| TimelineItem | :white_check_mark: |
| SegmentedControlPicker | :white_check_mark: |
| TimelinePreviewItem | :x: |
| TimelinePreviewItem | :white_check_mark: |
| ChartFloorplan | :x: |
| CollectionItem | :x: |
| BarcodeScanner | :x: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ extension KeyValueFormViewFioriStyle {
.foregroundStyle(self.getTitleColor(configuration))
.font(.fiori(forTextStyle: .subheadline, weight: .semibold))
}
.mandatoryFieldIndicatorStyle { indicatorConf in
MandatoryFieldIndicator(indicatorConf)
.foregroundStyle(self.getTitleColor(configuration))
.font(.fiori(forTextStyle: .subheadline, weight: .semibold))
}
.focused(self.$isFocused)
}

Expand Down Expand Up @@ -90,7 +95,7 @@ extension KeyValueFormViewFioriStyle {

func makeBody(_ configuration: MandatoryFieldIndicatorConfiguration) -> some View {
MandatoryFieldIndicator(configuration)
.foregroundStyle(Color.preferredColor(self.keyValueFormViewConfiguration.controlState == .disabled ? .separator : .primaryLabel))
.foregroundStyle(Color.preferredColor(self.keyValueFormViewConfiguration.controlState == .disabled ? .quaternaryLabel : .primaryLabel))
.font(.fiori(forTextStyle: .subheadline, weight: .semibold))
.padding(.bottom, -4)
.padding(.top, 11)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ extension NoteFormViewFioriStyle {
TextInputInfoView(config)
.textInputInfoViewStyle(style)
.typeErased
.padding(.top, -8)
}
.placeholderTextEditorStyle { config in
PlaceholderTextEditor(config)
Expand All @@ -62,14 +63,14 @@ extension NoteFormViewFioriStyle {
.onChange(of: configuration.text) { s in
self.checkCharCount(configuration, textString: s)
}
.padding(.bottom, self.isInfoViewNeeded(configuration) ? 0 : 9)
.padding(.bottom, self.isInfoViewNeeded(configuration) ? 0 : 7)
}
.textViewStyle { config in
TextView(config)
.foregroundStyle(self.getTextColor(configuration))
.font(.fiori(forTextStyle: .body))
}
.padding(.top, 9)
.padding(.top, 7)
}

func getTextColor(_ configuration: NoteFormViewConfiguration) -> Color {
Expand Down Expand Up @@ -101,15 +102,15 @@ extension NoteFormViewFioriStyle {
}

func getMinHeight(_ configuration: NoteFormViewConfiguration) -> CGFloat {
// Somehow, the minHeight is 14pt higher than the specified. Use this adjustment.
let minHeightAdjustMent = 14.0
// TextEditor will add some other views that the minHeight is 16pt higher than the specified. Use this to adjust.
let minHeightAdjustment = 16.0
guard let minHeight = configuration.minTextEditorHeight else {
return 88 - minHeightAdjustMent
return 88 - minHeightAdjustment
}
guard minHeight > 44 else {
return 88 - minHeightAdjustMent
return 88 - minHeightAdjustment
}
return minHeight - minHeightAdjustMent
return minHeight - minHeightAdjustment
}

func getMaxHeight(_ configuration: NoteFormViewConfiguration) -> CGFloat {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public struct PlaceholderTextEditorBaseStyle: PlaceholderTextEditorStyle {
public func makeBody(_ configuration: PlaceholderTextEditorConfiguration) -> some View {
ZStack(alignment: .topLeading) {
configuration._textView.body
.focused(self.$isFocused)
.focused(self.$isFocused)
.onReceive(NotificationCenter.default.publisher(for: UIResponder.keyboardDidHideNotification)) { _ in
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public struct PlaceholderTextFieldBaseStyle: PlaceholderTextFieldStyle {
Image(systemName: "xmark.circle")
.font(.fiori(forTextStyle: .body))
.foregroundColor(.preferredColor(.tertiaryLabel))
.padding(.trailing, 8)
.padding(.trailing, 1)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SwiftUI
/// The base layout style for `TextFieldFormView`.
public struct TextFieldFormViewBaseStyle: TextFieldFormViewStyle {
public func makeBody(_ configuration: TextFieldFormViewConfiguration) -> some View {
VStack(alignment: .leading) {
VStack(alignment: .leading, spacing: 4) {
HStack(spacing: 0) {
configuration.title
if configuration.isRequired {
Expand All @@ -15,6 +15,12 @@ public struct TextFieldFormViewBaseStyle: TextFieldFormViewStyle {
}
configuration._titleFormView
}
.padding(.top, -1)
.padding(.bottom, self.isInfoViewNeeded(configuration) ? 0 : 1)
}

func isInfoViewNeeded(_ configuration: TextFieldFormViewConfiguration) -> Bool {
TextInputFormViewConfiguration(configuration, isFocused: false).isInfoViewNeeded()
}
}

Expand Down Expand Up @@ -63,6 +69,7 @@ extension TextFieldFormViewFioriStyle {
TextInputInfoView(config)
.textInputInfoViewStyle(style)
.typeErased
.padding(.top, -3)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ struct TextInputFormViewConfiguration {
func getTextColor() -> Color {
switch self.getControlState() {
case .disabled:
return .preferredColor(.separator)
return .preferredColor(.quaternaryLabel)
default:
return .preferredColor(.primaryLabel)
}
Expand Down Expand Up @@ -417,7 +417,7 @@ struct TextInputFormViewConfiguration {
}

func getBackgroundColor() -> Color {
self.getEditable() ? .clear : .preferredColor(.tertiaryFill)
self.getEditable() ? .clear : .preferredColor(.quaternaryFill)
}

func getBorderWidth() -> CGFloat {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public struct TitleFormViewBaseStyle: TitleFormViewStyle {
.disabled(self.getDisabled(configuration))
}
.textInputInfoView(isPresented: Binding(get: { self.isInfoViewNeeded(configuration) }, set: { _ in }), description: self.getInfoString(configuration), counter: self.getCounterString(configuration))
.backgroundStyle(.red)
.padding(.top, -1)
.padding(.bottom, self.isInfoViewNeeded(configuration) ? -12 : -1)
}

func getDisabled(_ configuration: TitleFormViewConfiguration) -> Bool {
Expand Down Expand Up @@ -51,6 +52,7 @@ extension TitleFormViewFioriStyle {
TextInputInfoView(config)
.textInputInfoViewStyle(style)
.typeErased
.padding(.top, -4)
}
.placeholderTextFieldStyle { config in
PlaceholderTextField(config)
Expand All @@ -59,8 +61,6 @@ extension TitleFormViewFioriStyle {
}
.background(self.getBackgroundColor(configuration))
}
.padding(.top, 0)
.padding(.bottom, self.isInfoViewNeeded(configuration) ? -9 : 0)
}
}

Expand Down

0 comments on commit 1a078a1

Please sign in to comment.