← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~nik90/ubuntu-clock-app/improve-setting-listitem into lp:ubuntu-clock-app

 

Nekhelesh Ramananthan has proposed merging lp:~nik90/ubuntu-clock-app/improve-setting-listitem into lp:ubuntu-clock-app.

Commit message:
Made the expandable list item used in AlarmSettings.qml into a generic component to avoid code duplication and also polished its visual style (related to side anchors and tick to indicate selected setting).

Requested reviews:
  Ubuntu Clock Developers (ubuntu-clock-dev)

For more details, see:
https://code.launchpad.net/~nik90/ubuntu-clock-app/improve-setting-listitem/+merge/252930

Made the expandable list item used in AlarmSettings.qml into a generic component to avoid code duplication and also polished its visual style (related to side anchors and tick to indicate selected setting).
-- 
Your team Ubuntu Clock Developers is requested to review the proposed merge of lp:~nik90/ubuntu-clock-app/improve-setting-listitem into lp:ubuntu-clock-app.
=== modified file 'app/alarm/AlarmSettingsPage.qml'
--- app/alarm/AlarmSettingsPage.qml	2015-03-12 23:22:12 +0000
+++ app/alarm/AlarmSettingsPage.qml	2015-03-13 17:01:12 +0000
@@ -116,140 +116,58 @@
                 }
             }
 
