Got an eat message to display on screen if it's not hooked up yet
This commit is contained in:
parent
8eb238a74e
commit
e6f714a657
1 changed files with 20 additions and 5 deletions
25
src/c/main.c
25
src/c/main.c
|
|
@ -5,6 +5,7 @@
|
||||||
static Window *s_main_window;
|
static Window *s_main_window;
|
||||||
static TextLayer *s_time_layer;
|
static TextLayer *s_time_layer;
|
||||||
static TextLayer *s_date_layer;
|
static TextLayer *s_date_layer;
|
||||||
|
static TextLayer *s_eat_layer;
|
||||||
|
|
||||||
// A struct for our specific settings (see main.h)
|
// A struct for our specific settings (see main.h)
|
||||||
static ClaySettings settings;
|
static ClaySettings settings;
|
||||||
|
|
@ -55,10 +56,10 @@ static void inbox_recieved_callback(DictionaryIterator *iter, void *context) {
|
||||||
Tuple *fast_end_t = dict_find(iter, MESSAGE_KEY_FastEnd);
|
Tuple *fast_end_t = dict_find(iter, MESSAGE_KEY_FastEnd);
|
||||||
if (fast_end_t) {
|
if (fast_end_t) {
|
||||||
settings.FastEnd = fast_end_t->value->cstring;
|
settings.FastEnd = fast_end_t->value->cstring;
|
||||||
|
|
||||||
// Save the new settings to persistent storage
|
|
||||||
prv_save_settings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save the new settings to persistent storage
|
||||||
|
prv_save_settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_time() {
|
static void update_time() {
|
||||||
|
|
@ -80,6 +81,10 @@ static void update_time() {
|
||||||
|
|
||||||
// Display the date
|
// Display the date
|
||||||
text_layer_set_text(s_date_layer, s_date_buffer);
|
text_layer_set_text(s_date_layer, s_date_buffer);
|
||||||
|
|
||||||
|
// TODO: compare the time and change accordingly
|
||||||
|
static const char eatmsg[] = "Eat";
|
||||||
|
text_layer_set_text(s_eat_layer, eatmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
|
static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
|
||||||
|
|
@ -99,7 +104,6 @@ static void main_window_load(Window *window) {
|
||||||
fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
|
fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
|
||||||
text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
|
text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
|
||||||
|
|
||||||
// Add it as a child layer to the Window's root layer
|
|
||||||
layer_add_child(window_layer, text_layer_get_layer(s_time_layer));
|
layer_add_child(window_layer, text_layer_get_layer(s_time_layer));
|
||||||
|
|
||||||
// Create the date TextLayer
|
// Create the date TextLayer
|
||||||
|
|
@ -111,11 +115,22 @@ static void main_window_load(Window *window) {
|
||||||
fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
|
fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
|
||||||
text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter);
|
text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter);
|
||||||
|
|
||||||
// Add to Window
|
|
||||||
layer_add_child(window_layer, text_layer_get_layer(s_date_layer));
|
layer_add_child(window_layer, text_layer_get_layer(s_date_layer));
|
||||||
|
|
||||||
|
// Create the eat Textlayer
|
||||||
|
s_eat_layer = text_layer_create(
|
||||||
|
GRect(0, PBL_IF_ROUND_ELSE(160, 154), bounds.size.w, 30));
|
||||||
|
text_layer_set_background_color(s_eat_layer, settings.BackgroundColor);
|
||||||
|
text_layer_set_text_color(s_eat_layer, settings.ForegroundColor);
|
||||||
|
text_layer_set_font(s_eat_layer,
|
||||||
|
fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
|
||||||
|
text_layer_set_text_alignment(s_eat_layer, GTextAlignmentCenter);
|
||||||
|
|
||||||
|
layer_add_child(window_layer, text_layer_get_layer(s_eat_layer));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void main_window_unload(Window *window) {
|
static void main_window_unload(Window *window) {
|
||||||
|
text_layer_destroy(s_eat_layer);
|
||||||
text_layer_destroy(s_date_layer);
|
text_layer_destroy(s_date_layer);
|
||||||
text_layer_destroy(s_time_layer);
|
text_layer_destroy(s_time_layer);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue