Merge lp:~martin-borho/ubuntu-weather-app/ImprovedScrollingFastSlow into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Martin Borho
Status: Merged
Approved by: Raúl Yeguas
Approved revision: 107
Merged at revision: 105
Proposed branch: lp:~martin-borho/ubuntu-weather-app/ImprovedScrollingFastSlow
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 189 lines (+61/-56)
3 files modified
components/CurrentWeather.qml (+54/-52)
components/LocationTab.qml (+0/-1)
ubuntu-weather-app.qml (+7/-3)
To merge this branch: bzr merge lp:~martin-borho/ubuntu-weather-app/ImprovedScrollingFastSlow
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Raúl Yeguas Approve
Review via email: mp+183658@code.launchpad.net

Commit message

improved scrolling, added slow/fast scrolling for day/hour scrolling distinction

Description of the change

* improved scrolling
* added slow/fast scrolling for day/hour scrolling distinction
* expanded MouseArea for scrolling
* switches back after hourly scrolling to the overall day data

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Raúl Yeguas (neokore) wrote :

Can't wait to try it in a device, because by now it looks great.
Maybe you could delete the holdFeedback item and onPressAndHold event because they are not neccesary now; but, for me, it's OK.

Tell me your opinion and I'll aprrove it.

review: Approve
107. By Martin Borho

removed obsolete code

Revision history for this message
Martin Borho (martin-borho) wrote :

