1313// limitations under the License.
1414
1515#include "waiting.h"
16+ #include "lockscreen.h"
1617
1718#include "image.h"
1819#include "ui_images.h"
2122#include <screen.h>
2223#include <ui/ui_util.h>
2324
25+ #include <stdbool.h>
2426#include <string.h>
2527
26- static void _render (component_t * component )
27- {
28- // TODO - add an interesting animation?
29- ui_util_component_render_subcomponents (component );
30- }
28+ typedef struct {
29+ bool show_logo ;
30+ } data_t ;
3131
3232/********************************** Component Functions **********************************/
3333
@@ -36,7 +36,7 @@ static void _render(component_t* component)
3636 */
3737static component_functions_t _component_functions = {
3838 .cleanup = ui_util_component_cleanup ,
39- .render = _render ,
39+ .render = ui_util_component_render_subcomponents ,
4040 .on_event = NULL ,
4141};
4242
@@ -47,6 +47,12 @@ static component_functions_t _component_functions = {
4747 */
4848component_t * waiting_create (void )
4949{
50+ data_t * data = malloc (sizeof (data_t ));
51+ if (!data ) {
52+ Abort ("Error: malloc waiting data" );
53+ }
54+ memset (data , 0 , sizeof (data_t ));
55+
5056 component_t * waiting = malloc (sizeof (component_t ));
5157 if (!waiting ) {
5258 Abort ("Error: malloc waiting" );
@@ -57,14 +63,37 @@ component_t* waiting_create(void)
5763 waiting -> dimension .height = SCREEN_HEIGHT ;
5864 waiting -> position .top = 0 ;
5965 waiting -> position .left = 0 ;
66+ waiting -> data = data ;
67+
68+ ui_util_add_sub_component (waiting , lockscreen_create ());
69+
70+ return waiting ;
71+ }
72+
73+ void waiting_switch_to_logo (component_t * component )
74+ {
75+ data_t * data = (data_t * )component -> data ;
76+ if (data -> show_logo ) {
77+ return ;
78+ }
79+ data -> show_logo = true;
80+
81+ if (component -> sub_components .amount != 1 ) {
82+ // Sanity check to avoid memory bugs, should never happen.
83+ Abort ("waiting_switch_to_logo" );
84+ return ;
85+ }
86+
87+ ui_util_component_cleanup (component -> sub_components .sub_components [0 ]);
88+
6089 image_logo_data_t logo = image_logo_data ();
6190 component_t * bb2_logo = image_create (
6291 logo .buffer .data ,
6392 logo .buffer .len ,
6493 logo .dimensions .width ,
6594 logo .dimensions .height ,
6695 CENTER ,
67- waiting );
68- ui_util_add_sub_component ( waiting , bb2_logo );
69- return waiting ;
96+ component );
97+
98+ component -> sub_components . sub_components [ 0 ] = bb2_logo ;
7099}
0 commit comments