@@ -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 compute the max width of the first line of the given text fitting in maxWidth
108
112
*
@@ -756,24 +760,27 @@ int nbgl_layoutAddSwitch(nbgl_layout_t *layout, const nbgl_layoutSwitch_t *switc
756
760
textArea -> obj .alignmentMarginY = 3 ;
757
761
layoutAddObject (layoutInt , (nbgl_obj_t * ) textArea );
758
762
759
- // add switch description
760
- textArea = (nbgl_text_area_t * ) nbgl_objPoolGet (TEXT_AREA , layoutInt -> layer );
761
- textArea -> textColor = WHITE ;
762
- textArea -> text = PIC (switchLayout -> subText );
763
- textArea -> textAlignment = CENTER ;
764
- textArea -> fontId = BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp ;
765
- textArea -> obj .area .width = AVAILABLE_WIDTH ;
766
- textArea -> obj .area .height = 2 * nbgl_getFontLineHeight (textArea -> fontId );
767
- textArea -> wrapping = true;
768
- nbLines = nbgl_getTextNbLinesInWidth (textArea -> fontId , textArea -> text , AVAILABLE_WIDTH , true);
769
- // if more than 2 lines on screen
770
- if (nbLines > 2 ) {
771
- // TODO: warning for screenshots
772
- return -1 ;
763
+ if (switchLayout -> subText != NULL ) {
764
+ // add switch description
765
+ textArea = (nbgl_text_area_t * ) nbgl_objPoolGet (TEXT_AREA , layoutInt -> layer );
766
+ textArea -> textColor = WHITE ;
767
+ textArea -> text = PIC (switchLayout -> subText );
768
+ textArea -> textAlignment = CENTER ;
769
+ textArea -> fontId = BAGL_FONT_OPEN_SANS_REGULAR_11px_1bpp ;
770
+ textArea -> obj .area .width = AVAILABLE_WIDTH ;
771
+ textArea -> obj .area .height = 2 * nbgl_getFontLineHeight (textArea -> fontId );
772
+ textArea -> wrapping = true;
773
+ nbLines
774
+ = nbgl_getTextNbLinesInWidth (textArea -> fontId , textArea -> text , AVAILABLE_WIDTH , true);
775
+ // if more than 2 lines on screen
776
+ if (nbLines > 2 ) {
777
+ // TODO: warning for screenshots
778
+ return -1 ;
779
+ }
780
+ textArea -> obj .alignment = CENTER ;
781
+ textArea -> obj .alignmentMarginY = 1 ; // not exactly centered
782
+ layoutAddObject (layoutInt , (nbgl_obj_t * ) textArea );
773
783
}
774
- textArea -> obj .alignment = CENTER ;
775
- textArea -> obj .alignmentMarginY = 1 ; // not exactly centered
776
- layoutAddObject (layoutInt , (nbgl_obj_t * ) textArea );
777
784
778
785
button = (nbgl_button_t * ) nbgl_objPoolGet (BUTTON , ((nbgl_layoutInternal_t * ) layout )-> layer );
779
786
button -> foregroundColor = BLACK ;
0 commit comments