Skip to content
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

AI-638: FieldSet Component #2053

Merged
merged 10 commits into from
Aug 26, 2024
Merged

AI-638: FieldSet Component #2053

merged 10 commits into from
Aug 26, 2024

Conversation

AlaaAmrAmin
Copy link
Contributor

@AlaaAmrAmin AlaaAmrAmin commented Aug 26, 2024

Contribue BPKFieldSet component. Figma design.

Remember to include the following changes:

If you are curious about how we review, please read through the code review guidelines

@AlaaAmrAmin AlaaAmrAmin added swiftui minor Non breaking change labels Aug 26, 2024
@AlaaAmrAmin AlaaAmrAmin requested a review from frugoman August 26, 2024 11:38
Copy link
Contributor

Snapshots were updated. Please verify the changes match the expected layout.

' D Backpack-SwiftUI/Tests/BannerAlert/Snapshots/BPKBannerAlertTests/test_multilineBannerAlert.dark-mode.png'%0A' D Backpack-SwiftUI/Tests/BannerAlert/Snapshots/BPKBannerAlertTests/test_multilineBannerAlert.light-mode.png'%0A' D Backpack-SwiftUI/Tests/BannerAlert/Snapshots/BPKBannerAlertTests/test_multilineBannerAlert.rtl.png'%0A' D Backpack-SwiftUI/Tests/NavigationTabGroup/Snapshots/BPKNavigationTabGroupTests/test_dark.dark-mode.png'%0A' D Backpack-SwiftUI/Tests/NavigationTabGroup/Snapshots/BPKNavigationTabGroupTests/test_dark.light-mode.png'%0A' D Backpack-SwiftUI/Tests/NavigationTabGroup/Snapshots/BPKNavigationTabGroupTests/test_dark.rtl.png'%0A' D Backpack-SwiftUI/Tests/NavigationTabGroup/Snapshots/BPKNavigationTabGroupTests/test_default.dark-mode.png'%0A' D Backpack-SwiftUI/Tests/NavigationTabGroup/Snapshots/BPKNavigationTabGroupTests/test_default.light-mode.png'%0A' D Backpack-SwiftUI/Tests/NavigationTabGroup/Snapshots/BPKNavigationTabGroupTests/test_default.rtl.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_clearableField_withCustomPrefixText.dark-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_clearableField_withCustomPrefixText.light-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_clearableField_withCustomPrefixText.rtl.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_clearableField_withPrefixIcon.dark-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_clearableField_withPrefixIcon.light-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_clearableField_withPrefixIcon.rtl.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_defaultSettings_withCustomPrefixText.dark-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_defaultSettings_withCustomPrefixText.light-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_defaultSettings_withCustomPrefixText.rtl.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_defaultSettings_withPrefixIcon.dark-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_defaultSettings_withPrefixIcon.light-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_defaultSettings_withPrefixIcon.rtl.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_disabledField_withCustomPrefixText.dark-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_disabledField_withCustomPrefixText.light-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_disabledField_withCustomPrefixText.rtl.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_disabledField_withPrefixIcon.dark-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_disabledField_withPrefixIcon.light-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_disabledField_withPrefixIcon.rtl.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_emptyField_withCustomPrefixText.dark-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_emptyField_withCustomPrefixText.light-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_emptyField_withCustomPrefixText.rtl.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_emptyField_withPrefixIcon.dark-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_emptyField_withPrefixIcon.light-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_emptyField_withPrefixIcon.rtl.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_errorField_withCustomPrefixText.dark-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_errorField_withCustomPrefixText.light-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_errorField_withCustomPrefixText.rtl.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_errorField_withPrefixIcon.dark-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_errorField_withPrefixIcon.light-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_errorField_withPrefixIcon.rtl.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_validField_withCustomPrefixText.dark-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_validField_withCustomPrefixText.light-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_validField_withCustomPrefixText.rtl.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_validField_withPrefixIcon.dark-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_validField_withPrefixIcon.light-mode.png'%0A' D Backpack-SwiftUI/Tests/TextField/Snapshots/BPKTextFieldTests/test_validField_withPrefixIcon.rtl.png'%0A'?? Backpack-SwiftUI/Tests/FieldSet/Snapshots/'

Alaa Amin added 3 commits August 26, 2024 13:07
…er/backpack-ios into chai/AI-638_field-set-component

* 'chai/AI-638_field-set-component' of github.com:Skyscanner/backpack-ios:
  Updated snapshots

// swiftlint:disable closure_body_length
@ViewBuilder
private func constructViews(inErrorState: Bool) -> some View {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code should not be here, it should be contained within the previows. here it's accessible from the component and that should not be the case.

you could create only one #preview and then assigne names to the 2 scroll views it'd have inside!

import SwiftUI
import UIKit

public protocol BPKFieldSetStatusHandling: View {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: could you rename this protocol to be BPKFieldSetContentView?

var body: some View {
ScrollView {
VStack(spacing: .md) {
Text("With Label & Description").fontWeight(.bold)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change these to be BPKText?

}
}

struct FieldSetExampleView_Previews: PreviewProvider {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use the new #preview macro instead

VStack(alignment: .leading, spacing: .sm) {
labelView
content
.inputState(state)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure I understand how this works? the implementations in the Text field, text area and BPKSelect just return mapping a state? but how is the style applied in the end I dont understand

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just got it! it's calling each element's method!

public func inputState(_ state: BPKFieldSet<BPKTextArea>.State) -> BPKTextArea {
switch state {
case .default:
return inputState(BPKTextArea.State.default)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it calling itself? is this not an infinite loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh.. it's not calling itself, but the component's method, okay sorry!

@frugoman frugoman merged commit c747062 into main Aug 26, 2024
14 checks passed
@frugoman frugoman deleted the chai/AI-638_field-set-component branch August 26, 2024 16:04
AlaaAmrAmin pushed a commit that referenced this pull request Aug 27, 2024
* main:
  AI-638: FieldSet Component (#2053)
  Add decision doc for accessibility identifiers in UI-tests (#2050)
  DON-591: Contribute Search Control Input component (#2038)
  Bump @babel/preset-env from 7.25.3 to 7.25.4 (#2051)
  Bump rexml from 3.3.3 to 3.3.6 (#2052)

# Conflicts:
#	Backpack-SwiftUI/FieldSet/Classes/BPKFieldSet.swift
#	Backpack-SwiftUI/FieldSet/Classes/BPKFieldSetState.swift
#	Backpack-SwiftUI/FieldSet/README.md
#	Example/Backpack/SwiftUI/Components/FieldSet/FieldSetExampleView.swift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants