← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~nik90/ubuntu-clock-app/new-bottom-edge into lp:ubuntu-clock-app

 

Nekhelesh Ramananthan has proposed merging lp:~nik90/ubuntu-clock-app/new-bottom-edge into lp:ubuntu-clock-app.

Commit message:
Use the new bottom edge

Requested reviews:
  Ubuntu Clock Developers (ubuntu-clock-dev)
Related bugs:
  Bug #1543496 in Ubuntu Clock App: "‘Shutter’ effect animation on title bar when opening bottom edge should not be present."
  https://bugs.launchpad.net/ubuntu-clock-app/+bug/1543496
  Bug #1549988 in Ubuntu Clock App: "Clock should use standard Bottom Page"
  https://bugs.launchpad.net/ubuntu-clock-app/+bug/1549988

For more details, see:
https://code.launchpad.net/~nik90/ubuntu-clock-app/new-bottom-edge/+merge/287236

Use the new bottom edge
-- 
Your team Ubuntu Clock Developers is requested to review the proposed merge of lp:~nik90/ubuntu-clock-app/new-bottom-edge into lp:ubuntu-clock-app.
=== modified file 'app/MainPage.qml'
--- app/MainPage.qml	2016-02-20 08:13:21 +0000
+++ app/MainPage.qml	2016-02-25 22:07:07 +0000
@@ -26,7 +26,7 @@
 import "stopwatch"
 import "components"
 
