Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
FokkeZB committed Apr 5, 2016
0 parents commit 6eae327
Show file tree
Hide file tree
Showing 74 changed files with 3,023 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/_assets
.DS_Store
Resources
build.log
build
npm-debug.log
tmp
.map
.project
.settings
Thumbs.db
/i18n
/platform
Binary file added DefaultIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016 Fokke Zandbergen <https://fokkezb.nl/rwanda>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# RideTracker

This app is an Open Source work in progress by [Appcelerator](http://www.appcelerator.com) Developer Evangelist [Fokke Zandbergen](http://fokkezb.nl). He plans to [cycle 400km](http://fokkezb.nl/rwanda) through Rwanda in June 2016 and raise €10.000 for the work of [Compassion](http://www.compassion.com/): *Releasing children from poverty in Jesus' name*.

![Screenshots](docs/screenshots.png)

## License

This software is licensed under [MIT](http://choosealicense.com/licenses/mit/). Learn from it and use it in any way you want, as long as you include the copyright notice and permission notice in [LICENSE](LICENSE), including the link to [http://fokkezb.nl/rwanda](http://fokkezb.nl/rwanda). Also consider to [donate](https://www.muskathlon.com/en-us/athletes/1134/fokke-zandbergen.html) to Compassion.
15 changes: 15 additions & 0 deletions app/alloy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Use a SEF to protect the global scope of the app
(function() {

// Load FontAwesome icon chars into global for use in TSS
Alloy.Globals.icons = require('icons');

// If country-locale of the device is set to a country that uses imperial units, make that the default
if (_.contains(Alloy.CFG.imperialCountries, Ti.Locale.currentCountry)) {
Alloy.CFG.settings.system.def = 'imperial';
}

// Set Moment.js to the locale of the device
require('alloy/moment').locale(Ti.Locale.currentLocale);

})();
Binary file added app/assets/android/appicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/fonts/FontAwesome.otf
Binary file not shown.
Binary file added app/assets/iphone/images/tabIcon_rides.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/iphone/images/tabIcon_rides@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/iphone/images/tabIcon_rides@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/iphone/images/tabIcon_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/iphone/images/tabIcon_settings@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/iphone/images/tabIcon_settings@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/iphone/images/tabIcon_track.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/iphone/images/tabIcon_track@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/iphone/images/tabIcon_track@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions app/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"global": {
"colors": {
"brandLighter": "#B4D6F6",
"brandLight": "#0076E8",
"brand": "#0054a6",
"brandDark": "#004486",
"grayLight": "#E0E0E0",
"gray": "#858585",
"grayDarker": "#333"
},
"minUpdateDistance": 1,
"trackDelta": 0.075,
"pointDelta": 0.5,
"settings": {
"system": {
"type": "string",
"def": "metric"
}
},
"imperialCountries": ["US", "MMR", "LBR", "GB"],
"verRowPadding": 10,
"horRowPadding": 10
},
"env:development": {},
"env:test": {},
"env:production": {},
"os:android": {
"accuracy": 10,
"minAge": 1000,
"maxAge": 5000
},
"os:blackberry": {},
"os:ios": {
"horRowPadding": 20
},
"os:mobileweb": {},
"os:windows": {},
"dependencies": {}
}
26 changes: 26 additions & 0 deletions app/controllers/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var openChild;

/**
* I use a self executing function (SEF) to wrap all code that executes on creation.
*/
(function() {

openChild = $.args.openChild;

$.data.fetch({
query: 'SELECT * FROM `data` WHERE `ride` = "' + $.args.rideId + '"'
});

})();

function openDatapoint(e) {

openChild(Alloy.createController('datapoint', {
id: e.itemId
}).getView());

}

function close() {
$.win.close();
}
61 changes: 61 additions & 0 deletions app/controllers/datapoint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
var properties = require('properties');

/**
* I use a self executing function (SEF) to wrap all code that executes on creation.
*/
(function() {

$.datapoint.on('fetch', setAnnotation);

// Fetch the data for the passed id into the empty model instance
$.datapoint.fetch({
id: $.args.id
});

// When the user changes the unit system
properties.on('change:system', onSystemChange);

})();

// Clean up global listeners on close
function onClose(e) {
properties.off('change:system', onSystemChange);
}

// Fires when the datapoint has been fetched
function setAnnotation() {

// Remove the map (if still there) when we have no location
if (!_.isFinite($.datapoint.get('latitude'))) {

if ($.map) {
$.map.parent.remove($.map);
$.map = null;
}
}

var point = {
latitude: parseFloat($.datapoint.get('latitude')),
longitude: parseFloat($.datapoint.get('longitude'))
};

$.map.applyProperties({
annotations: [
require('ti.map').createAnnotation(point)
],
region: _.defaults({
latitudeDelta: Alloy.CFG.pointDelta,
longitudeDelta: Alloy.CFG.pointDelta,
}, point)
});
}

function onSystemChange(e) {

// trigger change on model so that the UI rerenders
$.datapoint.trigger('change');
}

function close() {
$.win.close();
}
1 change: 1 addition & 0 deletions app/controllers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$.index.open();
12 changes: 12 additions & 0 deletions app/controllers/map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* I use a self executing function (SEF) to wrap all code that executes on creation.
*/
(function() {

$.map.rideId = $.args.rideId;

})();

function close() {
$.win.close();
}
95 changes: 95 additions & 0 deletions app/controllers/partials/map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
var map = require('ti.map');

/**
* I use a self executing function (SEF) to wrap all code that executes on creation.
*/
(function() {

$.map.applyProperties($.args);

})();

function renderRide(rideId) {

// Move this heavy stuff to the end of the callstack
_.defer(function() {

$.data.fetch({
query: 'SELECT * FROM data WHERE `ride` = "' + rideId + '"',
success: function() {

var latitudeNorth, latitudeSouth, longitudeEast, longitudeWest;

var points = [];

$.data.each(function(point) {

if (!point.has('latitude') || !point.has('longitude')) {
return;
}

point = {
latitude: point.get('latitude'),
longitude: point.get('longitude')
};

// Updates the bounds of our points

if (latitudeNorth === undefined || point.latitude > latitudeNorth) {
latitudeNorth = point.latitude;
}

if (latitudeSouth === undefined || point.latitude < latitudeSouth) {
latitudeSouth = point.latitude;
}

if (longitudeEast === undefined || point.longitude > longitudeEast) {
longitudeEast = point.longitude;
}

if (longitudeWest === undefined || point.longitude < longitudeWest) {
longitudeWest = point.longitude;
}

points.push(point);

});

var latitudeDelta = (latitudeNorth - latitudeSouth);
var longitudeDelta = (longitudeEast - longitudeWest);

$.map.region = {

// The center of our bounds
latitude: latitudeNorth - (latitudeDelta / 2),
longitude: longitudeEast - (longitudeDelta / 2),

// Add a margin
latitudeDelta: latitudeDelta + Alloy.CFG.trackDelta,
longitudeDelta: longitudeDelta + Alloy.CFG.trackDelta
};

// Add annotations for start and finish
if (points[0]) {
$.map.addAnnotation(map.createAnnotation(points[0]));

if (points.length > 2) {
$.map.addAnnotation(map.createAnnotation(_.defaults({
pincolor: map.ANNOTATION_GREEN
}, points[points.length - 1])));

$.map.addRoute(map.createRoute({
color: Alloy.CFG.colors.brand,
points: points
}));
}
}
}
});

});
}

Object.defineProperty($, 'rideId', {
set: _.once(renderRide)
});
32 changes: 32 additions & 0 deletions app/controllers/ride.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var crud = require('crud');

var openChild;

/**
* I use a self executing function (SEF) to wrap all code that executes on creation.
*/
(function() {

openChild = $.args.openChild;

$.ride.fetch({
id: $.args.rideId
});

})();

function openView(e) {

openChild(Alloy.createController(e.itemId, {
rideId: $.ride.id,
openChild: openChild
}).getView());
}

function close() {
$.win.close();
}

function confirmToDeleteRide(e) {
crud.confirmToDeleteRide($.args.rideId, close);
}
36 changes: 36 additions & 0 deletions app/controllers/rides.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
var crud = require('crud');

/**
* I use a self executing function (SEF) to wrap all code that executes on creation.
*/
(function() {

Alloy.Collections.ride.fetch();

})();

// Filter to only show completed rides
function dataFilter(col) {
return col.filter(function(model) {
return !!model.get('toTime');
}).reverse();
}

function onItemclick(e) {

// We use a helper that we also pass on so that additional windows can be
// opened under this tab without them needing to know of the context
openChild(Alloy.createController('ride', {
openChild: openChild,
rideId: e.itemId
}).getView());
}

function openChild(win) {
$.tab.open(win);
}

// Event listener for iOS only delete event on the list
function confirmToDeleteRide(e) {
crud.confirmToDeleteRide(e.itemId);
}
Loading

0 comments on commit 6eae327

Please sign in to comment.