@@ -103,6 +103,10 @@ static void buttonCallback(nbgl_screen_t *screen, nbgl_buttonEvent_t buttonEvent
103
103
}
104
104
}
105
105
106
+ /**********************
107
+ * GLOBAL FUNCTIONS
108
+ **********************/
109
+
106
110
/**
107
111
* @brief adds the given obj to the layout
108
112
*
@@ -118,10 +122,6 @@ void layoutAddObject(nbgl_layoutInternal_t *layout, nbgl_obj_t *obj)
118
122
layout -> nbChildren ++ ;
119
123
}
120
124
121
- /**********************
122
- * GLOBAL FUNCTIONS
123
- **********************/
124
-
125
125
/**
126
126
* @brief returns a layout of the given type. The layout is reset
127
127
*
@@ -689,24 +689,27 @@ int nbgl_layoutAddSwitch(nbgl_layout_t *layout, const nbgl_layoutSwitch_t *switc
689
689
textArea -> obj .alignmentMarginY = 3 ;
690
690
layoutAddObject (layoutInt , (nbgl_obj_t * ) textArea );
691
691
692
- // add switch description
693
- textArea = (nbgl_text_area_t * ) nbgl_objPoolGet (TEXT_AREA , layoutInt -> layer );
694
- textArea -> textColor = WHITE ;
695
- textArea -> text = PIC (switchLayout -> subText );
696
- textArea -> textAlignment = CENTER ;
697
- textArea -> fontId = BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp ;
698
- textArea -> obj .area .width = AVAILABLE_WIDTH ;
699
- textArea -> obj .area .height = 2 * nbgl_getFontLineHeight (textArea -> fontId );
700
- textArea -> wrapping = true;
701
- nbLines = nbgl_getTextNbLinesInWidth (textArea -> fontId , textArea -> text , AVAILABLE_WIDTH , true);
702
- // if more than 2 lines on screen
703
- if (nbLines > 2 ) {
704
- // TODO: warning for screenshots
705
- return -1 ;
692
+ if (switchLayout -> subText != NULL ) {
693
+ // add switch description
694
+ textArea = (nbgl_text_area_t * ) nbgl_objPoolGet (TEXT_AREA , layoutInt -> layer );
695
+ textArea -> textColor = WHITE ;
696
+ textArea -> text = PIC (switchLayout -> subText );
697
+ textArea -> textAlignment = CENTER ;
698
+ textArea -> fontId = BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp ;
699
+ textArea -> obj .area .width = AVAILABLE_WIDTH ;
700
+ textArea -> obj .area .height = 2 * nbgl_getFontLineHeight (textArea -> fontId );
701
+ textArea -> wrapping = true;
702
+ nbLines
703
+ = nbgl_getTextNbLinesInWidth (textArea -> fontId , textArea -> text , AVAILABLE_WIDTH , true);
704
+ // if more than 2 lines on screen
705
+ if (nbLines > 2 ) {
706
+ // TODO: warning for screenshots
707
+ return -1 ;
708
+ }
709
+ textArea -> obj .alignment = CENTER ;
710
+ textArea -> obj .alignmentMarginY = 1 ; // not exactly centered
711
+ layoutAddObject (layoutInt , (nbgl_obj_t * ) textArea );
706
712
}
707
- textArea -> obj .alignment = CENTER ;
708
- textArea -> obj .alignmentMarginY = 1 ; // not exactly centered
709
- layoutAddObject (layoutInt , (nbgl_obj_t * ) textArea );
710
713
711
714
button = (nbgl_button_t * ) nbgl_objPoolGet (BUTTON , ((nbgl_layoutInternal_t * ) layout )-> layer );
712
715
button -> foregroundColor = BLACK ;
0 commit comments