Add segment control component#4434
Conversation
Added the component to the checkspage Made the checkspage scrollable
Matched the font to Figma design
Pull Request Test Coverage Report for Build 23792443815Details
💛 - Coveralls |
📦 Build Artifacts Ready
|
|
|
||
| property string allText: qsTr( "All" ) | ||
| property string trueText: qsTr( "True" ) | ||
| property string falseText: qsTr( "False" ) |
There was a problem hiding this comment.
| property string allText: qsTr( "All" ) | |
| property string trueText: qsTr( "True" ) | |
| property string falseText: qsTr( "False" ) |
| MMText { id: allMeasure; text: root.allText; font: __style.t3; visible: false } | ||
| MMText { id: trueMeasure; text: root.trueText; font: __style.t3; visible: false } | ||
| MMText { id: falseMeasure; text: root.falseText; font: __style.t3; visible: false } |
There was a problem hiding this comment.
| MMText { id: allMeasure; text: root.allText; font: __style.t3; visible: false } | |
| MMText { id: trueMeasure; text: root.trueText; font: __style.t3; visible: false } | |
| MMText { id: falseMeasure; text: root.falseText; font: __style.t3; visible: false } |
There was a problem hiding this comment.
for the calculation of implicitWidth can't we use the width of children + margins?
| Rectangle { | ||
| anchors.fill: parent | ||
| radius: __style.radius12 | ||
| color: __style.primaryColor |
There was a problem hiding this comment.
This color doesn't exist
| model: [ | ||
| { text: root.allText, index: MMSegmentControl.Options.All }, | ||
| { text: root.trueText, index: MMSegmentControl.Options.True }, | ||
| { text: root.falseText, index: MMSegmentControl.Options.False } | ||
| ] |
There was a problem hiding this comment.
| model: [ | |
| { text: root.allText, index: MMSegmentControl.Options.All }, | |
| { text: root.trueText, index: MMSegmentControl.Options.True }, | |
| { text: root.falseText, index: MMSegmentControl.Options.False } | |
| ] | |
| model: 3 |
I think this should be enough and in delegate you can work with index
| delegate: Item { | ||
| id: segment | ||
|
|
||
| required property var modelData |
There was a problem hiding this comment.
| required property var modelData | |
| required property int index |
| } | ||
|
|
||
| MMText { | ||
| anchors.centerIn: parent |
There was a problem hiding this comment.
| anchors.centerIn: parent | |
| anchors.centerIn: segment |
| MMText { | ||
| anchors.centerIn: parent | ||
|
|
||
| text: segment.modelData.text |
There was a problem hiding this comment.
| text: segment.modelData.text | |
| text: { | |
| switch ( segment.index ) { | |
| case MMSegmentControl.Options.All: { | |
| qsTr( "All" ) | |
| break | |
| } | |
| case MMSegmentControl.Options.True: { | |
| qsTr( "True" ) | |
| break | |
| } | |
| case MMSegmentControl.Options.False: { | |
| qsTr( "False" ) | |
| break | |
| } | |
| } | |
| } |
| Rectangle { | ||
| anchors.fill: parent | ||
| radius: __style.radius8 | ||
|
|
||
| visible: segment.isSelected | ||
|
|
||
| color: segment.isAllOption ? __style.mediumGreenColor : __style.positiveColor | ||
|
|
||
| border.color: segment.isAllOption ? __style.transparentColor : __style.forestColor | ||
| border.width: segment.isAllOption ? 0 : 1.0 * __dp | ||
| } |
There was a problem hiding this comment.
Can't we use this as background for MMText?
| } | ||
|
|
||
| MouseArea { | ||
| anchors.fill: parent |
There was a problem hiding this comment.
| anchors.fill: parent | |
| anchors.fill: segment |
| property string trueText: qsTr( "True" ) | ||
| property string falseText: qsTr( "False" ) | ||
|
|
||
| signal selectionChanged( int index ) |
There was a problem hiding this comment.
We don't need this, every property in QML has onPropertyChanged signal attached by default
|
Regarding the visuals, why do we have different highlight box for all? |
Created a new segment control component.
Added it to the gallery app in the ChecksPage and made the page scrollable.
To be used for boolean values when filtering.
Visual references:

segment-control.mp4