From d12aaec87ea6d4ef6c7815d01a84191f5ef38ca6 Mon Sep 17 00:00:00 2001 From: Khushboo Mehta Date: Tue, 26 Oct 2021 11:30:05 +0200 Subject: [PATCH] refactor: Remove and replace StatusSwitch from ui/shared/status --- .../AppLayouts/Profile/views/PrivacyView.qml | 7 +- ui/shared/status/StatusSettingsLineButton.qml | 4 +- ui/shared/status/StatusSwitch.qml | 66 ------------------- 3 files changed, 7 insertions(+), 70 deletions(-) delete mode 100644 ui/shared/status/StatusSwitch.qml diff --git a/ui/app/AppLayouts/Profile/views/PrivacyView.qml b/ui/app/AppLayouts/Profile/views/PrivacyView.qml index d3c57226a5..b52aa72f7d 100644 --- a/ui/app/AppLayouts/Profile/views/PrivacyView.qml +++ b/ui/app/AppLayouts/Profile/views/PrivacyView.qml @@ -12,6 +12,7 @@ import "../../Onboarding/shared" as OnboardingComponents import StatusQ.Core 0.1 import StatusQ.Core.Theme 0.1 import StatusQ.Components 0.1 +import StatusQ.Controls 0.1 as StatusQControls import "../popups" @@ -162,7 +163,7 @@ Item { title: qsTrId("display-all-profile-pictures--not-only-contacts-") implicitHeight: 52 components: [ - StatusSwitch { + StatusQControls.StatusSwitch { id: switch1 checked: !appSettings.onlyShowContactsProfilePics } @@ -181,7 +182,7 @@ Item { title: qsTrId("display-images-in-chat-automatically") implicitHeight: 52 components: [ - StatusSwitch { + StatusQControls.StatusSwitch { id: switch2 checked: appSettings.displayChatImages } @@ -259,7 +260,7 @@ Item { title: qsTrId("allow-new-contact-requests") implicitHeight: 52 components: [ - StatusSwitch { + StatusQControls.StatusSwitch { id: switch3 checked: !root.store.messagesFromContactsOnly } diff --git a/ui/shared/status/StatusSettingsLineButton.qml b/ui/shared/status/StatusSettingsLineButton.qml index afa3fd1845..7caa84cf29 100644 --- a/ui/shared/status/StatusSettingsLineButton.qml +++ b/ui/shared/status/StatusSettingsLineButton.qml @@ -5,6 +5,8 @@ import utils 1.0 import ".." import "../panels" +import StatusQ.Controls 0.1 as StatusQControls + Rectangle { property string text property bool isSwitch: false @@ -70,7 +72,7 @@ Rectangle { } - StatusSwitch { + StatusQControls.StatusSwitch { id: switchItem enabled: root.isEnabled visible: root.isSwitch diff --git a/ui/shared/status/StatusSwitch.qml b/ui/shared/status/StatusSwitch.qml deleted file mode 100644 index 30894f267b..0000000000 --- a/ui/shared/status/StatusSwitch.qml +++ /dev/null @@ -1,66 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtGraphicalEffects 1.13 - -import utils 1.0 -import "../../shared" -import "../../shared/panels" - -Switch { - id: control - - indicator: Rectangle { - id: oval - implicitWidth: 52 - implicitHeight: 28 - x: control.leftPadding - y: parent.height / 2 - height / 2 - radius: 14 - color: control.checked ? Style.current.primary : Style.current.inputBackground - - Rectangle { - id: circle - y: 4 - width: 20 - height: 20 - radius: 10 - color: Style.current.white - layer.enabled: true - layer.effect: DropShadow { - width: parent.width - height: parent.height - visible: true - verticalOffset: 1 - fast: true - cached: true - color: "#22000000" - } - - states: [ - State { - name: "on" - when: control.checked - PropertyChanges { target: circle; x: oval.width - circle.width - 4 } - }, - State { - name: "off" - when: !control.checked - PropertyChanges { target: circle; x: 4 } - } - ] - - transitions: Transition { - reversible: true - NumberAnimation { properties: "x"; easing.type: Easing.Linear; duration: 120; } - } - } - } - - contentItem: StyledText { - text: control.text - opacity: enabled ? 1.0 : 0.3 - verticalAlignment: Text.AlignVCenter - leftPadding: !!control.text ? control.indicator.width + control.spacing : control.indicator.width - } -} -