Replaced, is now ready to approve! :)

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components/CurrentWeather.qml'
2--- components/CurrentWeather.qml 2013-08-30 12:59:44 +0000
3+++ components/CurrentWeather.qml 2013-09-04 09:44:48 +0000
4@@ -24,82 +24,84 @@
5 property string precipScale: (mainView.settings["units"] === "imperial") ? "in" : "mm"
6
7 width: parent.width
8- height: units.gu(40)
9+ anchors.fill: parent
10 anchors.horizontalCenter: parent.horizontalCenter
11
12 Flipable {
13 id: flipable
14- anchors.fill: parent
15-
16+ height: parent.height
17+ width:parent.width
18+ anchors.verticalCenter: parent.verticalCenter
19+ anchors.verticalCenterOffset: -units.gu(3)
20 property bool flipped: false
21
22- Rectangle {
23- id: holdFeedback
24- opacity: 0
25- width: units.gu(4)
26- height: units.gu(4)
27- radius: units.gu(2)
28-
29- transform: Scale {
30- id: scaleTransform
31- property real scale: 0
32- xScale: scale
33- yScale: scale
34- origin.x: units.gu(2)
35- origin.y: units.gu(2)
36- }
37-
38- SequentialAnimation{
39- id: holdFeedbackanim;
40- running: false;
41- ParallelAnimation {
42- PropertyAnimation {target: scaleTransform; property: "scale"; duration: 200; easing.type: Easing.InOutQuad; from: 0.0; to: 1.0;}
43- NumberAnimation {target: holdFeedback; property: "opacity"; duration: 200; easing.type: Easing.InOutQuad; to: 0.6;}
44- }
45- NumberAnimation {target: holdFeedback; property: "opacity"; duration: 100; easing.type: Easing.InOutQuad; to: 0;}
46- }
47- }
48-
49 MouseArea {
50 id: flippedarea
51- property int pos: 0
52- anchors.fill: parent
53+ property bool wasHourlyScrolled: false
54+ property int startY: 0
55+ property double startTime: 0
56+ property int sectionHeight: parent.height/hourly.count
57+ // without tab header!
58+ height: parent.height-units.gu(9.5)
59+ width:parent.width
60+ anchors.bottom: parent.bottom
61 onClicked: {
62 mouse.accepted = true;
63- flipable.flipped = !flipable.flipped;
64+ if(!wasHourlyScrolled) {
65+ var movement = Math.round(startY-mouse.y);
66+ if(movement < 10 && movement > -10) {
67+ // flip to detail data
68+ flipable.flipped = !flipable.flipped;
69+ } else {
70+ // switch to next/prevoius day
71+ if(movement >= 10) {
72+ dailyForecastList.incrementCurrentIndex();
73+ } else if(movement <= -10) {
74+ dailyForecastList.decrementCurrentIndex();
75+ }
76+ dailyForecastList.positionViewAtIndex(dailyForecastList.currentIndex,ListView.SnapPosition);
77+ }
78+ }
79 }
80 onPressed: {
81- pos = mouse.y;
82+ wasHourlyScrolled = false;
83+ startY = mouse.y;
84+ startTime = new Date().getTime()
85 }
86 onPositionChanged: {
87 mouse.accepted = true;
88- if(mouse.wasHeld){
89- var movement = Math.round((pos - mouse.y)/30);
90- if(movement > 1){
91- if(currentWeather.hourly.get(movement) !== undefined) {
92- currentConditionIcon.condition = currentWeather.hourly.get(movement).icon;
93- var temp = currentWeather.hourly.get(movement)[mainView.settings["units"]].temp;
94+ var distance = (parent.height - mouse.y),
95+ now = new Date().getTime(),
96+ speed = distance/(now-startTime);
97+ if(speed < 1 && !flipable.flipped) {
98+ // slow scrolling detected
99+ var movement = Math.round(distance/sectionHeight);
100+ if(movement > 0) {
101+ var hourIndex = movement-1;
102+ if(currentWeather.hourly.get(hourIndex) !== undefined) {
103+ wasHourlyScrolled = true;
104+ currentConditionIcon.condition = currentWeather.hourly.get(hourIndex).icon;
105+ var temp = currentWeather.hourly.get(hourIndex)[mainView.settings["units"]].temp;
106 currentConditionTempContent.currentTemp = temp;
107 adjustBackground(Math.round(temp));
108- var dateTime = new Date(currentWeather.hourly.get(movement).date);
109+ var dateTime = new Date(currentWeather.hourly.get(hourIndex).date);
110 var dateTimeString = Qt.formatDateTime(dateTime, 'dddd, dd MMMM yyyy - HH:mm');
111 dateComponent.dateString = dateTimeString;
112 dateComponent.renderText();
113 }
114 }
115- }else{
116- var movement = Math.round((pos - mouse.y) / 100);
117- if(movement === 1)
118- dailyForecastList.incrementCurrentIndex();
119- else if(movement === -1)
120- dailyForecastList.decrementCurrentIndex();
121- dailyForecastList.positionViewAtIndex(dailyForecastList.currentIndex,ListView.SnapPosition);
122 }
123 }
124- onPressAndHold: {
125- holdFeedback.y = mouse.y-units.gu(2);
126- holdFeedback.x = mouse.x-units.gu(2);
127- holdFeedbackanim.start();
128+ onReleased: {
129+ if(wasHourlyScrolled) {
130+ // reset temp and date to current day
131+ var currentDayData = dayForecastModel.get(dailyForecastList.currentIndex);
132+ currentConditionIcon.condition = currentDayData.condIcon;
133+ currentConditionTempContent.currentTemp = currentDayData.temp;
134+ adjustBackground(Math.round(currentDayData.temp));
135+ dateComponent.dateString = currentDayData.date;
136+ dateComponent.renderText();
137+ }
138 }
139 }
140
141
142=== modified file 'components/LocationTab.qml'
143--- components/LocationTab.qml 2013-08-30 13:31:25 +0000
144+++ components/LocationTab.qml 2013-09-04 09:44:48 +0000
145@@ -81,7 +81,6 @@
146 }else if(degrees >330 && degrees <= 360){
147 direction = "N";
148 }
149- print(dailyForecasts[x].icon)
150 dayForecastModel.append({
151 dateRel: "",//Tomorrow",
152 date: formatTimestamp(dailyForecasts[x].timestamp, 'dddd, dd MMMM yyyy'),
153
154=== modified file 'ubuntu-weather-app.qml'
155--- ubuntu-weather-app.qml 2013-08-30 12:59:44 +0000
156+++ ubuntu-weather-app.qml 2013-09-04 09:44:48 +0000
157@@ -73,25 +73,29 @@
158 property: "headerColor"
159 from: headerColor
160 to: newHeaderColor
161- duration:500
162+ duration:UbuntuAnimation.BriskDuration
163+ easing: UbuntuAnimation.StandardEasing
164 }
165 ColorAnimation {
166 target: mainView
167 property: "backgroundColor"
168 from: backgroundColor
169 to: newBackgroundColor
170- duration:500
171+ duration:UbuntuAnimation.BriskDuration
172+ easing: UbuntuAnimation.StandardEasing
173 }
174 ColorAnimation {
175 target: mainView
176 property: "footerColor"
177 from: footerColor
178 to: newFooterColor
179- duration:500
180+ duration:UbuntuAnimation.BriskDuration
181+ easing: UbuntuAnimation.StandardEasing
182 }
183 }
184
185 function adjustBackground(degrees) {
186+ gradientAnimation.stop()
187 var celsius = (settings.units === "imperial") ? Math.round((degrees-32)/1.8) : degrees,
188 colors = Gradients.getGradients(celsius);
189 newHeaderColor = colors.header;

Subscribers

People subscribed via source and target branches