Skip to content
This repository has been archived by the owner on Nov 23, 2022. It is now read-only.

Commit

Permalink
v1.1 ready
Browse files Browse the repository at this point in the history
Layout for weather and location
  • Loading branch information
dieghernan committed May 29, 2017
1 parent fd4142e commit cfdf60b
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 17 deletions.
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"HourColor",
"MinColor",
"HourColorNight",
"MinColorNight"
"MinColorNight",
"WeatherLayout"
],
"projectType": "native",
"resources": {
Expand All @@ -55,8 +56,9 @@
"type": "font"
},
{
"characterRegex": "[0-9 a-z A-Z]",
"file": "fonts/Gotham Light.otf",
"name": "FONT_GLIGHT_10",
"name": "FONT_GLIGHT_12",
"targetPlatforms": null,
"type": "font"
},
Expand All @@ -67,23 +69,22 @@
"type": "font"
},
{
"characterRegex": "[0-9 a-z A-Z]",
"file": "fonts/Gotham Light.otf",
"name": "FONT_GLIGHT_12",
"name": "FONT_GLIGHT_10",
"targetPlatforms": null,
"type": "font"
},
{
"characterRegex": "[0-9:]",
"file": "fonts/Gotham Bold.otf",
"name": "FONT_GBOLD_18",
"name": "FONT_GBOLD_34",
"targetPlatforms": null,
"type": "font"
},
{
"characterRegex": "[0-9:]",
"file": "fonts/Gotham Bold.otf",
"name": "FONT_GBOLD_34",
"name": "FONT_GBOLD_18",
"targetPlatforms": null,
"type": "font"
},
Expand All @@ -105,5 +106,5 @@
"watchface": true
}
},
"version": "1.0.0"
"version": "1.1.0"
}
46 changes: 38 additions & 8 deletions src/c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ static void prv_default_settings(){
settings.NightTheme = true;
settings.IsNightNow = false;
settings.ClockMode=1;
settings.WeatherLayout=1;
}
//////End Configuration///
///////////////////////////
Expand Down Expand Up @@ -155,29 +156,54 @@ static void layer_update_proc(Layer * layer, GContext * ctx){
}
}
// Complications
//Settings by Default
GRect loc_rect=GRect(hour_rect.origin.x-17, hour_rect.origin.y-20, hour_rect.size.w+34, 25);
GRect temprect = GRect(hour_rect.origin.x - 10,hour_rect.origin.y + hour_rect.size.h + 1,
hour_rect.size.w / 2 + 9,(inner.size.h / 2 - hour_rect.size.h / 2) / 2);
GRect condrect = GRect(hour_rect.origin.x + hour_rect.size.w / 2 + 1,temprect.origin.y,
hour_rect.size.w / 2 - 1,(inner.size.h / 2 - hour_rect.size.h / 2) / 2);

//Alt location
GRect loc_rect_alt=GRect(loc_rect.origin.x, hour_rect.origin.y+hour_rect.size.h-5, loc_rect.size.w, loc_rect.size.h);
GRect temprect_alt=GRect(temprect.origin.x, hour_rect.origin.y-temprect.size.h+5, temprect.size.w, temprect.size.h);
GRect condrect_alt=GRect(condrect.origin.x, temprect_alt.origin.y, condrect.size.w, condrect.size.h);
if (settings.DisplayLoc || settings.DisplayTemp){
if (!settings.BTOn){
graphics_draw_text(ctx, "a", FontSymbol, loc_rect, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
if (settings.WeatherLayout==1){
graphics_draw_text(ctx, "a", FontSymbol, loc_rect, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
else {
graphics_draw_text(ctx, "a", FontSymbol, loc_rect_alt, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
}
else if (!settings.GPSOn){
graphics_draw_text(ctx, "b", FontSymbol, loc_rect, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
if (settings.WeatherLayout==1){
graphics_draw_text(ctx, "b", FontSymbol, loc_rect, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
else {
graphics_draw_text(ctx, "b", FontSymbol, loc_rect_alt, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
}
else{
if (settings.DisplayLoc){
graphics_draw_text(ctx, citistring, FontCiti, loc_rect, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
if (settings.WeatherLayout==1){
graphics_draw_text(ctx, citistring, FontCiti, loc_rect, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
else {
graphics_draw_text(ctx, citistring, FontCiti, loc_rect_alt, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
}
}
if (settings.DisplayTemp){
graphics_draw_text(ctx, tempstring, FontTemp, temprect, GTextOverflowModeTrailingEllipsis, GTextAlignmentRight, NULL);
graphics_draw_text(ctx, condstring, FontCond, condrect, GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
if (settings.WeatherLayout==1){
graphics_draw_text(ctx, tempstring, FontTemp, temprect, GTextOverflowModeTrailingEllipsis, GTextAlignmentRight, NULL);
graphics_draw_text(ctx, condstring, FontCond, condrect, GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
}
else {
graphics_draw_text(ctx, tempstring, FontTemp, temprect_alt, GTextOverflowModeTrailingEllipsis, GTextAlignmentRight, NULL);
graphics_draw_text(ctx, condstring, FontCond, condrect_alt, GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL);
}
}
}
}
}
}
}
/////////////////////////////////////////
////Init: Handle Settings and Weather////
Expand Down Expand Up @@ -308,6 +334,10 @@ static void prv_inbox_received_handler(DictionaryIterator * iter, void * context
settings.ClockMode=atoi(clockmode_t->value->cstring);
APP_LOG(APP_LOG_LEVEL_DEBUG, "Mode %d",settings.ClockMode);
}
Tuple * layout_t = dict_find(iter, MESSAGE_KEY_WeatherLayout);
if (layout_t){
settings.WeatherLayout=atoi(layout_t->value->cstring);
}
//Update colors
layer_mark_dirty(s_canvas);
window_set_background_color(s_window, ColorSelect( settings.BackgroundColor, settings.BackgroundColorNight));
Expand Down
1 change: 1 addition & 0 deletions src/c/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ typedef struct ClaySettings {
int HourSunrise;
int HourSunset;
int ClockMode;
int WeatherLayout;
char* WeatherTemp;
bool DisplayDate;
bool DisplayTemp;
Expand Down
19 changes: 17 additions & 2 deletions src/pkjs/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,22 @@ module.exports = [
"label": "Weather",
"defaultValue": false
},
{
{"type": "select",
"messageKey": "WeatherLayout",
"defaultValue": "1",
"label": "Layout",
"options": [
{
"label": "T: Location - B: Weather",
"value": "1"
},
{
"label": "T: Weather - B: Location",
"value": "2"
},
]
},
{
"type": "toggle",
"messageKey": "WeatherUnit",
"label": "Temperature in Fahrenheit",
Expand Down Expand Up @@ -193,7 +208,7 @@ module.exports = [
},
{
"type": "heading",
"defaultValue": "version v1.0",
"defaultValue": "version v1.1",
"size":6
},
{
Expand Down

0 comments on commit cfdf60b

Please sign in to comment.