-PageWithBottomEdge {
+Page {
     id: _mainPage
     objectName: "mainPage"
 
@@ -49,9 +49,16 @@
     property var alarmModel
 
     flickable: null
-    bottomEdgeTitle: _mainPage.visible ? alarmUtils.set_bottom_edge_title(alarmModel, notLocalizedDateTimeString)
-                                       : i18n.tr("No active alarms")
-    bottomEdgePageComponent: AlarmPage {}
+
+    BottomEdge {
+        id: bottomEdge
+        height: parent.height
+        hint.text: "Alarms"
+        contentComponent: AlarmPage {
+            width: bottomEdge.width
+            height: bottomEdge.height
+        }
+    }
 
     AlarmUtils {
         id: alarmUtils

=== modified file 'app/alarm/AlarmList.qml'
--- app/alarm/AlarmList.qml	2015-10-22 16:49:23 +0000
+++ app/alarm/AlarmList.qml	2016-02-25 22:07:07 +0000
@@ -31,7 +31,7 @@
     signal selectAll()
 
     clip: true
-    anchors.fill: parent
+    currentIndex: -1
 
     Timer {
         id: alarmTimer
@@ -71,7 +71,7 @@
             if (selectMode) {
                 selected = !selected
             } else {
-                pageStack.push(Qt.resolvedUrl("EditAlarmPage.qml"), {isNewAlarm: false, tempAlarm: model, alarmModel: alarmModel})
+                mainStack.push(Qt.resolvedUrl("EditAlarmPage.qml"), {isNewAlarm: false, tempAlarm: model, alarmModel: alarmModel})
             }
         }
 

=== modified file 'app/alarm/AlarmPage.qml'
--- app/alarm/AlarmPage.qml	2015-10-22 16:49:23 +0000
+++ app/alarm/AlarmPage.qml	2016-02-25 22:07:07 +0000
@@ -24,102 +24,105 @@
 
     readonly property bool isAlarmPage: true
 
-    title: i18n.tr("Alarms")
     objectName: 'AlarmPage'
-    flickable: null
+    header: standardHeader
 
     Component.onCompleted: console.log("[LOG]: Alarm Page loaded")
 
-    states: [
-        PageHeadState {
-            name: "default"
-            head: alarmPage.head
-            when: !alarmListView.ViewItems.selectMode
-
-            backAction: Action {
-                iconName: "down"
-                text: i18n.tr("Back")
-                onTriggered: {
-                    pageStack.pop()
-                }
-            }
-
-            actions: [
-                Action {
-                    objectName: "addAlarmAction"
-                    iconName: "add"
-                    text: i18n.tr("Alarm")
-                    onTriggered: {
-                        pageStack.push(Qt.resolvedUrl("EditAlarmPage.qml"))
-                    }
-                }
-            ]
-        },
-
-        PageHeadState {
-            name: "selection"
-            head: alarmPage.head
-            when: alarmListView.ViewItems.selectMode
-
-            backAction: Action {
+    PageHeader {
+        id: standardHeader
+        title: i18n.tr("Alarms")
+        leadingActionBar.actions: [
+            Action {
+                text: "close"
+                iconName: "go-down"
+                onTriggered: {
+                    bottomEdge.collapse()
+                }
+            }
+        ]
+        trailingActionBar.actions: [
+            Action {
+                objectName: "addAlarmAction"
+                iconName: "add"
+                text: i18n.tr("Alarm")
+                onTriggered: {
+                    mainStack.push(Qt.resolvedUrl("EditAlarmPage.qml"))
+                }
+            }
+        ]
+    }
+
+    PageHeader {
+        id: selectionHeader
+        visible: alarmListView.ViewItems.selectMode
+        leadingActionBar.actions: [
+            Action {
                 iconName: "back"
                 text: i18n.tr("Back")
                 onTriggered: {
+                    alarmPage.header = standardHeader
                     alarmListView.ViewItems.selectMode = false
                 }
             }
-
-            actions: [
-                Action {
-                    text: {
-                        if(alarmListView.ViewItems.selectedIndices.length === alarmListView.count) {
-                            return i18n.tr("Select None")
-                        } else {
-                            return i18n.tr("Select All")
-                        }
-                    }
-
-                    iconSource: {
-                        if(alarmListView.ViewItems.selectedIndices.length === alarmListView.count) {
-                            return Qt.resolvedUrl("../graphics/select-none.svg")
-                        } else {
-                            return Qt.resolvedUrl("../graphics/select.svg")
-                        }
-                    }
-
-                    onTriggered: {
-                        if(alarmListView.ViewItems.selectedIndices.length === alarmListView.count) {
-                            alarmListView.clearSelection()
-                        } else {
-                            alarmListView.selectAll()
-                        }
-                    }
-                },
-
-                Action {
-                    iconName: "delete"
-                    text: i18n.tr("Delete")
-                    enabled: alarmListView.ViewItems.selectedIndices.length !== 0
-
-                    onTriggered: {
-                        var items = alarmListView.ViewItems.selectedIndices
-
-                        for(var i=0; i < alarmListView.ViewItems.selectedIndices.length; i++) {
-                            var alarm = alarmModel.get(alarmListView.ViewItems.selectedIndices[i])
-                            alarm.cancel()
-                        }
-
-                        alarmListView.closeSelection()
-                    }
-                }
-            ]
-        }
-    ]
+        ]
+
+        trailingActionBar.actions: [
+            Action {
+                text: {
+                    if(alarmListView.ViewItems.selectedIndices.length === alarmListView.count) {
+                        return i18n.tr("Select None")
+                    } else {
+                        return i18n.tr("Select All")
+                    }
+                }
+
+                iconSource: {
+                    if(alarmListView.ViewItems.selectedIndices.length === alarmListView.count) {
+                        return Qt.resolvedUrl("../graphics/select-none.svg")
+                    } else {
+                        return Qt.resolvedUrl("../graphics/select.svg")
+                    }
+                }
+
+                onTriggered: {
+                    if(alarmListView.ViewItems.selectedIndices.length === alarmListView.count) {
+                        alarmListView.clearSelection()
+                    } else {
+                        alarmListView.selectAll()
+                    }
+                }
+            },
+
+            Action {
+                iconName: "delete"
+                text: i18n.tr("Delete")
+                enabled: alarmListView.ViewItems.selectedIndices.length !== 0
+
+                onTriggered: {
+                    var items = alarmListView.ViewItems.selectedIndices
+
+                    for(var i=0; i < alarmListView.ViewItems.selectedIndices.length; i++) {
+                        var alarm = alarmModel.get(alarmListView.ViewItems.selectedIndices[i])
+                        alarm.cancel()
+                    }
+
+                    alarmListView.closeSelection()
+                }
+            }
+        ]
+    }
 
     AlarmList {
         id: alarmListView
         model: alarmModel
-        anchors.fill: parent
+        anchors {
+            top: alarmPage.header.bottom
+            left: parent.left
+            right: parent.right
+            bottom: parent.bottom
+        }
+
         localTime: {
             return new Date
                 (
@@ -137,7 +140,7 @@
     Loader {
         id: emptyStateLoader
         anchors {
-            top: parent.top
+            top: alarmPage.header.bottom
             topMargin: units.gu(5)
             left: parent.left
             right: parent.right

=== modified file 'app/alarm/AlarmUtils.qml'
--- app/alarm/AlarmUtils.qml	2015-12-11 02:13:16 +0000
+++ app/alarm/AlarmUtils.qml	2016-02-25 22:07:07 +0000
@@ -50,39 +50,6 @@
         }
     }
 
-    // Function to set the bottom edge title with "Next Active in..."
-    function set_bottom_edge_title(alarmModel, clockTimeString) {
-        var bottom_edge_title = i18n.tr("No active alarms")
-
-        var clockTime = new Date
-                (
-                    clockTimeString.split(":")[0],
-                    clockTimeString.split(":")[1] - 1,
-                    clockTimeString.split(":")[2],                    
-                    clockTimeString.split(":")[3],
-                    clockTimeString.split(":")[4],
-                    clockTimeString.split(":")[5],
-                    0
-                    )
-        /*
-         Check if alarm model received is valid and has saved alarms and only
-         then proceed to find the next active alarm.
-        */
-        if (!alarmModel || !alarmModel.count) {
-            return bottom_edge_title
-        }
-
-        var activeAlarmDate = _get_next_active_alarm(alarmModel, clockTime)
-
-        // Return immediately if there are no active alarms found
-        if (!activeAlarmDate)  {
-          return bottom_edge_title
-        }
-
-        bottom_edge_title = i18n.tr("Next Alarm %1").arg(get_time_to_alarm(activeAlarmDate, clockTime))
-        return bottom_edge_title
-    }
-
     function get_utc_time(dateTime) {
         return new Date(dateTime.getUTCFullYear(),
                         dateTime.getUTCMonth(),
@@ -153,27 +120,6 @@
       INTERNAL FUNCTIONS
     */
 
-    /*
-     Function to get the next active alarm. This function ignores alarms in the
-     past and also iteratively looks through every alarm since the alarm model
-     does not always list the active alarms in chronological order.
-    */
-    function _get_next_active_alarm(alarmModel, clockTime) {
-        var activeAlarmDate = undefined
-
-        for (var i=0; i<alarmModel.count; i++) {
-            var currentAlarm = alarmModel.get(i)
-            if (currentAlarm.enabled && currentAlarm.date > clockTime) {
-                if (activeAlarmDate === undefined ||
-                        currentAlarm.date < activeAlarmDate) {
-                    activeAlarmDate = currentAlarm.date
-                }
-            }
-        }
-
-        return activeAlarmDate
-    }
-
     // Function to split time (in ms) into days, hours and minutes
     function _split_time(totalTime) {
         // increase by a minute, so we could make a nicer time

=== modified file 'app/alarm/EditAlarmPage.qml'
--- app/alarm/EditAlarmPage.qml	2016-02-17 22:19:15 +0000
+++ app/alarm/EditAlarmPage.qml	2016-02-25 22:07:07 +0000
@@ -31,22 +31,26 @@
     property var tempAlarm
     property bool isNewAlarm: true
 
-    title: isNewAlarm ? i18n.tr("New alarm") : i18n.tr("Edit alarm")
     visible: false
 
-    head.actions: Action {
-        id: saveAlarmButton
-        iconName: "ok"
-        objectName: "saveAlarmAction"
-        text: i18n.tr("Alarm")
-        onTriggered: {
-            if(isNewAlarm) {
-                saveNewAlarm()
-            }
-            else {
-                updateAlarm()
-            }
-        }
+    header: PageHeader {
+        title: isNewAlarm ? i18n.tr("New alarm") : i18n.tr("Edit alarm")
+        trailingActionBar.actions: [
+            Action {
+                id: saveAlarmButton
+                iconName: "ok"
+                objectName: "saveAlarmAction"
+                text: i18n.tr("Alarm")
+                onTriggered: {
+                    if(isNewAlarm) {
+                        saveNewAlarm()
+                    }
+                    else {
+                        updateAlarm()
+                    }
+                }
+            }
+        ]
     }
 
     Component.onCompleted: {
@@ -225,7 +229,7 @@
         id: _alarmColumn
 
         width: parent.width
-        anchors.top: parent.top
+        anchors.top: _addAlarmPage.header.bottom
 
         DatePicker {
             id: _timePicker

=== modified file 'app/ubuntu-clock-app.qml'
--- app/ubuntu-clock-app.qml	2016-02-25 17:50:48 +0000
+++ app/ubuntu-clock-app.qml	2016-02-25 22:07:07 +0000
@@ -126,8 +126,6 @@
             */
 
             alarmModel: alarmModelLoader.item
-            bottomEdgeEnabled: alarmModelLoader.status === Loader.Ready && alarmModelLoader.item.isReady && isClockPage
-
             /*
                FIXME: When the upstream QT bug at
                https://bugreports.qt-project.org/browse/QTBUG-40275 is fixed

=== modified file 'app/worldclock/UserWorldCityDelegate.qml'
--- app/worldclock/UserWorldCityDelegate.qml	2016-02-17 21:30:07 +0000
+++ app/worldclock/UserWorldCityDelegate.qml	2016-02-25 22:07:07 +0000
@@ -33,6 +33,7 @@
 
     height: units.gu(9)
     divider.visible: false
+    highlightColor: "Transparent"
 
     Item {
         id: delegate

=== modified file 'app/worldclock/UserWorldCityList.qml'
--- app/worldclock/UserWorldCityList.qml	2015-10-22 16:49:23 +0000
+++ app/worldclock/UserWorldCityList.qml	2016-02-25 22:07:07 +0000
@@ -21,12 +21,13 @@
 import U1db 1.0 as U1db
 import Ubuntu.Components 1.3
 
-ListView {
+UbuntuListView {
     id: worldCityColumn
     objectName: "userWorldCityRepeater"
 
     clip: true
     anchors.fill: parent
+    currentIndex: -1
 
     onFlickStarted:  {
         forceActiveFocus()


Follow ups