Skip to content

Add segment control component#4434

Open
gabriel-bolbotina wants to merge 4 commits intodev/filteringfrom
add-segment-control-component
Open

Add segment control component#4434
gabriel-bolbotina wants to merge 4 commits intodev/filteringfrom
add-segment-control-component

Conversation

@gabriel-bolbotina
Copy link
Copy Markdown
Contributor

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:
image

segment-control.mp4

@github-actions
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 23792443815

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 57.858%

Totals Coverage Status
Change from base Build 23430504555: 0.0%
Covered Lines: 8780
Relevant Lines: 15175

💛 - Coveralls

@github-actions
Copy link
Copy Markdown

📦 Build Artifacts Ready

OS Status Build Info Workflow run
macOS Build Build failed or not found. #6608
linux Build 📬 Mergin Maps 66191 x86_64 Expires: 29/06/2026 #6619
win64 Build 📬 Mergin Maps 58031 win64 Expires: 29/06/2026 #5803
Android Build 📬 Mergin Maps 792011 APK [armeabi-v7a] Expires: 29/06/2026 #7920
Android Build 📬 Mergin Maps 792051 APK [arm64-v8a] Expires: 29/06/2026 #7920
iOS Build Build failed or not found. #8859

Comment on lines +19 to +22

property string allText: qsTr( "All" )
property string trueText: qsTr( "True" )
property string falseText: qsTr( "False" )
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
property string allText: qsTr( "All" )
property string trueText: qsTr( "True" )
property string falseText: qsTr( "False" )

Comment on lines +32 to +34
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 }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
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 }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for the calculation of implicitWidth can't we use the width of children + margins?

Rectangle {
anchors.fill: parent
radius: __style.radius12
color: __style.primaryColor
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This color doesn't exist

Comment on lines +48 to +52
model: [
{ text: root.allText, index: MMSegmentControl.Options.All },
{ text: root.trueText, index: MMSegmentControl.Options.True },
{ text: root.falseText, index: MMSegmentControl.Options.False }
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
required property var modelData
required property int index

}

MMText {
anchors.centerIn: parent
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
anchors.centerIn: parent
anchors.centerIn: segment

MMText {
anchors.centerIn: parent

text: segment.modelData.text
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
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
}
}
}

Comment on lines +65 to +75
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
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can't we use this as background for MMText?

}

MouseArea {
anchors.fill: parent
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
anchors.fill: parent
anchors.fill: segment

property string trueText: qsTr( "True" )
property string falseText: qsTr( "False" )

signal selectionChanged( int index )
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We don't need this, every property in QML has onPropertyChanged signal attached by default

@Withalion
Copy link
Copy Markdown
Contributor

Regarding the visuals, why do we have different highlight box for all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants