1414#include "node_list.h"
1515
1616extern void flash_dump (void );
17+ extern const char git_version [];
1718
1819static Window * s_main_window ;
1920static Menu * s_menu ;
2021
22+ static Window * s_about_window ;
23+ static Layer * s_aboutCanvas_layer ;
24+ static ScrollLayer * s_about_scroll ;
25+ static void about_update_proc (Layer * layer , GContext * nGContext );
26+ static GBitmap * logo_bitmap ;
27+ static GBitmap * rocket_bitmap ;
28+
2129StatusBarLayer * status_bar ;
2230
2331typedef struct {
@@ -59,6 +67,12 @@ static MenuItems* notification_item_selected(const MenuItem *item)
5967 return NULL ;
6068}
6169
70+ static MenuItems * about_item_selected (const MenuItem * item )
71+ {
72+ window_stack_push (s_about_window , false);
73+ return NULL ;
74+ }
75+
6276static MenuItems * watch_list_item_selected (const MenuItem * item ) {
6377 MenuItems * items = menu_items_create (16 );
6478 // loop through all apps
@@ -123,7 +137,7 @@ static void systemapp_window_load(Window *window)
123137 menu_items_add (items , MenuItem ("Settings" , "Config" , RESOURCE_ID_SPANNER , settings_item_selected ));
124138 menu_items_add (items , MenuItem ("Tests" , NULL , RESOURCE_ID_CLOCK , run_test_item_selected ));
125139 menu_items_add (items , MenuItem ("Notifications" , NULL , RESOURCE_ID_SPEECH_BUBBLE , notification_item_selected ));
126- menu_items_add (items , MenuItem ("RebbleOS" , "... v0.0.0.2" , RESOURCE_ID_SPEECH_BUBBLE , NULL ));
140+ menu_items_add (items , MenuItem ("RebbleOS" , "... v0.0.0.2" , RESOURCE_ID_SPEECH_BUBBLE , about_item_selected ));
127141 menu_set_items (s_menu , items );
128142
129143#ifdef PBL_RECT
@@ -140,6 +154,76 @@ static void systemapp_window_unload(Window *window)
140154 menu_destroy (s_menu );
141155}
142156
157+ static void window_exit_handler (ClickRecognizerRef recognizer , void * context )
158+ {
159+ window_stack_pop (true);
160+ }
161+
162+ static void about_window_load (Window * window )
163+ {
164+ Layer * window_layer = window_get_root_layer (s_about_window );
165+ GRect bounds = layer_get_bounds (window_layer );
166+
167+ status_bar = status_bar_layer_create ();
168+ status_bar_layer_set_separator_mode (status_bar , StatusBarLayerSeparatorModeDotted );
169+
170+ status_bar_layer_set_colors (status_bar , PBL_IF_COLOR_ELSE (GColorRed ,GColorBlack ), GColorWhite );
171+
172+ status_bar_layer_set_text (status_bar , "About RebbleOS" );
173+
174+ s_about_scroll = scroll_layer_create (bounds );
175+ scroll_layer_set_click_config_onto_window (s_about_scroll , window );
176+
177+ s_aboutCanvas_layer = layer_create (bounds );
178+ layer_set_update_proc (s_aboutCanvas_layer , about_update_proc );
179+ scroll_layer_add_child (s_about_scroll , s_aboutCanvas_layer );
180+ layer_mark_dirty (s_aboutCanvas_layer );
181+
182+ layer_add_child (window_layer , scroll_layer_get_layer (s_about_scroll ));
183+ layer_add_child (window_layer , status_bar_layer_get_layer (status_bar ));
184+
185+ #ifdef PBL_BW
186+ //TODO: Get black and white rocket bitmap for Classic
187+ logo_bitmap = gbitmap_create_with_resource (RESOURCE_ID_REBBLE_LOGO_BW );
188+ rocket_bitmap = gbitmap_create_with_resource (RESOURCE_ID_TO_MOON_BW );
189+ #else
190+ logo_bitmap = gbitmap_create_with_resource (RESOURCE_ID_REBBLE_LOGO_DARK );
191+ rocket_bitmap = gbitmap_create_with_resource (RESOURCE_ID_TO_MOON );
192+ #endif
193+
194+ }
195+
196+ static void about_update_proc (Layer * layer , GContext * nGContext )
197+ {
198+ GRect bounds = layer_get_unobstructed_bounds (layer );
199+ graphics_context_set_text_color (nGContext , GColorBlack );
200+ graphics_context_set_compositing_mode (nGContext , GCompOpSet );
201+
202+ window_single_click_subscribe (BUTTON_ID_BACK , window_exit_handler );
203+
204+ graphics_draw_text (nGContext , "Version:" , fonts_get_system_font (FONT_KEY_GOTHIC_18_BOLD ), GRect ((bounds .size .w /2 )- 70 , (bounds .size .h /2 )- 10 , 140 , 20 ),
205+ GTextOverflowModeTrailingEllipsis , GTextAlignmentCenter , 0 );
206+
207+ graphics_draw_text (nGContext , git_version , fonts_get_system_font (FONT_KEY_GOTHIC_18 ), GRect ((bounds .size .w /2 )- 70 , (bounds .size .h /2 )+ 5 , 140 , 20 ),
208+ GTextOverflowModeTrailingEllipsis , GTextAlignmentCenter , 0 );
209+
210+ graphics_draw_text (nGContext , "Join us!" , fonts_get_system_font (FONT_KEY_GOTHIC_18_BOLD ), GRect ((bounds .size .w /2 )- 70 , (bounds .size .h /2 )+ 20 , 140 , 20 ),
211+ GTextOverflowModeTrailingEllipsis , GTextAlignmentCenter , 0 );
212+
213+ graphics_draw_text (nGContext , "https://rebble.io/discord" , fonts_get_system_font (FONT_KEY_GOTHIC_14 ), GRect ((bounds .size .w /2 )- 70 , (bounds .size .h /2 )+ 38 , 140 , 20 ),
214+ GTextOverflowModeTrailingEllipsis , GTextAlignmentCenter , 0 );
215+
216+ graphics_draw_bitmap_in_rect (nGContext , logo_bitmap , GRect ((bounds .size .w /2 )- 17 , (bounds .size .h /2 )- 63 , 34 , 53 ));
217+ graphics_draw_bitmap_in_rect (nGContext , rocket_bitmap , GRect ((bounds .size .w /2 )- 8 , (bounds .size .h /2 )+ 60 , 19 , 19 ));
218+ }
219+
220+ static void about_window_unload (Window * window )
221+ {
222+ scroll_layer_destroy (s_about_scroll );
223+ gbitmap_destroy (logo_bitmap );
224+ gbitmap_destroy (rocket_bitmap );
225+ }
226+
143227void systemapp_init (void )
144228{
145229 s_main_window = window_create ();
@@ -149,12 +233,20 @@ void systemapp_init(void)
149233 .unload = systemapp_window_unload ,
150234 });
151235
236+ s_about_window = window_create ();
237+
238+ window_set_window_handlers (s_about_window , (WindowHandlers ) {
239+ .load = about_window_load ,
240+ .unload = about_window_unload ,
241+ });
242+
152243 window_stack_push (s_main_window , true);
153244}
154245
155246void systemapp_deinit (void )
156247{
157248 window_destroy (s_main_window );
249+ window_destroy (s_about_window );
158250}
159251
160252void systemapp_main (void )
0 commit comments