-            ListItem.Expandable {
+            ExpandableListItem {
                 id: _alarmDuration
 
-                anchors {
-                    left: parent.left
-                    right: parent.right
-                }
-
-                collapseOnClick: true
-                expandedHeight: _contentColumn.height + units.gu(1)
-
-                Column {
-                    id: _contentColumn
-
-                    anchors {
-                        left: parent.left
-                        right: parent.right
-                        margins: units.gu(-2)
-                    }
-
-                    Item {
-                        width: parent.width
-                        height: _alarmDuration.collapsedHeight
-
-                        SubtitledListItem {
-                            id: _header
-                            text: i18n.tr("Silence after")
-                            subText: i18n.tr("%1 minute", "%1 minutes", alarmSettings.duration).arg(alarmSettings.duration)
-                            onClicked: _alarmDuration.expanded = true
-
-                            Icon {
-                                id: _upArrow
-
-                                width: units.gu(2)
-                                height: width
-                                anchors.right: parent.right
-                                anchors.rightMargin: units.gu(2)
-                                anchors.verticalCenter: parent.verticalCenter
-
-                                name: "go-down"
-                                color: "Grey"
-                                rotation: _alarmDuration.expanded ? 180 : 0
-
-                                Behavior on rotation {
-                                    UbuntuNumberAnimation {}
-                                }
-                            }
-                        }
-                    }
-
-                    ListView {
-                        id: _resultsList
-
-                        interactive: false
-                        model: durationModel
-                        width: parent.width
-                        height: units.gu(24)
-
-                        delegate: ListItem.Standard {
-                            text: model.text
-                            onClicked: {
-                                alarmSettings.duration = duration
-                                _alarmDuration.expanded = false
-                            }
-                        }
+                listViewHeight: units.gu(24)
+                text: i18n.tr("Silence after")
+                subText: i18n.tr("%1 minute", "%1 minutes", alarmSettings.duration).arg(alarmSettings.duration)
+
+                model: durationModel
+
+                delegate: ListItem.Standard {
+                    text: model.text
+                    onClicked: {
+                        alarmSettings.duration = duration
+                        _alarmDuration.expanded = false
+                    }
+
+                    Icon {
+                        width: units.gu(2)
+                        height: width
+                        name: "ok"
+                        visible: alarmSettings.duration === duration
+                        anchors.right: parent.right
+                        anchors.rightMargin: units.gu(2)
+                        anchors.verticalCenter: parent.verticalCenter
                     }
                 }
             }
 
-            ListItem.Expandable {
+            ExpandableListItem {
                 id: _alarmSnooze
 
-                anchors {
-                    left: parent.left
-                    right: parent.right
-                }
-
-                collapseOnClick: true
-                expandedHeight: _snoozeContentColumn.height + units.gu(1)
-
-                Column {
-                    id: _snoozeContentColumn
-
-                    anchors {
-                        left: parent.left
-                        right: parent.right
-                        margins: units.gu(-2)
-                    }
-
-                    Item {
-                        width: parent.width
-                        height: _alarmSnooze.collapsedHeight
-
-                        SubtitledListItem {
-                            id: _snoozeHeader
-                            text: i18n.tr("Snooze for")
-                            subText: i18n.tr("%1 minute", "%1 minutes", alarmSettings.snoozeDuration).arg(alarmSettings.snoozeDuration)
-                            onClicked: _alarmSnooze.expanded = true
-
-                            Icon {
-                                id: _snoozeUpArrow
-
-                                width: units.gu(2)
-                                height: width
-                                anchors.right: parent.right
-                                anchors.rightMargin: units.gu(2)
-                                anchors.verticalCenter: parent.verticalCenter
-
-                                name: "go-down"
-                                color: "Grey"
-                                rotation: _alarmSnooze.expanded ? 180 : 0
-
-                                Behavior on rotation {
-                                    UbuntuNumberAnimation {}
-                                }
-                            }
-                        }
-                    }
-
-                    ListView {
-                        id: _snoozeResultsList
-
-                        interactive: false
-                        model: snoozeModel
-                        width: parent.width
-                        height: units.gu(24)
-
-                        delegate: ListItem.Standard {
-                            text: model.text
-                            onClicked: {
-                                alarmSettings.snoozeDuration = duration
-                                _alarmSnooze.expanded = false
-                            }
-                        }
+                listViewHeight: units.gu(24)
+                text: i18n.tr("Snooze for")
+                subText: i18n.tr("%1 minute", "%1 minutes", alarmSettings.snoozeDuration).arg(alarmSettings.snoozeDuration)
+
+                model: snoozeModel
+
+                delegate: ListItem.Standard {
+                    text: model.text
+                    onClicked: {
+                        alarmSettings.snoozeDuration = duration
+                        _alarmSnooze.expanded = false
+                    }
+
+                    Icon {
+                        width: units.gu(2)
+                        height: width
+                        name: "ok"
+                        visible: alarmSettings.snoozeDuration === duration
+                        anchors.right: parent.right
+                        anchors.rightMargin: units.gu(2)
+                        anchors.verticalCenter: parent.verticalCenter
                     }
                 }
             }

=== added file 'app/components/ExpandableListItem.qml'
--- app/components/ExpandableListItem.qml	1970-01-01 00:00:00 +0000
+++ app/components/ExpandableListItem.qml	2015-03-13 17:01:12 +0000
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2015 Podbird Team
+ *
+ * This file is part of Podbird.
+ *
+ * Podbird is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * Podbird is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import QtQuick 2.3
+import Ubuntu.Components 1.1
+import Ubuntu.Components.ListItems 1.0 as ListItem
+
+/*
+ Component which extends the SDK Expandable list item and provides a easy
+ to use component where the title, subtitle and a listview can be displayed. It
+ matches the design specification provided for clock.
+*/
+
+ListItem.Expandable {
+    id: expandableListItem
+
+    // Public APIs
+    property ListModel model
+    property Component delegate
+    property alias text: expandableHeader.text
+    property alias subText: expandableHeader.subText
+    property alias listViewHeight: expandableList.height
+
+    anchors {
+        left: parent.left
+        right: parent.right
+        margins: units.gu(-2)
+    }
+
+    collapseOnClick: true
+    expandedHeight: contentColumn.height + units.gu(1)
+
+    Column {
+        id: contentColumn
+
+        anchors {
+            left: parent.left
+            right: parent.right
+        }
+
+        Item {
+            width: parent.width
+            height: expandableListItem.collapsedHeight
+
+            SubtitledListItem {
+                id: expandableHeader
+                onClicked: expandableListItem.expanded = true
+
+                Icon {
+                    id: arrow
+
+                    width: units.gu(2)
+                    height: width
+                    anchors.right: parent.right
+                    anchors.rightMargin: units.gu(2)
+                    anchors.verticalCenter: parent.verticalCenter
+
+                    name: "go-down"
+                    color: "Grey"
+                    rotation: expandableListItem.expanded ? 180 : 0
+
+                    Behavior on rotation {
+                        UbuntuNumberAnimation {}
+                    }
+                }
+            }
+        }
+
+        ListView {
+            id: expandableList
+            width: parent.width
+            interactive: false
+            model: expandableListItem.model
+            delegate: expandableListItem.delegate
+        }
+    }
+}
+

=== modified file 'debian/changelog'
--- debian/changelog	2015-03-12 23:23:31 +0000
+++ debian/changelog	2015-03-13 17:01:12 +0000
@@ -12,6 +12,8 @@
   * Fixed empty state description not wrapping (LP: #1428165)
   * Fixed edit alarm crash issue in vivid (thanks to Zsombor) (LP: #1429273)
   * Fixed strings not following gettext-style plural forms. (LP: #1431446)
+  * Created a generic expandable listitem component for the settings page to avoid
+    code duplication in AlarmSettings.qml
 
   [Brendan Donegan]
   * Fixed AP failure by waiting for the bottom edge tip visible property to be true

=== modified file 'po/com.ubuntu.clock.pot'
--- po/com.ubuntu.clock.pot	2015-03-12 23:22:12 +0000
+++ po/com.ubuntu.clock.pot	2015-03-13 17:01:12 +0000
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-03-13 00:18+0100\n"
+"POT-Creation-Date: 2015-03-13 17:52+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"
@@ -69,8 +69,8 @@
 #: ../app/alarm/AlarmSettingsPage.qml:55 ../app/alarm/AlarmSettingsPage.qml:56
 #: ../app/alarm/AlarmSettingsPage.qml:65 ../app/alarm/AlarmSettingsPage.qml:66
 #: ../app/alarm/AlarmSettingsPage.qml:67 ../app/alarm/AlarmSettingsPage.qml:68
-#: ../app/alarm/AlarmSettingsPage.qml:146
-#: ../app/alarm/AlarmSettingsPage.qml:215
+#: ../app/alarm/AlarmSettingsPage.qml:125
+#: ../app/alarm/AlarmSettingsPage.qml:152
 #, qt-format
 msgid "%1 minute"
 msgid_plural "%1 minutes"
@@ -81,19 +81,19 @@
 msgid "Alarm volume"
 msgstr ""
 
-#: ../app/alarm/AlarmSettingsPage.qml:145
+#: ../app/alarm/AlarmSettingsPage.qml:124
 msgid "Silence after"
 msgstr ""
 
-#: ../app/alarm/AlarmSettingsPage.qml:214
+#: ../app/alarm/AlarmSettingsPage.qml:151
 msgid "Snooze for"
 msgstr ""
 
-#: ../app/alarm/AlarmSettingsPage.qml:259
+#: ../app/alarm/AlarmSettingsPage.qml:175
 msgid "Vibration"
 msgstr ""
 
-#: ../app/alarm/AlarmSettingsPage.qml:293
+#: ../app/alarm/AlarmSettingsPage.qml:209
 msgid "Change time and date"
 msgstr ""
 


Follow ups