-
Notifications
You must be signed in to change notification settings - Fork 76
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: [UI - Swap] Create row radiobutton component with custom field #14887
feat: [UI - Swap] Create row radiobutton component with custom field #14887
Conversation
Jenkins BuildsClick to see older builds (36)
|
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.
Looks nice in general, however I have an idea for a bit different structure of code:
The idea is to make the StatusButtonRow
possibly generic row of buttons, with API inspired by ComboBox:
StatusButtonRow {
// writable properties:
var model
var defaultValue
string textRole
string valueRole
// readonly properties:
int currentIndex
int currentText
var currentValue
}
Then StatusButtonRow
gives the user full freedom what is value, what is text and how it's composed. Currently we are limited to numbers with customizable suffix.
Then, using this StatusButtonRow
via composition as a building block we could build the specific component we need, e.g. SlippageSelector
. It would contain buttons row, additional input field and the whole additional logic needed here. However it would be simpler than current impl, because button row logic would be externalized, and we don't need loaders for and logic for controlling custom component.
The public api of the SlippageSelector
could be very simple, even just
SlippageSelector {
// readonly props:
bool valid
double value
}
It will be also easier to cover some specific needs of this case - e.g. now 200 %
is presented as valid input and there is no way via api of that component to mark it as invalid.
I think that this approach is more resistant to components overparametrization. When new case base of button rows is needed, generalized and simplified StatusButtonRow
can be used as a building block without modifications and also SlippageSelector
stays intact.
Playing with the component, I noticed some small undesired behavior regarding red border around input field:
Screencast.from.24.05.2024.14.14.09.webm
Please shared wdyt regarding structure. Thanks!
Pretty much agree overall, I can definitely publish the
Yeah for this specific usecase I don't have a clear idea/answer yet; I'd have to somehow make the customInput's validator public/customizable.
Most likely rounding errors, can't see anything like that on a highres screen :/ |
Oh and this has to be writable imho (as it is currently), you still might want to preselect a custom (previously saved) value that's not part of the model |
@micieslak the red/validation border rect: Zaznam.obrazovky.z.2024-05-24.15-32-57.webm |
Screencast.from.24.05.2024.15.38.50.webmFirst click deselect input, the second - not |
For that reason I would opt for stop trying to parametrize all things here and do just custom component at the end of the chain implementing the specific logic of that case.
is the second deselection working as intended? |
yes |
Screencast.from.24.05.2024.16.00.37.webmProbably in that case, the component should switch into "custom mode" |
Yeah right, setting the |
d424572
to
08895e9
Compare
08895e9
to
796bc92
Compare
1800226
to
794cdf0
Compare
- Create row radiobutton component like the one defined in design - It shall contain custom set of buttons - It shall contain a Custom button that will be converted to an input field - Add the new component into a new storybook page - Create necessary qml tests to cover the component logic Fixes #14784
…mplified, fixed issue with setting values from outside
- also split the SB pages
do not overwrite it and display the Custom button when we click one of the predefined buttons
794cdf0
to
131b597
Compare
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.
Cool! Just some minor comments.
131b597
to
8823862
Compare
8823862
to
914f90e
Compare
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.
LGTM! Awesome work.
What does the PR do
Fixes #14784
Affected areas
StatusButtonRow, SlippageSelector
Screenshot of functionality (including design for comparison)
StatusButtonRow:
SlippageSelector:
Zaznam.obrazovky.z.2024-05-28.00-00-33.webm