-
Notifications
You must be signed in to change notification settings - Fork 4
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
[CheckboxGroup#864] Fix disable checkbox group issue #867
Merged
aycil-alican
merged 12 commits into
component/checkbox_bug
from
component/checkbox_bug_864
Apr 16, 2024
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a0405e1
[RadioButton#853] Fix size of radio button
aycil-alican 0303043
[RadioButton#853] Fix size of swiftui radio button
aycil-alican d1c3fd0
[RadioButton#853] Add demo controllers for testing radio and checkbox…
aycil-alican 826a072
Merge branch 'main' into component/853_radio_button_bug
aycil-alican 0abd060
[CheckboxGroup#864] Add isDisabled parameter to uikit checkbox group
aycil-alican 2e18c12
[CheckboxGroup#864] Fix partially disable issue on swiftui checkbox g…
aycil-alican 8298c53
Merge pull request #856 from adevinta/component/853_radio_button_bug
aycil-alican 21ff38d
[Slider#1977] Updated Slider handle size from 24x24 to 32x32
LouisBorleeAdevinta 1d26fbd
Merge branch 'main' into 1977-bug-slider-handler-is-too-small
LouisBorleeAdevinta cb0ab1f
Merge pull request #869 from adevinta/1977-bug-slider-handler-is-too-…
LouisBorleeAdevinta b5ed99f
Merge branch 'main' into component/checkbox_bug_864
aycil-alican ea3213e
Merge branch 'component/checkbox_bug' into component/checkbox_bug_864
aycil-alican 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
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
115 changes: 115 additions & 0 deletions
115
spark/Demo/Classes/View/ListView/Controllers/RadioCheckboxUIViewController.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,115 @@ | ||
// | ||
// RadioCheckboxUIViewController.swift | ||
// SparkDemo | ||
// | ||
// Created by alican.aycil on 22.03.24. | ||
// Copyright © 2024 Adevinta. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import SparkCore | ||
import Combine | ||
|
||
final class RadioCheckboxUIViewController: UIViewController { | ||
|
||
private let theme = SparkThemePublisher.shared.theme | ||
private var cancellables = Set<AnyCancellable>() | ||
|
||
private lazy var alignment: CheckboxUIView = { | ||
let view = CheckboxUIView( | ||
theme: self.theme, | ||
text: "Alignment: Click to change postion.", | ||
checkedImage: DemoIconography.shared.checkmark.uiImage, | ||
isEnabled: true, | ||
selectionState: .selected, | ||
alignment: .left | ||
) | ||
view.translatesAutoresizingMaskIntoConstraints = false | ||
return view | ||
}() | ||
|
||
private lazy var lineView: UIView = { | ||
let view = UIView() | ||
view.backgroundColor = UIColor.lightGray | ||
view.translatesAutoresizingMaskIntoConstraints = false | ||
return view | ||
}() | ||
|
||
private lazy var checkboxGroup: CheckboxGroupUIView = { | ||
var items = [ | ||
CheckboxGroupItemDefault(title: "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", id: "1", selectionState: .selected, isEnabled: true), | ||
CheckboxGroupItemDefault(title: "Hello World", id: "2", selectionState: .selected, isEnabled: true) | ||
] | ||
let view = CheckboxGroupUIView( | ||
checkedImage: DemoIconography.shared.checkmark.uiImage, | ||
items: items, | ||
alignment: alignment.isSelected ? CheckboxAlignment.left : CheckboxAlignment.right, | ||
theme: self.theme, | ||
intent: .main, | ||
accessibilityIdentifierPrefix: "Checkbox" | ||
) | ||
view.translatesAutoresizingMaskIntoConstraints = false | ||
return view | ||
}() | ||
|
||
private lazy var radioButtonGroup: RadioButtonUIGroupView = { | ||
var items = [ | ||
RadioButtonUIItem(id: 0, label: "Hello World"), | ||
RadioButtonUIItem(id: 1, label: "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.") | ||
] | ||
let view = RadioButtonUIGroupView( | ||
theme: self.theme, | ||
intent: .main, | ||
selectedID: 0, | ||
items: items, | ||
labelAlignment: alignment.isSelected ? RadioButtonLabelAlignment.trailing : RadioButtonLabelAlignment.leading, | ||
groupLayout: .vertical | ||
) | ||
view.translatesAutoresizingMaskIntoConstraints = false | ||
return view | ||
}() | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
self.navigationItem.title = "Radio Checkbox UIKit" | ||
|
||
self.setupView() | ||
self.subscribe() | ||
} | ||
|
||
private func setupView() { | ||
self.view.backgroundColor = UIColor.systemBackground | ||
|
||
self.view.addSubview(alignment) | ||
self.view.addSubview(lineView) | ||
self.view.addSubview(checkboxGroup) | ||
self.view.addSubview(radioButtonGroup) | ||
|
||
NSLayoutConstraint.activate([ | ||
|
||
self.alignment.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor, constant: 16), | ||
self.alignment.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 16), | ||
self.alignment.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: -16), | ||
|
||
self.lineView.topAnchor.constraint(equalTo: self.alignment.bottomAnchor, constant: 32), | ||
self.lineView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 16), | ||
self.lineView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: -16), | ||
self.lineView.heightAnchor.constraint(equalToConstant: 1), | ||
|
||
self.checkboxGroup.topAnchor.constraint(equalTo: self.lineView.bottomAnchor, constant: 32), | ||
self.checkboxGroup.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 16), | ||
self.checkboxGroup.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: -16), | ||
|
||
self.radioButtonGroup.topAnchor.constraint(equalTo: self.checkboxGroup.bottomAnchor, constant: 16), | ||
self.radioButtonGroup.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 16), | ||
self.radioButtonGroup.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: -16) | ||
]) | ||
} | ||
|
||
private func subscribe() { | ||
self.alignment.publisher.subscribe(in: &self.cancellables) { [weak self] isSelected in | ||
self?.radioButtonGroup.labelAlignment = isSelected == .selected ? RadioButtonLabelAlignment.trailing : RadioButtonLabelAlignment.leading | ||
self?.checkboxGroup.alignment = isSelected == .selected ? CheckboxAlignment.left : CheckboxAlignment.right | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
spark/Demo/Classes/View/ListView/Controllers/RadioCheckboxView.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 @@ | ||
// | ||
// RadioCheckboxView.swift | ||
// SparkDemo | ||
// | ||
// Created by alican.aycil on 22.03.24. | ||
// Copyright © 2024 Adevinta. All rights reserved. | ||
// | ||
|
||
import Spark | ||
import SparkCore | ||
import SwiftUI | ||
|
||
struct RadioCheckboxView: View { | ||
|
||
// MARK: - Properties | ||
@State private var theme: Theme = SparkThemePublisher.shared.theme | ||
@State private var alignment: CheckboxAlignment = .left | ||
@State private var selectedIcon = CheckboxListView.Icons.checkedImage | ||
@State private var selectedID: Int? = 0 | ||
@State private var items: [any CheckboxGroupItemProtocol] = [ | ||
CheckboxGroupItemDefault(title: "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", id: "1", selectionState: .selected, isEnabled: true), | ||
CheckboxGroupItemDefault(title: "Hello World", id: "2", selectionState: .selected, isEnabled: true) | ||
] | ||
@State private var radioGroupItems: [RadioButtonItem<Int>] = [ | ||
RadioButtonItem(id: 0, label: "Hello World"), | ||
RadioButtonItem(id: 1, label: "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.") | ||
] | ||
|
||
|
||
// MARK: - View | ||
var body: some View { | ||
Component( | ||
name: "Radio Checkbox SwiftUI", | ||
configuration: { | ||
|
||
EnumSelector( | ||
title: "Alignment", | ||
dialogTitle: "Select a Alignment", | ||
values: CheckboxAlignment.allCases, | ||
value: self.$alignment | ||
) | ||
}, | ||
integration: { | ||
VStack(alignment: .leading) { | ||
CheckboxGroupView( | ||
checkedImage: self.selectedIcon.image, | ||
items: self.$items, | ||
layout: .vertical, | ||
alignment: self.alignment, | ||
theme: self.theme, | ||
intent: .main, | ||
accessibilityIdentifierPrefix: "checkbox-group" | ||
) | ||
|
||
RadioButtonGroupView( | ||
theme: self.theme, | ||
intent: .main, | ||
selectedID: self.$selectedID, | ||
items: self.radioGroupItems, | ||
labelAlignment: self.alignment == .left ? .trailing : .leading, | ||
groupLayout: .vertical | ||
) | ||
} | ||
} | ||
) | ||
} | ||
} |
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.
I'm not sure of the logic here. Why can't all the checkboxes be set to enabled as in the disabled states?
If someone enables the whole component, shouldn't it override the status of each single component?
self.checkboxes.forEach { $0.isEnabled == isEnabled }
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.
ex; Checkbox group has 3 item and first item is disable then consumer wants to disable all and enable all in this case first item will be enable but it should be disable